function init(doit){
	for (i=0; document.getElementById('div_open_'+i+'_0_0'); i++) for (k=0; document.getElementById('div_open_'+i+'_'+k+'_0'); k++) for (l=0; d=document.getElementById('div_open_'+i+'_'+k+'_'+l); l++) {
		var childs=d.getElementsByTagName('div');
		for(j=0;j<childs.length;j++){
			var id=childs[j].id.split('_');
			if(id[0] == 'yyy'){
				var yyy=document.getElementById(childs[j].id);
				//alert(yyy.innerHTML);
					name=yyy.getAttribute('name');
					tmp=name.split('_');
					if(doit == 1){
						innertxt='<div class="small_br"></div><table cellspacing="0" cellspacing="0"  onclick="open_gallery(\''+name+'\');aj('+id[1]+', \'edit\',\'div_element_child_'+tmp[2]+'_'+tmp[3]+'\');change_class(\''+childs[j].id+'\',\'xxx\');">';
					}else{
						if(document.getElementById(name).style.display == 'none' && yyy.className=='xxx'){
							innertxt='<div class="small_br"></div><table cellspacing="0" cellspacing="0"  onclick="open_gallery(\''+name+'\');">';
						}else{
							innertxt='<div class="small_br"></div><table cellspacing="0" cellspacing="0"  onclick="open_gallery(\''+name+'\');aj('+id[1]+', \'edit\',\'div_element_child_'+tmp[2]+'_'+tmp[3]+'\');change_class(\''+childs[j].id+'\',\'xxx\');">';
						}
					}
					innertxt+=			'<tr>'+
												'<td width="4" height="30" style="background: url(/img/menu/change_left.jpg) right center no-repeat;">'+
													'&nbsp;'+
												'</td>'+
												'<td height="30" width="115" style="background: url(/img/menu/change_px.jpg) right center repeat-x;">'+
													'<div class="count_change">'+
														meb_change+
													'</div>'+
												'</td>'+
												'<td width="4" height="30" style="background: url(/img/menu/change_right.jpg) left center no-repeat;">'+
													'&nbsp;'+
												'</td>'+
											'</tr>'+
										'</table>'+
										'<div><img src="/img/0.gif" width="42" height="15" alt="" /></div>';
					document.getElementById(name+'-title').innerHTML=innertxt;
					//add_event(name+'-title', 'click', name);
				
			}
			//alert(id);
		}
	}
	close_galleries_div();
}
function init_edit(){
	for (i=0; document.getElementById('div_open_'+i+'_0_0'); i++) for (k=0; document.getElementById('div_open_'+i+'_'+k+'_0'); k++) for (l=0; d=document.getElementById('div_open_'+i+'_'+k+'_'+l); l++) {
		var childs=d.getElementsByTagName('div');
		for(j=0;j<childs.length;j++){
			var id=childs[j].id.split('_');
			if(id[0] == 'yyy'){
				var yyy=document.getElementById(childs[j].id);
				//alert(yyy.innerHTML);
					name=yyy.getAttribute('name');
					innertxt='<div class="small_br"></div><table cellspacing="0" cellspacing="0"  onclick="open_gallery(\''+name+'\');">';
					innertxt+=			'<tr>'+
												'<td width="4" height="30" style="background: url(/img/menu/change_left.jpg) right center no-repeat;">'+
													'&nbsp;'+
												'</td>'+
												'<td height="30" width="115" style="background: url(/img/menu/change_px.jpg) right center repeat-x;">'+
													'<div class="count_change">'+
														meb_change+
													'</div>'+
												'</td>'+
												'<td width="4" height="30" style="background: url(/img/menu/change_right.jpg) left center no-repeat;">'+
													'&nbsp;'+
												'</td>'+
											'</tr>'+
										'</table>'+
										'<div><img src="/img/0.gif" width="42" height="15" alt="" /></div>';
					document.getElementById(name+'-title').innerHTML=innertxt;
					//add_event(name+'-title', 'click', name);
				
			}
			//alert(id);
		}
	}
	close_galleries_div();
}
function open_gallery(id){
	var div=document.getElementById(id);
	if(div){
		close_galleries_div();
		document.getElementById(div.id+'-title').innerHTML='<div><img src="/img/0.gif" width="42" height="15" alt="" /></div>'+
																'<table cellspacing="0" cellspacing="0" onclick="close_galleries_div();">'+
																	'<tr>'+
																		'<td width="5" height="42" style="background: url(/img/menu/change_act_left.jpg) right center no-repeat;">'+
																			'&nbsp;'+
																		'</td>'+
																		'<td height="42" width="125" style="background: url(/img/menu/change_act_px.jpg) right center repeat-x;">'+
																			'<div class="count_change_act">'+
																				meb_change+
																			'</div>'+
																		'</td>'+
																		'<td width="5" height="42" style="background: url(/img/menu/change_act_right.jpg) left center no-repeat;">'+
																			'&nbsp;'+
																		'</td>'+
																	'</tr>'+
																'</table>';
		div.style.display="block"
		id=div.id
		tmp=id.split('_');
		gid=tmp[3];
		elid=tmp[2];
		div_child=document.getElementById('div_element_child_'+elid+'_'+gid)
		var top=getElementTop(id)-2;
		var left=getElementLeft ('div_location_'+gid)
		div_child.style.position="absolute"
		div_child.style.left=left+'px'
		div_child.style.top=top+'px'
		document.getElementById('div_element_'+elid+'_'+gid).style.height = document.getElementById('div_element_child_'+elid+'_'+gid).clientHeight+'px';		
	}
}
function close_galleries_div(){
	//var galleries_div=$(divid);
	//for(i=0;i<galleries_div.length;i++){
	for (i=1; galleries_div=document.getElementById('div_open_div_'+i); i++){
		child_div=galleries_div.childNodes;
		for(k=0;k<child_div.length;k++){
			if(child_div[k].tagName == 'DIV'){
				if(child_div[k].style.display != 'none'){
					child_div[k].style.display = 'none';
					var gal_but_name=document.getElementById(child_div[k].id+'-title').getAttribute('name');
					var yyy=document.getElementById(gal_but_name);
						name=yyy.getAttribute('name');
						document.getElementById(name+'-title').innerHTML='<div class="small_br"></div><table cellspacing="0" cellspacing="0" onclick="open_gallery(\''+name+'\');">'+
											'<tr>'+
												'<td width="4" height="30" style="background: url(/img/menu/change_left.jpg) right center no-repeat;">'+
													'&nbsp;'+
												'</td>'+
												'<td height="30" width="115" style="background: url(/img/menu/change_px.jpg) right center repeat-x;">'+
													'<div class="count_change">'+
														meb_change+
													'</div>'+
												'</td>'+
												'<td width="4" height="30" style="background: url(/img/menu/change_right.jpg) left center no-repeat;">'+
													'&nbsp;'+
												'</td>'+
											'</tr>'+
										'</table>'+
										'<div><img src="/img/0.gif" width="42" height="15" alt="" /></div>';
						//add_event(name+'-title', 'click', name);					
				}
			}
		}
	}
}
function change_class(id,classname){
	$(id).className=classname;
}
