// <![CDATA[

// Begin Ad Muncher helper script

// Do not remove without removing all references to this in the below page (eg: everything containing "ywz" or "ywb")

// Original URL:   http://www.dynamicdrive.com/dynamicindex17/switchcontent.js

// Retrieved from: 208.75.149.97:80

function ywzn(){return false;};

function ywzbHelp(a,b){ywzXgp(a);ywzXbn();return;};

function ywzb(a,b,c,d){ywzXgp(a);ywzXbn();return ywzXfw(b);};

function ywzXpp(a){ywzXppa=a;if(a)ywzXorgsti("ywzXppa=0;",500);};

function ywzbtePopup(a,b,c,d,e,f){ywzXgp();ywzXbn();return ywzXfw();};

function ywzbModalDialog(a,b,c){ywzXgp(a);ywzXbn();return ywzXfw();};

function ywzXj(m,u,l){if(ywzXolp){ywzXqn=ywzXqnbu;ywzXolp=0;};return true;};

function ywzbModelessDialog(a,b,c){ywzXgp(a);ywzXbn();return ywzXfw();};

function ywzXpl(a,b,c){while(a.indexOf(b)!=-1)a=a.replace(b,c);return a;};

function ywzXtry(a,z){if(ywzXtryk())eval("try{"+a+"}catch(e){};");else eval(a);};

function ywzc(){ywzXqn=ywzXqnbu=10;ywzXorgsti("ywzXqn=ywzXqnbu=0;",500);return;};

function ywzX__amscript_addonload(a){ywzX_ams_onload[ywzX_ams_onload_i++]=(typeof(a)=="function")?a:new Function(a);};

function ywzX__amscript_addonunload(a){ywzX_ams_onunload[ywzX_ams_onunload_i++]=(typeof(a)=="function")?a:new Function(a);};

function ywzXfcs(z){ywzXfcsr=0;if(z){ywzXfcsrz=z;ywzXtry("ywzXfcsr=ywzXfcsd();");};return ywzXfcsr;};

function ywzXfc(a,z){for(var i=0;i<a.length;i++)if(a[i].name==z||ywzXfc(a[i].frames,z))return 1;return 0;};

function ywb(z){if(typeof(z.location)!="undefined"||typeof(z.blur)=="undefined")return false;return z.blur();};

function ywzf(z){if(typeof(z.location)!="undefined"||typeof(z.focus)=="undefined")return false;return z.focus();};

function ywzXHelp(a,b){if(ywzXck(a))return;if(ywzXqn)ywzXqn-=1;if(b)return showHelp(a,b);else return showHelp(a);};

function ywzTimeout(a,b){if(((!ywzXqn&&!ywzXa)||ywzXppa||ywzXul)&&typeof(a)=="string")return ywzXorgsti("ywzXpp(1);"+a+";ywzXpp(0);",b);return ywzXorgsti(a,b);};

function ywzInterval(a,b){if(((!ywzXqn&&!ywzXa)||ywzXppa||ywzXul)&&typeof(a)=="string")return ywzXorgsin("ywzXpp(1);"+a+";ywzXpp(0);",b);return ywzXorgsin(a,b);};

function ywzXbn(){if(ywzXd&&ywzXm){if(ywzXb){ywzXc="s";ywzXb+=", "+ywzXm;}else{ywzXc="";ywzXb=ywzXm;};ywzXi="Popup"+ywzXc+" on page blocked by Ad Muncher: "+ywzXb;ywzXu();};};

function ywzXox(){var x;for(var i=0;i<ywzX_ams_onunload.length;i++){if(typeof(ywzX_ams_onunload[i])=="function")ywzX_ams_onunload[i]();};if(typeof(ywzXffad)!="undefined"&&!ywzXffadd){if(ywzXkou)ywzXul=1;ywzXffadd=1;if(typeof(ywzXffad)=="function")x=ywzXffad();else eval(ywzXffad);ywzXul=0;};return x;};

function ywzXModalDialog(a,b,c){if(ywzXck(a,b))return ywzXfw();if(ywzXqn)ywzXqn-=1;if(c)return showModalDialog(a,b,c);else if(b)return showModalDialog(a,b);else return showModalDialog(a);};

function ywzXs(a){if((typeof(a.target)!="undefined"&&typeof(a.action)!="undefined"&&a.target&&ywzXnw(a.target)&&ywzXck(a.action))||typeof(a.submit)=="undefined")return false;return a.submit();};

