// JavaScript Document
var divString = "";

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var privWin = 0;
function callPopWin(href, width, height) {
	if(!width && !height) {
		width = 455;
		height = 450;
	}
	popRelWin(privWin,'privWin',href,width,height,10,10);
}

function popRelWin(PopUpWin, winName, URLStr, width, height,offsetx, offsety){
	
	if (!offsetx || !offsety) {
		offsetx = offsety = 10;
	}
	var x
	var y
		if ((isNaN(window.screenX)&&document.getElementById)|| (document.all) || (document.layers)) {
			x=window.screenLeft + offsetx;
			y=window.screenTop + offsety;
		} else {
			x=window.pageXOffset - offsetx;
			y=window.pageYOffset- offsety;
		}
			
	var strProp
	strProp += "toolbar=no,";
	strProp += "location=no,";
	strProp += "directories=no,";
	strProp += "status=no,";
	strProp += "menubar=no,";
	strProp += "scrollbars=yes,";
	strProp += "resizable=yes,";
	strProp += "copyhistory=yes,";
	strProp += "width="+width+",";
	strProp += "height="+height+",";
	strProp += "left="+ x +",";
	strProp += "top="+ y +",";
	strProp += "screenX="+ x +",";
	strProp += "screenY="+ y +" ";
	
	if(PopUpWin)
	{
    if(!PopUpWin.closed) PopUpWin.close();
  }
	if (URLStr.indexOf("?") > -1) 
	{
		URLStr += "&";
	} else
	{
		URLStr += "?";
	}
	URLStr += "referer=" + escape(window.location);
  PopUpWin = window.open(URLStr, winName, strProp);
	PopUpWin.focus();
}

function ZoonRelocater(command) {
if (command == "overview"){
	window.location = "activity.asp?actid=" + actNum;
	}
else if (command == "resources"){
	openChildWindow();
	}
else if (command == "extensions"){
	window.location = "extensions.asp?actid=" + actNum;
	}
else if (command == "standards"){
	window.location = "standards.asp?actid=" + actNum;
	}
else if (command == "video"){
	window.location = "video.asp?actid=" + actNum;
	}
}


function Mc_E_dees () {
	var allcookies = document.cookie;
	var pos = allcookies.indexOf("divState=");
	if (pos != -1) {
		var start = pos + 9;
		var end = allcookies.indexOf(";",start);
		if (end == -1) {end = allcookies.length};
		var value = allcookies.substring(start, end);
		value = unescape(value);
		for (i=0;i <= chicArray.length-1;i++){
		var valArray = value.split(",");
		chicArray[i] = valArray[i];
		}
	}else { 
		for(i=0;i <= chicArray.length-1;i++){
		if (divString == "" ){
		divString = "0";}
		else {divString += ",0";}
		}
	document.cookie = "divState=" + escape(divString); 
	}
	menuRecall();
}
	 	
function makeBig(IDName,notRoot,path) {
	// variable strings with names based on naming conventions above
	// that refer to ids of objects below
	if (IDName.id){
	var IDName = IDName.id.slice(0,4);
	}
	var IDNum = IDName.slice(3,4);
	var tdCont = IDName + "td";
	var subDiv = IDName + "sub";
	var subTbl = IDName + "subtbl";
	//alert(callObj.id + " , " + IDName + " , " + subDiv  + " , " + subTbl );
	
	// get reference to objects based on the string manipulation above
	var td_Obj = MM_findObj(tdCont);
	var div_Obj = MM_findObj(subDiv);
	var tbl_Obj = MM_findObj(subTbl);
	var mainTbl_Obj = MM_findObj("table");
	// finding main table height and sub menu table height
	// before expansion or contraction and using it later to 
	// contract size correctly
	var mainTblHeight = mainTbl_Obj.offsetHeight;
	var subTblHeight =  tbl_Obj.offsetHeight;
	//Expander
	//if this div is not expanded -- expand it
	if (div_Obj.style.height == "0px"){
	div_Obj.style.height = tbl_Obj.offsetHeight.toString() + "px";
	tbl_Obj.style.visibility = "visible";
	div_Obj.style.position = "relative"
	td_Obj.height = tbl_Obj.offsetHeight;
	td_Obj.valign = "top"
	if(notRoot == true){
	MM_swapImage("Arrowbutton" + IDNum,'', path + "images/O_Arrowbutton2.gif",1);
	//set cookie to indicate that the div has been expanded
	}else{
	MM_swapImage("Arrowbutton" + IDNum,'','images/O_Arrowbutton2.gif',1);
	}
	if(chicArray){
	chicArray[IDNum-1] = "1";
	var chicJoin = chicArray.join();
	document.cookie = "divState=" + chicJoin; 
	}
	}
	
	//Contractor
	//if div is already expanded -- contract it and return main table to correct height
	else if (div_Obj.style.height != "0px"){
	div_Obj.style.height = "0px";
	tbl_Obj.style.visibility = "hidden";
	div_Obj.style.position = "absolute";
	td_Obj.height = 1;
	if(notRoot == true){
	MM_swapImage("Arrowbutton" + IDNum,'', path + "images/O_Arrowbutton.gif",1);
	//set cookie to indicate that the div has been expanded
	}else{
	MM_swapImage("Arrowbutton" + IDNum,'','images/O_Arrowbutton.gif',1);
	}
	//set cookie to indicate that the div has been contracted
	if(chicArray){
	chicArray[IDNum-1] = "0";
	var chicJoin = chicArray.join();
	document.cookie = "divState=" + chicJoin;
	}
	}	
}
function ResmakeBig(IDName) {
	// variable strings with names based on naming conventions above
	// that refer to ids of objects below
	if (IDName.id){
	var IDName = IDName.id.slice(0,4);
	}
	var IDNum = IDName.slice(3,4);
	var tdCont = IDName + "td";
	var subDiv = IDName + "sub";
	var subTbl = IDName + "subtbl";
	//alert(callObj.id + " , " + IDName + " , " + subDiv  + " , " + subTbl );
	
	// get reference to objects based on the string manipulation above
	var td_Obj = MM_findObj(tdCont);
	var div_Obj = MM_findObj(subDiv);
	var tbl_Obj = MM_findObj(subTbl);
	var mainTbl_Obj = MM_findObj("table");
	// finding main table height and sub menu table height
	// before expansion or contraction and using it later to 
	// contract size correctly
	var mainTblHeight = mainTbl_Obj.offsetHeight;
	var subTblHeight =  tbl_Obj.offsetHeight;
	//Expander
	//if this div is not expanded -- expand it
	if (div_Obj.style.height == "0px"){
	div_Obj.style.height = tbl_Obj.offsetHeight.toString() + "px";
	td_Obj.height = tbl_Obj.offsetHeight;
	td_Obj.valign = "top"
	tbl_Obj.style.visibility = "visible";
	div_Obj.style.position = "relative"
	MM_swapImage("Arrowbutton" + IDNum,'','images/O_Arrowbutton2.gif',1);
	adjustSize();
	}
	
	//Contractor
	//if div is already expanded -- contract it and return main table to correct height
	else if (div_Obj.style.height != "0px"){
	div_Obj.style.height = "0px";
	td_Obj.height = 1;
	tbl_Obj.style.visibility = "hidden";
	div_Obj.style.position = "absolute";
	MM_swapImage("Arrowbutton" + IDNum,'','images/O_Arrowbutton.gif',1);
	adjustSize();
	}	
}

