/* SWFObject v2.0 <http://code.google.com/p/swfobject/> Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis. This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();
/* Content toggles */
tabarea = function(ob, whichtab){
	tta = ob.parentNode.parentNode.parentNode;
	//find correct element node
	var theul = tta.childNodes[0];
	while (theul.nodeType != 1){
		theul = theul.nextSibling;
	}
	thetabs = theul.getElementsByTagName("li");

	for(i=0; i < thetabs.length; i++){
		thetabs[i].className = "";
	}
	tabcontents = tta.getElementsByTagName("*");
	for(i=0;i<tabcontents.length;i++){
		if(tabcontents[i].className == "tabcontent"){
			tabcontents[i].className = "tabcontent hide";
		}
	}
	ob.parentNode.className = "active";
	$(whichtab).className = "tabcontent";
};
togglefilter = function(whichfilter){
	d = $$("#filter_" + whichfilter + " div");
	a = $$("#filter_" + whichfilter + " a");
	for(i=0; i < a.length; i++){
		if(a[i].className == "rarw"){
			thelink = a[i];
		}
	}
	for(i=0; i < d.length; i++){
		if(d[i].className == "moreoptions"){
			d[i].className = "moreoptions hide";
			thelink.innerHTML = "More options";
		}else if(d[i].className == "moreoptions hide"){
			d[i].className = "moreoptions";
			thelink.innerHTML = "Hide options";
		}
	}
};
// Generator functions
generator_color = function(fld, clr){$(fld).value=clr};
generator_over = function(fld, clr){
	if(clr !== ""){
		$(fld).innerHTML = clr.innerHTML;
	}else{
		$(fld).innerHTML = "Select a color";
	}
};
generator_selectclr = function(el){
	var ilen = el.className.length;
	var iseg = el.className.substring(ilen, ilen - 4);
	if(iseg == "over"){
		el.className=el.className.replace(" over", "");
		el.style.left = "0px";
		el.style.top = "0px";
	}else{
		var ell = $(el).getPosition().x;
		var elt = $(el).getPosition().y;
		el.className+=" over";
		el.style.left = (ell - 1) + "px";
		el.style.top = (elt - 149) + "px";
	}
};

// Select dropdown list functions, used to replace wide select fields which need wrapping
var timo = new Object();
var timot = new Object();
argz=1000;
selectdropdown_toggle = function(caller,targ,val){
	timot.o = $(caller).parentNode.parentNode.parentNode;
	if(timot.o.className == "selectdropdown show"){
		timo.o = timot.o;
		$(targ).value = val;
		timo.li = timo.o.getElementsByTagName("li");
		for(i=0;i<timo.li.length;i++){ if(!$(timo.li[i]).hasClass("section")){timo.li[i].className=""} }
		caller.parentNode.className="selected";
		selectdropdown_hide();
	}else{
		if(timo.t){clearTimeout(timo.t);}
		if(timo.t){
			timo.o.className="selectdropdown";
			timo.o.style.overflow="hidden";
			if(Browser.Engine.trident){
				timo.o.getElementsByTagName("ul")[0].style.height="auto";
				timo.o.getElementsByTagName("ul")[0].style.overflow = "hidden";
			}
		}
		timo.o = timot.o;
		timo.o.className="selectdropdown show";
		if(Browser.Engine.trident){
			timo.o.parentNode.style.zIndex=argz++;//Ensures selected element is on top, needed for IE to stack properly
			if(timo.o.getElementsByTagName("ul")[0].offsetHeight > 300){
				timo.o.getElementsByTagName("ul")[0].style.height="300px";
			}else{
				timo.o.getElementsByTagName("ul")[0].style.height="auto";
			}
			timo.o.getElementsByTagName("ul")[0].style.overflow = "auto";
		}
		timo.o.onmouseover=function(){clearTimeout(timo.t)};
		timo.o.onmouseout=function(){timo.t=setTimeout(selectdropdown_hide,500)};
	}
};
selectdropdown_hide = function(){
	clearTimeout(timo.t);
	timo.o.className="selectdropdown";
	timo.o.style.overflow="hidden";
	if(Browser.Engine.trident){
		timo.o.getElementsByTagName("ul")[0].style.height = "auto";
		timo.o.getElementsByTagName("ul")[0].style.overflow = "hidden";
	}
};

