/* <![CDATA[ (FOR XHTML VALIDATION)*/

// SET HOST TYPE
var	urlH = document.domain.replace(/^www\./i,"");
var GameDropStatus;
var	hType;
var	hPath;
var	hID;
var xmlDoc;
var hPattern = "^(?:https?:)?\/\/(?:(?:www)\.)?" + urlH + "\/ed\/?";
if (window.location.href.match(hPattern)) {
	hType = "TEACHERS";
	hPath = "ed";
	hID = 1;
} else {
	hType = "STUDENTS";
	hPath = "stu";
	hID = 2;
}
//alert("Host Type = " +  hType);
	
// MODAL/ VARIABLES
var ModalStatus;
var gameTimeout;
var gTime;
var g_start_time;
var userIP;
var gCat;
var gAct;
var gLab;
var gVal;
var unload1;
var unload2;
var x_title;

// MODAL EXIT FUNCTIONS
function exitGame(exitStatus, exitType, exitTrack,exitID) {
	gameTime();
	var xDate = new Date();
	var xDT = gLab + " | " + xDate;
	_gaq.push(['_trackEvent', hType + ' | GAMEPLAY | MODAL (COMPLETE!)','ET [' + exitType + ']' + gAct + gTime +  " | " + x_title, xDT, gVal]);
	exitID = exitID + '';
	if(exitID.match(/sp/) == null) {
	} else {
		exitID = exitID.replace('sp', '');
	}
	$.colorbox.close();
	ModalStatus = 0;
	gameTimeout=setTimeout('exitDelay(' + exitStatus + ', ' + exitType + ', ' + exitTrack + ', ' + exitID + ')',700);			
}
function exitDelay(exitStatus, exitType, exitTrack, exitID) {
	// CLEAR TIMEOUT
	clearTimeout(gameTimeout);

	// CONVERT PageGameIDs [Current/Next] (ie, 403) TO gListIDs (ie, 10)
	var x1=xmlDoc.getElementsByTagName('Game');
	var gid1;			
	for (i=0;i<x1.length;i++) {
		if(x1[i].getAttribute("id") == exitID) {
			this.fNameCurrent =  xmlDoc.getElementsByTagName("fName")[i].childNodes[0].nodeValue;
		}
	}

	// DELAY LINK & GETURL
	if (exitType == 1) {
		if (hID == 1) {
			exitLink = "http://webadventures.rice.edu/" + hPath + "/Teacher-Resources/_games/" + this.fNameCurrent + "/index.html";
		} else {
			exitLink = "http://webadventures.rice.edu/" + hPath + "/Games/" + this.fNameCurrent + "/index.html";
		}
		getURL(exitLink, "_self");
	} else if (exitType == 2) {
		getForm(7,hID,exitID);
	} else if (exitType == 3) {
		if (hID == 1) {
			exitLink = "http://webadventures.rice.edu/" + hPath + "/Teacher-Resources/_games/" + this.fNameCurrent + "/_" + exitID + "/Cool-Links.html?REFERER=" + exitID;
		} else {
			exitLink = "http://webadventures.rice.edu/" + hPath + "/Games/" + this.fNameCurrent + "/_" + exitID + "/Cool-Links.html?REFERER=" + exitID;
		}
		getURL(exitLink, "_self");
	} else if (exitType == 4) {
		getModal(exitTrack);
	}
}

// DETECT BROWSER BACK/REFRESH WHEN MODAL ACTIVE
window.onbeforeunload = function(){ 
	unload1="1";
	var gDate = new Date();
	var pDT = gLab + " | " + gDate;
	if (ModalStatus > 0 && unload2 !== "1") {
		gameTime();
		unload1="1";
		_gaq.push(['_trackEvent', gCat, gAct + gTime +  " | " + x_title, pDT, gVal]);
		if (ModalStatus > 10) {
			return 'Your form data will not be saved!!';
		} else {
			return 'Your game will not be saved!!';
		}
	} else {
		unload1="0";
	}
}
window.onunload = function(){ 
	unload2="1";
	var gDate = new Date();
	var pDT = gLab + " | " + gDate;
	if (ModalStatus > 0 && unload1 !== "1") {
		unload2="1";
		_gaq.push(['_trackEvent', gCat, gAct + gTime, pDT, gVal]);
		if (ModalStatus > 10) {
			return 'Your form data will not be saved!!';
		} else {
			return 'Your game will not be saved!!';
		}
	} else {
		unload2="0";
	}
}