function ywzXt(a){if((ywzXqn||ywzXa)&&!ywzXppa&&!ywzXul){if(ywzXqn)ywzXqn-=1;return alert(a);};if(a&&ywzXd){ywzXi="Alert message blocked by Ad Muncher: "+ywzXpl(a,"\n"," ");ywzXu();};return false;};

function ywzXModelessDialog(a,b,c){if(ywzXck(a,b))return ywzXfw();if(ywzXqn)ywzXqn-=1;if(c)return showModelessDialog(a,b,c);else if(b)return showModelessDialog(a,b);else return showModelessDialog(a);};

function ywzXsp(a,z){if(a.split)return a.split(z);var j,c,s,n,b,e;j=b=0;c=on.length;s=new Array();a+=z;n=a.length;while(b<n){e=z?a.indexOf(z,b):b+1;s[j++]=a.substring(b,e);b=e+c;};return s.length=j,s;};

function ywzXu(a){ywzXi=ywzXpl(ywzXpl(ywzXi.substring(0,1024),'"',"<~am~`"),"<~am~`",'\\"');ywzXir='defaultStatus="'+ywzXi+'";';if(!ywzXss){ywzXss=1;ywzXorgsin("eval(ywzXir);",3000);};ywzXorgsti("eval(ywzXir);",1000);};

function ywzXe(){ywzXa=0;ywzXqnbu=ywzXqn;ywzXqn=0;ywzXolp=1;ywzXorgsti("ywzXa=1;",1000);if(!ywzXffd){ywzXffd=1;for(var i=0;i<ywzX_ams_onload.length;i++){if(typeof(ywzX_ams_onload[i])=="function")ywzX_ams_onload[i]();};if(typeof(ywzXff)!="undefined"){if(typeof(ywzXff)=="function")ywzXff();else eval(ywzXff);};};ywzXqn=ywzXqnbu;ywzXolp=0;ywzXx();};

function ywzXnw(a){ywzXagt=navigator.userAgent.toLowerCase();if(a!="_self"&&a!="_top"&&a!="_main"&&a!="_parent"&&!ywzXfcs(a)&&((ywzXagt.indexOf("msie")==-1||ywzXagt.indexOf("opera")!=-1)||(a!="_search"&&a!="_media")))return 1;return 0;};

function ywzXobx(){var x;if(typeof(ywzXffreunload)!="undefined"&&!ywzXffreunloadd){if(ywzXkou)ywzXul=1;ywzXffreunloadd=1;if(typeof(ywzXffreunload)=="function")x=ywzXffreunload();else eval(ywzXffreunload);ywzXffreunloadd=0;ywzXul=0;};return x;};

function ywzXtryk(){var b=navigator.userAgent.toLowerCase();var c=parseInt(navigator.appVersion);if((b.indexOf("mozilla")!=-1&&b.indexOf("compatible")== -1&&c>=5)||(b.indexOf("opera")!=-1&&c>=6)||(b.indexOf("msie")!=-1&&c>=4))return 1;return 0;};

function ywzXfcsd(){var v=self;if(ywzXfc(v.frames,ywzXfcsrz)||(typeof(v.name)!="undefined"&&v.name==ywzXfcsrz))return 1;while(v!=v.parent){v=v.parent;if(ywzXfc(v.frames,ywzXfcsrz)||(typeof(v.name)!="undefined"&&v.name==ywzXfcsrz))return 1;};return 0;};

function ywzXtePopup(a,b,c,d,e,f){if(ywzXck())return ywzXfw();if(ywzXqn)ywzXqn-=1;if(f)return createPopup(a,b,c,d,e,f);else if(e)return createPopup(a,b,c,d,e);else if(d)return createPopup(a,b,c,d);else if(c)return createPopup(a,b,c);else if(b)return createPopup(a,b);else return createPopup(a);};

function ywzXmc(){if(typeof(document.layers)!="undefined")document.captureEvents(Event.KeyDown|Event.MouseUp|Event.Blur|Event.KeyPress|Event.Move|Event.Click|Event.KeyUp|Event.Reset|Event.Change|Event.Load|Event.Resize|Event.DblClick|Event.MouseDown|Event.Select|Event.DragDrop|Event.MouseMove|Event.Submit|Event.Error|Event.MouseOut|Event.Unload|Event.Focus|Event.MouseOver);document.onmousedown=ywzXr;return 0;};

