// FrameChecker -- Remove if frames site.
/*
if (window!=top) { top.location.replace(document.location.href); } */

// Show/Hide element
function fnToggleElementVisibility(strElementId) {
	//alert("fnToggleVisibility('" + strElementId + "');");
	var objElement = document.getElementById(strElementId);
	var blnVisible;
	if ( objElement != null ) {
			//alert("Found element named '" + strElementId + "'.");
		blnVisible = objElement.style.display != "none";
		if ( blnVisible == true ) {
				//alert("Hiding element '" + strElementId + "'.");
			objElement.style.display = "none"; } else {
				//alert("Showing element '" + strElementId + "'.");
			objElement.style.display = "block"; }
	} else { alert("Could not find '" + strElementId + "' element."); }
}
// Cross-Browser Block Element Display Toggler
function toggleElement(elId) {
	var visibleStyle = "block";
	if (!document.all) {
		var el = document.getElementById(elId);
		if((el != null) && (typeof(el) == 'object')) {
			var elName = el.tagName.toLowerCase();
			if (elName == "tr") {
				visibleStyle = "table-row";
			}
			else if (elName == "tbody") {
				visibleStyle = "table-row-group";
			}
			else {
				visibleStyle = "block";
			}
		} else {
			alert("ElementId '" + elId + "' is null or not an object.");
		}
	}
	var v = ((document.getElementById(elId).style.display == visibleStyle) || (document.getElementById(elId).style.display == ""));
	document.getElementById(elId).style.display = v ? "none" : visibleStyle;
}

// Popup Windows
function strOpenWindowFeatures(iWindowWidth, iWindowHeight) {
	var iMouseX = 10;
	var iMouseY = 10;
	if ( window.event != null ) {
		iMouseX = window.event.screenX;
		iMouseY = window.event.screenY; }
	var iScreenX = window.screen.availWidth;
	var iScreenY = window.screen.availHeight;
	var iWindowLeft = iMouseX;
	if ( iWindowLeft + iWindowWidth > iScreenX ) { iWindowLeft = iMouseX - iWindowWidth - 10; }
	if ( iWindowLeft < 10 ) { iWindowLeft = 10; }
	var iWindowTop = iMouseY;
	if ( iWindowTop + iWindowHeight > iScreenY - 50 ) { iWindowTop = iMouseY - iWindowHeight - 60; }
	if ( iWindowTop < 10 ) { iWindowTop = 10; }
	return "width=" + iWindowWidth + ", height=" + iWindowHeight + ", left=" + iWindowLeft + ", top=" + iWindowTop + ", resizable=yes";
}
function fnOpenWindow(strWindowURL, strWindowName, iWindowWidth, iWindowHeight) {
	var objNewWindow = window.open(strWindowURL, strWindowName, strOpenWindowFeatures(iWindowWidth, iWindowHeight), false);
	if ( objNewWindow != null ) {
		objNewWindow.focus();
	}
}
// Simplified Popup
// Usage: <a onclick="return popUp(this.href,250,250);" href="popup.aspx">Link</a>
function popUp(theLink, popUpWidth, popUpHeight) {
	var popUpWindow = window.open(theLink, "popUp", "width=" + popUpWidth +
	", height=" + popUpHeight +
	", left=50, top=50, resizable=yes, scrollbars=yes", false);
	if ( popUpWindow != null ) {
		popUpWindow.focus();
	}
	return false;
}
function closePopUp() {
window.close();
}