// Enable/disable "is required" checkboxes upon clicking generator "optional fields" checkboxes
generatoropt = function(caller){
	tc = caller.parentNode.parentNode;
	if(caller.checked){
		tc.getElementsByTagName("input")[1].disabled=false;
		tc.getElementsByTagName("label")[1].className=tc.getElementsByTagName("label")[1].className.replace(/ reqdisabled/g, "");
	}else{
		tc.getElementsByTagName("input")[1].disabled=true;
		tc.getElementsByTagName("label")[1].className=tc.getElementsByTagName("label")[1].className + " reqdisabled";
	}
};

// Popup Layer class and init of default object
var PopupWindow = new Class({
	initialize: function(){
		//create and compose basic popup layer
		__poplayer = new Element('div', {id:'poplayer', styles:{opacity:0} }).injectInside($('shell'));
		__popwrapper = new Element('div', {id:'popwrap', styles:{opacity:0, display:'none'}, html:'<div id="popwrap2"><div id="PopupTitle"></div><span id="PopupClose">Close</span></div>'}).injectInside($('shell'));
		this.PopupContent = new Element('div', {id:'PopupContent'}).injectInside($('popwrap2'));
		this.PopupTitle = $('PopupTitle');
		$('PopupClose').addEvent('click', function(){Popup.hide()});
		// ie6 needs a transparent iframe underneath the popup to prevent select elements from stacking incorrectly
		if(Browser.Engine.trident4){__popiframe = new Element('iframe', {id:'popiframe', styles: {zIndex:8995, opacity:0, border:0}	}).injectInside($('shell'))}
	},
	show: function(windowcontent, options){
		if(Browser.Engine.trident4 && this.attach == 'undefined'){window.removeEvent('scroll', PopupScroll)}
		__popwrapper.style.display='block';
		//Parse options
		if(!options){options = 'undefined'}
		this.modal = typeof options.modal != 'undefined'? options.modal : false;
		this.size = typeof options.size != 'undefined'? options.size : 'default';
		this.attach = typeof options.attach != 'undefined'? $(options.attach) : 'undefined';
		this.wtitle = typeof options.wtitle != 'undefined'? options.wtitle : 'undefined';
		
		//Add title
		if(this.wtitle != 'undefined'){this.PopupTitle.set('html', this.wtitle)}else{this.PopupTitle.set('html', '&nbsp;')}

		//Inject content
		this.PopupContent.empty();
		if(windowcontent != null){windowcontent.clone(true, true).injectInside(this.PopupContent)}
		//Ensure scroll position is reset:
		this.PopupContent.scrollTo(0,0);

		//show popup layer
		if(__popwrapper.className != "showpop"){
			__popwrapper.className="showpop";
			if(Browser.Engine.trident4){
				__popwrapper.setStyle('opacity','1');
				__popiframe.setStyle('opacity','1');
			}else{
				__popwrapper.fade('in');
			}
		}
		//modal or nonmodal?
		if(this.modal && !Browser.Engine.trident4 && !Browser.Platform.ipod){__poplayer.className = "mdl";__poplayer.fade(0.85)}else{__poplayer.className = "";__poplayer.fade('out')}
		//set popup height
		if(this.size == 'short'){__popwrapper.className += " popshort"}else if(this.size == 'large'){__popwrapper.className += " poplarge"}else if(this.size == 'extralarge'){__popwrapper.className += " popexlarge"}

		//position popup
		if(this.attach != 'undefined'){
			//popup positioned adjacent to an element:
			__popwrapper.style.position="absolute";
			__popwrapper.style.left = this.attach.getPosition().x + 'px';
			__popwrapper.style.top = this.attach.getPosition().y + this.attach.getSize().y + 'px';
			__popwrapper.style.marginTop = "0";
			__popwrapper.style.marginLeft = "0";
		}else{
			//centered popup:
			
			//For some reason, IE only positions correctly if top of window is
			//currently visible, so we have to scroll to the top first.
			//This needs further investigation.
			if(Browser.Engine.trident){window.scrollTo(0,0);}
			
			__popwrapper.style.position="fixed";
			__popwrapper.style.top="50%";
			__popwrapper.style.marginTop = "-" + (__popwrapper.getSize().y/2) +"px";
			__popwrapper.style.left= ($('content').getSize().x - __popwrapper.getSize().x) /2 + 'px';
			__popwrapper.style.marginLeft = "0";
			//horizontally centered popup
			//__popwrapper.style.left="50%";__popwrapper.style.marginLeft = "-" + (__popwrapper.getSize().x/2) +"px";

			if(Browser.Engine.trident4){
				PopupScroll = function(){
					__popwrapper.style.marginTop = "0";
					__popwrapper.style.top = ((window.getSize().y - __popwrapper.getSize().y) /2) + document.documentElement.scrollTop + 'px';
					//__popiframe.style.top = ((window.getSize().y - __popwrapper.getSize().y) /2) + document.documentElement.scrollTop + 'px';
					__popiframe.style.top = __popwrapper.getPosition().y + 'px';
				};
				var delayedinit = function(){this.PopupScroll();};
				delayedinit.delay(100);
				window.addEvent('scroll', PopupScroll);
				
			}
			
		}
		PopupResize = function(){Popup.resize()};
		window.addEvent('resize', PopupResize);
		this.resize();
		if(this.modal){
			PopupKey = function(e){
				if(e.key=='esc'){
					Popup.hide();
				}
			};
			window.addEvent('keydown', PopupKey);
		}
		
		//Add inline help behaviors
		//Initialize inline help sections
		if($$('#PopupContent .inlinehelp.hide').length > 0){
			var initinlinehelp = function(){
				$$('#PopupContent .inlinehelp.hide').each(function(item, index){
					//alert('help!');
					this['helpsection' + index] = new InlineHelp(item);
				});
			};
			initinlinehelp.delay(100);//tiny delay is needed to allow firefox to render height properly
		}
		
	},
	hide: function(){
		window.removeEvent('resize', PopupResize);
		if(this.modal){window.removeEvent('keydown', PopupKey);}
		if(Browser.Engine.trident4){
			__popiframe.setStyle('opacity','0');
			__popwrapper.setStyle('opacity','0');
		}else{
			__poplayer.fade('out');
			__popwrapper.fade('out');
		}
		var resetpop = function(){
			__popwrapper.className="";
			__poplayer.className="";
			__poplayer.style.width = 0;
			__poplayer.style.height = 0;
		}
		resetpop.delay(500);
		if(Browser.Engine.trident4 && this.attach == 'undefined'){window.removeEvent('scroll', PopupScroll)}
	},
	resize: function(){
		// resize popup layer, should be set to fire upon Popup.show and upon window.resize
		if(this.modal && !Browser.Engine.trident4){
			__poplayer.style.width = $(document.body).getSize().x + "px";
			__poplayer.style.height =  $('shell').getSize().y + $('navbar').getSize().y + "px";
		}
		if(Browser.Engine.trident4){
			__popiframe.style.display = 'block';
			__popiframe.style.left = __popwrapper.getPosition().x + 'px';
			__popiframe.style.top = __popwrapper.getPosition().y + 'px';
			__popiframe.style.width = __popwrapper.getSize().x + 'px';
			__popiframe.style.height = __popwrapper.getSize().y + 'px';
		}
		if(__popwrapper.getSize().x + __popwrapper.getPosition().x > window.getSize().x || __popwrapper.getSize().y + __popwrapper.getPosition().y > window.getSize().y){//If larger than window size, set to absolute to allow scrolling with window contents
			__popwrapper.style.position = 'absolute';
		}else{//otherwise, used fixed position
			__popwrapper.style.position = 'fixed';
		}
		if(this.attach == 'undefined'){
			if(__popwrapper.getPosition().y < 0){
				__popwrapper.style.top = "0";
				__popwrapper.style.marginTop="0";
			}else{
				__popwrapper.style.top="50%";
				__popwrapper.style.marginTop = "-" + (__popwrapper.getSize().y/2) +"px";
			}
		}
	}
});

// Inline Help class: converts inline help divs to collapsable sections
var InlineHelp = new Class({
	helpcontent: $empty,
	initialize: function(el){
		helpcontent = el.getChildren();
		if(helpcontent.length > 0){
			this.__helpwrapper = new Element('div', {'class':'inlinehelpwrapper'}).wraps(el);
			if(el.hasClass("right")){this.__helpwrapper.addClass("right")}
			if(el.hasClass("popuphelp")){this.__helpwrapper.addClass("popuphelp")}
			this.__helptoggle = new Element('span', {'html':el.get('title'), 'class':'help'}).inject(this.__helpwrapper, 'before');
			if(el.hasClass("right")){this.__helptoggle.addClass("right")}
			if(el.hasClass("popuphelp")){
				this.__helptoggle.addClass("popuphelp");
				this.__helptoggle.addEvent('click', function(e){
					$('PopupContent').scrollTo(0,0);
				});
			}
			this.helpheight = this.__helpwrapper.getSize().y;
			el.set('title', '');
			this.__helptoggle.addEvent('click', this.togglehelp.bind(this));
			this.__helpwrapper.style.overflow='hidden';
			this.__helpwrapper.style.height = '0px';
		}
	},
	togglehelp: function(){
		if(this.__helpwrapper.getSize().y <= 10){
			this.__helpwrapper.tween('height', this.helpheight + 'px');
		}else{
			this.__helpwrapper.tween('height', '0px');
		}
	}
});

selectallbehavior = function(el){
	if(el.getElements('.selectall input').length > 0){
		el.getElements('.selectall input').each(function(item){
			//add event to each "select all" checkbox
			item.addEvent('click', function(){
				var parent = this.getParent('.selectallparent');
				var c = new Array();
				c = parent.getElementsByTagName('input');
				for(i=0;i<c.length;i++){
					if(c[i].type == 'checkbox'){
						if(this.checked){
							c[i].checked = true;
						}else{
							c[i].checked = false;
						}
					}
				}
			});
			//add events to all select inputs grouped with the "select all" checkbox
			var h = $A(item.getParent('.selectallparent').getElementsByTagName('input'));
			for(i=0;i<h.length;i++){
				$(h[i]).addEvent('click', function(){
					if(!this.checked){
						$(this).getParent('.selectallparent').getElement('.selectall input').checked=false;
					}
				});
			}
		});
	}
};

//Deactivate inputs
disableinputs = function(p){
	if(p != undefined){
		$$(p.getElementsByTagName('select'), p.getElementsByTagName('input'), p.getElementsByTagName('a'), p.getElementsByTagName('textarea'), p.getElementsByTagName('button')).each(function(item){
			item.disabled=true;
		});
		p.addClass('disabled');
	}
};
enableinputs = function(p){
	if(p != undefined){
		$$(p.getElementsByTagName('select'), p.getElementsByTagName('input'), p.getElementsByTagName('a'), p.getElementsByTagName('textarea'), p.getElementsByTagName('button')).each(function(item){
			item.disabled=false;
		});
		p.removeClass('disabled');
	}
};


