function ubsd(id){
	var obj=document.getElementById('ub_div_'+id)
	if(obj){
		obj.style.display='';
		reverseDir(id)
		hideSelects(id)
	}
}
function ubhd(id){
	var obj=document.getElementById('ub_div_'+id)
	if(obj){
		obj.style.display='none';
		showSelects()
	}
}
function ubon(id){
	var obj=document.getElementById('ub_tr_'+id)
	if(obj) obj.className=obj.className+"_H";
	var obj=document.getElementById('ub_td_'+id)
	if(obj) obj.className=obj.className+"_H";
	var obj=document.getElementById('ub_a_'+id)
	if(obj) obj.className=obj.className+"_H";
	var obj=document.getElementById('ub_img_'+id)
	//alert('ub_img_'+id)
	if(obj!=null){
		//alert(obj.getAttributeNode("src_on").value)
		obj.className=obj.className+"_H";
		obj.src = obj.getAttributeNode("src_on").value
	}
}
function uboff(id){

      

      var obj=document.getElementById('ub_tr_'+id)

      if(obj) obj.className=obj.className.replace(/_H$/,"");

      

      var obj=document.getElementById('ub_td_'+id)

      if(obj) obj.className=obj.className.replace(/_H$/,"");

      

      try{

          var obj=document.getElementById('ub_a_'+id)

          if(obj) obj.className=obj.className.replace(/_H$/,"");

      }catch(e){

        obj.className ="ub_item_lev1_H";

      } 

        

      var obj=document.getElementById('ub_img_'+id)

      if(obj){

            obj.src = obj.getAttributeNode("src_off").value

            obj.className=obj.className.replace(/_H$/,"");

            

      }

      

}



///////////////////////////////////////////////////////////////
// Show/hide selects functions
var hiddenSelects={};
function hideSelects(id){
	var obj=document.all['ub_div_'+id]
	if(!obj) return
	
	function hideSelect(obj){
		obj.style.visibility='hidden'
		eval("hiddenSelects."+String(obj.uniqueID)+"=1")
	}
	var objOffLeft=0,objOffTop=0,objOffWidth=0,objOffHeight=0;
	//DIV COORDINATES:
	var divLT={},divRT={},divLB={},divRB={};

	objOffWidth=obj.offsetWidth;
	objOffHeight=obj.offsetHeight;
	objOffLeft=obj.offsetLeft;
	objOffTop=obj.offsetTop;
	var objPar=obj.offsetParent;
	while(objPar){
		obj=objPar;
		objOffLeft+=obj.offsetLeft;
		objOffTop+=obj.offsetTop;
		objPar=obj.offsetParent;
	}
	divLT.x=objOffLeft;
	divLT.y=objOffTop;
	divRT.x=objOffLeft+objOffWidth;
	divRT.y=objOffTop;
	divLB.x=objOffLeft;
	divLB.y=objOffTop+objOffHeight;
	divRB.x=objOffLeft+objOffWidth;
	divRB.y=objOffTop+objOffHeight;

	var selects=document.getElementsByTagName("SELECT");
	for(var i=0;i<selects.length;i++){
		var offLeft=0,offTop=0,offW=0,offH=0;
		//SELECT COORDINATES:
		var selLT={},selRT={},selLB={},selRB={};

		var ob=selects[i];
		offW=ob.offsetWidth;
		offH=ob.offsetHeight;
		offLeft+=ob.offsetLeft;
		offTop+=ob.offsetTop;
		var par=ob.offsetParent;
		while(par){
			ob=par;
			offLeft+=ob.offsetLeft;
			offTop+=ob.offsetTop;
			par=ob.offsetParent;
		}

		selLT.x=offLeft;
		selLT.y=offTop;
		selRT.x=offLeft+offW;
		selRT.y=offTop;
		selLB.x=offLeft;
		selLB.y=offTop+offH;
		selRB.x=offLeft+offW;
		selRB.y=offTop+offH;

		if(selLT.y>=divLB.y) continue;
		if((selLT.x>=divLB.x) && (selLT.x<divRB.x)){
			hideSelect(selects[i]);
			continue;
		}
		if((selRT.x>=divLB.x) && (selRT.x<divRB.x)){
			hideSelect(selects[i]);
			continue;
		}
		if((selLT.x<=divLB.x) && (selRT.x>=divRB.x)){
			hideSelect(selects[i]);
			continue;
		}
	}
}
function getOffsetLeft(ob){
	var offLeft=ob.offsetLeft;
	var par=ob.offsetParent;
	while(par){
		offLeft+=par.offsetLeft;
		par=par.offsetParent;
	}
	return offLeft
}
function showSelects()
{
	try
	{
		for(var x in hiddenSelects)
		{
			if(!isnull(hiddenSelects[x]))
			{
				document.all[x].style.visibility='visible'
				hiddenSelects[x]=null
			}
		}
	}catch(e){}
}
function reverseDir(id){
	//return
	var menudiv = document.all['ub_div_'+id]
	var upperMenusDiv=document.all['ub_cont_lev0'];
	var tdContainer=document.all['ub_td_'+id]
	try{
		if(dir.toUpperCase()=="RTL" && getOffsetLeft(menudiv)<getOffsetLeft(upperMenusDiv)){
			tdContainer.style.direction="LTR"
		}
		if(dir.toUpperCase()=="LTR" && (getOffsetLeft(menudiv)+menudiv.offsetWidth)>(getOffsetLeft(upperMenusDiv)+upperMenusDiv.offsetWidth)){
			tdContainer.style.direction="RTL"
		}
	}catch(e){
	}
}
