//var prevBG = new Array;
var MenuSH = new Array;
var lastId = "";
var alwaysOpen = 0;

function OverOutTD(idTd, type, pause)
{
	var tdObj = document.getElementById(idTd);
	//var widthTd = tdObj.offsetWidth;
	//var addWidthTd = (tdObj.offsetWidth*30)/100;
	//var widthSub = widthTd + addWidthTd;
	//var widthSub = widthTd-10;
	//widthSub = (widthSub<180)?180:widthSub;
	
	if (tdObj)
	{
		//hideAll(idTd);
		
		var subObj = document.getElementById('sub_'+idTd);
		//var aObj = document.getElementById('a_'+idTd);
		var imgObj = document.getElementById('i_'+idTd);
		var tdObj2 = document.getElementById('td_'+idTd);
		
		switch (type)
		{
			case "over":
				MenuSH[idTd]=1;	
				//if (prevBG[idTd]=="" || !prevBG[idTd])
					//prevBG[idTd] = tdObj.style.background;
				
				//if (subObj)	
					//tdObj.style.background = "url('img/bg/menu_over2.gif') no-repeat center top";
				//else
					tdObj.style.background = "#ffd74e";
				
				if (tdObj2)
				{
					tdObj2.style.background = "#ffd74e";
				}
									
				if (imgObj)
				{
					imgObj.src = "img/ico_downmenu.jpg";
				}							
				//if (aObj)
				//{
					//aObj.className = "overMade";
				//}				
				if (subObj)
				{
					//subObj.style.width = widthSub + "px";
					//if (lastId == idTd)
						//subObj.style.marginLeft = "-"+(addWidthTd+7)+ "px";
					//var lineObj = document.getElementById("line_"+idTd);
					//if (!lineObj)
					//{
						//addLine = "<div id=\"line_"+idTd+"\" style=\"background:#ffffff;height:4px;margin-bottom:14px;margin-left:"+(widthTd-7)+"px;\"></div>";
						//subObj.innerHTML = addLine + subObj.innerHTML;
					//} 					
					subObj.style.display = "block";
				}
				break;
				
			case "out":
				MenuSH[idTd]=0;
				if (pause == -1)
					pause = 0;
				else
					pause = 700
				setTimeout('outTD("'+idTd+'")',pause);				
				break;
		}		
	}
}

function outTD(idTd)
{
	if (MenuSH[idTd]==0)
	{
		var tdObj = document.getElementById(idTd);
		//if (prevBG[idTd] && prevBG[idTd]!="")
		//{
			tdObj.style.background = "none";
			//prevBG[idTd] = "none";	
		//}

		var tdObj2 = document.getElementById('td_'+idTd);		
		if (tdObj2)
		{
			tdObj2.style.background = "none";
		}
				
		var imgObj = document.getElementById('i_'+idTd);
		if (imgObj)
		{
			imgObj.src = "img/ico_upmenu.jpg";
		}
				
		var subObj = document.getElementById('sub_'+idTd);
		if (subObj)
		{
			subObj.style.display = "none";
		}	
						
		//var aObj = document.getElementById('a_'+idTd);
		//if (aObj)
		//{
			//aObj.className = "outMade";
		//}		
	}
}

function hideAll(currentTd)
{
	for (i=0; i < MainDivs.length; i++) 
	{	
		if (MainDivs[i])
		{
			if (MainDivs[i]!=currentTd && MainDivs[i]!=alwaysOpen) 
			{
				var obj = document.getElementById(MainDivs[i]);
				if (obj)
				{
					//if (prevBG[MainDivs[i]] && prevBG[MainDivs[i]]!="")
					//{
						obj.style.background = "none";
						//prevBG[MainDivs[i]] = "none";
					//}
				}
				
				var tdObj2 = document.getElementById('td_'+MainDivs[i]);		
				if (tdObj2)
				{
					tdObj2.style.background = "none";
				}
						
				var imgObj = document.getElementById('i_'+MainDivs[i]);
				if (imgObj)
				{
					imgObj.src = "img/ico_upmenu.jpg";
				}
						
				var subObj = document.getElementById('sub_'+MainDivs[i]);
				if (subObj)
				{
					subObj.style.display = "none";
				}
				
				//var aObj = document.getElementById('a_'+MainDivs[i]);
				//if (aObj)
				//{
					//aObj.className = "outMade";
				//}					
			}
			
			lastId = MainDivs[i];				
		}
	}	
}

function add_click (url,target) {
	if (url) {
	//alert("Debug:"+url);
	//alert("Debug:"+target);
	if (target=="_parent") {
	parent.location.href=url;
	}
	if (target=="_blank") {
	window.open(url);
	}
	if (target=="_self") {
	location.href=url;
	}
	if (target=="_top") {
	top.location.href=url;
	}
	}//end if !url
} 

function clearValue(obj)
{
	if (obj)
		obj.value = "";
}


function popupW(url,w,h,id) 
{
	w=w+16;
	h=h+20;
	window.open(url,'popupWindow'+id,'width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,screenX=150,screenY=150,top=150,left=150');
} 

function  ShowHide2Panels(id1, id2)
{	
	var obj1 = document.getElementById(id1);
	var obj2 = document.getElementById(id2);
	if (obj1 != null && obj2 != null)
	{
		switch (obj2.style.display)
		{
			case "none":
				obj2.style.display = "block";
				obj1.style.display = "none";
				break;
				
			case "block":
				obj2.style.display = "none";
				obj1.style.display = "block";
				break;
		}
	}	
}

function selectAllCB(elemName,esJs,idCheckBox)
{
	var c = null;
	
	if (esJs)
	{
		if (idCheckBox)
		{
			var idCheckBox = document.getElementById(idCheckBox);
			idCheckBox.checked = (idCheckBox.checked)?false:true;
		}	
		else
		{
			var idCheckBox = document.getElementById("all_check_"+elemName);
			//idCheckBox.checked = (idCheckBox.checked)?false:true;
		}
						

		for (var i = 0; i < esJs.length; i++)
		{
			c = document.forms['formFiltr']['filtr['+elemName+']['+esJs[i]+']'];
			c.checked = (idCheckBox.checked)?true:false;
			//c = document.forms['filtr_tur4'][elemName+'['+esJs1[i]+']'];
			//c.checked = (c.checked)?false:true;					
		}
	}
}

function checkAllBox(elemName,esJs)
{
	var all_check_ = "all_check_"+elemName;
	
	if (esJs)
	{
		var idCheckBox = document.getElementById(all_check_);
		
		var j=0;
		for (var i = 0; i < esJs.length; i++)
		{
			c = document.forms['formFiltr']['filtr['+elemName+']['+esJs[i]+']'];
			if (c.checked)
				j++;
		}	
		//alert(j);
		
		if (j == esJs.length)
			idCheckBox.checked = 1;
		else
			idCheckBox.checked = 0;			
	}
}