
var focusCounter = 0;
function focusWatch() {
	var currentFocus = document.hasFocus()
	if (currentFocus == false) {
		self.focus();
	} 
	focusCounter ++;
 	if (focusCounter >= 100) {
 		clearInterval(intervalID);
	} 
}
		

function logEvent(ApplicationEvent_ID,ApplicationEventObject_ID){

	urlString = 'ApplicationEvent_ID='+ApplicationEvent_ID+'&ApplicationEventObject_ID='+ApplicationEventObject_ID;
	
	//alert(urlString);
	
	loadurl('LogApplicationEvent.cfm?'+urlString, null, 'replace', null);

	}

	function doZip(zipIn,cityFormElement,stateFormElement,httpPath,oneTime,sipx){
	
	//var whatever = loadurl(httpPath+'zipLookup.cfm?sipx='+sipx+'&oneTime='+oneTime+'&cityFormElement='+cityFormElement+'&stateFormElement='+stateFormElement+'&zipIn='+zipIn,null,'replace',null);
	
	var whatever = loadurl('./zipLookup.cfm?sipx='+sipx+'&oneTime='+oneTime+'&cityFormElement='+cityFormElement+'&stateFormElement='+stateFormElement+'&zipIn='+zipIn,null,'replace',null);
	//alert(whatever);
	eval(whatever);
	
	
	}


var subPops = new Array();

function psnClick(thisArray){
	
	validate_form(thisArray);
	//alert('submit is next');
	document.CFForm_1.submit();
	return true;
}

function Luminize(){
	window.open('','newPS','width=800,height=400,scrollbars=1,menubar=0,toolbar=0,location=0,status=0');
	//return true;
}
	function extra()
{
    //self.name = 'mainWin';  
	self.name = 'PSiframe';
	//alert('Hello. My name is : '+self.name);
	return true;
}

function removeQIDfromValidation(rQID) {
//removes qid entirely from array

	jsvalidatearray.splice(rQID,1);
	//var o1 = 'jsvalidatearray["'+rQID+'"]["qid"]';
	//alert("qid " + rQID+' removed from validation array');
	//alert("check for this item is "+eval(o1)); //if this throws an error, your qid has been removed

}

function addQIDtoValidation(aReq,aQid,aQuestion,aType) {
//adds a qid to the array
//alert("we had an append request for qid " +aQid+ " (" +aQuestion+","+aType+","+aReq+")");

var nQ = "q"+aQid;
var a1 = nQ+" = new Array();";
//alert(a1);
eval(a1);
var a1 = nQ+'["req"] = aReq;';
//alert(a1);
eval(a1);
var a1 = nQ+'["qid"] = aQid;';
//alert(a1);
eval(a1);
var a1 = nQ+'["question"] = aQuestion;';
//alert(a1);
eval(a1);
var a1 = nQ+'["type"] = aType;';
//alert(a1);
eval(a1);

var a1 = 'jsvalidatearray["'+nQ+'"]='+nQ;
//alert(a1);
eval(a1);

var o1 = 'jsvalidatearray["'+nQ+'"]["req"]';
var o2 = 'jsvalidatearray["'+nQ+'"]["qid"]';
var o3 = 'jsvalidatearray["'+nQ+'"]["question"]';
var o4 = 'jsvalidatearray["'+nQ+'"]["type"]';
  
//	alert(' ADDED jsvalidatearray[' + nQ + '] is '+eval(o1)+','+eval(o2)+','+eval(o3)+','+eval(o4));

}