// Init functions
window.addEvent('domready', function(){
	//find and deactivate appropriate form elements
	if($$('.disabled').length > 0){
		$$('.disabled').each(function(item){
			disableinputs($(item));
		});
	}
	
	//Make dropdown menus for IE6
	if(Browser.Engine.trident4){
		var mainnav = $('mainnav').getElementsByTagName('ul')[0].getElementsByTagName('li');
		for(i=0;i<mainnav.length;i++){
			mainnav[i].onmouseover = function(){this.className+=" over"};
			mainnav[i].onmouseout = function(){this.className=this.className.replace(" over", "")};
		}
	}

	//Action menu tables
	if($$('table.actionmenu tr').length > 0){
		$$('table.actionmenu tr').each(function(item){
			item.addEvents({
				'mouseover': function(){this.className=this.className.replace("amoff", "amon")},
				'mouseout': function(){this.className=this.className.replace("amon", "amoff")}
			});
		});
	}

	//Create single popup instance
	Popup = new PopupWindow();

	//Initialize inline help sections
	if($$('.inlinehelp.hide').length > 0){
		var initinlinehelp = function(){
			$$('.inlinehelp.hide').each(function(item, index){
				this['helpsection' + index] = new InlineHelp(item);
			});
		};
		initinlinehelp.delay(100);//pointless tiny delay is needed to allow firefox to render height properly
	}
	
	//Create nice tooltips for subscription icons
	if($$('.mobsub', '.emasub', '.comsub').length > 0){
		var subsicontips = new Tips( $$('.mobsub', '.emasub', '.comsub'), {offsets: {'x': 16, 'y': 0} } );
	}
	
	//results hide/rollover behaviors
	if(Browser.Engine.trident4 && $A($$('.result .actions ul')).length > 0){
		$A($$('.result .actions ul')).each(function(item, index){
			item.addEvent('mouseover', function(){
				this.addClass('hover');
			});
			item.addEvent('mouseleave', function(){
				this.removeClass('hover');
			});
		});
	}
	toggledresults = $A($$('.result.hide'));
	if(toggledresults.length > 0){
		toggledresults.each(function(item){
			item.set('title', 'Click to show/hide details');
			item.addEvent('click', function(){this.toggleClass("hide")});
		});
		var resultshidden=true;
		resultstoggle = new Element('span', {
			'class':'resultstoggle',
			'html':'Expand all result details',
			'events':{
		        'click': function(){
		            if(resultshidden){
						toggledresults.each(function(item){
							item.removeClass("hide");
							resultstoggle.set('html','Hide all result details');
						});
						resultshidden=false;
					}else{
						toggledresults.each(function(item){
							item.addClass("hide");
							resultstoggle.set('html','Expand all result details');
						});
						resultshidden=true;
					}
		        }
			}
		}).inject(toggledresults[0], 'before');
	}
	
	//Create filter calendar instances
	if($$('input.selectdate').length > 0){
		$$('input.selectdate').each(function(item, index){
			var xoff = item.getParent('.rcol') ? -172 : -94;
			eval("selectday" + index + " = new Calendar({ " + item.get('id') + " : 'm/d/Y' }, { editable: true, classes: ['popcal'], navigation: 2, tweak: { x: xoff, y: 20 }})");
		});
	}

	//Add "select all" behaviors
	if($$('.selectall input').length > 0){
		selectallbehavior($(document.body));
	}
	
	if($$('.export_flyout').length > 0 && Browser.Engine.trident4){
		$$('.export_flyout').addEvent('mouseover', function(){
			this.addClass('hover');
			$$('select').each(function(item){
				item.style.visibility = 'hidden';
			});
		});
		$$('.export_flyout').addEvent('mouseout', function(){
			this.removeClass('hover');
			$$('select').each(function(item){
				item.style.visibility = 'visible';
			});
		});
	}
	

	//Right column filters collapsable sections
	if($$('.filtersection .content').length){
		$$('.filtersection .content').setStyle('display','none');
		$$('.filtersection.active .content').setStyle('display','block');
		$$('.filtersection h4').addEvent('click', function(){
			//$$('.filtersection .content').setStyle('display','none');
			if(this.getNext('.content').style.display == 'block'){
				this.getNext('.content').setStyle('display','none');
				this.getParent('.filtersection').removeClass('active');
			}else{
				this.getNext('.content').setStyle('display','block');
				this.getParent('.filtersection').addClass('active');
			}

		});
	}
	
});
