// JavaScript Document
function OpenClose(PanelName, IcoName, IcoFileOpen, IcoFileClose, alwaysopen){
 MenuObj = document.getElementById(PanelName);
 if (MenuObj) 
 {
  if (MenuObj.style.display!='none') {
   if (!alwaysopen) {
    MenuObj.style.display ='none';
    document.getElementById(IcoName).src =IcoFileOpen;
   }
  }
  else { 
   MenuObj.style.display ='';
   document.getElementById(IcoName).src =IcoFileClose;
      
  };
 }
}

function OpenClose2(PanelName, alwaysopen){
 MenuObj = document.getElementById(PanelName);
 if (MenuObj) 
 {
  if (MenuObj.style.display!='none') {
   if (alwaysopen==false) {
    MenuObj.style.display ='none';
   }
  }
  else { 
   MenuObj.style.display ='';
  };
 }
}

function getClassname(Obj){
	var Parent = Obj.parentNode;
	var result = Obj.className;
	while ((Parent!=null) && (result=="")){
		result = Parent.className;
		Parent = Parent.parentNode;
	}
	return result;
}

/*
function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
*/

// IcoIDOpen, IcoIDClose   devono avere la proprietà background-image
function OpenCloseClassName(PanelName, IcoName, alwaysopen){
 MenuObj = document.getElementById(PanelName);
 if (MenuObj) 
 {
	var StyleName = getClassname(MenuObj);
	if (StyleName=="") return OpenClose(PanelName, IcoName, 'img/btn_open.gif', 'img/btn_close.gif', alwaysopen);
	
  if (MenuObj.style.display!='none') {
   if (alwaysopen==false) {
    MenuObj.style.display ='none';
	//alert(getStyle('openclose_btn_open', 'background-image'));
    document.getElementById(IcoName).src ='img/'+StyleName+'/btn_open.gif';
   }
  }
  else { 
   MenuObj.style.display ='';
   document.getElementById(IcoName).src ='img/'+StyleName+'/btn_close.gif';
  };
 }
}

function GetCloseBtnClassName(PanelName){
	StyleName = getClassname(MenuObj);
	if (StyleName="") return 'img/btn_close.gif';
	
	return 'img/'+StyleName+'/btn_close.gif';
}
