// check for bad values in the url
	var sQueryStr = window.top.location.search.substring(1);
	if(sQueryStr != null)
	{		
		if ( (sQueryStr.indexOf("\"") >= 0) || (sQueryStr.indexOf("&quot;") >= 0) || (sQueryStr.indexOf("&#34") >= 0) || (sQueryStr.indexOf("%22") >= 0) || (sQueryStr.indexOf("script") >= 0) || (sQueryStr.indexOf("%29") >= 0) || (sQueryStr.indexOf("&#41") >=0) || (sQueryStr.indexOf("(") >= 0) || (sQueryStr.indexOf("%28") >= 0) || (sQueryStr.indexOf("&#40") >= 0) || (sQueryStr.indexOf("(") >= 0) || (sQueryStr.indexOf("&lt;") >= 0) || (sQueryStr.indexOf("<") >= 0) || (sQueryStr.indexOf("&#60") >= 0) || (sQueryStr.indexOf("%3c") >= 0) || (sQueryStr.indexOf("&gt;") >= 0) || (sQueryStr.indexOf(">") >= 0) ||(sQueryStr.indexOf("&#62") >= 0) || (sQueryStr.indexOf("%3e") >= 0) )
		{
			window.location = ('http://encarta.degreesandtraining.com/internalerror.jsp');
		}	
	}	

// JavaScript Document

/***********************************************
* Switch Content script-  Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
*
* Updated for image swapping 09/05/2007
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

var hidesymbol='- ' //HTML for hide symbol. For image, use: <img src="../scripts/whatever.gif">
var showsymbol='+ ' //HTML for show symbol.

var expandimg = "images/expand.gif"
var collapseimg = "images/collapse.gif"

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.content{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}


function swapImage(imgname, thestate) {
	if(thestate=="block") {
		if(document[imgname])
			document[imgname].src = collapseimg
		else if (document.getElementById(imgname))
			document.getElementById(imgname).src = collapseimg
	} 
	else {
		if(document[imgname]) 
			document[imgname].src = expandimg;
		else if (document.getElementById(imgname)) {
			document.getElementById(imgname).src = expandimg
		}
	} 	
}

function viewall(ec){
	var thestate=(ec=="show")? "block" : "none"
	var inc=0
	while (ccollect[inc]){
		ccollect[inc].style.display=thestate
		var imgname = "img_"+ccollect[inc].id
		swapImage(imgname, thestate);
		inc++
	}
	revivestatus()
}


function hidecontent(omit){
var inc=0
while (ccollect[inc]){
	if (ccollect[inc].id!=omit) {
		ccollect[inc].style.display="none"
	}
	inc++
}
}

function showcontent(curobj, cid){
	if(curobj !== null) {
		var spantags=curobj.getElementsByTagName("SPAN")
		var showstateobj=getElementbyClass(spantags, "showstate")
		var imgname = "img_"+cid;
		
		if (ccollect.length>0){
					
			if (collapseprevious=="yes")
				hidecontent(cid)
			
			if(document.getElementById(cid) !== null) {
				document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
				
				swapImage(imgname, document.getElementById(cid).style.display) 
				
				if (showstateobj.length>0){ //if "showstate" span exists in header
					if (collapseprevious=="no") 
					showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? hidesymbol : showsymbol
					else
					revivestatus()
				}
			} // end of document.getElementById(cid) !== null
		} // end of collect.length
	} // end of if curobj !== null
}

function revivecontent(){
hidecontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
	var inc=0
	while (statecollect[inc]){
		if (ccollect[inc].style.display=="block") {
		statecollect[inc].innerHTML=hidesymbol
		}
		else {
		statecollect[inc].innerHTML=showsymbol
		}
	inc++
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "content")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate
