/* START: Do not change these scripts */
function CustomInit () {}
function GetObjRef (objId) {
	var returnObj = null;
	if (document.getElementById) {
		returnObj = document.getElementById(objId);
	}
	else if (document.all) {
		returnObj = document.all[objId];
	}
	return returnObj;
}
function GetCurrentStyle (obj, prop) {
	if (obj.currentStyle) {
		return obj.currentStyle[prop];
	}
	else if (window.getComputedStyle) {
		prop = prop.replace (/([A-Z])/g, "-$1");
		prop = prop.toLowerCase ();
		return window.getComputedStyle (obj, "").getPropertyValue(prop);
	}
	return null;
}

function ShowObj (objId) {
	var returnObj = GetObjRef (objId);
	if (returnObj && returnObj.style) {
		returnObj.style.display = "block";
	}
}
function HideObj (objId) {
	var returnObj = GetObjRef (objId);
	if (returnObj && returnObj.style) {
		returnObj.style.display = "none";
	}
}
function ToggleObj (objId) {
	var returnObj = GetObjRef (objId);
	if (returnObj && returnObj.style) {
		if (returnObj.style.display == "block") {
			returnObj.style.display = "none";
		}
		else {
			returnObj.style.display = "block";
		}
	}
}

function GetTarget (e, thisObj) {
	if (!e) {e = window.event;}
	if (!e) {return null;}
	var target;
	if (e.currentTarget) {
		target = e.currentTarget;
	}
	else if (thisObj.tagName) {
		// at least we know it's a tag
		target = thisObj;
	}
	return target;
}
function ReturnTarget (e, returnValue) {
	if (!e) {e = window.event;}
	if (!e) {return null;}
	if (e.preventDefault && returnValue == false) {
		e.preventDefault ();
	}
	else if (e.returnValue) {
		e.returnValue = returnValue;
	}
	else {
		return returnValue;
	}
}

var CustomPageDimension = new Object;
CustomPageDimension.x = -1;
CustomPageDimension.y = -1;
function SetCustomPageDimension (ids) {
	var c = ids.length;
	for (var i=0; i<c; i++) {
			var obj = GetObjRef (ids[i][0]);
			if (obj) {
				if (obj.offsetWidth + ids[i][1]> CustomPageDimension.x) {
					CustomPageDimension.x = obj.offsetWidth + ids[i][1];
				}
				if (obj.offsetHeight + ids[i][2] > CustomPageDimension.y) {
					CustomPageDimension.y = obj.offsetHeight + ids[i][2];
				}
			}
	}
}
function GetPageDimension () {
	if (document.body.scrollHeight || document.body.offsetHeight) {
		var dimension = new Object ();
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;
		if (test1 > test2) {
			// all but Explorer Mac
			dimension.x = document.body.scrollWidth;
			dimension.y = document.body.scrollHeight;
		}
		else {
			// Explorer Mac;
			// would also work in Explorer 6 Strict, Mozilla and Safari
			dimension.x = document.body.offsetWidth;
			dimension.y = document.body.offsetHeight;
		}
		if (CustomPageDimension.x > dimension.x) {
			dimension.x = CustomPageDimension.x;
		}
		if (CustomPageDimension.y > dimension.y) {
			dimension.y = CustomPageDimension.y;
		}
		return dimension;
	}
	else {
		return null;
	}
}
function InvertColor (hexColor) {
	hexColor = hexColor.replace ("#", "");
	var r = parseInt (hexColor.substr (0, 2), 16);
	var g = parseInt (hexColor.substr (2, 2), 16);
	var b = parseInt (hexColor.substr (4, 2), 16);
	var ir = (255 - r).toString (16);
		if (ir.length < 2) {ir = "0" + ir};
	var ig = (255 - g).toString (16);
		if (ig.length < 2) {ig = "0" + ig};
	var ib = (255 - b).toString (16);
		if (ib.length < 2) {ib = "0" + ib};
	return ("#" + ir + ig + ib);
}
function DarkenColor (hexColor, change) {
	hexColor = hexColor.replace (/\s/g, "");
	var r;
	var g;
	var b;
	if (hexColor.substr (0,1) == "#") {
		hexColor = hexColor.replace ("#", "");
		r = parseInt (hexColor.substr (0, 2), 16);
		g = parseInt (hexColor.substr (2, 2), 16);
		b = parseInt (hexColor.substr (4, 2), 16);
	}
	else if (hexColor.substr (0,3) == "rgb") {
		hexColor = hexColor.replace (/rgb\(([^\)]+)\)/g, "$1");
		var rgb = hexColor.split (",");
		r = parseInt (rgb[0], 10);
		g = parseInt (rgb[1], 10);
		b = parseInt (rgb[2], 10);
	}
	r = r - change;
	g = g - change;
	b = b - change;
	if (r < 0) {r = 0};
	if (g < 0) {g = 0};
	if (b < 0) {b = 0};
	r = r.toString (16);
		if (r.length < 2) {r = "0" + r};
	g = g.toString (16);
		if (g.length < 2) {g = "0" + g};
	b = b.toString (16);
		if (b.length < 2) {b = "0" + b};
	return ("#" + r + g + b);
}
function LightenColor (hexColor, change) {
	hexColor = hexColor.replace (/\s/g, "");
	var r;
	var g;
	var b;
	if (hexColor.substr (0,1) == "#") {
		hexColor = hexColor.replace ("#", "");
		r = parseInt (hexColor.substr (0, 2), 16);
		g = parseInt (hexColor.substr (2, 2), 16);
		b = parseInt (hexColor.substr (4, 2), 16);
	}
	else if (hexColor.substr (0,3) == "rgb") {
		hexColor = hexColor.replace (/rgb\(([^\)]+)\)/g, "$1");
		var rgb = hexColor.split (",");
		r = parseInt (rgb[0], 10);
		g = parseInt (rgb[1], 10);
		b = parseInt (rgb[2], 10);
	}
	r = r + change;
	g = g + change;
	b = b + change;
	if (r > 255) {r = 255};
	if (g > 255) {g = 255};
	if (b > 255) {b = 255};
	r = r.toString (16);
		if (r.length < 2) {r = "0" + r};
	g = g.toString (16);
		if (g.length < 2) {g = "0" + g};
	b = b.toString (16);
		if (b.length < 2) {b = "0" + b};
	return ("#" + r + g + b);
}
/* END: Do not change these scripts */