function changeReq(aReq,aQid) {
//alert("we had a req change request for qid " +aQid);

var dQID = 'jsvalidatearray["'+aQid+'"]["req"]='+aReq;
var oQID =  'jsvalidatearray["'+aQid+'"]["req"]';
//alert("executing:  "+dQID);
//alert("oQID is " +oQID);

eval(dQID);

	//alert("jsvalidatearray["+aQid+"][req] is now " + eval(oQID));

}		

		
function rebuildSelect(whichQ) {

var z;
var parentQ = "q" + whichQ;
var currentIndex = document.CFForm_1[parentQ].options.selectedIndex;
var currentValue = document.CFForm_1[parentQ].options[currentIndex].value;

for (z = 0; z < eval("pq" + whichQ + ".length"); z++) {
		var thisCQ = eval("pq" + whichQ + "[" + z + "]");
		var thisQname = "q" + thisCQ;
		var x;
		document.CFForm_1[thisQname].options.length = 1; 
		var thisCQarray = "qa" + thisCQ;
		var y;
		for (y = 0; y < eval(thisCQarray + ".length"); y ++) {
		
			if (eval(thisCQarray + "[" + y + "][2]") == "" || eval(thisCQarray + "[" + y + "][2]") == currentValue) {
			
			//alert('yes');
			var nu = document.CFForm_1[thisQname].length++
			document.CFForm_1[thisQname].options[nu].value = eval(thisCQarray + "[" + y + "][0]")
			document.CFForm_1[thisQname].options[nu].text = eval(thisCQarray + "[" + y + "][1]")
					
			}
		
		}


		if (document.CFForm_1[thisQname].length == 1) {
		
		//no answers, especially bad for a required q
		var nu = document.CFForm_1[thisQname].length++
		document.CFForm_1[thisQname].options[nu].value = -1
		document.CFForm_1[thisQname].options[nu].text = "Other/Not Listed"
		
		}


	}	
	
}



function seriesOn(series, seriesName, sipx) {
document.getElementById(seriesName).style.display='';
	//alert('series name is: '+seriesName);
	//alert('series is: '+series);
 for (i = 0;i < series.length;i++) {
	//alert('eval(series['+i+']_req = 1)');
	//eval(series[i] + '_req = 1');//old stuff
	//var onQ = series[i];
	//alert('onQ is: '+onQ); 
	//alert('changeReq(1,'+series[i]+')');
	changeReq(1,series[i]); //this is the new stuff
	
	}
	
	var seriesID = seriesName.replace("series_", "");
	//alert('logging event 1 series on for '+seriesID);
	//logEvent(1,seriesID); //log series on event
}

function seriesOff(series,seriesName, sipx) {

document.getElementById(seriesName).style.display='none';
 for (i = 0;i < series.length;i++) {
	
	//eval(series[i] + '_req = 0');
	//var offQ = series[i];
	//alert('offQ is: '+offQ); 
	//alert('changeReq(0,'+series[i]+')');
	changeReq(0,series[i]); //this is the new stuff
	
	

	}
	
	var seriesID = seriesName.replace("series_", "");
	//alert('logging event 2 series off for '+seriesID);
	//logEvent(2,seriesID); //log series off event
} 


function togSeries(series, seriesName) {

if (document.getElementById(seriesName).style.display=='')
	{
	seriesOff(series, seriesName)
	return true
	}
else 
	{
	seriesOn(series, seriesName)
	return true
	}	 

}




function togSeriesSelect(series, seriesName, seriesOnAid, triggerQID, defaultVisibility) {


var thisVisible = document.getElementById(seriesName).style.display;
var thisSelectedIndex = document.CFForm_1[triggerQID].selectedIndex;
	
	if (defaultVisibility == 0 && thisVisible == 'none') {
		//in its initial state, so flip it when the aid is selected
		if (document.CFForm_1[triggerQID].options[thisSelectedIndex].value == seriesOnAid) {
			seriesOn(series, seriesName)
			return true	
		}
	}
	
	else if (defaultVisibility == 0 && thisVisible == '') {
		//already flipped, so flip it when the aid is deselected
		if (document.CFForm_1[triggerQID].options[thisSelectedIndex].value != seriesOnAid) {
			seriesOff(series, seriesName)
			return true
		}
	
	}
	
	
	else if (defaultVisibility == 1 && thisVisible == '') {
		//in its initial state, so flip it when the aid is selected
		if (document.CFForm_1[triggerQID].options[thisSelectedIndex].value == seriesOnAid) {
			seriesOff(series, seriesName)
			return true
		}
	
	}
	
	else if (defaultVisibility == 1 && thisVisible == 'none') {
		//already flipped, so flip it on when the aid is deselected
		if (document.CFForm_1[triggerQID].options[thisSelectedIndex].value != seriesOnAid) {
			seriesOn(series, seriesName)
			return true
		}
	
	}


}



