/***********************************************
* Switch Content script II- © 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
***********************************************/

	var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
	var memoryduration="7" //persistence in # of days
	var xmlHttp

	var contractsymbol='../../asp/help/images/minus' //Path to image to represent contract state.
	var expandsymbol='../../asp/help/images/plus' //Path to image to represent expand state.
	var imgextension='.gif'

	/////No need to edit beyond here //////////////////////////

	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 sweeptoggle(ec){
		var inc=0
		while (ccollect[inc]){
			ccollect[inc].style.display=(ec=="contract")? "none" : "";
			inc++;
		}
		revivestatus();
	}


	function expandcontent(curobj, cid, altID){
		if (ccollect.length>0){	
			if(document.getElementById(cid).style.display == "none")
			{
					document.getElementById(cid).style.display = "";
					curobj.src = contractsymbol + '_' + lang + imgextension;
					postQuestion(altID);
			}
			else
			{
					document.getElementById(cid).style.display = "none";
					curobj.src = expandsymbol  + '_' + lang + imgextension;
			}
		
		}
	}

	function revivecontent(){
		selectedItem=getselectedItem();
		selectedComponents=selectedItem.split("|");
		
		for (i=0; i<selectedComponents.length-1; i++)
		{
			if(document.getElementById(selectedComponents[i]) != null)
				document.getElementById(selectedComponents[i]).style.display="none";
		}

	}

	function revivestatus(){
		var inc=0
		while (statecollect[inc]){
			if (ccollect[inc].style.display=="none")
				statecollect[inc].src=expandsymbol + '_' + lang + imgextension;
			else
				statecollect[inc].src=contractsymbol + '_' + lang + imgextension;
			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=="none")selectedItem+=ccollect[inc].id+"|";
			inc++;
		}
		if (get_cookie(window.location.pathname)!=selectedItem){ 
			//only update cookie if current states differ from cookie's
			var expireDate = new Date();
			expireDate.setDate(expireDate.getDate()+parseInt(memoryduration));
			document.cookie = window.location.pathname+"="+selectedItem+";path=/;expires=" + expireDate.toGMTString();
		}
	}

	function do_onload(){
		uniqueidn=window.location.pathname+"firsttimeload";
		var alltags=document.all? document.all : document.getElementsByTagName("*");
		ccollect=getElementbyClass(alltags, "switchcontent");
		statecollect=getElementbyClass(alltags, "showstate");
		if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0) revivecontent();
		if (ccollect.length>0 && statecollect.length>0)	revivestatus();
		sweeptoggle('contract');
	}

	// AJAX CALL
	function postQuestion(questionID)
	{ 
		xmlHttp=GetXmlHttpObject()
		var url="../../asp/help/asp/AjaxQsUpdate.asp"
		var poststr = "questionID=" + questionID
		
		if (xmlHttp==null)
		{
			return;
		} 
		  
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("POST",url,true)
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", poststr.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(poststr)
	}

	function stateChanged() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			// OK STATE
			//alert(xmlHttp.responseText);
		} 
	} 

	function GetXmlHttpObject()
	{ 

		var objXMLHttp=null
			if (window.XMLHttpRequest)
			{
				//genre mozilla
				objXMLHttp=new XMLHttpRequest()
			}
			else if (window.ActiveXObject)
			{
				//genre ie
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
		return objXMLHttp
	}

	function submitContactUSForm(form)
	{ 
		var tmp = document.getElementById("submitted");
		tmp.value = 'true';
		form.submit();
	}

	function showContactUs()
	{ 
		var sLocation = window.location.href.replace("#","");
		if(sLocation.indexOf("?") > -1)
			window.location = sLocation + "&contactUs=true";
		else
			window.location = sLocation + "?contactUs=true";
	}

	function cleanUpForm()
	{	
		var i, inputs, input, selects, divs
		
		inputs = document.getElementsByTagName("input"); 
		for (i = 0; i < inputs.length; i++)
		{
	    	inputs[i].value = "";
			inputs[i].className = "textField";
		}
		
		input = document.getElementById("message"); 
		input.value = '';
		input.className = "commentBox";
		
		selects = document.getElementsByTagName("select"); 
		for (i = 0; i < selects.length; i++)
	    	selects[i].selectedIndex = 0;

		divs = document.getElementsByName("err"); 
		for (i = 0; i < divs.length; i++)
	    	divs[i].className = "ErrorOff";
	}



	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;