// This function is also in the admin.js file,
//  and fully documented there...
function fnSimulateRepeaterCommand(strLinkButtonUniqueID, strHiddenFieldUniqueID, strHiddenFieldValue) {
	//alert("fnSimulateRepeaterCommand('" + strLinkButtonUniqueID + "', '" + strHiddenFieldUniqueID + "', '" + strHiddenFieldValue + "');");

	// Split and Join the UniqueID property of the LinkButton to get
	//  the DHTML ID and .NET __doPostBack ID for the server control.
	var aryLinkButtonID = strLinkButtonUniqueID.toString().split(":");
	var strLinkButtonClientID = aryLinkButtonID.join("_");
	var strLinkButtonPostBackID = aryLinkButtonID.join("$");

	// Split and Join the UniqueID property of the HtmlInputHidden
	//  to get the DHTML ID for the server control.
	var aryHiddenFieldID = strHiddenFieldUniqueID.toString().split(":");
	var strHiddenFieldClientID = aryHiddenFieldID.join("_");

	// Look for DHTML objects for the LinkButton and HtmlInputHidden.
	var objLinkButton = document.getElementById(strLinkButtonClientID);
	var objHiddenField = document.getElementById(strHiddenFieldClientID);

	// A variable to verify that everything will work...
	var blnOK = false;
	//alert("typeof __doPostback = '" + typeof __doPostBack + "'");
	if ( typeof __doPostBack == 'function' ) {
		if ( objLinkButton != null ) {
			if ( typeof objLinkButton == 'object' ) {
				if ( objHiddenField != null ) {
					if ( typeof objHiddenField == 'object' ) {
						if ( objHiddenField.value != null ) {
							if ( strHiddenFieldValue.toString().length > 0 ) {
								blnOK = true;
							} else { alert("ERROR! strHiddenFieldValue parameter is an empty string!"); }
						} else { alert("ERROR! DHTML element with id='" + strHiddenFieldClientID + "' has no 'value' attribute!"); }
					} else { alert("ERROR! DHTML element with id='" + strHiddenFieldClientID + "' is not an object!"); }
				} else { alert("ERROR! Could not find a DHTML element with id='" + strHiddenFieldClientID + "'"); }
			} else { alert("ERROR! DHTML element with id='" + strLinkButtonClientID + "' is not an object!"); }
		} else { alert("ERROR! Could not find a DHTML element with id='" + strLinkButtonClientID + "'"); }
	} else { alert("ERROR! Could not find a '__doPostBack' function!"); }

	if ( blnOK == true ) {
		objHiddenField.value = strHiddenFieldValue.toString();
		try {
			__doPostBack(strLinkButtonPostBackID,'');
		} catch (err) {
			alert("JavaScript error:\n" + err.description);
		}
	}
}
// For video popups
// Source: http://player.broadbandvideo.com/BroadbandVideo_PlayerInit.asp?station=chospital9
sBBV_WindowURLbase = 'http://player.broadbandvideo.com/PlayShow.asp?station=chospital9';
sBBV_WindowName = 'broadbandvideo';
sBBV_WindowParams = 'toolbar=no,location=no,directories=no,menubar=no';
sBBV_WindowParams += ',scrollbars=no,width=275,height=175';
if (navigator.appName.indexOf('Microsoft')>=0) {
	sBBV_WindowParams += ',height=560, width=480';
} else {
	sBBV_WindowParams += ',height=568, width=487';
}
iBBV_ShowPassOk = 'n';
var iBBV_StartOffset = 0;
function BroadbandVideo_StartOffset(iOffset) {
	iBBV_StartOffset = iOffset;
}
function BroadbandVideo_PlayShow(sShow) {
	sBBV_WindowURL = sBBV_WindowURLbase + '&Show=' + sShow;
	if (iBBV_StartOffset != 0) 
		sBBV_WindowURL = sBBV_WindowURL + '&StartOffset=' + iBBV_StartOffset;
	if (iBBV_ShowPassOk == 'y') 
		sBBV_WindowURL = sBBV_WindowURL + '&ShowPassOk=y';
	var open_child_window = window.open(sBBV_WindowURL, sBBV_WindowName, sBBV_WindowParams);
	iBBV_StartOffset = 0;
}
function BroadbandVideo_PlayClip(sClip) {
	sBBV_WindowURL = sBBV_WindowURLbase + '&Clip=' + sClip;
	if (iBBV_StartOffset != 0) 
		sBBV_WindowURL = sBBV_WindowURL + '&StartOffset=' + iBBV_StartOffset;
	var open_child_window = window.open(sBBV_WindowURL, sBBV_WindowName, sBBV_WindowParams);
	iBBV_StartOffset = 0;
}
function broadbandvideo_playshow(sShow) {
	BroadbandVideo_PlayShow(sShow);
}
function broadbandvideo_playclip(sClip) {
	BroadbandVideo_PlayClip(sClip);
}
// Used for multiple window.onload events
// http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/
/*
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
	// more code to run on page load 
});
*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
			window.onload = function() {
			oldonload();
			func();
		}
	}
}


function goToPage(theLink) {
	if (theLink.value != "") {
		location.href = theLink.value;
	}
}

// LEFT NAV IMAGE SWAP
$(document).ready(function() {
	$(".SectionName1 p:contains('Lower Level')").addClass("LowerLevel");
	$(".SectionName1 p:contains('Level 1')").addClass("Level1");
	$(".SectionName1 p:contains('Level 2')").addClass("Level2");
	$(".SectionName1 p:contains('Level 3')").addClass("Level3");
	$(".SectionName1 p:contains('Level 4')").addClass("Level4");
	$(".SectionName1 p:contains('Level 6')").addClass("Level6");
	$(".SectionName1 p:contains('Level 7')").addClass("Level7");
	$(".SectionName1 p:contains('Level 8')").addClass("Level8");
	$(".SectionName1 p:contains('Level 9')").addClass("Level9");
});


// PHOTO SLIDER
$(document).ready(function() {
    $('.PhotoSlider').wrapInner('<div class="Border"></div>');
	$('.PhotoSlider ul').wrap('<div class="Overflow"></div>');
	$('<p class="PhotoCaption" />').insertAfter('.Overflow');
	$('.Overflow ul').addClass('Container');
	$('.Container li').addClass('Slide');
	$('<div class="Buttons"></div>').insertAfter('p.PhotoCaption');
	$('<a href="#" class="Prev"></a>').appendTo('.Buttons');
	$('<a href="#" class="Next"></a>').appendTo('.Buttons');
	$('<em class="Count"></em>').insertBefore('.Next');
});

$.fn.accessSlider = function() {
    return this.each(function(i) {
        aSlider.init(this);
    });
};

var slideWidth = 260; // equals width of image plus padding on its container <li>
var slideSpeed = "slow";
var scrollNum = 1; // number of items scrolled left
var aSlider = {
    init: function(p) {
        slideLength = $(".Slide",p).length;
        $(".Count",p).prepend("<span></span>&nbsp;" + " of " + slideLength );
        newsContainerWidth = slideLength * slideWidth;
        $(".Container",p).css("width",newsContainerWidth + "px");
        $(".Prev",p).addClass("Inactive");
        animating = false;
        $(".Next",p).bind("click",{p:p,cssClass:".Next",alternateClass:".Prev"}, Slider_ButtonClick);
        $(".Prev",p).bind("click",{p:p,cssClass:".Prev",alternateClass:".Next"}, Slider_ButtonClick);
		$(".Count span").html(1);
		
		var currentSlide = $(".Slide", p).eq(0);
		$(".PhotoCaption", p).html($("img", currentSlide).attr("alt"));
    }
};

/// This function handles the click event for all buttons (Previous and Next inside the PhotoSlider)
function Slider_ButtonClick(event)
{
	//Assign Parameters from data oblject passed by jQuery, to local variables.
	var p = event.data.p;
	var cssClass = event.data.cssClass;
	var alternateClass = event.data.alternateClass;
	var isNext = cssClass == ".Next";

	// Clears the Click event so that 'Next' Click does not shoot up to the top of the screen.
	$(cssClass,p).click(function(){return false;});

            if (animating == false) {
                animating = true;
                animateLeft = parseInt($(".Container",p).css("left")) 
                if(isNext)
					animateLeft -= (slideWidth * scrollNum);
                else
					animateLeft += (slideWidth * scrollNum);
					
				var shouldContinue = isNext
										? animateLeft + parseInt($(".Container",p).css("width")) > 0
										: (animateLeft + parseInt($(".Container",p).css("width"))) <= parseInt($(".Container",p).css("width"));
				
                if (shouldContinue)
                {
                        $(alternateClass,p).removeClass("Inactive");
						$(".Container",p).animate({left: animateLeft}, slideSpeed, function()
						{
							$(this).css("left",animateLeft);
                        
			                
							//****** SETS THE Text Of the Caption on the box to reflect current Image Index ******//
							
							var current = parseInt($(".Count span", p).html());
							
							//The next two lines Copies the text from the alt of the new Img being scrolled to and then puts it in the title of the correct Image Container.
							
							//if its next you do not subtract anything because the div ids are 1 based and you will get a node in the correct slot.
							// however if the user clicked the back button, then you subtract 2, one for the one based index offset and 1 more for the back click.
							var currentSlide = $(".Slide", p).eq((isNext ? current : (current - 2)));
							if($("img", currentSlide).attr("alt") != null)
								$(".PhotoCaption", p).html($("img", currentSlide).attr("alt"));
							else
								$(".PhotoCaption", p).html("&nbsp;");
							
							var newCurrent = isNext ? current + 1: current -1;
							
							$(".Count span",p).html(newCurrent);
							//****** END SETS THE Text ... ******//
							
							var hitLimit = isNext
										? parseInt($(".Container",p).css("left")) + parseInt($(".Container",p).css("width")) <= slideWidth * scrollNum
										: parseInt($(".Container",p).css("left")) == 0;
							if (hitLimit)
							{
								$(cssClass,p).addClass("Inactive");
								$(cssClass,p).click(function(){return false;});
							}
							else
							{
								$(cssClass,p).bind("click",{p:p,alternateClass:alternateClass,cssClass:cssClass}, Slider_ButtonClick);
							}
							$(alternateClass,p).bind("click",{p:p,cssClass:alternateClass,alternateClass:cssClass}, Slider_ButtonClick);

							animating = false; 
                    });
                } else {
                    animating = false;
                }
				return false;
            }
        }