function exclusiveAid(qid, aid, currentAid) {

	exclusiveAidChecked = 0;
	exclusiveAidPos = -1;
	otherChecked = 0;
	
	if (aid != currentAid) {
	
	otherChecked = 1;
	//alert(otherChecked);
	
	}
		
	  for (i=0; i < document.CFForm_1[qid].length; i++)
	    	{
		if (document.CFForm_1[qid][i].checked && document.CFForm_1[qid][i].value == aid)
			{
			exclusiveAidChecked = 1;
			exclusiveAidPos = i;
			}
		}
		
		if (exclusiveAidChecked == 1 && otherChecked ==0) {
		
			for (i=0; i < document.CFForm_1[qid].length; i++)
	    	{
				if (i != exclusiveAidPos)
				{
				document.CFForm_1[qid][i].checked = false
				}
			}
		
		}			
		else if (exclusiveAidChecked == 1) {
		
		document.CFForm_1[qid][exclusiveAidPos].checked = false
		
		}
		
				

}	



function validate_form(validationArray){

var regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/
var regexAC = /[0-9]{3}/
var regexNum = /[0-9]{4}/
//var regexZip = /[0-9]{5}/
exit=false;

//validation, looping through the array of stuff to be validated
 //array positions are as follows:
	
//jsvalidatearray[q432][req] is: 1
//jsvalidatearray[q432][qid] is: 432
//jsvalidatearray[q432][question] is: My Birthdate:
//jsvalidatearray[q432][type] is: date



	  for ( a in validationArray)
      {
	  //all your validation stuff goes here
         //document.write("this item is validationArray[" + a + "]<br>");
		 //alert('now validating item: ' +a);
		  var thisReq = validationArray[a]["req"];
		  var thisQID = validationArray[a]["qid"];
		  var thisQuestion = validationArray[a]["question"];
		  var thisType = validationArray[a]["type"];
		  var thisFocus = "q"+validationArray[a]["focus"];
		  var thisQ = "q"+thisQID;
		// alert("a is: "+a+" and i need to validate qid "+thisQID+" ("+thisQuestion+") as req "+thisReq+" type "+thisType+"<br>");
		 
		 
//determine the type
 switch (thisType) {
  		 case "text":
		 case "textarea":
		 	//alert('QID ' + thisQID + ' is a text.');
			//alert('function validate_text called for '+thisQ);
			var thisF = 'document.CFForm_1.'+thisQ+'.value';
			var thisO = 'document.getElementById(\''+thisFocus+'\').focus()';
			
			if (thisReq == 1){
				if (eval(thisF) == ''){
					
					alert(thisQuestion+' is required and you answered = '+eval(thisF));
					eval(thisO);
					return false;
					} 
			}
			break;

					 
		 case "email":
		 	//alert('QID ' + thisQID + ' is an email.');
		//alert('function validate_email called for '+thisQ);
		var thisF = 'document.CFForm_1.'+thisQ+'.value';
		var thisO = 'document.getElementById(\''+thisFocus+'\').focus()';

		//required
			if (thisReq == 1 && (eval(thisF) == '' || regex.test(eval(thisF)) == false)) {
		   		alert('Please provide an answer for '+thisQuestion+' and be sure that the address provided is correct.');
				eval(thisO);
				return false;		   
		   		}
	
		//not required but filled in		   
		   else if (thisReq == 0 && (eval(thisF) != '' && regex.test(eval(thisF)) == false)) {
		   //else if (thisReq == 0 && (len(eval(thisF)) != 0 && regex.test(eval(thisF)) == false)) {
		   		alert('Although an answer is not required for question '+thisQuestion+', if you do provide one, be sure that is a valid e-mail address.');
				eval(thisO);
				return false;
		   }
			break;
			
		 case "select":
		 	//alert('QID ' + thisQID + ' is a select.');
			//alert('function validate_select called for '+thisQ);
			var thisF = 'document.CFForm_1.'+thisQ+'.selectedIndex';
			var thisO = 'document.getElementById(\''+thisFocus+'\').focus()';
			
				if (thisReq == 1){
					if (eval(thisF)==0) {//didna select anything
						alert('Please provide an answer for '+thisQuestion);
						eval(thisO);
						return false;
						}
					}
			break;

			
		 case "phone":
		 	//alert('QID ' + thisQID + ' is a phone.');
			//alert('function validate_phone called for '+thisQ);
			var thisF1 = 'document.CFForm_1.'+thisQ+'_area.value';
			var thisF2 = 'document.CFForm_1.'+thisQ+'_exch.value';
			var thisF3 = 'document.CFForm_1.'+thisQ+'_num.value';
			var thisO1 = 'document.CFForm_1.'+thisQ+'_area.focus()';
			var thisO2 = 'document.CFForm_1.'+thisQ+'_exch.focus()';
			var thisO3 = 'document.CFForm_1.'+thisQ+'_num.focus()';
			var ac = eval(thisF1);
			var pre = eval(thisF2);
			var num = eval(thisF3);
			
			
			if (thisReq == 1) {
			
			if (ac == '' || regexAC.test(ac) == false) {
				alert('Please provide an answer for '+thisQuestion+'. Be sure the phone number is formatted as NNN-NNN-NNNN.');
				eval(thisO1);
				return false;
			   }
			   
			 if (pre == '' || regexAC.test(pre) == false) {
				alert('Please provide an answer for '+thisQuestion+'. Be sure the phone number is formatted as NNN-NNN-NNNN.');
				eval(thisO2);
				return false;
			   }  
			   
			if (num == '' || regexNum.test(num) == false) {
				alert('Please provide an answer for '+thisQuestion+'. Be sure the phone number is formatted as NNN-NNN-NNNN.');
				eval(thisO3);
				return false;
			   }   
			
			
			}
			
		if (thisReq == 0) {
			
			if (ac.length != 0 && regexAC.test(ac) == false) {
				alert('ac.length= '+ac.length);
				alert('Though an answer for '+thisQuestion+' is not required, if you choose to provide one, please be sure the phone number is formatted as NNN-NNN-NNNN.');
				eval(thisO1);
				return false;
			   }
			   
			 if (pre.length != 0 && regexAC.test(pre) == false) {
				alert('Though an answer for '+thisQuestion+' is not required, if you choose to provide one, please be sure the phone number is formatted as NNN-NNN-NNNN.');
				eval(thisO2);
				return false;
			   }  
			   
			if (num.length != 0 && regexNum.test(num) == false) {
				alert('Though an answer for '+thisQuestion+' is not required, if you choose to provide one, please be sure the phone number is formatted as NNN-NNN-NNNN.');
				eval(thisO3);
				return false;
			   }   
			
			
			}
			 
			break;
		
			
		 case "checkbox":
		 case "radio":
		 //	alert('QID ' + thisQID + ' is a checkbox.');
		//	alert('function validate_checkbox called for '+thisQ);
			
			if (thisQID == 3871){
			var thisValidQLang = thisQuestion;
			} else {
			var thisValidQLang = "Please provide an answer for "+thisQuestion+".";
			}
			
			var thisFieldOk = 0;
			var thisF = 'document.CFForm_1.'+thisQ+'.checked';
			var thisO = 'document.getElementById(\''+thisFocus+'\').focus()';
			var thisL = 'document.CFForm_1.'+thisQ+'.length';
			thisL = eval(thisL);
			
			//alert('QID '+thisQID+' is len'+eval(thisL));
			
			if (!thisL){
			
				if (eval(thisF)){
				//alert('QID '+thisQID+' is checked.');
		   			thisFieldOk = 1;}
			
				if (thisReq == 1 && thisFieldOk == 0) {
		   
		   			LogUrl = 'http://www.surveynetworks.com/logApplicationEvent.cfm?sipx='+document.CFForm_1.sipx.value+'&applicationEvent_ID=15&q='+thisQID;
				loadurl(LogUrl,null,'APPEND',null); //log the event
				//alert('event logged! logUrl is: '+LogUrl);
					
		   			alert(thisValidQLang);
					eval(thisO);
					return false;
		   
		  			 }
			
			}else{
			
			//start workin here
			for (i=0; i < thisL; i++)  	{
			var thisF = 'document.CFForm_1.'+thisQ+'[i].checked';
			//document.getElementById('myAnchor')
			//var thisO = 'document.CFForm_1.'+thisFocus+'.focus()';
			var thisO = 'document.getElementById(\''+thisFocus+'\').focus()';
			
			if (eval(thisF))
				thisFieldOk = 1;
				}
	
	       if (thisReq == 1 && thisFieldOk == 0) {
		   
		   		LogUrl = 'http://www.surveynetworks.com/logApplicationEvent.cfm?sipx='+document.CFForm_1.sipx.value+'&applicationEvent_ID=15&q='+thisQID;
				loadurl(LogUrl,null,'APPEND',null); //log the event
				//alert('event logged! logUrl is: '+LogUrl);
					
		   		alert(thisValidQLang);
				//document.getElementById('q4100').focus();
				eval(thisO);
				return false;
		  		 }			
			}

			break;
			
		 case "date":
		 	//alert('QID ' + thisQID + ' is a date.');
			//alert('function validate_date called for '+thisQ);
			//alert('document.CFForm_1.'+thisQ+'_month.selectedIndex=');
			
			var gotDate = 3;
			var goodDate = 0;
			
			var monthObject = 'document.CFForm_1.'+thisQ+'_month';
			var dayObject = 'document.CFForm_1.'+thisQ+'_day';
			var yearObject = 'document.CFForm_1.'+thisQ+'_year';
			
			var thisF1 = monthObject+'.selectedIndex';
			//alert(thisF1);
			var thisF2 = dayObject+'.selectedIndex';
			var thisF3 = yearObject+'.selectedIndex';
			var thisO1 = monthObject+'.focus()';
			var thisO2 = dayObject+'.focus()';
			var thisO3 = yearObject+'.focus()';
			var mm = eval(thisF1);
			var dd = eval(thisF2);
			var yy = eval(thisF3);
			//alert(yy);
			var fy = yearObject+'.options['+yy+'].text';
			var yyyy = eval(fy);
			
			if (thisReq == 1){
			
			//alert(mm+' is month '+dd+' is day '+yy+' is year REQ=1 '+thisQ);
			
				if (mm==0){
				gotDate = gotDate-1;
				alert('Please provide select a month for '+thisQuestion+'.');
				eval(thisO1);
				return false;
				}
				
				if (dd==0){
				gotDate = gotDate-1;
				alert('Please provide select a day for '+thisQuestion+'.');
				eval(thisO2);
				return false;
				}
				
				if (yy==0){
				gotDate = gotDate-1;
				alert('Please provide select a year for '+thisQuestion+'.');
				eval(thisO3);
				return false;
				}
			
					
			}
			
			//alert(gotDate);
			
			
			if (thisReq == 0){
			
			//alert(mm+' is month '+dd+' is day '+yy+' is year REQ=0 '+thisQ);
			
				if (mm!=0 || dd!=0 || yy!=0){ //we have at least part of a date
				
				if (mm==0){
				gotDate = gotDate-1;
				alert(thisQuestion+' is not required, but if you choose to complete it, please enter a valid date.');
				eval(thisO1);
				return false;
				}
				
				if (dd==0){
				gotDate = gotDate-1;
				alert(thisQuestion+' is not required, but if you choose to complete it, please enter a valid date.');
				eval(thisO2);
				return false;
				}
				
				if (yy==0){
				gotDate = gotDate-1;
				alert(thisQuestion+' is not required, but if you choose to complete it, please enter a valid date.');
				eval(thisO3);
				return false;
				}
				
				} else {
				gotDate=0;
				
					}
						}
			
			
			if (gotDate==3){
				//isValidDate(dd,mm,yyyy);
				//validateDate(monthObject,vDate);//mm/dd/yyyy
				var dateStr = mm+'/'+dd+'/'+yyyy;
				var goodDate = 0;
    			var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    			var errorMessage = 'Please enter valid date. '+dateStr+' does not appear to be valid.';
    				if ((dateStr.match(RegExPattern)) && (dateStr!='')) {
        				//alert('Date is OK'); 
						goodDate = 1;
					} else {
      
						alert(errorMessage);
						eval(thisO1);
						return false;
					}
			}
			
			break;
			
		
		 case "":
		 default:
		// alert('No idea what type QID' + thisQID + 'is, sorry.');
		 
		 }


		 
		 }
		 
		
		 
		 return moreCheck()
	

}

