/* General Open Window Function... 
Arguments: url, name, width (int), height (int), scrollbars (boolean 0 or 1)--
width, height, and scrollbars values are optional.*/
function openWin(url, name, w, h, s) {
	if (w) { w = "width=" + w; } else { w = "width=300" }
	if (h) { h = "height=" + h; } else { h = "height=400"}
	if (s) { s = "scrollbars=" + s } else { s = "scrollbars=0" }
	messagewindow = window.open(url, name, ""+w+","+h+","+s+",menubar=no,top=50,left=50,resizable=yes");
	messagewindow.focus();
}

/* Target Opener:
Send location url to window.opener and closes the pop up. */
function targetOpener(url) {
	if (!window.opener) { 
		location.replace(url);
	} else {
		window.opener.location.replace(url);
		window.opener.focus();
		window.close(self);
	}
}

/* Swap Image.
image   = to be efficient, this is part of the actual graphic's filename, 
          minus the "_A" or "_B", AND part of the image's "name=" parameter
state   = either 0 (Off, default state) or 1 (On)
*/
function chgImg(image,state) {
	var imgName = image;
	var status  = state;
	if(document.images) {
		if (status == 1) {
			document.images[imgName].src = "/images/"+imgName+"_on.gif";
		}
		else {
			document.images[imgName].src = "/images/"+imgName+"_off.gif";
		}
	}
}

/* Swap Table Cell background color. 
IE5+ and NS6+ only. Ignored in older browsers. */
function chgBG(cellID,bgColor) {
	var cell     = cellID;
	var newColor = bgColor;
	if ((document.getElementById) || (document.getElementById && !document.all)) {
		document.getElementById(cell).style.background = newColor;
	}
}

/* Swap a font's color inside an Object */
function chgFontColor(cellID,fontColor) {
	cell     = cellID;
	newColor = fontColor;
	if ((document.getElementById) || (document.getElementById && !document.all)) {
		document.getElementById(cell).style.color = newColor;
	}
}

/*
Print Page handler. No arguments.
*/
function printPage() {
	var destLoc
	var pageURL    = window.location.href;
	var pageQStr   = window.location.search;
	var strPrintIt = "PrintIt=1";
	
	/* remove any anchors from the URL -- this confuses the ASP that handles
	hiding page elements. */
	if (pageURL.indexOf("#")) {
		pageURLArray = (pageURL.split("#"));
		pageURL = pageURLArray[0];
	}
	
	/* Create the printable URL and send to browser */
	if ((pageQStr.length!="") || (pageQStr.length!=0)) {
		destLoc = pageURL + "&" + strPrintIt;
	} else {
		destLoc = pageURL + "?" + strPrintIt;
	}
	//window.location.href = destLoc;
	window.open(destLoc, "print", "width=800,height=600,scrollbars=yes, menubar=yes,top=50,left=50,resizable=yes");
}

/*
E-mail to Colleague handler. Single argument: the 'pageTitle' variable in
URL encoded form.
*/
function emailColleague(Title) {
	var pageURL   = window.location.href;
	var pageTitle = Title;
	window.open("/pop_colleague.asp?refURL="+pageURL+"&refPageTitle="+pageTitle, "Email_Colleague", "width=410,height=460,scrollbars=yes, menubar=no,top=50,left=50,resizable=yes");
}

/* getClientWidth()
 * Returns width of browser window.
 **/
function getClientWidth() {
	if (self.innerWidth) {
			cWidth = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
			cWidth = document.documentElement.clientWidth;
	} else if (document.body) {
			cWidth = document.body.clientWidth;
	}
	return cWidth;
}

/* getClientHeight()
 * Returns height of browser window.
 **/
function getClientHeight() {
	if (self.innerHeight) {
			cHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
			cHeight = document.documentElement.clientHeight;
	} else if (document.body) {
			cHeight = document.body.clientHeight;
	}
	return cHeight;
}