function ywzXck(a,b){if(!ywzXul&&!ywzXppa&&(ywzXro||ywzXqn||ywzXa||(b&&!ywzXnw(b)))){return 0;};ywzXgp(a);var l,s,c;for(var i=0;i<ywzXpmx.length;i++){l=0;s=ywzXsp(ywzXpmx[i],"*");for(var z=0;z<s.length;z++){c=ywzXn.indexOf(s[z],l);if(c==-1){l=0;break;};l=c;};if(l)return 0;};ywzXbn();if(ywzXrp){ywzXrpi5=ywzXrpi4;ywzXrpi4=ywzXrpi3;ywzXrpi3=ywzXrpi2;ywzXrpi2=ywzXrpi1;ywzXrpi1=new Image();var ywzXzn;ywzXtry("ywzXzn=document.referrer");ywzXrpi1.src="http://www.admuncher.com/cgi-bin/pr.pl?p="+escape(ywzXm)+"&s="+escape(document.location.href)+"&r="+escape(ywzXzn)+"&v=4.7.27105&l=1383";};return 1;};

function ywzXr(e){if((e&&e.which==1)||(typeof(window.event)!="undefined"&&window.event.button==1)){ywzXqn=ywzXqnbu=10;ywzXorgsti("ywzXqn=ywzXqnbu=0;",500);if(typeof(document.ywzXusedown)!="undefined"){if(typeof(document.ywzXusedown)=="function")return document.ywzXusedown(e);else return eval(document.ywzXusedown);};};if(typeof(document.ywzXusedown)!="undefined"){if(e||typeof(window.event)!="undefined"){if(typeof(document.ywzXusedown)=="function"){ywzXpp(0);var ywzXtn=document.ywzXusedown(e);ywzXpp(1);return ywzXtn;}else return eval("ywzXpp(1);"+document.ywzXusedown+";ywzXpp(0);");};if(typeof(document.ywzXusedown)=="function")return document.ywzXusedown(e);else return eval(document.ywzXusedown);};return true;};

function ywzXx(){ywzXtry('if(typeof(window.onload)=="undefined")window.onload=ywzXe;else{ywzXq=""+window.onload;if(!window.onload||!ywzXq||ywzXq.indexOf("ywzXe")!=-1)window.onload=ywzXe;};if(typeof(window.onunload)=="undefined")window.onunload=ywzXox;else{ywzXq=""+window.onunload;if(!window.onunload||!ywzXq||ywzXq.indexOf("ywzXox")!=-1)window.onunload=ywzXox;};if(typeof(window.onbeforeunload)=="undefined")window.onbeforeunload=ywzXobx;else{ywzXq=""+window.onbeforeunload;if(!window.onbeforeunload||!ywzXq||ywzXq.indexOf("ywzXobx")!=-1)window.onbeforeunload=ywzXobx;};if(typeof(window.onmousedown)=="undefined")ywzXmc();else{ywzXq=""+document.onmousedown;if(!window.onmousedown||!ywzXq||ywzXq.indexOf("ywzXr")!=-1){ywzXmc();};};');};

function ywzXgp(a){if(a){var ywzXckjs=/[A-Za-z]+:/;if(a.search(ywzXckjs)!=-1){if(a.substring(0,5).toLowerCase()!="http:"){ywzXm="(No URL)";ywzXn=a.toLowerCase()+" "+document.URL.toLowerCase();return;};};ywzXp="/admuncherpopcheck&"+Math.random()+"&"+document.URL;ywzXmi3=ywzXmi2;ywzXmi2=ywzXmi1;ywzXmi1=new Image();ywzXn=a;ywzXnn=ywzXn.indexOf("#");if(ywzXnn!=-1)ywzXn=ywzXn.substring(0,ywzXnn);ywzXmi1.src=ywzXn+ywzXp;ywzXnn=ywzXmi1.src.indexOf(ywzXp);if(ywzXnn!=-1)ywzXm=ywzXmi1.src.substring(0,ywzXnn);ywzXn=ywzXm.toLowerCase()+" "+document.URL.toLowerCase();}else{ywzXm="(No URL)";ywzXn=document.URL.toLowerCase();ywzXp="/admuncherpopchecknourl&"+Math.random();ywzXmi3=ywzXmi2;ywzXmi2=ywzXmi1;ywzXmi1=new Image();ywzXmi1.src=document.URL+ywzXp;};};