// IMAGE ROLLOVER FUNCTIONS
function gOver(i_name,i_src) {
	document.getElementById(i_name).src=i_src;
}
function gOut(i_name,i_src) {
	document.getElementById(i_name).src=i_src;
}
// HIDE / SHOW BLOCKS  [action_type 1 = 'show' / action_type 2 = 'hide' / action_type 3 = 'toggle']
function gAnswer(action_type, css_type, pid) {
	if (action_type == 1) {
		$(css_type + pid).css('display','block');
	} else if (action_type == 2) {
		$(css_type + pid).css('display','none');
	} else if (action_type == 3) {
		//alert("action_type = " + action_type + ": css_type = " + css_type + ": pid = " + pid);
		if ($(css_type + pid).css('display') == 'none') {
			$(css_type + pid).css('display','block');
		} else if ($(css_type + pid).css('display') == 'block') {
			$(css_type + pid).css('display','none');
		}
	}
}

// GET URL AND PARSE(FILTER) FOR GOOGLE _trackEvent FUNCTION
function getURL(url,target) {
	var	urlHost = document.domain.replace(/^www\./i,"");
	var gDate = new Date();
	// SET HOST PATTERN FOR MATCHING
	var urlPattern = "^(?:https?:)?\/\/(?:(?:www)\.)?" + urlHost + "\/?";
	var pURL = document.createElement("a");
	pURL.href=url;
	if (PageGameID == "" || PageGameID == "0" || PageGameID == undefined) {
		pGID = '';
		//FilterValue = 1;
	} else {
		pGID = PageGameID + ' | '	
		//FilterValue = PageGameID;
	}	
	// FILTER LINK DATA
	// FILE NAME
	var FilterName = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
	// FILE TYPE
	var FilterType = url.substring(url.lastIndexOf('.') + 1);
	var FilterValue = 1;
	userIP;
	// IF HREF DOES NOT MATCH HOST SITE
	if ((url.match(/^https?\:/i)) && (!url.match(urlPattern))){
		if (url.match(/^.*\.(pdf|jpg|png|gif|zip|mp3|txt|doc|rar|js|py|eps|svg|xls|ppt|css|exe|mov|avi|wmv|mp3)$/i)) {
			//alert("DOWNLOAD EXTERNAL ACTION: " + pGID + pURL.hostname + " | " + target);
			_gaq.push(['_trackEvent', hType + ' | DOWNLOAD ' + ' | EXTERNAL', pGID + pURL.hostname + " | " + target, url + ' | ' + navigator.appVersion + ' | ' + userIP + " | " + gDate, FilterValue]);
		} else {
			//alert("LINK EXTERNAL ACTION: " + pGID + pURL.hostname + " | " + target);
			_gaq.push(['_trackEvent', hType + ' | LINK ' + ' | EXTERNAL', pGID + pURL.hostname + " | " + target, url + ' | ' + navigator.appVersion + ' | ' + userIP + " | " + gDate, FilterValue]);
		}
	// IF URL MATCH MAILTO
	} else if (url.match(/^mailto\:/i)) {
			//alert("MAIL INTERNAL ACTION: " + pGID + 'Get Mail Client');
			_gaq.push(['_trackEvent', hType + ' | EMAIL ' + ' | INTERNAL', pGID + 'Get Mail Client', url + ' | ' + navigator.appVersion + ' | ' + userIP + " | " + gDate, FilterValue]);
	// IF URL MATCH HOST SITE OR RELATIVE LINK
	} else if (url.match(urlPattern) || !url.match(/^https?\:/i)) {
		if (url.match(/^.*\.(pdf|jpg|png|gif|zip|mp3|txt|doc|rar|js|py|eps|svg|xls|ppt|css|exe|mov|avi|wmv|mp3)$/i)) {
			//alert("DOWNLOAD INTERNAL ACTION: " + pGID + FilterType + " | " + FilterName.replace("-"," ") + " | " + target);
			_gaq.push(['_trackEvent', hType + ' | DOWNLOAD ' + ' | INTERNAL', pGID + FilterType + " | " + FilterName + " | " + target, url + ' | ' + navigator.appVersion + ' | ' + userIP + " | " + gDate, FilterValue]);
		} else {
				//alert("LINK INTERNAL ACTION: " + pGID + FilterType + " | " + FilterName.replace("-"," ") + " | " + target);
			_gaq.push(['_trackEvent', hType + ' | LINK ' + ' | INTERNAL', pGID + FilterType + " | " + FilterName + " | " + target, url + ' | ' + navigator.appVersion + ' | ' + userIP + " | " + gDate, FilterValue]);
		}
	}
	// GO TO URL			
	if (target == '_blank') {
		window.open(url);
	} else {
		if (window.location.href == url) {
		} else {
			window.location.href = url;
		}
	}
}

