/*cfLightBox.js by Cory Fischer http://www.planetkodiak.com*/function heavyJsBrowserCheck() { // checks to see if browser is fast enough to render heavy scripts	if (BrowserDetect.browser == "Safari" || BrowserDetect.browser == "Firefox") {		return true;	} else {		return false;	}}var GLOBAL_SHADOW_CONTENT	= ""; // holds the html that will go into the iframevar GLOBAL_STORY_SHOWN		= ""; // holds the ID of the <div> this content came fromfunction removeDiv(div) {	var olddiv = document.getElementById(div); // get container div	document.getElementById('bodyWrapper').removeChild(olddiv);}function hideStories(elmToHide) {	try{		document.getElementById(GLOBAL_STORY_SHOWN).innerHTML = GLOBAL_SHADOW_CONTENT; // resetting the HTML back to normal		GLOBAL_STORY_SHOWN = "";		GLOBAL_SHADOW_CONTENT = "";	} catch(e){}	if (heavyJsBrowserCheck()) { // run heavy js animations if browser can handle it		unSetBoxOpacity = setOpacity;		document.getElementById('shadowIframe').src = 'http://wvnetworkmedia.org/blank.htm'		for (var i=opacity;i>0;i--) { // opacity is global var. should be set to 10			setTimeout("unSetBoxOpacity('"+elmToHide+"',"+i+")",Math.abs(30*(Math.abs(i) - 10)));		}		setTimeout("document.getElementById('"+elmToHide+"').style.left = '-999em';document.getElementById('"+elmToHide+"').style.opacity = 0;",opacity*30);	} else {		document.getElementById(elmToHide).style.left = '-999em';		document.getElementById('shadowIframe').src = 'http://wvnetworkmedia.org/blank.htm';	}	GLOBAL_SLIDESHOW_ON = true; // reinitiate slideshow	hideOverlay();}function centerDiv(obj,width) {		if(typeof obj=='string'){obj=document.getElementById(obj);}		var yScroll 		= parseInt(document.body.scrollTop)|| parseInt(document.documentElement.scrollTop);		obj.style.top 		= 120+parseInt(yScroll)+"px";		if (document.all) { // Internet Explorer			var screenWidth = document.body.clientWidth;			var screenHeight = document.body.clientHeight;		} else { // FF, Opera etc.			var screenWidth = window.innerWidth;			var screenHeight = window.innerHeight;		}		var newScreenWidth 	= parseInt((screenWidth/2) -(width/2));		obj.style.marginLeft= (newScreenWidth-15)+"px";		//obj.style.right	= "79px";}var window_x_src = "http://media.worldvision.org/home/images/window_x2.png";if (BrowserDetect.browser == "Explorer" && parseInt(BrowserDetect.version) == 6) {	var window_x_src = "http://media.worldvision.org/home/images/window_x2.gif";}function shadowBox(id, html, width, height, ajaxPage,drag,center,overLay,src) {	if (GLOBAL_STORY_SHOWN != "") {		document.getElementById(GLOBAL_STORY_SHOWN).innerHTML = GLOBAL_SHADOW_CONTENT;	}	if (!src) { // not a link to external page		GLOBAL_SHADOW_CONTENT	= html.innerHTML;		GLOBAL_STORY_SHOWN		= html.id;	}	if (overLay) {displayOverlay();}	if (!document.getElementById(id)) { // if div has not been created yet.		var newdiv = document.createElement('div');		newdiv.setAttribute('id', id);		newdiv.className 		= 'floatingDiv';		newdiv.style.position 	= "absolute";		newdiv.style.zIndex 	= 20;		var bodyWidth 		= document.body.clientWidth;		var screenWidth		= screen.width;		if (bodyWidth>screenWidth){newWidth=bodyWidth;}else{newWidth=screenWidth;}		newdiv.style.marginLeft	= parseInt((newWidth/2)-(width/2)-15)+"px";		document.body.appendChild(newdiv);				// drag window		//if (drag) {Drag.init(document.getElementById(id+"TitleBar"),document.getElementById(id));}				var winInfo = document.createElement('div');		winInfo.setAttribute('id', id+"InfoWindow");		newdiv.appendChild(winInfo);		// add info to the 'info window' through ajax function		//if (ajaxPage) {ajaxPageToContainer(ajaxPage,id+"InfoWindow");}				// displays veil over body		if (BrowserDetect.browser == "Explorer") {			//if (parseInt(BrowserDetect.version) >= 7) { // IE7				var lightBoxHeader = '<div id="lightBoxHeader" style="position:absolute; right: -25px; top: -25px; cursor: pointer;"><img src="'+window_x_src+'" border="0" onclick="hideStories(\''+id+'\');" /></div>\n';				var iframeHtml		= '<iframe name="shadowIframe" id="shadowIframe" width="100%" height="100%" src="http://wvnetworkmedia.org/blank.htm" frameborder="0" style="margin: 5px 0 0 0;"></iframe>\n';			//} else { // IE6			//	var lightBoxHeader 	= '<div id="lightBoxHeader" style="position:absolute; right: -13px; top: -25px; cursor: pointer;"><img src="'+window_x_src+'" border="0" onclick="hideStories(\''+id+'\');" /></div>\n';			//	var iframeHtml		= '<iframe name="shadowIframe" id="shadowIframe" width="'+(width-10)+'" height="'+(height-15)+'" src="http://wvnetworkmedia.org/blank.htm" frameborder="0" style="margin: 5px 0 0 0;"></iframe>\n';			//}		} else {			var lightBoxHeader = '<div style="position:absolute; right: -45px; top: -25px; cursor: pointer;"><img src="'+window_x_src+'" border="0" onclick="hideStories(\''+id+'\');" /></div>\n';			var iframeHtml		= '<iframe name="shadowIframe" id="shadowIframe" width="100%" height="100%" src="http://wvnetworkmedia.org/blank.htm" frameborder="0" style="margin: 5px 0 0 0;"></iframe>\n';		}		var newHtml = '<div id="frameContainer" style="width: '+(width+10)+'px; height: '+(height+10)+'px;">\n';		newHtml+= lightBoxHeader;		newHtml+= iframeHtml;		newHtml+= '<div id="frameCommands">\n';			newHtml+= '<div id="emailIconBubble" style="right: '+(34)+'px;"></div>\n';				newHtml+= '<img src="http://media.worldvision.org/home/images/email_icon.gif" border="0" alt="email" id="emailArticle" onmouseover="document.getElementById(\'emailIconBubble\').style.display=\'block\';" onmouseout="document.getElementById(\'emailIconBubble\').style.display=\'none\';" style="right: '+(50)+'px;" onclick="referfriend();return false;" />\n';			newHtml+= '<div id="printIconBubble" style="right: '+(84)+'px;"></div>\n';				newHtml+= '<img src="http://media.worldvision.org/home/images/print_icon.gif" border="0" alt="print" id="printArticle" onmouseover="document.getElementById(\'printIconBubble\').style.display=\'block\';" onmouseout="document.getElementById(\'printIconBubble\').style.display=\'none\';" style="right: '+(100)+'px;" onclick="window.frames[\'shadowIframe\'].print();" />\n';		newHtml+= '</div>\n';		newHtml+= '</div>\n';		document.getElementById(id).innerHTML = newHtml;	} else {		var marginOffset = 10;		document.getElementById('frameContainer').style.width = (width+marginOffset)+"px";		document.getElementById('frameContainer').style.height= (height+marginOffset)+"px";	}	// set width and center div is requested	if (width) {		if (document.all) {// IE has weird sizing issue. Add 20px			document.getElementById(id).style.width = (width+20)+"px";			if (BrowserDetect.browser == "Explorer" && parseInt(BrowserDetect.version) <= 7) {				document.getElementById('shadowIframe').style.width = (width+25)+"px";				document.getElementById('shadowIframe').style.height= (height+24)+"px";			}		} else {			document.getElementById(id).style.width = width+"px";		}		if (center) {			document.getElementById(id).style.opacity = 0;			centerDiv(document.getElementById(id),width);		}	}	var shadowBoxObj = document.getElementById("floatingStory");	if (!src) { // if NOT link to external page, don't bring in content dynamically from same page		if (document.getElementById('shadowIframe').src.indexOf("http://wvnetworkmedia.org/blank.htm") >= 0) {			document.getElementById('shadowIframe').src = "http://wvnetworkmedia.org/blank.htm";			createIframe(html);			shadowBoxObj.style.opacity = 0;			setBoxOpacity = setOpacity;			for (var i=0;i<=opacity;i++) { // opacity is global var. should be set to 10				setTimeout("setBoxOpacity('floatingStory',"+i+")",50*i);			}		} else {			document.getElementById('shadowIframe').src = "http://wvnetworkmedia.org/blank.htm";			setTimeout('createIframe(document.getElementById("'+html.id+'"))',500);		}	} else {		document.getElementById('shadowIframe').src = src;		centerDiv(document.getElementById(id),width);		if (heavyJsBrowserCheck()) { // run heavy js animations if browser can handle it *****  && (!shadowBoxObj || shadowBoxObj.style.left == "-999em")			shadowBoxObj.style.opacity = 0;			setBoxOpacity = setOpacity;			for (var i=0;i<=opacity;i++) { // opacity is global var. should be set to 10				setTimeout("setBoxOpacity('floatingStory',"+i+")",50*i);			}		} else {			document.getElementById("floatingStory").style.opacity = 1;		}	}	if (!document.getElementById(id).style.left == "") { // recenter iframe if it exists		document.getElementById(id).style.left = "0";	}	// initiate anchor tag fix (all browsers)	setTimeout("iFrAnchors()",1000);}function resizeBox(obj,width,height,math) {	if (typeof obj=='string'){obj=document.getElementById(obj);}	if(width) {		obj.style.width = width+'px';	}	if(height) {		obj.style.height = height+'px';	}}function resizeLightBox(newWidth,newHeight) {	var frameCon = document.getElementById('frameContainer');	var oldWidth = parseInt(frameCon.style.width);	var oldHeight= parseInt(frameCon.style.height);	if (newWidth) {		if (oldWidth > newWidth) { // shrink			var diff = oldWidth - newWidth;			document.getElementById('floatingStory').style.width = newWidth+'px';			document.getElementById('frameContainer').style.width = (newWidth+10)+'px';			if (BrowserDetect.browser == "Explorer") {				if (parseInt(BrowserDetect.version) < 7) { // IE6 and below					document.getElementById('shadowIframe').style.width = (newWidth-3)+"px";				} else if (parseInt(BrowserDetect.version) >= 7) { // IE7					document.getElementById('floatingStory').style.width = (newWidth+15)+"px";				}			}			centerDiv('floatingStory',(oldWidth-diff));		} else {			var diff = newWidth-oldWidth;			if (BrowserDetect.browser == "Explorer" && parseInt(BrowserDetect.version) < 7) {				document.getElementById('shadowIframe').style.width = (newWidth+25)+"px";			}			document.getElementById('floatingStory').style.width = newWidth+'px';			document.getElementById('frameContainer').style.width = (newWidth+10)+'px';			centerDiv('floatingStory',(oldWidth+diff));		}	}	// now height	if (newHeight) {		if (oldHeight > newHeight) { // shrink			var diff2 = oldHeight - newHeight;			document.getElementById('floatingStory').style.height = newHeight+'px';			document.getElementById('frameContainer').style.height = newHeight+'px';			if (BrowserDetect.browser == "Explorer" && parseInt(BrowserDetect.version) < 7) {				document.getElementById('shadowIframe').style.height = (newHeight+20)+"px";			}		} else {			var diff2 = newHeight-oldHeight;			if (BrowserDetect.browser == "Explorer" && parseInt(BrowserDetect.version) < 7) {				document.getElementById('shadowIframe').style.height = (newHeight+20)+"px";			}			document.getElementById('floatingStory').style.height = (newHeight)+'px';			document.getElementById('frameContainer').style.height = (newHeight)+'px';		}	}}function createIframe(html) {	var iframe = document.getElementById('shadowIframe');	if (iframe && iframe.contentDocument) {		iframeDoc = iframe.contentDocument;	}	else if (iframe && iframe.contentWindow) {		iframeDoc = iframe.contentWindow.document;	}	else if (iframe && window.frames[iframe.name]) {		iframeDoc = window.frames[iframe.name].document;	}	if (iframeDoc) {		try {			iframe.src = "http://wvnetworkmedia.org/blank.htm";			iframeDoc.open();			iframeDoc.write('<html><head><link rel="stylesheet" type="text/css" href="http://www.wvnetworkmedia.org/styles_nonflash.css" /><link rel="stylesheet" type="text/css" href="http://www.wvnetworkmedia.org/print.css" media="print" /></head><body class="iFrame"><div id="printBanner"><img src="http://media.worldvision.org/home/images/header.jpg" border="0" alt="World Vision" /></div>'+GLOBAL_SHADOW_CONTENT+'<\/body><\/html>');			iframeDoc.close();			if (html) {				html.innerHTML = ""; // set it to nothing, then set it back when we're done.			}		} catch(e){}	}}function swapImg(oImg,newSrc) {oImg.src = newSrc;}function scrollToPos(elm,top) {	frame=window.frames["shadowIframe"];	doc = frame.document.body;	yScroll = parseInt(doc.scrollTop)|| parseInt(window.frames["shadowIframe"].document.documentElement.scrollTop);	if (top) {		var scrollAmount = 0 - yScroll;	} else {		var scrollAmount = elm.offsetTop - yScroll;	}	frame.scrollBy(0,scrollAmount); }function scrollToAnchor(href,top) {	var anchorName = href.substr(href.indexOf("#")+1,href.length);	var anchors = frames["shadowIframe"].document.getElementsByTagName("a");	var anchorElm = null;	if (top) {		scrollToPos(null,true);	} else {		for(var i=0;i<anchors.length;i++) {			if (anchors[i].name == anchorName) {				anchorElm = anchors[i];				break;			}		}		scrollToPos(anchorElm);	}}function iFrAnchors() {	if (window.frames.length == 0) {		createIframe();	}	while(!window.frames["shadowIframe"]) {		// continue loop until frame loads to prevent synchronous js	}	// proceed once frame has loaded	try {		var anchorLinks = window.frames["shadowIframe"].document.getElementsByTagName("a");		for(var i=0;i<anchorLinks.length;i++) {			if (!anchorLinks[i].target || anchorLinks[i].target == "") {				anchorLinks[i].target="_top";			}			if (anchorLinks[i].href.indexOf("#") > -1) { // this is an anchor link				for(var j=0;j<anchorLinks.length;j++) { // see if this name exists in this document. allows anchors in external links					if (anchorLinks[j].name == anchorLinks[i].href.substr(anchorLinks[i].href.indexOf("#")+1,anchorLinks[i].href.length)) { // name/href pair found						anchorLinks[i].onclick = function() {							scrollToAnchor(this.href);							return false;						}					}				}			}			if (anchorLinks[i].href.substr(anchorLinks[i].href.length - 4) == "#top") {				anchorLinks[i].onclick = function() {					scrollToAnchor(this.href,true);					return false;				}			}		}	} catch(e){}}var opacity = 10;setOpacity = function(id,intVal)	{	var e = document.getElementById(id);	e.style.opacity = intVal/10;}// opacity of background overlay//var veilOpacity = 7;// hides everything in the body except for the window that calls the functionfunction displayOverlay() {	if (!document.getElementById('bodyShadow')) {	    if (document.getElementById('selectcountry')){              document.getElementById('selectcountry').style.display='none';         }         if (document.getElementById('searchFields')){              document.getElementById('searchFields').style.display='none';         }         if (document.getElementById('wvuscrumbtrail')){             document.getElementById('wvuscrumbtrail').style.zIndex=0;         }		var bodyHeight 		= document.body.clientHeight;		var screenHeight	= screen.height;		if (bodyHeight > screenHeight) {			overlayHeight 	= bodyHeight;		} else {			overlayHeight 	= screenHeight;		}		var newdiv 			= document.createElement('div');		newdiv.className 	= 'bodyShadow';		//setBoxOpacity = setOpacity;		//for (var i=0;i<=veilOpacity;i++) {		//	setTimeout("setBoxOpacity('bodyShadow',"+i+")",30*i);		//}		newdiv.style.height = overlayHeight+'px';		if (BrowserDetect.browser == "Explorer") {			newdiv.style.height = '2000px';		}		newdiv.setAttribute('id', 'bodyShadow');		document.body.appendChild(newdiv);	}}function hideOverlay() {      if (document.getElementById('selectcountry')){              document.getElementById('selectcountry').style.display='block';         }         if (document.getElementById('searchFields')){              document.getElementById('searchFields').style.display='block';         }	if (document.getElementById('bodyShadow')) {		document.body.removeChild(document.getElementById('bodyShadow'));		/*		unSetBoxOpacity = setOpacity;		for (var i=veilOpacity;i>0;i--) {			setTimeout("unSetBoxOpacity('bodyShadow',"+i+")",30*(veilOpacity/i));		}		setTimeout("document.body.removeChild(document.getElementById('bodyShadow'))",veilOpacity*30);		*/	}}