function ywzX(a,b,c,d){if(ywzXck(a,b))return ywzXfw(b);if(ywzXqn)ywzXqn-=1;if(!a)a="";if(typeof(c)=="string"){c=ywzXpl(c.toLowerCase()," ","");if(ywzXw){c=ywzXpl(c,"height=","xxx=");c=ywzXpl(c,"width=","xxx=");c=ywzXpl(c,"top=","xxx=");c=ywzXpl(c,"left=","xxx=");c=ywzXpl(c,"screenx=","xxx=");c=ywzXpl(c,"screeny=","xxx=");};if(ywzXy){c=ywzXpl(c,"location=","xxx=");c=ywzXpl(c,"toolbar=","xxx=");c=ywzXpl(c,"menubar=","xxx=");c=ywzXpl(c,"resizable=","xxx=");c=ywzXpl(c,"scrollbars=","xxx=");c=ywzXpl(c,"status=","xxx=");c=ywzXpl(c,"titlebar=","xxx=");c=ywzXpl(c,"fullscreen=","xxx=");c=ywzXpl(c,"directories=","xxx=");};};if(ywzXy){if(typeof(c)=="string")c+=",";else c="";c+="location,toolbar,menubar,resizable,scrollbars,status,titlebar,directories";};if(d)return ywzXorgo(a,b,c,d);else if(c)return ywzXorgo(a,b,c);else if(b)return ywzXorgo(a,b);else return ywzXorgo(a);};

function ywzXso(c,a){if(typeof(a)=="string"&&a.substring(0,11)=="javascript:"){a=a.substring(11,a.length);};if(typeof(ywzXsod[c])=="undefined"||!ywzXsod[c]){ywzXsod[c]=1;var x=new Array('quot22','amp26','lt3C','gt3E','nbspA0','iexclA1','centA2','poundA3','yenA5','brvbarA6','sectA7','umlA8','copyA9','ordfAA','laquoAB','notAC','shyAD','regAE','macrAF','degB0','plusmnB1','sup2B2','sup3B3','acuteB4','microB5','paraB6','middotB7','cedilB8','sup1B9','ordmBA','raquoBB','frac14BC','frac12BD','frac34BE','iquestBF','AgraveC0','AacuteC1','AcircC2','AtildeC3','AumlC4','AringC5','AEligC6','CcedilC7','EgraveC8','EacuteC9','EcircCA','EumlCB','IgraveCC','IacuteCD','IcircCE','IumlCF','ETHD0','NtildeD1','OgraveD2','OacuteD3','OcircD4','OtildeD5','OumlD6','timesD7','OslashD8','UgraveD9','UacuteDA','UcircDB','UumlDC','YacuteDD','THORNDE','szligDF','agraveE0','aacuteE1','acircE2','atildeE3','aumlE4','aringE5','aeligE6','ccedilE7','egraveE8','eacuteE9','ecircEA','eumlEB','igraveEC','iacuteED','icircEE','iumlEF','ethF0','ntildeF1','ograveF2','oacuteF3','ocircF4','otildeF5','oumlF6','divideF7','oslashF8','ugraveF9','uacuteFA','ucircFB','uumlFC','yacuteFD','thornFE','yumlFF');var l,m;for(var i=0;i<x.length;i++){if (typeof(x[i])=="string"){l=x[i].length;m="&"+x[i].substring(0,(l-2))+";";a=ywzXpl(a,m,unescape("%"+x[i].substring((l-2),l)));};};if(c==1)ywzXff=new Function(a);if(c==2)ywzXffad=new Function(a);if(c==3)ywzXffreunload=new Function(a);};};