// GAME DROP MENU ONCHANGE EVENT
function changeGame(obj,type) {
	var ListID = obj.options[obj.selectedIndex].value;
	var ListText = obj.options[obj.selectedIndex].text;
	var changeURL;
	
	// SET CHANGE URL
	if (hType == "TEACHERS") {
		changeURL = "http://webadventures.rice.edu/ed/Teacher-Resources/_games/";
	} else {
		changeURL = "http://webadventures.rice.edu/stu/Games/";
	}
	
	if (ListID == "") { // GameRootIN
		alert("Current selection is not available now.");
	} else if (ListID == "100") { // GameRootIN
		if (hType == "TEACHERS") {
			getURL("http://webadventures.rice.edu/ed/Teacher-Resources/_games/Cool-Science-Careers/","_self");
		} else {
			getURL("http://webadventures.rice.edu/stu/Games/Cool-Science-Careers/","_self");
		}
	} else if (ListID == "200") { // GameRootIN
		if (hType == "TEACHERS") {
			getURL("http://webadventures.rice.edu/ed/Teacher-Resources/_games/CSI-The-Experience/","_self");
		} else {
			getURL("http://webadventures.rice.edu/stu/Games/CSI-The-Experience/","_self");
		}
		//getURL("http://forensics.rice.edu/index.html","_blank");
	} else if (ListID == "300") { // GameRootIN
		if (hType == "TEACHERS") {
			getURL("http://webadventures.rice.edu/ed/Teacher-Resources/_games/MedMyst/","_self");
		} else {
			getURL("http://webadventures.rice.edu/stu/Games/MedMyst/","_self");
		}
	} else if (ListID == "500") { // GameRootIN
		if (hType == "TEACHERS") {
			getURL("http://webadventures.rice.edu/ed/Teacher-Resources/_games/N-Squad/","_self");
		} else {
			getURL("http://webadventures.rice.edu/stu/Games/N-Squad/","_self");
		}
	} else if (ListID == "600") { // GameRootIN
		if (hType == "TEACHERS") {
			getURL("http://webadventures.rice.edu/ed/Teacher-Resources/_games/Reconstructors/","_self");
		} else {
			getURL("http://webadventures.rice.edu/stu/Games/Reconstructors/","_self");
		}
	} else {
		var CurrentURL = window.location.href;
		var PassURL;
		var fNameCurrent;
		
		// CONVERT PageGameIDs [Current/Next] (ie, 403) TO gListIDs (ie, 10)
		var x1=xmlDoc.getElementsByTagName('Game');
		var x2=xmlDoc.getElementsByTagName('Game');
		var gid1;
		var gid2;
			
		for (i=0;i<x1.length;i++) {
			if(x1[i].getAttribute("id") == PageGameID) {
				gid1 = xmlDoc.getElementsByTagName("gListID")[i].childNodes[0].nodeValue;
				fNameCurrent =  xmlDoc.getElementsByTagName("fName")[i].childNodes[0].nodeValue;
			}
		}
		if (type == 1) {
			for (i=0;i<x2.length;i++) {
				if(x2[i].getAttribute("id") == ListID) {
					gid2 = xmlDoc.getElementsByTagName("gListID")[i].childNodes[0].nodeValue;
					fNameNext =  xmlDoc.getElementsByTagName("fName")[i].childNodes[0].nodeValue;
					PassURL = xmlDoc.getElementsByTagName("edHome")[i].childNodes[0].nodeValue;
				}
			}
			if (PageGameID != "") { // GameDrop On A Game Page
				ReplaceURL01 = CurrentURL.replace(fNameCurrent, fNameNext);
				ReplaceURL02 = ReplaceURL01.replace(PageGameID, ListID);
				getURL(ReplaceURL02,"_self");
			} else { // GameDrop On Non-Game Page
				getURL(changeURL + PassURL,"_self");
			}
		} else {
			if (PageGameID != "") { // GameRootIN
				if (ListID == "1") {
					PassURL = changeURL + fNameCurrent + "/_" + PageGameID + "/Learning-Objectives/Standards/NHES.html";
				} else if (ListID == "2") {
					PassURL = changeURL + fNameCurrent + "/_" + PageGameID + "/Learning-Objectives/Standards/NSES.html";
				} else if (ListID == "3") {
					PassURL = changeURL + fNameCurrent + "/_" + PageGameID + "/Learning-Objectives/Standards/TEKS.html";
				}
				
				getURL(PassURL,"_self");
			} else {
				alert("Please select a game first from the drop menu.");				
			}
		}
		
		
	}

}

