/******************************/
/*     Drop Downs             */
/******************************/
var visShow, visHide;
var xel;
var temp;
var prev;
var offX;
var offY;
function showHide(obj, name, hide)
{	
	hide = (hide >= 1) ? 1 : 0;
	divshow = name;				//The div to show 
	xel = new getObj(divshow);    //Get on object for it
	
	if (obj) { offX = (obj.width / 2) - 37; offY = obj.height; setLyr(obj,divshow);	} //Move to the right place only when called from outside
	
	if (hide) {
		clearTimeout(temp);
		if(prev)
			prev.style.visibility = 'hidden';
			xel.style.visibility = 'visible';
	}
	else {
	 	if (location.href.indexOf(name) == -1) {
		}
		prev = xel.obj;
		temp = setTimeout('hide(xel.obj)',100);
	}
}

function hide(obj)
{
	obj.style.visibility = 'hidden';
}

function setLyr(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.top = (newY + offY) + 'px';
	if (document.body.clientWidth) {
		if ((newX + x.obj.offsetWidth) >= document.body.clientWidth) {
			newX = document.body.clientWidth - x.obj.offsetWidth;
		}
	}
	else if (window.innerWidth) {
		newX =  ((newX + x.obj.offsetWidth) > window.innerWidth) ? newX = window.innerWidth - 20 - x.obj.offsetWidth : newX;
	}

	x.style.left = (newX + offX) + 'px';
}


function findPosY(obj)
{
	var curtop = -25;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function findPosX(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 getObj(name) {
	visShow = 'visible';
	visHide = 'hidden';
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
		visShow = 'show';
		visHide = 'hide';
  }
}