function ywzXfw(b){var r=new Object();for(i in window)r[i]=window[i];var v=new Array("scrollBy","getSelection","scrollByLines","scrollByPages","sizeToContent","dump","setTimeout","setInterval","clearTimeout","clearInterval","setResizable","captureEvents","releaseEvents","routeEvent","enableExternalCapture","disableExternalCapture","prompt","open","openDialog","find","alert","confirm","focus","blur","back","forward","home","stop","print","moveTo","moveBy","resizeTo","resizeBy","scroll","close","show","updateCommands","escape","unescape","atob","btoa","addEventListener","removeEventListener","dispatchEvent","getComputedStyle");for(var i=0;i<v.length;i++)r[v[i]]=ywzn;v=new Array("captureEvents","close","open","releaseEvents","clear","writeln","getElementById","getElementsByName","elementFromPoint","createEvent","getSelection","write","createElement","createElementNS","createDocumentFragment","createTextNode","createComment","createAttribute","getElementsByTagName","importNode","attachEvent","detachEvent","hasAttributes","addEventListener","removeEventListener","dispatchEvent","contains","insertBefore","replaceChild","removeChild","appendChild","hasChildNodes","isSupported","normalize","cloneNode");r.document=new Object();for(var i=0;i<v.length;i++)r.document[v[i]]=ywzn;r.document.body=new Object();r.document.body.style=new Object();r.name=b;r.amwin="a";r.location=new Object(ywzXm);r.location.href=ywzXm;r.location.hash=window.location.hash;r.location.host=window.location.host;r.location.hostname=window.location.hostname;r.location.pathname=window.location.pathname;r.location.port=window.location.port;r.location.protocol=window.location.protocol;r.location.search=window.location.search;ywzXclct+=1;eval("ywzXpc["+ywzXclct+"]=r;ywzXorgsti(\"ywzXpc["+ywzXclct+"].closed=true;\",1500);");return r;};

if(typeof(self.ywzXinited)=="undefined"){

var ywzXinited=1;var ywzXa,ywzXb,ywzXc,ywzXd,ywzXi,ywzXir,ywzXk,ywzXm,ywzXmi1,ywzXmi2,ywzXmi3,ywzXn,ywzXnn,ywzXp,ywzXq,ywzXss,ywzXv,ywzXw,ywzXy,ywzXro,ywzXolp,ywzXqn,ywzXqnbu,ywzXplt,ywzXagt,ywzXtz,ywzXti,ywzXsa,ywzXeb,ywzXrp,ywzXrpi1,ywzXrpi2,ywzXrpi3,ywzXrpi4,ywzXrpi5,ywzXppa,ywzXffd,ywzXorgo,ywzXorgsin,ywzXorgsti,ywzXul,ywzXkou,ywzXffreunloadd,ywzXffadd,ywzXfcsr,ywzXfcsrz;var ywzX_ams_onload_i=0;var ywzX_ams_onload=new Array();var ywzX_ams_onunload_i=0;var ywzX_ams_onunload=new Array();var ywzXsod=new Array();for(var ywzXvin="";ywzXvin!="aaaaaaaaaaaaaaaaaaaa";ywzXvin+="a")eval("var AdMch"+ywzXvin+";");var ywzXclct=0;var ywzXpc=new Array();ywzXk=1;ywzXd=1;ywzXw=0;ywzXy=0;ywzXro=0;ywzXi="";ywzXtz=0;ywzXti=0;ywzXrp=0;ywzXkou=1;var ywzXpmx=new Array('.gov/funzone/','.passport.net/panehelp.','/apps/mediaplayer/','/online/popup.html?','/playradionow.jsp?','/private.php?','/privmsg.php?','/radio/launchradio.','/reviews_viewer.php?object=','/site/olspage.jsp?id=','/spurl.php?v=','/video/partners/','/vspot/player.','/watch_fullscreen?','isapi.dll?picture','launch.yahoo.*/play/','music.yahoo.','skinbase.org/files/','webmail.aol.com','webmessenger.msn.com');ywzXorgo=open;ywzXorgsti=setTimeout;ywzXorgsin=setInterval;ywzXx();if(ywzXk)ywzXtry("window.onerror=ywzXj;");var ywzXz;ywzXtry("ywzXz=document.referrer");if(!ywzXz){if(ywzXti){if(ywzXtz)ywzXz=location.protocol+"//"+location.host+"/";else ywzXz="http://www.admuncher.com/";};}else if(ywzXz.substring(0,7)=="http://"){ywzXsa=ywzXz;ywzXsa=ywzXsa.substring(7,1024);if(ywzXsa.indexOf("/")!=-1)ywzXsa=ywzXsa.substring(0,ywzXsa.indexOf("/"));if(ywzXsa!=location.host){if(ywzXtz)ywzXz=location.protocol+"//"+location.host+"/";else ywzXz="http://www.admuncher.com/";};};

};

// End Ad Muncher helper script

// ]]>



// -------------------------------------------------------------------

// Switch Content Script- By Dynamic Drive, available at: http://www.dynamicdrive.com

// Created: Jan 5th, 2007