// MAIN MODAL FUNCTION
function getModal (game_id) {
	$.colorbox.remove();
	$.colorbox.init();
	/// CONVERT game_id (ie, 403) TO gid (ie, 10)
	x=xmlDoc.getElementsByTagName('Game');
	var g_gid;
	ModalStatus = 1;
	for (i=0;i<x.length;i++) {
		if(x[i].getAttribute("id") == game_id) {
			g_gid = xmlDoc.getElementsByTagName("gListID")[i].childNodes[0].nodeValue;
			var g_url = xmlDoc.getElementsByTagName("gURL")[i].childNodes[0].nodeValue;
			var g_title = xmlDoc.getElementsByTagName("STitle")[i].childNodes[0].nodeValue + " - " + xmlDoc.getElementsByTagName("Title")[i].childNodes[0].nodeValue;
			x_title = g_title;
			var g_scroll = xmlDoc.getElementsByTagName("Game")[i].getAttribute("scroll");
			var g_width = Number((xmlDoc.getElementsByTagName("Game")[i].getAttribute("width")*.02565)) + Number(xmlDoc.getElementsByTagName("Game")[i].getAttribute("width"));
			var g_height = Number((xmlDoc.getElementsByTagName("Game")[i].getAttribute("height")*.1187)) + Number(xmlDoc.getElementsByTagName("Game")[i].getAttribute("height"));
			var g_innerwidth = xmlDoc.getElementsByTagName("Game")[i].getAttribute("innerwidth");
			var g_innerheight = xmlDoc.getElementsByTagName("Game")[i].getAttribute("innerheight");
			var g_speed = xmlDoc.getElementsByTagName("Game")[i].getAttribute("speed");
			var g_transition = xmlDoc.getElementsByTagName("Game")[i].getAttribute("transition");
			var g_overlayclose = xmlDoc.getElementsByTagName("Game")[i].getAttribute("overlayclose");
			var g_start_date;
			g_start_time;
			g_start_date = new Date();
			g_start_time = g_start_date.getTime();
			// GOOGLE _eventTrack FUNCTION
			var playID=Math.floor(Math.random()*100001)
			var FilterValue = Number(xmlDoc.getElementsByTagName("Game")[i].getAttribute("id"));
			// SET ENTER GAME DATA			
			gCat = hType + " - GAMEPLAY | MODAL (CANCELLED!!)";
			gAct = FilterValue + " | " + "Enter-Exit Game | Duration - ";
			gLab = g_title + " | " + navigator.appVersion + " | " + userIP;
			gVal = FilterValue;
			$("#cboxContent").css("background-color","#000000");
			
			//$("#cboxClose").css('background-image', 'url(/images/exit_up_text.png)');
			//$("#cboxClose").css("backgroundRepeat","no-repeat");
			//$("#cboxClose.hover").css('background-image', 'url(/images/exit_over_text.png)');
			//$("#cboxClose.hover").css("backgroundRepeat","no-repeat");
			
		}
	}	

	$.colorbox({iframe:true, title:g_title, href:g_url, scrolling:false, width:g_width, height:g_height,innerWidth:g_innerwidth, innerHeight:g_innerheight, speed:g_speed, transition:	g_transition, overlayClose:false,onComplete:function(){showFrame();}, onCleanup:function(){getRemove()} });
	function getRemove() {
		gameTime();
		var gDate = new Date();
		//alert("CATEGORY: " + hType + " - GAMEPLAY (MODAL) ");
		//alert("ACTION: " + FilterValue + " | " + "Enter-Exit Game | Play ID - " + playID + " | Duration - " + gTime);
		//alert("LABEL: " + g_title + " | " + navigator.appVersion + " | " + userIP + " | " + gDate);
		//alert("VALUE: " + FilterValue);
		//alert("VALUE: " + gTime);
		_gaq.push(['_trackEvent', hType + ' | GAMEPLAY | MODAL (CLOSED!!)', FilterValue + ' | ' + 'Enter-Exit Game | Duration | ' + gTime +  " | " + g_title, g_title + ' | ' + navigator.appVersion + ' | ' + userIP + " | " + gDate, FilterValue]);
		ModalStatus = 0;		
	}
	function showFrame() {
			//alert("SHOW IFRAME!!!");
	}
}