function instaPop(whichPop,i){
	/* 
	 whichPop[0] = previously popped
	 whichPop[1] = url
	 whichPop[2] = id
	 whichPop[3] = window params
	 whichPop[4] = over/under
	 whichPop[5] = main window name
	 */

	if (whichPop[0] == 0) {
		whichPop[0] = 1;
		windowName = 'pop' + whichPop[2];
		var newWindow = window.open(whichPop[1], windowName, whichPop[3]);
		if (whichPop[4] == 0) {
			//alert('p='+p+' shifting focus back to main page');
			for (x = 0; x < i; x ++) { 
			//push this back once for each pop window on screen
				if (newWindow) { 
					newWindow.blur();
				}
			}
			
			
		}
		
	}
}		 
			 
			 
function onSubPops() {	

var weGotPopUps = 0;

for (i = 0; i < subPops.length; i ++) { 

	instaPop(subPops[i],i);
	//if we have a 1 value for element [4] on any array member then weGotPopUps = 1
	if (subPops[i][4] == 1) {
		weGotPopUps = 1;
		}
	}

	if (weGotPopUps == 0 && subPops.length > 0){
		self.focus();
		//alert('we got pops!');
		//add form element to page to tell next page to self.focus
		
		var fThing = document.createElement('input'); 
		fThing.setAttribute('type', 'hidden'); 
		fThing.setAttribute('name', 'focusMain'); 
		fThing.setAttribute('value', '1'); 
		document.forms['CFForm_1'].appendChild(fThing);
		
	}
	
}		 
	 