// April 5th, 07: Added ability to persist content states by x days versus just session only

// March 27th, 08': Added ability for certain headers to get its contents remotely from an external file via Ajax (2 variables below to customize)

// -------------------------------------------------------------------



var switchcontent_ajax_msg='<em>Loading Ajax content...</em>' //Customize message to show while fetching Ajax content (if applicable)

var switchcontent_ajax_bustcache=true //Bust cache and refresh fetched Ajax contents when page is reloaded/ viewed again?



function switchcontent(className, filtertag){

	this.className=className

	this.collapsePrev=false //Default: Collapse previous content each time

	this.persistType="none" //Default: Disable persistence

	//Limit type of element to scan for on page for switch contents if 2nd function parameter is defined, for efficiency sake (ie: "div")

	this.filter_content_tag=(typeof filtertag!="undefined")? filtertag.toLowerCase() : ""

	this.ajaxheaders={} //object to hold path to ajax content for corresponding header (ie: ajaxheaders["header1"]='external.htm')

}



switchcontent.prototype.setStatus=function(openHTML, closeHTML){ //PUBLIC: Set open/ closing HTML indicator. Optional

	this.statusOpen=openHTML

	this.statusClosed=closeHTML

}



switchcontent.prototype.setColor=function(openColor, closeColor){ //PUBLIC: Set open/ closing color of switch header. Optional

	this.colorOpen=openColor

	this.colorClosed=closeColor

}



switchcontent.prototype.setPersist=function(bool, days){ //PUBLIC: Enable/ disable persistence. Default is false.

	if (bool==true){ //if enable persistence

		if (typeof days=="undefined") //if session only

			this.persistType="session"

		else{ //else if non session persistent

			this.persistType="days"

			this.persistDays=parseInt(days)

		}

	}

	else

		this.persistType="none"

}



switchcontent.prototype.collapsePrevious=function(bool){ //PUBLIC: Enable/ disable collapse previous content. Default is false.

	this.collapsePrev=bool

}



switchcontent.prototype.setContent=function(index, filepath){ //PUBLIC: Set path to ajax content for corresponding header based on header index

	this.ajaxheaders["header"+index]=filepath

}



switchcontent.prototype.sweepToggle=function(setting){ //PUBLIC: Expand/ contract all contents method. (Values: "contract"|"expand")

	if (typeof this.headers!="undefined" && this.headers.length>0){ //if there are switch contents defined on the page

		for (var i=0; i<this.headers.length; i++){

			if (setting=="expand")

				this.expandcontent(this.headers[i]) //expand each content

			else if (setting=="contract")

				this.contractcontent(this.headers[i]) //contract each content

		}

	}

}





switchcontent.prototype.defaultExpanded=function(){ //PUBLIC: Set contents that should be expanded by default when the page loads (ie: defaultExpanded(0,2,3)). Persistence if enabled overrides this setting.

	var expandedindices=[] //Array to hold indices (position) of content to be expanded by default

	//Loop through function arguments, and store each one within array

	//Two test conditions: 1) End of Arguments array, or 2) If "collapsePrev" is enabled, only the first entered index (as only 1 content can be expanded at any time)

	for (var i=0; (!this.collapsePrev && i<arguments.length) || (this.collapsePrev && i==0); i++)

		expandedindices[expandedindices.length]=arguments[i]

	this.expandedindices=expandedindices.join(",") //convert array into a string of the format: "0,2,3" for later parsing by script

}





//PRIVATE: Sets color of switch header.



switchcontent.prototype.togglecolor=function(header, status){

	if (typeof this.colorOpen!="undefined")

		header.style.color=status

}





//PRIVATE: Sets status indicator HTML of switch header.



switchcontent.prototype.togglestatus=function(header, status){

	if (typeof this.statusOpen!="undefined")

		header.firstChild.innerHTML=status

}





//PRIVATE: Contracts a content based on its corresponding header entered



switchcontent.prototype.contractcontent=function(header){

	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content container for this header

	innercontent.style.display="none"

	this.togglestatus(header, this.statusClosed)

	this.togglecolor(header, this.colorClosed)

}





//PRIVATE: Expands a content based on its corresponding header entered