function gameTime() {
	var g_end_date = new Date();
	var g_end_time = g_end_date.getTime();			
	var ms = g_end_time - g_start_time;
	var seconds=(ms/1000)%60
	var minutes=(ms/(1000*60))%60
	var hours=(ms/(1000*60*60))%24
	var f_seconds;
	var f_minutes;
	var f_hours;
	if (seconds < 10) {
		f_seconds = ":0" + seconds.toFixed(0);
	} else {
		f_seconds = ":" + seconds.toFixed(0);
	}
	if (minutes > 1 && minutes < 10) {
		f_minutes = ":0" + minutes.toFixed(0);
	} else if (minutes > 10) {
		f_minutes = ":" + minutes.toFixed(0);
	} else if (minutes < 1) {
		f_minutes = ":00";
	}
	if (hours > 1 && hours < 10) {
		f_hours = "0" + hours.toFixed(0);
	} else if (hours > 9) {
		f_hours = "00" + hours.toFixed(0);
	} else if (hours < 1) {
		f_hours = "00";
	}
	gTime = f_hours + f_minutes + f_seconds;
}

// GET IP / DROP MENU STATUS / ROTATOR & TOP MENU FUNCTIONS
$(document).ready(function(){
	
	//$.getJSON("http://dev.webadventures.rice.edu/getIP.php?format=json&jsoncallback=?", function (data) {
		//alert("IP = " + data.ip)
		//userIP = data.ip;
		userIP = "0";
	//});

	if (GameDropStatus == "") {
		$('#GameDrop').hide();
		$('#Google_Search').show();
		// $('#GameSearch').show();
	} else {
		$('#GameDrop').show();
		$('#Google_Search').hide();
	}			
	if (PStanDrop == "") {
		$('#StandardDrop').hide();
	} else {
		$('#StandardDrop').show();
	}
	
	// ROTATOR
	//Full Caption Sliding (Hidden to Visible)
		$('.xbox').hover(function(){
			//$(".game_btns .wa_csc_btn_lt").fadeIn('slow');
			//$(".game_btns .wa_csc_btn_rt").fadeIn('slow');
			//$(".game_btns .wa_csc_btn_start").fadeIn('slow');
		}, function() {
			$(".xbox.captionfull .wag_csc_btns").animate({top:'0px'},{queue:false,duration:160});
		});
		
	// TOP MENU FUNCTION
	$(function() {
		// Sets Opacity To Nill On Page Load
		$("ul#top_menu span").css("opacity","0");
		// Sets Default Menu Selection w/Passed Parameters
		if (PassMenu == "") {
		} else {
			$("ul#top_menu li a." + PassMenu).css('backgroundPosition', PassPosition);
		}
		// On Mouse Over
		$("ul#top_menu span").hover(function () {
			$(this).stop().animate({
				opacity: 1
			}, 'fast');
		},
		// On Mouse Out
		function () {
			$(this).stop().animate({
				opacity: 0
			}, 'fast');
		});
	});
	loadXMLDoc();
});