$(document).ready(function() {
    $(".PhotoSlider").accessSlider();
});

// Even/Odd Rows
$(document).ready(function() {
    $("#ResearchResults ul li:even").addClass('Alt');
});

// TABS
// Copyright (c) 2006 Patrick Fitzgerald
// http://www.barelyfitz.com/projects/tabber/
/* Optional: set an ID for each tab navigation link */
var tabberOptions = { 'addLinkId': true };
/* start minified tabs script*/
function tabberObj(argsObj)
{var arg;this.div=null;this.classMain="TabsContainer";this.classMainLive="TabsContainerlive";this.classTab="Tab";this.classTabDefault="Tabdefault";this.classNav="Tabnav ClearFix";this.classTabHide="Tabhide";this.classNavActive="Tabactive";this.summaryElements=['h2'];this.summaryElementsStripHTML=true;this.removeSummary=true;this.addLinkId=false;this.linkIdFormat='<tabberid>nav<tabnumberone>';for(arg in argsObj){this[arg]=argsObj[arg];}
this.REclassMain=new RegExp('\\b'+this.classMain+'\\b','gi');this.REclassMainLive=new RegExp('\\b'+this.classMainLive+'\\b','gi');this.REclassTab=new RegExp('\\b'+this.classTab+'\\b','gi');this.REclassTabDefault=new RegExp('\\b'+this.classTabDefault+'\\b','gi');this.REclassTabHide=new RegExp('\\b'+this.classTabHide+'\\b','gi');this.tabs=new Array();if(this.div){this.init(this.div);this.div=null;}}
tabberObj.prototype.init=function(e)
{var
childNodes,i,i2,t,defaultTab=0,DOM_ul,DOM_li,DOM_a,aId,headingElement;if(!document.getElementsByTagName){return false;}
if(e.id){this.id=e.id;}
this.tabs.length=0;childNodes=e.childNodes;for(i=0;i<childNodes.length;i++){if(childNodes[i].className&&childNodes[i].className.match(this.REclassTab)){t=new Object();t.div=childNodes[i];this.tabs[this.tabs.length]=t;if(childNodes[i].className.match(this.REclassTabDefault)){defaultTab=this.tabs.length-1;}}}
DOM_ul=document.createElement("ul");DOM_ul.className=this.classNav;for(i=0;i<this.tabs.length;i++){t=this.tabs[i];t.headingText=t.div.summary;if(this.removeSummary){t.div.summary='';}
if(!t.headingText){for(i2=0;i2<this.summaryElements.length;i2++){headingElement=t.div.getElementsByTagName(this.summaryElements[i2])[0];if(headingElement){t.headingText=headingElement.innerHTML;if(this.summaryElementsStripHTML){t.headingText.replace(/<br>/gi," ");t.headingText=t.headingText.replace(/<[^>]+>/g,"");}
break;}}}
if(!t.headingText){t.headingText=i+1;}
DOM_li=document.createElement("li");t.li=DOM_li;DOM_a=document.createElement("a");DOM_a.innerHTML = t.headingText;DOM_a.href="javascript:void(null);";DOM_a.summary=t.headingText;DOM_a.onclick=this.navClick;DOM_a.tabber=this;DOM_a.tabberIndex=i;if(this.addLinkId&&this.linkIdFormat){aId=this.linkIdFormat;aId=aId.replace(/<tabberid>/gi,this.id);aId=aId.replace(/<tabnumberzero>/gi,i);aId=aId.replace(/<tabnumberone>/gi,i+1);aId=aId.replace(/<tabsummary>/gi,t.headingText.replace(/[^a-zA-Z0-9\-]/gi,''));DOM_a.id=aId;}
DOM_li.appendChild(DOM_a);DOM_ul.appendChild(DOM_li);}
e.insertBefore(DOM_ul,e.firstChild);e.className=e.className.replace(this.REclassMain,this.classMainLive);this.tabShow(defaultTab);if(typeof this.onLoad=='function'){this.onLoad({tabber:this});}
return this;};tabberObj.prototype.navClick=function(event)
{var
rVal,a,self,tabberIndex,onClickArgs;a=this;if(!a.tabber){return false;}
self=a.tabber;tabberIndex=a.tabberIndex;a.blur();if(typeof self.onClick=='function'){onClickArgs={'tabber':self,'index':tabberIndex,'event':event};if(!event){onClickArgs.event=window.event;}
rVal=self.onClick(onClickArgs);if(rVal===false){return false;}}
self.tabShow(tabberIndex);return false;};tabberObj.prototype.tabHideAll=function()
{var i;for(i=0;i<this.tabs.length;i++){this.tabHide(i);}};tabberObj.prototype.tabHide=function(tabberIndex)
{var div;if(!this.tabs[tabberIndex]){return false;}
div=this.tabs[tabberIndex].div;if(!div.className.match(this.REclassTabHide)){div.className+=' '+this.classTabHide;}
this.navClearActive(tabberIndex);return this;};tabberObj.prototype.tabShow=function(tabberIndex)
{var div;if(!this.tabs[tabberIndex]){return false;}
this.tabHideAll();div=this.tabs[tabberIndex].div;div.className=div.className.replace(this.REclassTabHide,'');this.navSetActive(tabberIndex);if(typeof this.onTabDisplay=='function'){this.onTabDisplay({'tabber':this,'index':tabberIndex});}
return this;};tabberObj.prototype.navSetActive=function(tabberIndex)
{this.tabs[tabberIndex].li.className=this.classNavActive;return this;};tabberObj.prototype.navClearActive=function(tabberIndex)
{this.tabs[tabberIndex].li.className='';return this;};function tabberAutomatic(tabberArgs)
{var
tempObj,divs,i;if(!tabberArgs){tabberArgs={};}
tempObj=new tabberObj(tabberArgs);divs=document.getElementsByTagName("div");for(i=0;i<divs.length;i++){if(divs[i].className&&divs[i].className.match(tempObj.REclassMain)){tabberArgs.div=divs[i];divs[i].tabber=new tabberObj(tabberArgs);}}
return this;}
function tabberAutomaticOnLoad(tabberArgs)
{var oldOnLoad;if(!tabberArgs){tabberArgs={};}
oldOnLoad=window.onload;if(typeof window.onload!='function'){window.onload=function(){tabberAutomatic(tabberArgs);};}else{window.onload=function(){oldOnLoad();tabberAutomatic(tabberArgs);};}}
if(typeof tabberOptions=='undefined'){tabberAutomaticOnLoad();}else{if(!tabberOptions['manualStartup']){tabberAutomaticOnLoad(tabberOptions);}}






