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

function OverOutTD(idTd, type)
{
	var tdObj = document.getElementById(idTd);
	//var widthTd = tdObj.offsetWidth;
	//var widthSub = null;
	
	if (tdObj)
	{		
		var subObj = document.getElementById('sub_'+idTd);
		var aObj = document.getElementById('a_'+idTd);
		
		switch (type)
		{
			case "over":
				MenuSH[idTd]=1;	
				//tdObj.style.color = "#000000";
					
				if (aObj)
				{
					//aObj.className = "overMade";
				}				
				
				if (subObj)
				{
					//var widthTd = tdObj.offsetWidth;
					//var widthSub = widthTd+90;
					
					//if (widthSub && idTd!="m_current")
						//subObj.style.width = widthSub + "px";
					
					subObj.style.display = "block";
					//new Effect.Appear(subObj, { duration: 0.5 });
				}
				break;
				
			case "out":
				MenuSH[idTd]=0;
				setTimeout('outTD("'+idTd+'")',0);				
				break;
		}		
	}
}

function outTD(idTd)
{
	if (MenuSH[idTd]==0)
	{
		//var tdObj = document.getElementById(idTd);

		var subObj = document.getElementById('sub_'+idTd);
		if (subObj)
		{
			subObj.style.display = "none";
			//new Effect.Fade(subObj, { duration: 0.5 });
		}
				
		var aObj = document.getElementById('a_'+idTd);
		if (aObj)
		{
			aObj.className = "";
		}		
	}
}

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)
				//{
						//obj.style.background = "none";
				//}
				
				var subObj = document.getElementById('sub_'+MainDivs[i]);
				if (subObj)
				{
					subObj.style.display = "none";
					//subObj.hide();
					//new Effect.Fade(subObj, { duration: 0.3 });
				}
				
				var aObj = document.getElementById('a_'+MainDivs[i]);
				if (aObj)
				{
					//aObj.className = "";
				}					
			}
			
			lastId = MainDivs[i];				
		}
	}
}


function clearValue(obj,toPwd)
{
	if (obj)
	{
		obj.value = "";
		if (toPwd)
		{
			var parent = obj.parentNode;
			var objId = obj.id;
			
			if (parent != null)
			{
				var oldInput = parent.innerHTML;
				
				oldInput = oldInput.replace('type="text"','');
				oldInput = oldInput.replace('onfocus=clearValue(this,1);','onfocus=clearValue(this,0);');
				oldInput = oldInput.replace('onclick=clearValue(this,1);','onclick=clearValue(this,0);');
				oldInput = oldInput.replace('onfocus="clearValue(this,1);"','onfocus="clearValue(this,0);"');
				oldInput = oldInput.replace('onclick="clearValue(this,1);"','onclick="clearValue(this,0);"');

				oldInput = oldInput.replace('>',' type="password">');
				
				if (oldInput.search(/type=password/i) == -1)
				{
					parent.removeChild(obj);
					parent.innerHTML = oldInput;
				
					var newObj = document.getElementById(objId)
					if (newObj)
					{
						newObj.focus();
						newObj.focus();
					}
				}
			}
		}
	}
} 

function checkKey(e,withCtrl,keys,urls)
{
	var code;
	if (!e) var e = window.event;
	
	if (withCtrl == 1)
	{
		if (e.keyCode && e.ctrlKey) code = e.keyCode;
		else if (e.which && e.ctrlKey) code = e.which;	
	}
	else
	{
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;			
	}

	//alert(code);
	if (keys.length>0)
	{
		for (i=0; i < keys.length; i++)
		{
			if (code == keys[i])
			{
				if (urls[i])
				{
					//alert(urls[i]);
					window.location = urls[i];
				}
			}
		}
	}	
}

function checkKey2(e,id)
{
	var code;
	
	if (!e) var e = window.event;
	
	var keyPressObj = (e.srcElement)?e.srcElement:null;
	keyPressObj = (e.target)?e.target:keyPressObj;
	
	if (e.keyCode)
	{
		code = e.keyCode;
	}
	else if (e.which) 
	{
		code = e.which;	
	}
	
	var dontSubmit = 0;
	if (keyPressObj)
		if (keyPressObj.type == "textarea" || keyPressObj.type == "button")
			dontSubmit = 1;
	
	if (code == 13 && !dontSubmit)
	{
		var submitForm = document.getElementById(id);
		if (submitForm)
		{
			submitForm.submit();
		}
	}
	
} 

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 rollOver(thisObj,file)
{
	//thisObj.src = file;
	thisObj.style.background = "url('"+file+"')";
	thisObj.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + thisObj.style.backgroundImage.substr( 4, thisObj.style.backgroundImage.length - 5 ) + '", sizingMethod="crop")';	
	//thisObj.style.background = "#ffffff";
}

function rollOver2(id,file)
{
	var thisObj = document.getElementById(id);
	if (thisObj)
		thisObj.src = file;
}