function addOnSubPop(whichPop){

	subPops[subPops.length] = whichPop;

}




var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;


dun = 0;


function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}


          function loadPopWindows(windowUrl, place,frame, width, height, yLocation)
 {
 if (!ie5&&!ns6) {
 	if (windowUrl != "")
          		{window.open(windowUrl,"","width=width,height=height,scrollbars=1")}
	}
	
          else {
 

	 if (windowUrl != "") {
	 	//alert('thisun')


		
		winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
		winH = (ns4)? window.innerHeight : document.body.offsetHeight

		//alert(winW);
		
		initialwidth = width + "px";
		initialheight = height + "px";
		//winLeft = ns6? window.innerWidth-20+"px" : iecompattest().clientWidth-20+"px";
		//winTop = ns6? window.pageYOffset*1+90+"px" : iecompattest().scrollTop*1+90+"px"
           	winLeft = winW-20+"px";					
		eval("document.getElementById('" + place + "').style.display=''")
           	eval("document.getElementById('" + place + "').style.width='" + initialwidth + "'")
           	eval("document.getElementById('" + place + "').style.height='" + initialheight + "'")
           	eval("document.getElementById('" + place + "').style.left='" + winLeft + "'")
           	eval("document.getElementById('" + place + "').style.top='" + yLocation + "'")
           	eval("document.getElementById('" + frame + "').src='" + windowUrl + "'")
		place1 = place
		//alert(place1)
		slidePop(place1,500,100,10,winW)
		
		
           	}
	             
          	return false;
	}
          
}