/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["dynamicIframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++) {
if (document.getElementById) {
resizeIframe(iframeids[i])
}
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no") {
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr) {
currentfr.style.display = "block"; 
if (currentfr.Document && currentfr.Document.body.scrollHeight) {	                                                               //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
} else if (currentfr.contentDocument && currentfr.contentDocument.body.scrollHeight) {	//ns6+ / opera syntax
currentfr.height = currentfr.contentDocument.body.scrollHeight + FFextraHeight;
} else if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) {	//standards compliant syntax - probably nothing
																				
// will drop through to this
currentfr.height = currentfr.contentDocument.body.offsetHeight + FFextraHeight;
}
if (currentfr.addEventListener) {
currentfr.addEventListener("load", readjustIframe, false);
} else if (currentfr.attachEvent) {
currentfr.detachEvent("onload", readjustIframe);  // Bug fix line
currentfr.attachEvent("onload", readjustIframe);
}
}
}
/***********************************************
* End of fix for IE8 / Opera
***********************************************/

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot) {
resizeIframe(iframeroot.id);
}
}

function loadintoIframe(iframeid, url) {
if (document.getElementById) {
document.getElementById(iframeid).src=url
}
}

if (window.addEventListener) {
window.addEventListener("load", resizeCaller, false)
} else if (window.attachEvent) {
window.attachEvent("onload", resizeCaller)
} else {
window.onload=resizeCaller
}