function PrintThisPage (Id) {
	var url = "/printwindow.cms?";
	if (location.pathname.indexOf ("article.cms") > -1) {
		url = url + "articleId=" + Id + "&pageType=article";
	}
	else if (location.pathname.indexOf ("news.cms") > -1) {
		url = url + "newsId=" + Id + "&pageType=news";
	}
	else if (location.pathname.indexOf ("department.cms") > -1) {
		url = url + "articleId=" + Id + "&pageType=article";
	}
	else {
		// temp routine for debugging only
		url = url + "articleId=" + Id;
	}
	var printWin = window.open (url,'printWin','status=yes,scrollbars=yes,resizable=yes,width=520,height=400');
	printWin.focus ();
}
function PrintWindow () {
	if (window.print) {
		window.print ();
	}
}

function EmailToAFriend (id, type) {
	if (document.EmailFriendForm) {
		document.EmailFriendForm.elements[0].value = id;
		document.EmailFriendForm.elements[1].value = type;
		document.EmailFriendForm.submit();
	}
}
	





/* START: Home Page */
function ScrollerItem_Over (thisObj) {
	var bgcolor = DarkenColor (GetComputedStyle (thisObj, "backgroundColor"), 30);
	thisObj.style.backgroundColor = bgcolor;
}
function ScrollerItem_Out (thisObj) {
	var bgcolor = LightenColor (GetComputedStyle (thisObj, "backgroundColor"), 30);
	thisObj.style.backgroundColor = bgcolor;
}
/* END: Home Page */


