//************* DROP DOWN MENU FUNCTIONS ******************************
var timer; //will hold the timer object
var xOffset=0; // pixel offset to the left
var yOffset=0; // pixel offset to the left
var iframe; //reference to the frame object
var selectArray; //will hold the selects on page

function hideOneClick() {if(timer){clearTimeout(timer);}timer = setTimeout('hideNow()',500);}
function showOneClick() {if (timer) {clearTimeout(timer);} showNow()} //if mouse over menu then clear the hide timer
function showClick() {var mobj; mobj = getObject('oneclick');if (timer) {clearTimeout(timer);}if(mobj && mobj.style.display=='block') {hideNow()} else {showNow();}}
function showNow() {
	
	var mobj; mobj = getObject('oneclick');
	var sender; sender = getObject('sender');
	var browser;
	
	if(mobj && mobj.style.display!='block') {
		if (csBrowserInfo()==0) {hideSelects('hidden');}
		if (csBrowserInfo()==2){mobj.style.filter = "progid:DXImageTransform.Microsoft.RevealTrans(transition=1, duration=0.1)";mobj.filters.item(0).enabled=1;mobj.filters.item(0).apply();} //apply the filter only if this is the first time the meun is shown
		mobj.style.display='block'; //show the selected menu
		mobj.style.left = getRealLeft(sender)+getWidth(sender)-getWidth(mobj)+xOffset+'px' //the the left point of the menu
		mobj.style.top = getRealTop(sender)+getHeight(sender)+yOffset+'px'; //set the top point of the menu
		mobj.style.display=''; //redraw for opera bug
		mobj.style.display='block';
		if (csBrowserInfo()==2){mobj.filters.item(0).play();} //run apllied filter if the browser is internet explorer 6.0+
		if (iframe) {iframe.style.top=mobj.style.top;iframe.style.left=mobj.style.left;iframe.style.width=getWidth(mobj);iframe.style.height=getHeight(mobj);iframe.style.display='';mobj.style.zIndex=2000;}
	} else {
	
	}
}

function hideNow() {
	var mobj; mobj = getObject('oneclick');
	if (mobj) {mobj.style.display='';} //hide the active menu
	if (iframe) {iframe.style.top = '0px';iframe.style.left = '0px';iframe.style.width = '0px';iframe.style.height = '0px';iframe.style.display = 'none';}
	if (csBrowserInfo()==0) {hideSelects('visible');}
}

//this function writes an iframe used to hide form elements that would otherwise show up through a html layer
function initializeMenu() {
	if (iframe!=true && csBrowserInfo()>0 ) {
		document.write("<iframe id=\"iframe\" style=\"display: none; width:0px; height:0px; left:0px; position:absolute; top: 0px; z-index:1000;\" src=\"javascript:false;\" frameBorder=\"0\" scrolling=\"no\"></iframe>")
		iframe = document.getElementById("iframe");
	}
}

// these functions return the x,y,width and height of an object
function getRealLeft(obj){var curleft = 0;if (obj.offsetParent) {while (obj.offsetParent){curleft += obj.offsetLeft;obj = obj.offsetParent;}} else if (obj.x) curleft += obj.x; return curleft;}
function getRealTop(obj){var curtop = 0;if (obj.offsetParent) {while (obj.offsetParent){curtop += obj.offsetTop;obj = obj.offsetParent;}} else if (obj.y) curtop += obj.y; return curtop;}
function getHeight(objID) {return objID.offsetHeight}
function getWidth(objID) {return objID.offsetWidth}

//get browser info in order to detect if the browser supports filters and if the browser is IE 5.0 (if 5.0 requires the hiding of select boxes)
function csBrowserInfo()
{
	var csUserAgent = String(navigator.userAgent);
	if (!document.getElementById) return -1;
	else if(csUserAgent.indexOf("MSIE 5.0") > -1) return 0;
	else if(csUserAgent.indexOf("Opera") > -1) return 1;
	else if(csUserAgent.indexOf("MSIE 6") > -1) return 2;
	else return 1;
}

//hide selects for ie 5.0 since the iframe hack does not work
function hideSelects(action) {
	var numberForms = document.forms.length;
	for (formIndex = 0; formIndex < numberForms; formIndex++)
	{
	   var numberElems; numberElems = document.forms[formIndex].elements.length
	   for (formElemIndex = 0; formElemIndex < numberElems; formElemIndex++)
		{
		   if (document.forms[formIndex].elements[formElemIndex].tagName=='SELECT') {
			document.forms[formIndex].elements[formElemIndex].style.visibility=action;
		   }
		}
	}
}