switchcontent.prototype.expandcontent=function(header){

	var innercontent=document.getElementById(header.id.replace("-title", ""))

	if (header.ajaxstatus=="waiting"){//if this is an Ajax header AND remote content hasn't already been fetched

		switchcontent.connect(header.ajaxfile, header)

	}

	innercontent.style.display="block"

	this.togglestatus(header, this.statusOpen)

	this.togglecolor(header, this.colorOpen)

}



// -------------------------------------------------------------------

// PRIVATE: toggledisplay(header)- Toggles between a content being expanded or contracted

// If "Collapse Previous" is enabled, contracts previous open content before expanding current

// -------------------------------------------------------------------



switchcontent.prototype.toggledisplay=function(header){

	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content container for this header

	if (innercontent.style.display=="block")

		this.contractcontent(header)

	else{

		this.expandcontent(header)

		if (this.collapsePrev && typeof this.prevHeader!="undefined" && this.prevHeader.id!=header.id) // If "Collapse Previous" is enabled and there's a previous open content

			this.contractcontent(this.prevHeader) //Contract that content first

	}

	if (this.collapsePrev)

		this.prevHeader=header //Set current expanded content as the next "Previous Content"

}





// -------------------------------------------------------------------

// PRIVATE: collectElementbyClass()- Searches and stores all switch contents (based on shared class name) and their headers in two arrays

// Each content should carry an unique ID, and for its header, an ID equal to "CONTENTID-TITLE"

// -------------------------------------------------------------------



switchcontent.prototype.collectElementbyClass=function(classname){ //Returns an array containing DIVs with specified classname

	var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element

	this.headers=[], this.innercontents=[]

	if (this.filter_content_tag!="") //If user defined limit type of element to scan for to a certain element (ie: "div" only)

		var allelements=document.getElementsByTagName(this.filter_content_tag)

	else //else, scan all elements on the page!

		var allelements=document.all? document.all : document.getElementsByTagName("*")

	for (var i=0; i<allelements.length; i++){

		if (typeof allelements[i].className=="string" && allelements[i].className.search(classnameRE)!=-1){

			if (document.getElementById(allelements[i].id+"-title")!=null){ //if header exists for this inner content

				this.headers[this.headers.length]=document.getElementById(allelements[i].id+"-title") //store reference to header intended for this inner content

				this.innercontents[this.innercontents.length]=allelements[i] //store reference to this inner content

			}

		}

	}

}





//PRIVATE: init()- Initializes Switch Content function (collapse contents by default unless exception is found)



switchcontent.prototype.init=function(){

	var instanceOf=this

	this.collectElementbyClass(this.className) //Get all headers and its corresponding content based on shared class name of contents

	if (this.headers.length==0) //If no headers are present (no contents to switch), just exit

		return

	//If admin has changed number of days to persist from current cookie records, reset persistence by deleting cookie

	if (this.persistType=="days" && (parseInt(switchcontent.getCookie(this.className+"_dtrack"))!=this.persistDays))

		switchcontent.setCookie(this.className+"_d", "", -1) //delete cookie

	// Get ids of open contents below. Four possible scenerios:

	// 1) Session only persistence is enabled AND corresponding cookie contains a non blank ("") string

	// 2) Regular (in days) persistence is enabled AND corresponding cookie contains a non blank ("") string

	// 3) If there are contents that should be enabled by default (even if persistence is enabled and this IS the first page load)

	// 4) Default to no contents should be expanded on page load ("" value)

	var opencontents_ids=(this.persistType=="session" && switchcontent.getCookie(this.className)!="")? ','+switchcontent.getCookie(this.className)+',' : (this.persistType=="days" && switchcontent.getCookie(this.className+"_d")!="")? ','+switchcontent.getCookie(this.className+"_d")+',' : (this.expandedindices)? ','+this.expandedindices+',' : ""

	for (var i=0; i<this.headers.length; i++){ //BEGIN FOR LOOP

		if (typeof this.ajaxheaders["header"+i]!="undefined"){ //if this is an Ajax header

			this.headers[i].ajaxstatus='waiting' //two possible statuses: "waiting" and "loaded"

			this.headers[i].ajaxfile=this.ajaxheaders["header"+i]

		}

		if (typeof this.statusOpen!="undefined") //If open/ closing HTML indicator is enabled/ set

			this.headers[i].innerHTML='<span class="status"></span>'+this.headers[i].innerHTML //Add a span element to original HTML to store indicator

		if (opencontents_ids.indexOf(','+i+',')!=-1){ //if index "i" exists within cookie string or default-enabled string (i=position of the content to expand)

			this.expandcontent(this.headers[i]) //Expand each content per stored indices (if ""Collapse Previous" is set, only one content)

			if (this.collapsePrev) //If "Collapse Previous" set

			this.prevHeader=this.headers[i]  //Indicate the expanded content's corresponding header as the last clicked on header (for logic purpose)

		}

		else //else if no indices found in stored string

			this.contractcontent(this.headers[i]) //Contract each content by default

		this.headers[i].onclick=function(){instanceOf.toggledisplay(this)}

	} //END FOR LOOP

	switchcontent.dotask(window, function(){instanceOf.rememberpluscleanup()}, "unload") //Call persistence method onunload

}





