
var detect=navigator.userAgent.toLowerCase();var OS,browser,version,total,thestring,place;var MM_contentVersion=6;var MM_FlashCanPlay;var plugin=(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"])?navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;if(plugin){var words=navigator.plugins["Shockwave Flash"].description.split(" ");for(var i=0;i<words.length;++i)
{if(isNaN(parseInt(words[i])))
continue;var MM_PluginVersion=words[i];}
MM_FlashCanPlay=MM_PluginVersion>=MM_contentVersion;}else if(navigator.userAgent&&navigator.userAgent.indexOf("MSIE")>=0&&(navigator.appVersion.indexOf("Win")!=-1)){document.write('<SCR'+'IPT LANGUAGE=VBScript\> \n');document.write('on error resume next \n');document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');document.write('</SCR'+'IPT\> \n');}
function canPlayFlash()
{if(MM_FlashCanPlay)
return true;else
return false;}
function checkIt(string)
{place=detect.indexOf(string)+1;thestring=string;return place;}
if(checkIt('konqueror'))
{browser="Konqueror";OS="Linux";}
else if(checkIt('safari'))browser="Safari";else if(checkIt('omniweb'))browser="OmniWeb";else if(checkIt('opera'))browser="Opera";else if(checkIt('webtv'))browser="WebTV";else if(checkIt('icab'))browser="iCab";else if(checkIt('msie'))browser="Internet Explorer";else if(!checkIt('compatible'))
{browser="Netscape Navigator";version=detect.charAt(8);}
else browser="An unknown browser";if(!version)version=detect.charAt(place+thestring.length);if(!OS)
{if(checkIt('linux'))OS="Linux";else if(checkIt('x11'))OS="Unix";else if(checkIt('mac'))OS="Mac";else if(checkIt('win'))OS="Windows";else OS="an unknown operating system";}
function getsJs(){if((browser=="Netscape Navigator")&&(version>=5))return true;else if((browser=="Internet Explorer")&&(version>=6))return true;else if(browser=="Safari")return true;else return false;}
var jsString;if(getsJs)jsString='<style>\n.script{display:block;}\n.noscript{display:none;}</style>';else jsString='<style>\n.script{display:none;}\n.noscript{display:block;}</style>';document.write(jsString);jsString=null;var zlocale='';function setLocale(){if(document.getElementById('locale_lang'))zlocale=document.getElementById('locale_lang').value;return zlocale;}
var scriptString;function getElementsByClassName(oElm,strTagName,strClassName){var arrElements=(strTagName=="*"&&document.all)?document.all:oElm.getElementsByTagName(strTagName);var arrReturnElements=new Array();strClassName=strClassName.replace(/\-/g,"\\-");var oRegExp=new RegExp("(^|\\s)"+strClassName+"(\\s|$)");var oElement;for(var i=0;i<arrElements.length;i++){oElement=arrElements[i];if(oRegExp.test(oElement.className)){arrReturnElements.push(oElement);}}
return(arrReturnElements);}
function collapseStates(elementID){var allOpen=true;var allClosed=true;var wrapper=document.getElementById(elementID+'-wrapper');var container=document.getElementById(elementID);var arrCollapse=getElementsByClassName(container,'div','collapse');for(var i=0;i<arrCollapse.length;i++){if(arrCollapse[i].getElementsByTagName('div')[0].style.display=='block')allClosed=false;if(arrCollapse[i].getElementsByTagName('div')[0].style.display=='none')allOpen=false;}
if(wrapper){var arrOpenSwitches=getElementsByClassName(wrapper,'div','collapse-1');var arrCloseSwitches=getElementsByClassName(wrapper,'div','collapse-0');for(i=0;i<arrCloseSwitches.length;i++){arrCloseSwitches[i].style.color="#999";}
if(allOpen){for(i=0;i<arrOpenSwitches.length;i++){arrOpenSwitches[i].style.color="#999";arrOpenSwitches[i].style.cursor='default';}
for(i=0;i<arrCloseSwitches.length;i++){arrCloseSwitches[i].style.color="#000";arrCloseSwitches[i].style.cursor='pointer';}}
else if(allClosed){for(i=0;i<arrCloseSwitches.length;i++){arrCloseSwitches[i].style.color="#999";arrCloseSwitches[i].style.cursor='default';}
for(i=0;i<arrOpenSwitches.length;i++){arrOpenSwitches[i].style.color="#000";arrOpenSwitches[i].style.cursor='pointer';}}
else{for(i=0;i<arrCloseSwitches.length;i++){arrCloseSwitches[i].style.color="#000";arrCloseSwitches[i].style.cursor='pointer';}
for(i=0;i<arrOpenSwitches.length;i++){arrOpenSwitches[i].style.color="#000";arrOpenSwitches[i].style.cursor='pointer';}}}}
function collapseEvents(){var collapseBody;var arrCollapse=getElementsByClassName(document.getElementsByTagName('body')[0],'div','collapse');for(var i=0;i<arrCollapse.length;i++){arrCollapseH3=arrCollapse[i].getElementsByTagName('h3')[0];if(arrCollapseH3!=null)
{arrCollapseH3.onmouseover=function(){this.style.cursor='pointer';};};arrCollapse[i].getElementsByTagName('div')[0].style.display='none';if(arrCollapseH3!=null)
{arrCollapseH3.onclick=function(){var div=this.parentNode.getElementsByTagName('div')[0];var divStyle=div.style;divStyle.display=(divStyle.display=='block'?'none':'block');var headingStyle=this.style;headingStyle.backgroundImage=(divStyle.display=='block'?closeImgUrl:openImgUrl);collapseStates(this.parentNode.parentNode.id);var action=(divStyle.display=='block')?'expand':'collapse';var nameFromDiv=div.parentNode.id;if(nameFromDiv==null||(nameFromDiv.length==0))
nameFromDiv=div.parentNode.parentNode.id;var actionName=nameFromDiv+'-'+action;recordClientSideClick(actionName,false);};arrCollapseH3.style.backgroundImage=openImgUrl;arrCollapseH3.style.paddingLeft='20px';};}}
function allCollapse(elementID,action){var container=document.getElementById(elementID);var arrCollapse=getElementsByClassName(container,'div','collapse');for(var i=0;i<arrCollapse.length;i++){arrCollapse[i].getElementsByTagName('div')[0].style.display=(action==1?'block':'none');headingStyle=arrCollapse[i].getElementsByTagName('h3')[0].style;headingStyle.backgroundImage=(action==1?closeImgUrl:openImgUrl);}
collapseStates(elementID);}
function collapseModule(btn,el){var btn_open_path=btnOpen;var btn_close_path=btnClose;elStyle=document.getElementById(el).style;if(elStyle.display===''){if(btn.src.indexOf(btn_close_path)>-1)elStyle.display='block';else elStyle.display='none';}
if(elStyle.display=='block'){elStyle.display='none';btn.src=btn_open_path;}
else if(elStyle.display=='none'){elStyle.display='block';btn.src=btn_close_path;}}
function getElementsByClassNameFromElement(strClass,strTag,objContElm){strTag=strTag||"*";objContElm=objContElm||document;var objColl=(strTag=='*'&&document.all)?document.all:objContElm.getElementsByTagName(strTag);var arr=new Array();var delim=strClass.indexOf('|')!=-1?'|':' ';var arrClass=strClass.split(delim);for(var i=0,j=objColl.length;i<j;i++){var arrObjClass=objColl[i].className.split(' ');if(delim==' '&&arrClass.length>arrObjClass.length)continue;var c=0;comparisonLoop:for(var k=0,l=arrObjClass.length;k<l;k++){for(var m=0,n=arrClass.length;m<n;m++){if(arrClass[m]==arrObjClass[k])c++;if((delim=='|'&&c==1)||(delim==' '&&c==arrClass.length)){arr.push(objColl[i]);break comparisonLoop;}}}}
return arr;}
Array.prototype.push=function(value){this[this.length]=value;};function helpOverlayInit(topOffset){if(document.getElementById('help')){Event.addEvent('help','click',getParamsFilter1Step1);}
Event.addEvent('help',"mouseover",function(){this.style.cursor="pointer";},this);}
function savedHelpOverlayInit(){Event.addEvent('help-saved','click',getSavedParamsStep1);Event.addEvent('help-saved',"mouseover",function(){this.style.cursor="pointer";},this);Event.addEvent('help-saved',"mouseout",function(){this.style.cursor="default";},this);}
function setCookie(cookieName,cookieValue){if(cookieValue.length===0){document.cookie=cookieName+"=;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT";}else{var expires=new Date(new Date().getTime()+(7*2*24)*3600000);document.cookie=cookieName+"="+cookieValue.sort().join(",")+";path=/;expires="+expires+";";}}
function getCookie(cookieName){var start=document.cookie.indexOf(cookieName+"=");if(start===null||start==-1)return null;var len=start+cookieName.length+1;var end=document.cookie.indexOf(";",len);if(end==-1)end=document.cookie.length;var cookie=document.cookie.substring(len,end).split(",");return cookie;}
function showFlash(idName,swfURL,swfWidth,swfHeight,swfColor,altPath,flashVars,openSiteTour){var newFlashVars="swfPath="+flashVars;if(openSiteTour=="true"){newFlashVars+="&openSiteTour=true";}else{newFlashVars+="&openSiteTour=false";}
newFlashVars+="&done=true";var node=document.getElementById(idName);var children=node.getElementsByTagName('div');if(checkIt('safari')){node.innerHTML=altPath;}else{var objectTag='';objectTag+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="../../../fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+swfWidth+'" height="'+swfHeight+'">';objectTag+='<param name="allowScriptAccess" value="sameDomain" />';objectTag+='<param name="movie" value="'+swfURL+'" />';objectTag+='<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';objectTag+='<param name="wmode" value="transparent" />';objectTag+='<param name="flashVars" value="swfPath='+flashVars+'">';objectTag+='<embed src="'+swfURL+'" wmode="transparent" quality="high" bgcolor="'+swfColor+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="../../../www.macromedia.com/go/getflashplayer" flashvars="'+newFlashVars+'" width="'+swfWidth+'" height="'+swfHeight+'" scale="noscale" ></embed></object>';node.innerHTML=objectTag;}}
var concatflashVars='';function checkAndShowFlash(idName,swfURL,swfWidth,swfHeight,swfColor,imageOffer,flashVars,openSiteTour)
{if(canPlayFlash()){showFlash(idName,swfURL,swfWidth,swfHeight,swfColor,imageOffer,flashVars,openSiteTour);}else{var node=document.getElementById(idName);node.innerHTML='<h2>'+imageOffer+'</h2>';}}
function showFlashGeneral(idName,swfURL,swfWidth,swfHeight,swfColor,altPath){var flashVars="";var node=document.getElementById(idName);var children=node.getElementsByTagName('div');for(var x=0;x<children.length;x++){flashVars+=children[x].getAttribute("id")+"="+children[x].innerHTML;if(x!=children.length-1)flashVars+="&";}
node.innerHTML='<embed src="'+swfURL+'" wmode="transparent" quality="high" bgcolor="'+swfColor+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="../../../www.macromedia.com/go/getflashplayer" flashvars="'+flashVars+'" width="'+swfWidth+'" height="'+swfHeight+'" scale="noscale" ></embed>';}
function resizeFlashDiv(elFlash,elText,action){var flashDiv=document.getElementById(elFlash);var textDiv=document.getElementById(elText);if(action=='expand'){flashDiv.style.width='408px';flashDiv.style.height='217px';flashDiv.style.zIndex='20';textDiv.style.zIndex='10';}
if(action=='contract'){flashDiv.style.width='176px';flashDiv.style.height='80px';flashDiv.style.zIndex='10';textDiv.style.zIndex='20';}}
function showPointer(){this.style.cursor="pointer";};function showDefaultCursor(){this.style.cursor="default";};function setECMCookie()
{var today=new Date();var expire=new Date();expire.setTime(today.getTime()+(3600000*24*60));document.cookie="ECM=Y;expires="+expire.toGMTString();}
var Event=function(){var listeners=[];return{addEvent:function(el,eventType,fn,scope){if(this._isCollection(el)){var isOk=true;for(var i=0;i<el.length;++i){isOk=(this.addEvent(el[i],eventType,fn,scope)&&isOk);}
return isOk;}
else if(typeof el=="string"){el=document.getElementById(el);}
if(!el){return false;}
var wrappedFn=function(e){return fn.call(el,e,scope);};var li=[el,eventType,fn,wrappedFn,scope];var index=listeners.length;listeners[index]=li;if(el.addEventListener){el.addEventListener(eventType,wrappedFn,false);}else if(el.attachEvent){el.attachEvent("on"+eventType,wrappedFn);}
wrappedFn=null;return true;},removeEvent:function(el,eventType,fn){if(this._isCollection(el)){var isOk=true;for(var i=0;i<el.length;++i){isOk=(this.removeEvent(el[i],eventType,fn)&&isOk);}
return isOk;}
else if(typeof el=="string"){el=document.getElementById(el);}
var cacheItem=null;var index=this._getCacheIndex(el,eventType,fn);if(index>=0){cacheItem=listeners[index];}
if(!el||!cacheItem){return false;}
var cachedFunction=cacheItem[3];if(el.removeEventListener){el.removeEventListener(eventType,cachedFunction,false);}else if(el.detachEvent){el.detachEvent("on"+eventType,cachedFunction);}
delete listeners[index][3];delete listeners[index][2];delete listeners[index];return true;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getPageX:function(el){return this.getPageXY(el).pageX;},getPageY:function(el){return this.getPageXY(el).pageY;},getPageXY:function(elem){var offsetTrail=elem;var offsetLeft=0;var offsetTop=0;while(offsetTrail){offsetLeft+=offsetTrail.offsetLeft;offsetTop+=offsetTrail.offsetTop;offsetTrail=offsetTrail.offsetParent;}
if(navigator.userAgent.indexOf("Mac")!=-1&&typeof document.body.leftMargin!="undefined"){offsetLeft+=parseInt(document.body.leftMargin);offsetTop+=parseInt(document.body.topMargin);}
return{pageX:offsetLeft,pageY:offsetTop};},removeAllEvents:function(el,obj){if(listeners&&listeners.length>0){for(var i=0;i<listeners.length;++i){var l=listeners[i];if(l){obj.removeEvent(l[0],l[1],l[2]);}}
listeners=null;}},getListeners:function(){return listeners;},_getCacheIndex:function(el,sType,fn){for(var i=0;i<listeners.length;++i){var li=listeners[i];if(li&&li[2]==fn&&li[0]==el&&li[1]==sType){return i;}}
return-1;},_isCollection:function(obj){return(obj&&obj.length&&typeof obj!="string"&&!obj.tagName&&!obj.alert&&typeof obj[0]!="undefined");}};}();

var myConnUrl='ajaxSearch.do';
//var myConnUrl='xml/ajaxSearchHome.xml';

var filter1form,arrInputs1,arrLabels1,cardcount,containers;var arrChecked,arrUnchecked;var filter1clicked=false;var group_count=0;

function Group(txt,ID){
	var containerGroups=document.getElementById('filter1-groups-container');
	var containerSingle=document.createElement('div');
	containerSingle.className='filter1-option';
	containerGroups.appendChild(containerSingle);

	var chkbox=document.createElement('input');
	chkbox.type='radio';
	chkbox.value=ID;
	chkbox.setAttribute('name','constituent');
	chkbox.className='filter1-box';
	containerSingle.appendChild(chkbox);
	group_count=group_count+1;
	chkbox.setAttribute("index",group_count);
	//if (group_count == 1) chkbox.setAttribute("checked","checked");

	var label=document.createElement('label');
	label.setAttribute('for',ID);
	containerSingle.appendChild(label);
	label.innerHTML=txt;
	if(browser=='Safari')label.style.position='relative';
	
	if (!Group.prototype.numGroups) Group.prototype.numGroups = 0;
	Group.prototype.numGroups++;

	Event.addEvent(chkbox,"click",function(){filter1clicked=true;resetFilter(true, this)});
}

var attr1_count=0;

function AttributesContainer() {
	this.attributes = new Array();
	var attributeCount = 0;
	
	this.add = function(txt,ID,parentAttr) {
		if (parentAttr) {
			var parAttr = this.getAttribute(parentAttr);
			if (parAttr) parAttr.addSubAttribute(txt,ID);
		} else {
			this.attributes[this.attributes.length] = new Attribute1(txt,ID);
		}

		attributeCount++;
	}
	
	this.init = function() {
		var containerAttrs = document.getElementById('filter1-attrs-container');
		var containerDiv = document.createElement('div');
		containerDiv.className = 'filter1-column';
		containerAttrs.appendChild(containerDiv);
		
		var midpoint = Math.ceil(attributeCount/2);
		var count = 0;
		var hitMidpoint = false;
		
		for (var i=0; i < this.attributes.length; i++) {
			count++;
			count = count + this.attributes[i].getSubAttributesLength();
			
			if (count > midpoint && !hitMidpoint) {
				var containerDiv = document.createElement('div');
				containerDiv.className = 'filter1-column filter1-column2';
				containerAttrs.appendChild(containerDiv);
				hitMidpoint = true;
			}
			this.attributes[i].init(containerDiv);
		}

	}

	this.getAttribute = function(id) {
		for (var i=0; i < this.attributes.length; i++) {
			if (this.attributes[i].getID() == id) return this.attributes[i];

			var subs = this.attributes[i].getSubAttributes();
			
			for (var j=0; j < subs.length; j++) {
				if (subs[j].getID() == id) {
					return subs[j];
				}
			}
		}

	}
	
	this.checkAttribute = function(id, val) {
		var attr = this.getAttribute(id);
		if (attr) {
			if (typeof(attr.parentIsChecked) != "boolean") {
				attr.setCheckbox(val);
			} else {
				if (attr.parentIsChecked == true) {
					attr.setCheckbox(true);
				} else {
					attr.setCheckbox(val);
				}
			}
		}
	}
	
	this.getAttributeFromSub = function(id) {
		for (var i=0; i < this.attributes.length; i++) {
			var subs = this.attributes[i].getSubAttributes();
			
			for (var j=0; j < subs.length; j++) {
				if (subs[j].getID() == id) {
					return this.attributes[i];
				}
			}
		}
	}

	this.getCheckbox = function(id) {
		var attr = this.getAttributeFromSub(id);
		
		if (attr) {
			return attr.getCheckbox();
		}
	}
}

function Attribute1(txt,ID){
	var subAttributes = new Array();
	this.id = ID;
	var checkbox;

	this.init = function(elm) {
		var containerSingle = document.createElement('div');
		containerSingle.className = 'filter1-option';

		var chkbox = document.createElement('input');
		chkbox.type = 'checkbox';
		chkbox.value = ID;
		chkbox.id = ID;
		chkbox.setAttribute('name','attrs');
		chkbox.className = 'filter1-box';
		containerSingle.appendChild(chkbox);
		checkbox = chkbox;
		
		attr1_count = attr1_count + 1;
		chkbox.setAttribute("index",attr1_count);

		var label = document.createElement('label');
		label.setAttribute('for',ID);
		containerSingle.appendChild(label);
		label.innerHTML = txt;
		
		elm.appendChild(containerSingle);

		if (browser == 'Safari') label.style.position = 'relative';
		
		for (var i=0; i < subAttributes.length; i++) {
			subAttributes[i].init(elm)
		}

		Event.addEvent(chkbox,"click",this.checked);
	}

	this.setCheckbox = function(val) {
		checkbox.checked = val;
		this.checked("", true);
	}

	this.checked = function(evt, noChange) {
		if (subAttributes.length > 0) {
			if (checkbox.checked) {
				for (var i=0; i < subAttributes.length; i++) {
					subAttributes[i].disable();
					subAttributes[i].parentIsChecked = true;
				}
			} else {
				for (var i=0; i < subAttributes.length; i++) {
					subAttributes[i].enable();
					subAttributes[i].parentIsChecked = false;
				}
			}
		}

		if (!noChange) {
			filter1clicked = true; 
			filterchange();
		}
	}
	
	this.getID = function() {
		return this.id;
	}

	this.getCheckbox = function() {
		return checkbox;
	}

	this.addSubAttribute = function(txt,ID) {
		subAttributes[subAttributes.length] = new subAttribute(txt, ID);
	}

	this.getSubAttributes = function() {
		return subAttributes;
	}

	this.getSubAttributesLength = function() {
		return subAttributes.length;
	}
}

function subAttribute(txt, ID) {
	var checkbox;
	this.label;
	this.id = ID;
	this.parentIsChecked = false;

	this.init = function(elm) {
		var containerSingle = document.createElement('div');
		containerSingle.className = 'filter1-option filter1-sub';
		
		var chkbox = document.createElement('input');
		chkbox.type = 'checkbox';
		chkbox.value = ID;
		chkbox.id = ID;
		chkbox.setAttribute('name','attrs');
		chkbox.className = 'filter1-box subAttribute';
		containerSingle.appendChild(chkbox);
		checkbox = chkbox;
	
		var label = document.createElement('label');
		label.setAttribute('for',ID);
		attr1_count = attr1_count + 1;
		chkbox.setAttribute("index",attr1_count);
		containerSingle.appendChild(label);
		label.innerHTML = txt;
		this.label = label;
		
		Event.addEvent(chkbox,"click",this.checked);

		elm.appendChild(containerSingle);
	}

	this.getID = function() {
		return this.id;
	}

	this.setCheckbox = function(val) {
		checkbox.checked = val;
	}
	
	this.getCheckbox = function() {
		return checkbox;
	}

	this.disable = function() {
		if (this.label.className.indexOf('disabled') == -1) {
			this.label.className += ' disabled';
		}

		checkbox.checked = true;
		checkbox.disabled = true;
	}

	this.trueDisable = function() {
		if (this.label.className.indexOf('disabled') == -1) {
			this.label.className += ' disabled';
		}

		checkbox.disabled = true;
	}

	this.enable = function() {
		if (this.label.className.indexOf('disabled') != -1) {
			this.label.className = this.label.className.replace('disabled', '');
		}

		checkbox.checked = false;
		checkbox.disabled = false;
	}
	
	this.trueEnable = function() {
		if (this.label.className.indexOf('disabled') != -1) {
			this.label.className = this.label.className.replace('disabled', '');
		}

		checkbox.disabled = false;
	}

	this.checked = function(evt) {
		if (checkbox.checked == false) {
			var parentAttr = attributes.getAttributeFromSub(this.id);
			var subAttrs = parentAttr.getSubAttributes();
			var numSubsChecked = 0;
			for (var x = 0, y = subAttrs.length; x < y; x++) {
				if (subAttrs[x].getCheckbox().checked == true) numSubsChecked++;
			}
			if (numSubsChecked == 0) {
				var parentCheckbox = parentAttr.getCheckbox();
				parentCheckbox.disabled = false;
				parentCheckbox.parentNode.style.color = "#000";
			}
		}
		filter1clicked = true;
		filterchange();
	}
}

function filter1(){
	if(document.getElementById('filter1-form')) {
		filter1form=document.getElementById('filter1-form');
		attrTable1=document.getElementById('filter1-attrs-table');
		createGroups();
		createAttributes();
		arrInputs1=getElementsByClassName(filter1form,'input','filter1-box');
		containers=getElementsByClassName(filter1form,'div','filter1-option');
		var foundGroup=false;
		if(getHomeGroupCookie()!=null){
			var group=getHomeGroupCookie();
			if (!Group.prototype.numGroups) Group.prototype.numGroups = 0;
			for(i=0;i<Group.prototype.numGroups;i++){
				for(j=0;j<group.length;j++){
					if(arrInputs1[i].value==group[j])arrInputs1[i].checked=true;foundGroup=true;
				}
			}
		} else {arrInputs1[0].checked=true;}

		if(getHomeAttrCookie()!=null){
			var arrCookie=getHomeAttrCookie();
			for(i=0;i<arrInputs1.length;i++){
				var inputchecked = false;
				for(j=0;j<arrCookie.length;j++){
					if(arrInputs1[i].value==arrCookie[j])inputchecked=true;
				}
				attributes.checkAttribute(arrInputs1[i].value, inputchecked);
			}
		}

		filterchange();
		
		var navBar = document.getElementById("nav-credit-cards");
		if (navBar) {
			var navBarLinks = navBar.getElementsByTagName("A");
			for (var i = 0, j = navBarLinks.length; i < j; i++) {
				var oldClickEvent = (navBarLinks[i].onclick) ? navBarLinks[i].onclick : function() {};
				navBarLinks[i].onclick = function() {clearHomeCookies(); oldClickEvent();};
			}
		}
	}
}

function resetFilter(attrsOnly, checkedEl) {
	var filter1group=document.getElementById('filter1-groups');
	var groupInputs1=getElementsByClassName(filter1group,'input','filter1-box');

	if(checkedEl){
		for(i=0;i<groupInputs1.length;i++){
			if(groupInputs1[i]==checkedEl){groupInputs1[i].checked=true;}
			else{groupInputs1[i].checked=false;}
		}
	}
	
	var filter1attrs=document.getElementById('filter1-attrs');
	var arrInputs1=getElementsByClassName(filter1attrs,'input','filter1-box');

	if (!attrsOnly) {
		for(i=0;i<groupInputs1.length;i++){
			groupInputs1[i].checked  = (i == 0);
		}
	}

	for(i=0;i<arrInputs1.length;i++){
		attributes.checkAttribute(arrInputs1[i].value, false);
	}

	filterchange();
}

function fnWhenDone(oXML){
	var arrDisable=oXML.responseXML.getElementsByTagName('disabled')[0].getElementsByTagName('attribute');
	cardcount=document.getElementById('filter1-number');
	cardcount.style.visibility='visible';
	var newcardcount=oXML.responseXML.getElementsByTagName('cardcount')[0].firstChild.nodeValue;
	if (!Group.prototype.numGroups) Group.prototype.numGroups = 0;
	for(i=Group.prototype.numGroups;i<arrInputs1.length;i++) {
		var disabledIt=false;
		for(j=0;j<arrDisable.length;j++) {
			if(arrInputs1[i].value==arrDisable[j].firstChild.nodeValue){
				if (arrInputs1[i].className.indexOf('subAttribute') != -1) {
					var thisSub = attributes.getAttribute(arrInputs1[i].value);
					thisSub.trueDisable();
					disabledIt = true;
				} else {
					arrInputs1[i].checked = false;
					arrInputs1[i].disabled = true;
					disabledIt = true;
					containers[i].style.color = '#999';
				}
			}
		}
		if (!disabledIt && arrInputs1[i].className.indexOf('subAttribute') == -1) {
			var subAttrs = attributes.getAttribute(arrInputs1[i].value).getSubAttributes();
			var numSubsChecked = 0;
			for (var x = 0, y = subAttrs.length; x < y; x++) {
				if (subAttrs[x].getCheckbox().checked == true) numSubsChecked++;
			}
			if (numSubsChecked == 0) {
				containers[i].style.color='#000';
				arrInputs1[i].disabled=false;
			}
		} else if (!disabledIt && (arrInputs1[i].className.indexOf('subAttribute') != -1 && !attributes.getCheckbox(arrInputs1[i].value).checked)) {
			var thisSub = attributes.getAttribute(arrInputs1[i].value);
			thisSub.trueEnable();
		}
	}

	cardcount.innerHTML=newcardcount;
	for(i=Group.prototype.numGroups;i<arrInputs1.length;i++) {
		if(!arrInputs1[i].checked&&!arrInputs1[i].disabled)arrUnchecked.push(arrInputs1[i].value);
	}
}

function filterchange(checkedEl){
	if (!Group.prototype.numGroups) Group.prototype.numGroups = 0;
	if(checkedEl){
		for(i=0;i<Group.prototype.numGroups;i++){
			if(arrInputs1[i]==checkedEl){arrInputs1[i].checked=true;}
			else{arrInputs1[i].checked=false;}
		}
	}

	arrChecked=new Array();
	arrUnchecked=new Array();
	arrLabels1=filter1form.getElementsByTagName('label');
	var group;

	for(i=0;i<Group.prototype.numGroups;i++) {
		if(arrInputs1[i].checked){group=arrInputs1[i].value;}
	}
	for(i=0;i<arrInputs1.length;i++){
		if(arrInputs1[i].checked) {
			var filterObj = attributes.getAttribute(arrInputs1[i].value);
			if (!filterObj) {
				arrChecked.push(arrInputs1[i].value);
			} else {
				if (typeof(filterObj.parentIsChecked) != "boolean") {
					arrChecked.push(arrInputs1[i].value);
				} else {
					if (filterObj.parentIsChecked == false) {
						var parentCheckbox = attributes.getAttributeFromSub(arrInputs1[i].value).getCheckbox();
						var parentContainer = parentCheckbox.parentNode;
						parentCheckbox.disabled = true;
						parentContainer.style.color = "#999";
						arrChecked.push(arrInputs1[i].value);
					}
				}
			}
		}
	}

	var myReq=new ajaxReq();
	var q='attrs=';
	var attrCookieValue='';
	for(i=0;i<arrChecked.length;i++) {
		if(i>0) {
			q=q+",";
			attrCookieValue=attrCookieValue+"|";
		}
		attrCookieValue=attrCookieValue+arrChecked[i];
		q=q+arrChecked[i];
	}

	myReq.req(myConnUrl,q,fnWhenDone);
	myReq=null;

	filter1form.onsubmit=function(){setF1AttrCookie(attrCookieValue);setF1GroupCookie(group);setHomeAttrCookie(attrCookieValue);setHomeGroupCookie(group); assignCVC7WSS();}
}

function changeFamilyAttrCookies(cardsMenu) {
	setF1AttrCookie("");
	var selectedFamily = cardsMenu.options[cardsMenu.selectedIndex].id;
	setF1GroupCookie(selectedFamily);
}

function clearHomeCookies() {
	setHomeGroupCookie("");
	setHomeAttrCookie("");
}

function setF1GroupCookie(cookieValue){var expiryDate=new Date();expiryDate.setDate(expiryDate.getDate()+14);if(cookieValue.length==0){document.cookie="citi-filter1-group=;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT;";}else{document.cookie="citi-filter1-group="+cookieValue+";path=/;expires="+expiryDate+";";}}
function getF1GroupCookie(){var start=document.cookie.indexOf("citi-filter1-group=");if(start==-1)return null;var len=start+19;var end=document.cookie.indexOf(";",len);if(end==-1)end=document.cookie.length;return document.cookie.substring(len,end).split("|");}
function setF1AttrCookie(cookieValue){var expiryDate=new Date();expiryDate.setHours(expiryDate.getHours()+12);if(cookieValue.length==0){document.cookie="citi-filter1-attrs=;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT;";}else{document.cookie="citi-filter1-attrs="+cookieValue+";path=/;expires="+expiryDate+";";}}
function getF1AttrCookie(){var start=document.cookie.indexOf("citi-filter1-attrs=");if(start==-1)return null;var len=start+19;var end=document.cookie.indexOf(";",len);if(end==-1)end=document.cookie.length;return document.cookie.substring(len,end).split("|");}

function setHomeGroupCookie(cookieValue){var expiryDate=new Date();expiryDate.setDate(expiryDate.getDate()+14);if(cookieValue.length==0){document.cookie="citi-home-group=;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT;";}else{document.cookie="citi-home-group="+cookieValue+";path=/;expires="+expiryDate+";";}}
function getHomeGroupCookie(){var start=document.cookie.indexOf("citi-home-group=");if(start==-1)return null;var len=start+16;var end=document.cookie.indexOf(";",len);if(end==-1)end=document.cookie.length;return document.cookie.substring(len,end).split("|");}
function setHomeAttrCookie(cookieValue){var expiryDate=new Date();expiryDate.setHours(expiryDate.getHours()+12);if(cookieValue.length==0){document.cookie="citi-home-attrs=;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT;";}else{document.cookie="citi-home-attrs="+cookieValue+";path=/;expires="+expiryDate+";";}}
function getHomeAttrCookie(){var start=document.cookie.indexOf("citi-home-attrs=");if(start==-1)return null;var len=start+16;var end=document.cookie.indexOf(";",len);if(end==-1)end=document.cookie.length;return document.cookie.substring(len,end).split("|");}

function filterclear(){arrLabels1=filter1form.getElementsByTagName('label');for(i=3;i<arrInputs1.length;i++){arrInputs1[i].checked=false;arrInputs1[i].disabled=false;containers[i].style.color='#000';}
filterchange();setF1AttrCookie('');}
function trackFilter1Submit() {
var param='form=filter1';
for(i=0;i<arrInputs1.length;i++) {
	if(arrInputs1[i].checked) {
		param=param+'&';param=param+arrInputs1[i].value+'=true';}
	}
	recordFormSubmit(param);
	//assignCVC7WSS();
}
// WebSideStory tracking functionality
function assignCVC7WSS() {
	
	
	if (cv != null) {
		var cvVar = "";
		var groupCookie = getHomeGroupCookie() + "";
		var attrCookie = getHomeAttrCookie() + "";
		
		if(groupCookie == attrCookie){
		attrCookie = attrCookie.replace(groupCookie, ""); // Replacing the constituencies from Group Cookie
		}
		else
		{		
		attrCookie = attrCookie.replace(groupCookie + ",", ""); // Replacing the constituencies from Group Cookie
		}
		attrCookie = attrCookie.replace (/,/g,":");
		cvVar = groupCookie + "|" + attrCookie ;
		
				 
		_hbSet('cv.c7', cvVar);
		_hbSend();			
	}
}

function setRememberMeCookie(){
	var expiryDate=new Date();
	expiryDate.setDate(expiryDate.getDate()+365);
	var rememberElem = document.getElementById('RememberMe');
	var rememberDisplay = document.getElementById('remember').style.display;
	if (rememberElem!=null && rememberDisplay!= 'none') {
		if (document.getElementById('RememberMe').checked) {
			var cookieValue = document.getElementById('USERNAME').value;
			document.cookie="BKCD_USR_LST="+cookieValue+";path=/;expires="+expiryDate+";";
			document.cookie="REMEMBER_ME_ENABLED=true;path=/;expires="+expiryDate+";";
		}else {
			document.cookie="BKCD_USR_LST=;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT;";
			document.cookie="REMEMBER_ME_ENABLED=false;path=/;expires=Fri, 02-Jan-1970 00:00:00 GMT;";
		}
	}
}
