/* 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();
}

/* preload any images (navigation, mouseovers, layers, etc.) */
var imgAr = new Array(
	"/images/icon_refer_A.gif",
	"/images/icon_refer_A.gif",
	"/images/icon_print_A.gif",
	"/images/icon_print_A.gif",
	"/images/icon_contactUs_A.gif",
	"/images/icon_contactUs_A.gif"
);

if (document.images) {
	var imgs = new Array();
	for (var i=0; i<imgAr.length; i++) {
  	imgs[i] = new Image(); 
		imgs[i].src = imgAr[i];
  }
}

/* a general swap image function.
*/
function swapImg(image,state) {
	if(document.images) {
		if (state!=0) {
		document.images[image].src = "/images/"+image+"_on.gif";
		}
		else {
		document.images[image].src = "/images/"+image+"_off.gif";
		}
	}
}

/*
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;
}

/*
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("/sendtoafriend.php?refURL="+pageURL+"&refPageTitle="+pageTitle, "Email_Friend", "width=500,height=600,menubar=no,top=50,left=50,resizable=yes");
}