function slidePop(moveThis,moveXTo,moveInc,moveSpeed,winW){
	//moveThis1 = moveThis;
	//moveXTo1 = moveXTo;
	//moveInc1 = moveInc;
	//moveSpeed1 = moveSpeed;
	
	if (!document.all&&document.getElementById){
		document.all = document.getElementsByTagName("*")
		}
	
	if (winW > 700) {
				
	stopWhen = winW - 700
	
	}
	
	else {
	
	stopWhen = 0
	
	}
	

	
	if (ns4){
		moveObj = document.layers[moveThis];
		pxlUnit=""; alert('ns4')}
	
	if (ie4){
		//moveObj = eval("document.all."+moveThis1+".style");alert('stillok');
		moveObj = eval("document.getElementById('" + moveThis + "').style");
		pxlUnit="px";}
		
	    moveObj.left = (parseInt(moveObj.left)+((stopWhen - parseInt(moveObj.left)) / moveInc))+pxlUnit;
		//moveObj.top = (parseInt(moveObj.top)+((moveYTo1 - parseInt(moveObj.top)) / moveInc1))+pxlUnit;
		//moveInc1 -= 1;
		currentPosition = parseInt(moveObj.left);
		alstring = moveThis + ' ' + currentPosition + ' ' + moveXTo + ' ' ;
		
		if (currentPosition > stopWhen) {
			//setTimeout("slide(moveThis,moveXTo,moveInc,moveSpeed);",moveSpeed);
			setTimeout("slidePop('" + moveThis + "','" + moveXTo + "','" + moveInc + "','" + moveSpeed + "','" + winW  + "');",10);
			//setTimeout("changeContent('" + newurl + "')",2000);
			
			//alert(alstring);
		}
		
}
		
		
function closeit(place){
eval("document.getElementById('" + place + "').style.display='none'")
//reSubmit();
}			



