// JavaScript Document
// Applied to <div> which contains copy for overlay

function hideshow_selects(para) {
/*cycles through Id=Container and hides/shows Select tags to prevent them bleeding through DIV tags in Internet Explorer*/

	var a = document.getElementsByTagName('select');
	
	if (para) {
		for (i=0; i<a.length; i++) {
			if(a[i].className != 'exempt') {
				a[i].style.visibility='hidden';
				}
		}
	}
	
	else {
		for (i=0; i<a.length; i++) {
			if(a[i].className != 'exempt') {
			a[i].style.visibility='visible';
			}
		}
	
	}
}

// This function toggles the translucent mask.  It is accessed in togglepopup() function.
	function mask(par) {
		if (par==true)
			document.getElementById('bgblock').style.display='';
		else if (par==false)
			document.getElementById('bgblock').style.display='none';
		else
			alert('Invalid parameter!');
	}
//This function toggles the popup. It takes two parameters.
//First parameter is the div ID. (popup1, popupbox, popup3, popup4, etc)
//Second parameter is boolean for the popup state. (close/open)
	function togglepopup(par, state){
	if (state==true){
		document.getElementById(par).style.display='';
		mask(true);
		resizebgblock();
		hideshow_selects(true);
		}
	else if (state==false){
		document.getElementById(par).style.display='none'
		mask(false);
		hideshow_selects(false);
		}
	else
		alert('Invalid parameter!')
	}
	function resizebgblock() {
	var height;
	var width;
			{
			if (document.documentElement.clientHeight <= document.body.clientHeight)
				//For IE
				{
					//Calculates if Body Content is taller than Browser display area
					if (document.body.scrollHeight > document.body.clientHeight)
						height = document.body.scrollHeight;
					else
						height = document.body.clientHeight;
						width = document.body.clientWidth;
				}
				else 
					{
					//For FF
					height = document.documentElement.clientHeight;
					width= document.documentElement.clientWidth;
					}				
			}
		var yy = height+'px';
		var zz = width+'px';
		document.getElementById("bgblock").style.width = zz;
		document.getElementById("bgblock").style.height = yy;		
	}
/* This function centers the popup. */
	function centerthis() {
	var browserwidth;
	var browserheight;
/* Begin Normalization of browser width/height calculation */
	if (self.innerWidth)
	{
		browserwidth = self.innerWidth;
		browserheight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		browserwidth = document.documentElement.clientWidth;
		browserheight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		browserwidth = document.body.clientWidth;
		browserheight = document.body.clientHeight;
	}
	else return;
/* End Normalization */
	var width = (browserwidth - document.getElementById("popupbox").offsetWidth)/2;
	var height = (browserheight - document.getElementById("popupbox").offsetHeight)/2;
	document.getElementById('popupbox').style.left=width+'px';
	document.getElementById('popupbox').style.top=height+'px';
}

//-->