function menuRecall() {
	var tdName
	var divName;
	var tblName;
	var div_Obj;
	var tbl_Obj;
	for(i=0; i<chicArray.length; i++) {
		tdName = "div" + (i+1) + "td";
		divName = "div" + (i+1) + "sub";
		tblName = divName + "tbl";
		arrowName = "Arrowbutton" + (i+1)
		td_Obj = MM_findObj(tdName);
		arrow_Obj = MM_findObj(arrowName);
		div_Obj = MM_findObj(divName);
		tbl_Obj = MM_findObj(tblName);
		if (chicArray[i] == 1) {
			div_Obj.style.height = tbl_Obj.offsetHeight.toString() + "px";
			td_Obj.height = tbl_Obj.offsetHeight;
			td_Obj.valign = "top"
			tbl_Obj.style.visibility = "visible";
			div_Obj.style.position = "relative";
			
			MM_swapImage(arrowName,'','images/Arrowbutton2.gif',1);
		}
	}
}
function arrowOver(arrowName,eventType,path){
if (!path){
path = "";
}
var arrowObj;
arrowObj= MM_findObj(arrowName);
if (eventType == "over"){
	 //alert(arrowObj.src.toLowerCase());
	if (arrowObj.src.toLowerCase() == "http://www.zoonzone.com/images/arrowbutton.gif"){
		MM_swapImage(arrowName,'',path + "images/O_Arrowbutton.gif",1);
		}
	else if(arrowObj.src.toLowerCase() == "http://www.zoonzone.com/images/arrowbutton2.gif"){
		MM_swapImage(arrowName,'',path + "images/O_Arrowbutton2.gif",1);
		}
 }
 else if (eventType == "out"){
	 //alert(arrowObj.src.toLowerCase());
	if (arrowObj.src.toLowerCase() == "http://www.zoonzone.com/images/o_arrowbutton.gif"){
		MM_swapImage(arrowName,'',path + "images/Arrowbutton.gif",1);
		}
	else if(arrowObj.src.toLowerCase() == "http://www.zoonzone.com/images/o_arrowbutton2.gif"){
		MM_swapImage(arrowName,'',path + "images/Arrowbutton2.gif",1);
		}
 	}
}

function BacktoAct(state){
if (state == 1){
	beenClicked = 1;
	MM_swapImage('Back_to_Act','','images/Reswin/Active-BacktoAct.gif',1);
	return;
	}
else if (beenClicked == 1&& state == "over"){
	MM_swapImage('Back_to_Act','','images/Reswin/over-BacktoAct.gif',1);
	return;
	}
else if (beenClicked == 1&& state == "out"){
	MM_swapImage('Back_to_Act','','images/Reswin/Active-BacktoAct.gif',1);
	return;
	}
else if (beenClicked == 1&& state == "updateParent"){
	window.opener.location = "Activity.asp?ActID=" + actNum;
	}
}

function adjustSize () {
//Resource Window -- onload and on resize adjust the window size based on
// the outer table height and max screen height
//set some variables for later
var maxHeight = window.screen.availHeight-100;
var outerTblObj = MM_findObj('ResWinTbl');
	if (maxHeight < outerTblObj.offsetHeight){
		window.resizeTo(206,maxHeight);
		}
	else if (maxHeight >= outerTblObj.offsetHeight + 50){
		window.resizeTo(206,(outerTblObj.offsetHeight + 50));
		}
}
function openChildWindow() {
	var Winfeatures
	if (window.screenX){
	var x = window.screenX - 10;
	var y = window.screenY - 100;
	Winfeatures = "width=206,height=300,screenX=" + x + ",screenY=" + y;
	}else {
	Winfeatures = "width=206,height=300"
	}
	var childWindow = window.open("resources.asp?ActID=" + actNum, "resWin",Winfeatures);
	childWindow.focus();
}
	
function updateParent (newUrl) {
if(opener){
opener.location = newUrl;}
else{window.open(newUrl);}
}

function changeColor(obj,color){
obj.bgColor = color;
}