function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
			} 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function setLayerIndex(id,x){
	document.getElementById(id).style.zIndex=x;
}


function phoneHome(elem) {

thispat = /[2-9][0-9]{2}/

iLen = String(elem).length;
thisPart = String(elem).substring(iLen, iLen - 3);
	
if (thisPart == 'rea') {
				
	nextPart = elem.replace('area', 'exch');
				
	}
				
else if (thisPart == 'xch') {
				
	nextPart = elem.replace('exch','num');
				
	}	

var thisF = 'document.CFForm_1.'+elem+'.value';

if (thispat.test(eval(thisF)) == true) {
		
	document.CFForm_1[nextPart].focus();	
	
		
	} 	

}

//MADS Custom functions for switching charity images
function imgSelect(imgID, imgSrc)
{
	if(imgSrc != ''){
		document[imgID].src = '/snet2/grph/mads/charity/'+imgSrc+'.jpg';
		document.getElementById('charityPopImg').onclick = function(){openBrWindow(imgSrc,'charityPop','width=450,height=425');};
	}
}

function openBrWindow(imgSrc,winName,features) { 
  theURL = '/snet2/grph/mads/'+imgSrc+'.jpg';
  window.open(theURL,winName,features);
}
//End MADS custom functions

//Begin custom tt 25633 Auto Customer Sat project
function togSeriesSelectCustom(seriesName, seriesOnAidArray1, seriesOnAid2, triggerQID1, triggerQID2) {
	
	
	var thisSelectedIndex = 0;
	var thisSelectedIndex2 = 0;
	
	//First check to see if element exists
	if(document.getElementById(seriesName)){
		
		var series = document.getElementById(seriesName);
		var found = 0;
		thisSelectedIndex = document.CFForm_1[triggerQID1].selectedIndex;
		thisSelectedIndex2 = document.CFForm_1[triggerQID2].selectedIndex;			
	
		//Loop over series array 
		for(var i = 0; i < seriesOnAidArray1.length; i++){		
			var seriesOnAid1 = seriesOnAidArray1[i];		
			//if a match flip on series year in 2007,2008,2009 and purchase is new
			if (document.CFForm_1[triggerQID1].options[thisSelectedIndex].value == seriesOnAid1 && document.CFForm_1[triggerQID2].options[thisSelectedIndex2].value == seriesOnAid2) {
				seriesOn(series, seriesName);
				found = 1;
				return true;
				break;
			} 
		}	
		//if no matches found shut the series off
		if(found == 0){
			seriesOff(series, seriesName);
			return true;	
		}
	}
}
// End custom tt 25633 Auto Customer Sat project