/* START: Roving Eye and Video Landing */
function SetPopUpGallery (id) {
	var galleryImages = document.getElementsByName (id);
	for (var i=0; i<galleryImages.length; i++) {
		if (galleryImages[i].src) {
			var parentLink = galleryImages[i].parentNode;
			if (parentLink.nodeName.toLowerCase() == "a") {
				parentLink.onclick = PopUpGallery_OnClick;
			}
		}
	}
}
function PopUpGallery_OnClick (e) {
	var target = GetTarget (e, this);
	if (target.tagName.toLowerCase () == "a") {
		var galleryPop = window.open (target.href, target.target, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=625,width=625,screenX=100,screenY=100,top=100,left=100');
		galleryPop.focus ();
	}
	return ReturnTarget (e, false);
}
/* END: Roving Eye and Video Landing */


/* START: Streaming Video */
function SetStreamingVideo () {
	var streamingVideoImages = document.getElementsByName ("StreamingVideo");
	for (var i=0; i<streamingVideoImages.length; i++) {
		if (streamingVideoImages[i].src) {
			var parentLink = streamingVideoImages[i].parentNode;
			if (parentLink.nodeName.toLowerCase() == "a") {
				parentLink.onclick = StreamingVideo_OnClick;
			}
		}
	}
}
function StreamingVideo_OnClick (e) {
	var target = GetTarget (e, this);
	if (target.tagName.toLowerCase () == "a") {
		var popWin = window.open (target.href, target.target, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,Width=400,height=400,screenX=150,screenY=150,top=150,left=150');
		popWin.focus ();
	}
	return ReturnTarget (e, false);
}
/* END: Streaming Video */


/* START: Streaming Video */
function SetSpeakOutLink () {
	var speakOutLinks = document.getElementsByName ("SpeakOutLink");
	if (speakOutLinks.length > 0) {
			var speakOutLink = speakOutLinks[0];
			speakOutLink.onclick = PopUpLink_OnClick;
			speakOutLink.popUpWidth = 400;
			speakOutLink.popUpHeight = 400;
	}
}
var sharedPopUpWin = null;
function PopUpLink_OnClick (e) {
	var target = GetTarget (e, this);
	if (target.tagName.toLowerCase () == "a") {
		if (sharedPopUpWin != null && sharedPopUpWin.closed == false) {
				sharedPopUpWin.close ();
		}
		var pWidth = (target.popUpWidth)? target.popUpWidth:400;
		var pHeight = (target.popUpHeight)? target.popUpHeight:400;
		sharedPopUpWin = window.open (target.href, target.target, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,Width=' + pWidth + ',height=' + pHeight);
		sharedPopUpWin.focus ();
	}
	return ReturnTarget (e, false);
}
/* END: Streaming Video */




/* START: Common Function */
function SetMastheadWidth () {
	var dimension = GetPageDimension ();
	var objMastheadBG = GetObjRef ("MastheadBG");
	if (objMastheadBG && dimension) {
		objMastheadBG.style.width = dimension.x + "px";
	}
	var objMainNav = GetObjRef ("MainNavBG");
	if (objMainNav && dimension) {
		objMainNav.style.width = dimension.x + "px";
	}
	var objHeaderAd = GetObjRef ("HeaderAd");
	if (objHeaderAd && dimension) {
		objHeaderAd.style.width = dimension.x + "px";
	}
}
function SetFooterPosition () {
	var dimension = GetPageDimension ();
	var objFooter = GetObjRef ("Footer");
	if (objFooter && dimension) {
		objFooter.style.top = dimension.y + "px";
		objFooter.style.display = "block";
	}
}
function SetRightColumnHeight () {
	var dimension = GetPageDimension ();
	var obj = GetObjRef ("RightColumn");
	var objFooter = GetObjRef ("FooterCore");
	if (obj && dimension) {
		var top = GetCurrentStyle (obj, "top");
		var footerMarginTop = GetCurrentStyle (objFooter, "marginTop");
		var footerBorderTopWidth = GetCurrentStyle (objFooter, "borderTopWidth");
		var footerPaddingTop = GetCurrentStyle (objFooter, "paddingTop");
		footerMarginTop = (footerMarginTop)? parseInt (footerMarginTop): 0;
		footerBorderTopWidth = (footerBorderTopWidth)? parseInt (footerBorderTopWidth): 0;
		footerPaddingTop = (footerPaddingTop)? parseInt (footerPaddingTop): 0;
		var footerTop = (footerMarginTop + footerBorderTopWidth + footerPaddingTop);
		if (top) {
			obj.style.height = dimension.y - parseInt (top) - footerTop + "px";
		}
	}
}

function mailToObfuscate(acc, domain) {
location.href = "mailto:" + acc + "@" + domain;
}
/* END: Common Function */





/* START: Anne's Scripts */

/* END: Anne's Scripts */