// -------------------------------------------------------------------

// PRIVATE: rememberpluscleanup()- Stores the indices of content that are expanded inside session only cookie

// If "Collapse Previous" is enabled, only 1st expanded content index is stored

// -------------------------------------------------------------------



//Function to store index of opened ULs relative to other ULs in Tree into cookie:

switchcontent.prototype.rememberpluscleanup=function(){

	//Define array to hold ids of open content that should be persisted

	//Default to just "none" to account for the case where no contents are open when user leaves the page (and persist that):

	var opencontents=new Array("none")

	for (var i=0; i<this.innercontents.length; i++){

		//If persistence enabled, content in question is expanded, and either "Collapse Previous" is disabled, or if enabled, this is the first expanded content

		if (this.persistType!="none" && this.innercontents[i].style.display=="block" && (!this.collapsePrev || (this.collapsePrev && opencontents.length<2)))

			opencontents[opencontents.length]=i //save the index of the opened UL (relative to the entire list of ULs) as an array element

		this.headers[i].onclick=null //Cleanup code

	}

	if (opencontents.length>1) //If there exists open content to be persisted

		opencontents.shift() //Boot the "none" value from the array, so all it contains are the ids of the open contents

	if (typeof this.statusOpen!="undefined")

		this.statusOpen=this.statusClosed=null //Cleanup code

	if (this.persistType=="session") //if session only cookie set

		switchcontent.setCookie(this.className, opencontents.join(",")) //populate cookie with indices of open contents: classname=1,2,3,etc

	else if (this.persistType=="days" && typeof this.persistDays=="number"){ //if persistent cookie set instead

		switchcontent.setCookie(this.className+"_d", opencontents.join(","), this.persistDays) //populate cookie with indices of open contents

		switchcontent.setCookie(this.className+"_dtrack", this.persistDays, this.persistDays) //also remember number of days to persist (int)

	}

}





// -------------------------------------------------------------------

// A few utility functions below:

// -------------------------------------------------------------------





switchcontent.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)

	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype

	if (target.addEventListener)

		target.addEventListener(tasktype, functionref, false)

	else if (target.attachEvent)

		target.attachEvent(tasktype, functionref)

}



switchcontent.connect=function(pageurl, header){

	var page_request = false

	var bustcacheparameter=""

	if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)

		try {

		page_request = new ActiveXObject("Msxml2.XMLHTTP")

		} 

		catch (e){

			try{

			page_request = new ActiveXObject("Microsoft.XMLHTTP")

			}

			catch (e){}

		}

	}

	else if (window.XMLHttpRequest) // if Mozilla, Safari etc

		page_request = new XMLHttpRequest()

	else

		return false

	page_request.onreadystatechange=function(){switchcontent.loadpage(page_request, header)}

	if (switchcontent_ajax_bustcache) //if bust caching of external page

		bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()

	page_request.open('GET', pageurl+bustcacheparameter, true)

	page_request.send(null)

}



switchcontent.loadpage=function(page_request, header){

	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content container for this header

	innercontent.innerHTML=switchcontent_ajax_msg //Display "fetching page message"

	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){

		innercontent.innerHTML=page_request.responseText

		header.ajaxstatus="loaded"

	}

}



switchcontent.getCookie=function(Name){ 

	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair

	if (document.cookie.match(re)) //if cookie found

		return document.cookie.match(re)[0].split("=")[1] //return its value

	return ""

}



switchcontent.setCookie=function(name, value, days){

	if (typeof days!="undefined"){ //if set persistent cookie

		var expireDate = new Date()

		var expstring=expireDate.setDate(expireDate.getDate()+days)

		document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()

	}

	else //else if this is a session only cookie

		document.cookie = name+"="+value

}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
