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_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_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];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
	obj.display=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/*
 * INTERACTIVES SCRIPT
 */
function OpenGame(whichGame) {
	var thisGame = whichGame;
	var gPath = "";
	var gWid = 0;
	var gHgt = 0;
	switch (thisGame) {
		case "P-Quiz": gPath="/includes/swf/"+thisGame+"/ClimateChange-Quiz.html"; gWid=750;gHgt=530; break;
		case "S-Quiz": gPath="/includes/swf/"+thisGame+"/ClimateChange-Quiz.html"; gWid=750;gHgt=530; break;
		default: break;
	}
	var win = window.open(gPath,"gameWin","width="+gWid+",height="+gHgt+",toolbar=no,menubar=no,location=no,status=no,left=10,top=10");
}

/*
 * DID YOU KNOW SCRIPT
 */
function MM_showHideAllFacts() {
  var i,p,v,obj,args=MM_showHideAllFacts.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    	obj.display=v;
	 }
}
function MM_showHideFacts() {
  var i,p,v,obj,args=MM_showHideFacts.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
		 if(obj.display == "block") { obj.display = "none"; }
		 else { obj.display = "block"; }
	 }
	return obj.display;
}
function ObjState() {
  var i,p,v,obj,args=ObjState.arguments;
  var disp="";
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
		 if(obj.display == "block") { disp = "none"; }
		 else { disp = "block"; }
	 }
	return disp;
}
function ShowFact(obj) {
	var objState = ObjState(obj,'','show');
	if(objState=="block") {
		for (var i=1; i<=numQandA; i++) {
			MM_showHideAllFacts('answer'+i,'','hide');
		}
	}
	var objDisp = MM_showHideFacts(obj,'','show');
}

/*If JavaScript is turned on then this function will hide all answer blocks until they're clicked on*/
function HideAllFacts() {
	var boolPrint = querySt("print");

	if(boolPrint!="yes") {
		for (var i=1; i<=numQandA; i++) {
			MM_showHideAllFacts('answer'+i,'','hide');
			ShowFindOutLinks('quizLink'+i,'','show');
		}
	}
	else {
		HidePrintButton('printPreview','','hide');
	}
}
function ShowFindOutLinks() {
  var i,p,v,obj,args=ShowFindOutLinks.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    	obj.display=v;
	 }

}
function HidePrintButton() {
  var i,p,v,obj,args=HidePrintButton.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    	obj.display=v;
	 }

}
function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}




/*
 * GLOSSARY SCRIPT
 */
//glossary lookup
function Lookup(lookup) {
	//MM_swapImgRestore();
	var glosBkgndCol = "#10A8D6";
	document.getElementById("Absorbed_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Adapt_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Atmosphere_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Breakingdown_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Carbondioxide_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("CFCs_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Climate_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Climatemodel_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Earthscrust_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Emissions_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Erode_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Erosion_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Evaporation_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Fertilisers_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Fossilfuel_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Globalwarming_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Greenhouse_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Greywater_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Infrastructure_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Landfill_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Marsupial_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Methane_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Ozonehole_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Permits_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Polarice_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Predict_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Resources_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Sewerage_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Stormwater_Img").style.backgroundColor = glosBkgndCol;
	document.getElementById("Vertebrates_Img").style.backgroundColor = glosBkgndCol;

	lookup = lookup.substr(1);
	if(lookup != "") {
		lookup = lookup + "_Img";
		//MM_swapImage(lookup,'','images/glossary-indi.gif',1);
        document.getElementById(lookup).style.backgroundColor = "#94BD0F";
	}
}

var numQandA = "";
function myload(e) {
	document.body.focus();
	if(numQandA!="") {
		HideAllFacts();
	}
}
window.onload = myload;
