/**
* Common JavaScript file to be called into every page within the Election Maps domain,
* immediately below the last <meta /> tag in the <head> section.
* 
* @author			: Toni Ruckwood
* @version			: 1.2 
* @create date		: 27 July 2007
* @modified date	: 23 May 2008
*/

/**
* Measures the width of the browser window and adjusts the position of the <body> tags background graphic accordingly. 
* @method			: fixBG
* @param				container	: DIV containing the entire page contents.
* @author			: Toni Ruckwood
* @since				: 1.0
* @create date		: 27 July 2007
* @modified date	: 
*/
function fixBG(){
	var container = document.getElementById("wrapper");
	if (container && container.offsetWidth > 0){
		eval('document.getElementsByTagName("body")[0].style.backgroundPosition = "-' + Math.round(750 - ((container.offsetWidth - 762)/2)) + 'px 58px"');
	}
}

/**
* Measures the height of the "textcontent" area and adjusts the height accordingly. 
* @method			: fixHeight
* @param				content	: DIV containing the main text content of the page.
* @author			: Toni Ruckwood
* @since				: 1.0
* @create date		: 30 August 2007
* @modified date	: 
*/
function fixHeight(){
	if (document.getElementById) {
		var content = document.getElementById("textcontent");
		if (content) {
			if (content.offsetHeight < 400) {
				content.style.height = "400px";
			}
		}
	}
}

/**
* Checks for IE6 and then applies a background filter to allow it to support PNG alpha transparency on background images. 
* @method			: fixPNG.
* @author			: Toni Ruckwood
* @since				: 1.0
* @create date		: 27 July 2007
* @modified date	: 23 May 2008
*/
function fixPNG(elem,imgpath){
	//Function call is on every page, so function contents commented-out as no longer required.
	/*if (navigator.userAgent.indexOf("MSIE") != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) < 7 && document.getElementById){
	document.getElementById(elem).style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imgpath + "',sizingMethod='scale')";
	}*/
}

/**
* Toggle the display of the "overview" and "layers" sections.. 
* @method			: showHide
* @param				elem	: element name to display.
* @author			: Toni Ruckwood
* @since				: 1.0
* @create date		: 27 July 2007
* @modified date	: 
*/
function showHide(elem){
	if (elem == "layers"){
		document.getElementById("overview").style.display = "none";
		document.getElementById("layers").style.display = "block";
	}
	else {
		document.getElementById("overview").style.display = "block";
		document.getElementById("layers").style.display = "none";

		// To solve problem of ov map rectangle not being properly refreshed when
      // the div is hidden
		forceOvRefresh();  
	}
}