// LOAD AND PARSE XML FOR GAMES AND MODAL SETTINGS		
function loadXMLDoc() {
	if(navigator.appName == "Microsoft Internet Explorer") {
		if (window.XMLHttpRequest) {
			// Object for IE7, IE8
			xmlhttp=new ActiveXObject("MSXML2.XMLHTTP.3.0");
		} else {
			// Object for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	} else {
		// Object for Firefox, Chrome, Opera, Safari
		xmlhttp=new window.XMLHttpRequest();			
	}
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			xmlDoc=xmlhttp.responseXML;
			// CONVERT PageGameID (ie, 403) TO gid (ie, 10)
			x=xmlDoc.getElementsByTagName('Game');
			var gid;
			var gStandard;
			for (i=0;i<x.length;i++) {
				if(x[i].getAttribute("id") == PageGameID) {
					gid = xmlDoc.getElementsByTagName("gListID")[i].childNodes[0].nodeValue;
					gStandard =  xmlDoc.getElementsByTagName("gStan")[i].childNodes[0].nodeValue;
					gGrant = xmlDoc.getElementsByTagName("gGrant")[i].childNodes[0].nodeValue;
					$('#GameGrant').append(gGrant);
				}
		}
			// SET DEFAULT GRANT INFORMATION FOR NON-GAME PAGES
			if (PageGameID == "") {
				$('#GameGrant').append("The projects on this page are supported by grants from the National Institutes of Health and the National Science Foundation.<br />This website is compliant with the <a onclick='JavaScript: getForm(6,hID,0)'>Children's Online Privacy Protection Act</a>.");	
			}

			document.getElementById('GameDrop').selectedIndex = gid;
			gListID = gid;
			if (PStanDrop == "") {
			} else {
				//$('.'+ PStanDrop).show();
				//$('#StandardDrop').empty().append('<option selected="selected" value="whatever">text</option>');
					if (gStandard.search("1") != -1) {
					$('#StandardDrop').append('<option value="1">NHES</option>');
				}
				if (gStandard.search("2") != -1) {
					$('#StandardDrop').append('<option value="2">NSES</option>');
				 }
				if (gStandard.search("3") != -1) {
					$('#StandardDrop').append('<option value="3">TEKS</option>');
				}
				//$('.sd_123').show();
				document.getElementById('StandardDrop').selectedIndex = sListID;
				$('#StandardDrop').show();
			}
			
		}
	} 
	xmlhttp.open("GET","http://webadventures.rice.edu/xml/games.xml",true);
	xmlhttp.send(null);
}

// LEFT MENU FUNCTIONS
var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.accordion=function(){
	function slider(n){this.n=n; this.a=[]}
	slider.prototype.init=function(t,e,m,o,k){
		var a=T$(t), i=s=0;
		var n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
		for(i;i<l;i++){
			var v=n[i];
			if(v.nodeType!=3){
				this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
				if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
			}
		}
		this.l=s
	};
	slider.prototype.pr=function(f,d){
		for(var i=0;i<this.l;i++){
			var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
			if((k!=1&&c.d==-1)&&(f==1||i==d)){
				c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
			}else if(k>0&&(f==-1||this.m||i==d)){
				c.d=-1; h.className=''; su(c,-1)
			}
		}
	};
	function su(c){c.t=setInterval(function(){sl(c)},20)};
	function sl(c){
		var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
		c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
		if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
	};
	return{slider:slider}
}();

// BREADCRUMBS
var	breadHost = document.domain.replace(/^www\./i,"");
var breadPattern = "^(?:https?:)?\/\/(?:(?:www)\.)?" + breadHost + "\/ed\/?";
var rootpath;

if (window.location.href.match(breadPattern)) {
	rootpath = "/" + "ed/"; // Use "/" for root of domain.
} else {
	rootpath = "/" + "stu/"; // Use "/" for root of domain.
}

var crumbsep = " > ";
var precrumb = "<span class=\"crumb\">";
var postcrumb = "</span>";
var sectionsep = "/";
var rootname = "Home";

var ucfirst = 1; // if set to 1, makes "directory" default to "Directory"

// Replace objurl values if needed, or remove using "_"
var objurl = new Object;
objurl['dev'] = "_";
objurl['educators'] = "_";
objurl['_WA'] = "_";
objurl['MedMyst-Reloaded'] = "MedMyst: Reloaded";

// Grab the page's url and break it up into directory pieces
var pageurl = (new String(document.location));
var protocol = pageurl.substring(0, pageurl.indexOf("//") + 2);
pageurl = pageurl.replace(protocol, ""); // remove protocol from pageurl
var rooturl = pageurl.substring(0, pageurl.indexOf(rootpath) + rootpath.length); // find rooturl
if (rooturl.charAt(rooturl.length - 1) == "/") //remove trailing slash 
{
  rooturl = rooturl.substring(0, rooturl.length - 1);
}
pageurl = pageurl.replace(rooturl, ""); // remove rooturl fro pageurl
if (pageurl.charAt(0) == '/') // remove beginning slash
{
  pageurl = pageurl.substring(1, pageurl.length);
}

var page_ar = pageurl.split(sectionsep);
var currenturl = protocol + rooturl;
// With Home
var allbread = precrumb + "<a href=\"" + currenturl + "\">" + rootname + "</a>" + postcrumb; // start with root
// Without Home
//var allbread = "";

for (i=0; i < page_ar.length-1; i++)
{
  var displayname = "";
  currenturl += "/" + page_ar[i];
  if (objurl[page_ar[i]])
  {
    displayname = objurl[page_ar[i]];
	
  }
  else
  {
    if (ucfirst == 1 || ucfirst == 2)
    {
		
		if (ucfirst == 2) {
			displayname = page_ar[i].toUpperCase();
		} else {
			displayname = page_ar[i].charAt(0).toUpperCase() + page_ar[i].substring(1);
		}
	
    }
    else
    {
      displayname = page_ar[i];
    }
  }
	if (displayname.substr(0,1) == "_") {
	} else {
		// With Home
		allbread += crumbsep + precrumb + "<a href=\"" + currenturl + "\">" + displayname.replace("-"," ") + "</a>" + postcrumb;
		// Without Home
		// allbread += precrumb + "<a href=\"" + currenturl + "\">" + displayname.replace("-"," ") + "</a>" + postcrumb + crumbsep;
	}
}
//With Home
allbread += ' > ';

PageRoot = "http://" + rooturl + "/" + pageurl;
//document.write(allbread);

/* ]]> HIDE FOR XHTML VALIDATION */ 

