//common.js -- web - JS functions called by WQO to generate survey HTML and collect response datafunction questionInit(){	alert("NO QUESTIONS FOUND!\n\nfunction questionInit(){questionAdd(questionID, question, questionextra, multiflag, choice1, choice2, ... choiceN); etc.");};function styleDisplayPointer(){	var strPointer="pointer";	strPointerDefault="auto";	if(document.all)	{/*			DISABLED -- since this makes it so the mouse is a POINTING FINGER ALWAYS				(might have been necessary in IE version <6 perhaps?				Cuz in 6 and 7, it is annoying; FF is fine of course.)		try{document.body.style.cursor=strPointer}		catch(e){strPointer="hand"};*/	};	var arClassesWithCursor=["unselected","selected","disabled","hovered","hoveredselected"];	var strHTML="";	for(var intIndex=0;intIndex<arClassesWithCursor.length;intIndex++)	{		strHTML+="."+arClassesWithCursor[intIndex]+" {cursor:"+strPointer+"}\n";	};	document.write("\n<"+"style>"+strHTML+"</"+"style>\n");};function hover(objCell){	if( !(!objCell) && typeof objCell=="object")	{		if(objCell.className!="disabled")		{			objCell.className=(objCell.className=="selected"?"hoveredselected":"hovered");		};	};};function unhover(objCell){	if( !(!objCell) && typeof objCell=="object")	{		if(objCell.className!="disabled")		{			objCell.className=(objCell.className=="hoveredselected"?"selected":"unselected");		};	};};function choice(objCell){	if( !(!objCell) && typeof objCell=="object")	{		if(objCell.className!="disabled")		{			var strChoiceClassOld=objCell.className;			var strID=objCell.id;			var arID=strID.split("_");			var intQuestion=1*arID[0];			var intChoice=1*arID[1];			var bMultiQuestion=arQuestions[intQuestion-1].multi;			var bNewChoice=true;			if(bMultiQuestion)			{				toggleMultiQuestion(intQuestion,intChoice,strChoiceClassOld);				getChoice(intQuestion,bMultiQuestion);			}			else if(strChoiceClassOld!="selected" && strChoiceClassOld!="hoveredselected")			{				var strClassOld="";				var strClassNew="";				var intIndex=0;				objCell=document.getElementById(intQuestion+"_"+(++intIndex));				while(objCell)				{					strClassOld=objCell.className;					strClassNew=(intChoice==intIndex)?"hoveredselected":"unselected";					objCell.className=strClassNew;					objCell=document.getElementById(intQuestion+"_"+(++intIndex));				};				arChoices[intQuestion]=intChoice;			}			else			{				bNewChoice=false;			};			//do special action only if there is one, and if the just-clicked choice wasn't already selected (unless multi-select which is "always" a new choice)			var strSpecial=(arSpecial[strID]?arSpecial[strID]:"");			if( bNewChoice && strSpecial)			{				eval(strSpecial);			};		};//end if(objCell.className!="disabled")	};//end if( !(!objCell) && typeof objCell=="object")};//end function choice(objCell)function toggleMultiQuestion(intQuestion,intChoice,strChoiceClassOld){	if(arguments.length>=3)	{		var objCell=document.getElementById(intQuestion+"_"+intChoice);		var bChoiceAlreadySelected=(strChoiceClassOld=="selected" || strChoiceClassOld=="hoveredselected");		if(bChoiceAlreadySelected)		{			objCell.className=(strChoiceClassOld=="hoveredselected")?"hovered":"unselected";		}		else		{			objCell.className=(strChoiceClassOld=="hovered")?"hoveredselected":"selected";		};	};};function enableQuestion(intQuestion){	if((""+intQuestion).toUpperCase().indexOf(" SUPP")!=-1)	return enableSupplemental(intQuestion,false,false);	//'Added 30Aug2006	if(typeof intQuestion=="string")	{		intQuestion=arQIDs[intQuestion];		if(typeof intQuestion=="number"){intQuestion++};	};	if(typeof intQuestion=="number")	{		setChoicesClasses(intQuestion,"unselected");		setChoice(intQuestion);		if(!arSupplementalDisabled[intQuestion])enableSupplemental(intQuestion,true,true);	//'Added 30Aug2006	};};function disableQuestion(intQuestion){	if((""+intQuestion).toUpperCase().indexOf(" SUPP")!=-1)	return disableSupplemental(intQuestion,false);	//'Added 30Aug2006	if(typeof intQuestion=="string")	{		intQuestion=arQIDs[intQuestion];		if(typeof intQuestion=="number"){intQuestion++};	};	if(typeof intQuestion=="number")	{		arChoices[intQuestion]=getChoice(intQuestion);		setChoicesClasses(intQuestion,"disabled");		disableSupplemental(intQuestion,true);	//'Added 30Aug2006	};};// 'Added 30Aug2006...function getSupplemental(intQuestion){	if(intQuestion!=1*intQuestion)	{		intQuestion=intQuestion.toLowerCase().substring(0,intQuestion.indexOf(" supp"));		if(intQuestion=="")return null;	};	if(intQuestion!=1*intQuestion)	{		intQuestion=arQIDs[intQuestion];		if(typeof intQuestion=="number"){intQuestion++};	};	return (typeof intQuestion=="number")?intQuestion:null;};function enableSupplemental(intQuestion,bSkipFocus,bForDisplayOnly){	intQuestion=getSupplemental(intQuestion);	if(!intQuestion)return false;	var objCell=document.getElementById(intQuestion+"_b0");	if(objCell)objCell.className="supplabel";	objCell=document.getElementById(intQuestion+"_b1");	if(objCell)objCell.className="suppfield";	objCell=document.forms[0]["txtSupp"+intQuestion];	if(objCell)	{		objCell.className="supptxt";		if(objCell.removeAttribute && objCell.setAttribute)		{			objCell.removeAttribute("disabled");		}		else		{			objCell.disabled=false;		};		if(objCell.focus && !bSkipFocus)setTimeout('document.forms[0]["txtSupp'+intQuestion+'"].focus()',50);	};	if(!bForDisplayOnly)arSupplementalDisabled[intQuestion]=false;};function disableSupplemental(intQuestion,bForDisplayOnly){	intQuestion=getSupplemental(intQuestion);	if(!intQuestion)return false;	var objCell=document.getElementById(intQuestion+"_b0");	if(objCell)objCell.className="suppdisabled";	objCell=document.getElementById(intQuestion+"_b1");	if(objCell)objCell.className="suppdisabled";	objCell=document.forms[0]["txtSupp"+intQuestion];	if(objCell)	{		objCell.className="suppdisabledtxt";		if(objCell.removeAttribute && objCell.setAttribute)		{			objCell.setAttribute("disabled",true);		}		else		{			objCell.disabled=true;		};	};	if(!bForDisplayOnly)arSupplementalDisabled[intQuestion]=true;};//Added 27Jun2007 to allow for "optional" supplemental fields...function isSupplementalOptional(intQuestion){	//check the template for that question's "supplemental" radio option "required if enabled?"	return !(self.strSuppReqList && strSuppReqList.indexOf(";" + intQuestion + ";")!=-1);};function isSupplementalRequired(intQuestion,bClearIfNot){	var rv=false;	var objCell=document.getElementById(intQuestion+"_b0");	if(objCell)rv=(objCell.className=="supplabel");	if(!rv)	{		objCell=document.getElementById(intQuestion+"_b1");		if(objCell)rv=(objCell.className=="suppfield");	};	objCell=document.forms[0]["txtSupp"+intQuestion];	if(!rv)	{		if(objCell)rv=(objCell.className=="supptxt");	};	if(!rv && bClearIfNot)	{		if(objCell)objCell.value="";		objCell=document.forms[0]["Q"+intQuestion+"b_ResponseText"];		if(objCell)objCell.value="";	};	//Added 27Jun2007 to allow for "optional" supplemental fields...	if(rv)rv=!isSupplementalOptional(intQuestion);	return rv;};function isSupplementalMissing(intQuestion){	var strSuppValue="";	var rv=isSupplementalRequired(intQuestion);	objCell=document.forms[0]["txtSupp"+intQuestion];	if(objCell)strSuppValue=objCell.value;	return rv && !strSuppValue;};function clearUnwantedSupplementals(){	for(var intQuestion=1;intQuestion<=arQuestions.length;intQuestion++)	{		isSupplementalRequired(intQuestion,true);	};};// /'Added 30Aug2006.function getChoice(intQuestion){	var bMultiQuestion=arQuestions[intQuestion-1].multi;	var intIndex=1;	var objCell=document.getElementById(intQuestion+"_"+intIndex);	arChoices[intQuestion]="";	while(objCell)	{		if(objCell.className=="selected" || objCell.className=="hoveredselected")		{			arChoices[intQuestion]+=";"+intIndex;			if(!bMultiQuestion)			{				intIndex=intMaxChoices+1;			};		};		objCell=document.getElementById(intQuestion+"_"+(++intIndex));	};	if(arChoices[intQuestion]){arChoices[intQuestion]=arChoices[intQuestion].substring(1)};	return (arChoices[intQuestion]?arChoices[intQuestion]:"");};function setChoice(intQuestion){	var objCell="";	var strChoices=(arChoices[intQuestion]?arChoices[intQuestion]:"");	if(strChoices)	{		var arValues=(""+strChoices).split(";");		var intChoice="";		for(var intIndex=0;intIndex<arValues.length;intIndex++)		{			intChoice=arValues[intIndex];			if( !(!intChoice) && typeof (1*intChoice)=="number")			{				objCell=document.getElementById(intQuestion+"_"+intChoice);				objCell.className="selected";			};		};	};//end if(strChoices)};//end function setChoice(intQuestion)function setChoicesClasses(intQuestion,strClassNew){	var intIndex=0;	var objCell=document.getElementById(intQuestion+"_"+intIndex);	while(objCell)	{		objCell.className=(intIndex!=0)?strClassNew:(strClassNew=="disabled"?"disabledmain":"questionmain");		objCell=document.getElementById(intQuestion+"_"+(++intIndex));	};};function questionDisplayAll(){	if(!self.arQuestions)	{		init();	};	var strHTML='<table width="100%" border="0">';	if(arQuestions.length>0)	{		for(var intIndex=0;intIndex<arQuestions.length;intIndex++)		{			strHTML+=questionDisplay(intIndex);			strHTML+=questionSupplementalDisplay(intIndex);	//'Added 30Aug2006			arSupplementalDisabled[intIndex]=false;	//'Added 30Aug2006		};	}	else	{		if(self.strFailure)		{			strHTML+='<tr><td class="errormissing"><b>' + strFailure + '</b><br /><br /></td></tr>';		};		strHTML+='<tr><td class="errormissing"><br />NO QUESTIONS FOUND!<br />\n<br />\nfunction questionInit(){questionAdd(questionID, question, questionextra, multiflag, choice1, choice2, ... choiceN); etc.);<br /><br /></td></tr>';	};	strHTML+='</table>';	document.write(strHTML);};function init(){//disableEvents();	// *DS* not during testing!	intMaxChoices=0;	arSpecial=[];	arQuestions=[];	arQuestionsSupplemental=[];	//'Added 30Aug2006	arSupplementalDisabled=[];	//'Added 30Aug2006	arContactFields=[];	strFOIPStatement="";//strFOIPActLink='<a target="_blank" href="http://www3.gov.ab.ca/foip">FOIP Act (Alberta)</a>';	// 'Modified 15Jun2006: "http://www.foip.gov.ab.ca/legislation" instead of "http://www3.gov.ab.ca/foip/legislation"	strFOIPActLink='<a target="_blank" href="http://www.foip.gov.ab.ca/legislation">Alberta Freedom of Information and Protection of Privacy (FOIP) Act</a>';	// 'Modified 15Jun2006: "Rural Development Sector" instead of "Information Technology Services Division"...	// 'Modified 03Apr2007: "Organizational Effectiveness and Rural Services" instead of "Rural Development Sector", and phone # is now 422-6796 (instead of 427-2101)...	strFOIPQuestions='Questions about the collection of this information and how it is stored may be directed to:<br />\n' + 'Branch Head, Ropin\' the Web<br />\n' + 'Organizational Effectiveness and Rural Services<br />\n' + 'telephone: (780) 422-6796<br />\n' + 'e-mail: <a target="_blank" href="&#109;ailto&#58;duke&#64;gov.ab.ca">duke&#64;gov.ab.ca</a>';	strEmailExplanation="";	arQIDs=[];	questionInit();	arChoices=[];	document.forms[0].onreset=function(){return false};	document.forms[0].onsubmit=function(){return false};};function disableEvents(){	window.onselectstart=rf;	document.onselectstart=rf;	document.body.onselectstart=rf;};function rf(){	return false};function questionAdd(strQID,strQuestion,strQuestionExtra,bMulti){	var bSuccess=false;	if(arguments.length==0)	{		//this is a question that has the checkbox "Enabled" unchecked.		var objNew=new questionObject();		arQuestions[arQuestions.length]=objNew;		bSuccess=true;	}	else if(arguments.length>=6)	{		if(typeof strQID=="string" && typeof strQuestion=="string" && typeof strQuestionExtra=="string" && (typeof bMulti=="boolean"|| typeof bMulti=="number"))		{			var bSuccess=false;			var objNew=new questionObject(strQID,strQuestion,strQuestionExtra,bMulti);			if(objNew.choices)			{				var strChoice="";				for(var intIndex=4;intIndex<arguments.length;intIndex++)				{					strChoice=arguments[intIndex];					if(typeof strChoice=="string")					{						objNew.choices[objNew.choices.length]=fixHTML(strChoice);						//since multiple values are separated by ";" when stored in Lotus Notes, for 'raw' data replace ";" with "," (unlikely this would ever even be necessary!)						objNew.choicesRaw[objNew.choicesRaw.length]=strChoice.replace(/\;/g,",");					};				};				if(objNew.choices.length>=2)				{					bSuccess=true;					arQIDs[strQID]=arQuestions.length;					arQuestions[arQuestions.length]=objNew;					intMaxChoices=(objNew.choices.length>intMaxChoices?objNew.choices.length:intMaxChoices);				};			};			if(!bSuccess)			{				delete objNew;			};		};	};//end if(arguments.length>=6)};//end function questionAdd(strQID,strQuestion,strQuestionExtra,bMulti)function questionSupplementalAdd(){	//'Added 30Aug2006...	var strLabel="";	for(var intIndex=0;intIndex<arQuestions.length;intIndex++)	{		strLabel="";		if(intIndex<arguments.length)		{			strLabel=arguments[intIndex];			if(typeof strLabel!="string")strLabel="";		};		arQuestionsSupplemental[intIndex]=strLabel;	};};//end function questionSupplementalAdd()function questionObject(strQID,strQuestion,strQuestionExtra,bMulti){	if(arguments.length>=4)	{		this.qid=strQID;		this.question=fixHTML(strQuestion);		this.questionExtra=fixHTML(strQuestionExtra);		this.multi=((!bMulti)?false:true);		this.choices=[];		this.choicesRaw=[];		this.index=arQuestions.length;		return this;	};};function fixHTML(strOld){	return strOld.replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\'/g,"&#39;").replace(/\"/g,"&#34;");};function questionSpecialAdd(strQID){	if(arguments.length>=2)	{		var intIndex=arQIDs[strQID];		if(typeof intIndex=="number")		{			var q=arQuestions[intIndex];			if(typeof q=="object")			{				var intQuestion=(q.index)+1;				var intChoice=0;				for(var intIndex=1;intIndex<arguments.length && (intIndex-1)<q.choices.length;intIndex++)				{					intChoice=intIndex;					arSpecial[intQuestion+"_"+intChoice]=arguments[intIndex];				};			};		};	};};function questionDisplay(intQuestion){	var s="";	var q=arQuestions[intQuestion++];	if(q)	{		//if field "Enabled"=="1" for this question, then .qid property should be a string...		if(q.qid)		{			var intCellWidth=parseInt(100/intMaxChoices);			var intWidthRemaining=100;			//generate the HTML for the question main text			s+='<tr><td class="questions">\n';			s+='<table width="100%" border="1" cellpadding="3">\n';			s+='<tr><td class="questionmain" colspan="'+intMaxChoices+'" id="'+intQuestion+'_0">'+intQuestion+'. '+q.question;			s+=(q.questionExtra?'<br />\n<span class="questionextra">'+q.questionExtra+'</span>':'');			s+='\n</td></tr>';			s+='<tr>\n';			//generate the HTML for the question choices			for(intIndex=0;intIndex<q.choices.length;intIndex++)			{				intCellWidth=(intWidthRemaining<intCellWidth)?intWidthRemaining:intCellWidth;				//if this question has the max # of choices (i.e. #==intMaxChoices), and if this last choice doesn't quite use up remaining width, then force this cell to use remaining width				if(intIndex==intMaxChoices-1 && intCellWidth<intWidthRemaining){intCellWidth=intWidthRemaining};				s+='<td class="unselected" onmouseover="hover(this)" onmouseout="unhover(this)" onmousedown="choice(this);"\n';				s+='	id="'+intQuestion+'_'+(intIndex+1)+'" width="'+intCellWidth+'%">'+q.choices[intIndex]+'</td>\n';				intWidthRemaining-=intCellWidth;			};			//generate extra cell covering remaining width, which should only happen if # of choices is less than intMaxChoices			s+=(intWidthRemaining>0)?'<td class="questions" colspan="'+(intMaxChoices-q.choices.length)+'">&nbsp;</td>\n':'';			s+='</tr>\n';			s+='</table>\n';			if(arQuestionsSupplemental[--intQuestion]==""){	//'Added 30Aug2006				s+='<br />\n';	};			s+='</td></tr>';		};	};	return s;};//end function questionDisplay(intQuestion)function questionSupplementalDisplay(intQuestion){	//'Added 30Aug2006	var s="";	var q=arQuestionsSupplemental[intQuestion++];	if(q)	{		//Added 19Jul2007 -- extra text before "q" to identify the supplemental as optional...		if(isSupplementalOptional(intQuestion))q="(optional) " + q;		//generate the HTML for the supplemental main text		s+='<tr><td>\n';		s+='<table width="75%" border="1" align="center" cellpadding="3">\n';		s+='<tr><td class="supplabel" align="right" width="50%" id="'+intQuestion+'_b0">'+q;		s+='\n</td>';		//generate the HTML for the supplemental text field		s+='<td class="suppfield"\n';		s+='	id="'+intQuestion+'_b1">'+'<input type="text" size="40" class="supptxt" name="txtSupp'+intQuestion+'" />'+'</td>\n';		s+='</tr>\n';		s+='</table>\n';		s+='<br />\n';		s+='</td></tr>';	};	return s;};//end function questionSupplementalDisplay(intQuestion)function getGoBack(bAllByMyself,strConfirmQuestion){	if(!strConfirmQuestion){strConfirmQuestion="Exit this survey screen?"};	var strConfirm="if(confirm('" + strConfirmQuestion + "')){";	var strGoBack=history.length<=0?"":(history.go)?"go(-1)":(history.back)?"back()":"";	if(strGoBack)	{		strGoBack='Go Back" onclick="' + strConfirm + 'history.' + strGoBack + '}';	}	else	{		strGoBack+='Close Window" onclick="' + strConfirm + 'self.close()}';	};	strGoBack='<input type="button" value="' + strGoBack + '" />';	if(bAllByMyself)	{		strGoBack='<br /><table width="100%" border="0"><tr><td class="buttons">' + strGoBack + '</td></tr></table><br />';	};	return strGoBack;};function resetChoices(objElement){	if(confirm("Clear all selections and blank out all data?"))	{		var strClassOld="";		var strClassNew="";		for(var intQuestion=1;intQuestion<=arQuestions.length;intQuestion++)		{			arChoices[intQuestion-1]="";			//since nothing is now supposed to be selected, make sure nothing is actually selected!			var intChoice=0;			objCell=document.getElementById(intQuestion+"_"+(intChoice));			if(objCell){objCell.className="questionmain"};			objCell=document.getElementById(intQuestion+"_"+(++intChoice));			while(objCell)			{				strClassOld=objCell.className;				strClassNew=(strClassOld=="hoveredselected" || strClassOld=="hovered")?"hovered":"unselected";				objCell.className=strClassNew;				objCell=document.getElementById(intQuestion+"_"+(++intChoice));			};			// 'Added 30Aug2006 -- if this question has a supplemental then reset it too			enableSupplemental(intQuestion,true,false);			var objCell=document.forms[0]["txtSupp"+intQuestion];			if(objCell)objCell.value="";			// '/Added 30Aug2006		};		(objElement.form).onreset=null;		(objElement.form).reset();		(objElement.form).onreset=function(){return false};	};};function buttonsAndFOIPDisplay(){	//NOTE: This is the last Javascript function to run, so 'on page load' stuff might go at the end of this	var strHTML="";	if(arQuestions.length>0 && arContactFields.length>0)	{		var strButtons='<input type="submit" name="btnSubmit" value="Submit" onclick="submitChoices(this)" />&nbsp;&nbsp;&nbsp;<input type="button" value="Reset" onclick="resetChoices(this)" />&nbsp;&nbsp;&nbsp;' + getGoBack();		strHTML+='<br /><table width="100%" border="0"><tr><td class="buttons">' + strButtons + '</td></tr></table>';		if(strFOIPStatement)		{			strHTML+='<table width="100%" border="0">';			strHTML+='<tr><td class="FOIPmain"><br />FOIP Statement<br /></td></tr>';			if(strFOIPStatement.indexOf("<<FOIPACTLINK>>")!=-1){strFOIPStatement=strFOIPStatement.replace("<<FOIPACTLINK>>",strFOIPActLink)};			if(strFOIPStatement.indexOf("<<FOIPQUESTIONS>>")!=-1){strFOIPStatement=strFOIPStatement.replace("<<FOIPQUESTIONS>>",strFOIPQuestions)};			strHTML+='<tr><td class="FOIPbody">' + strFOIPStatement + '</td></tr>';			strHTML+='</table>';		};	}	else	{		strHTML+=getGoBack(true);	};	document.write(strHTML);	//now that the HTML has been written, it might be time to run 'on page load' stuff	if(location.href.indexOf("&focus")!=-1)	{		setTimeout("if(document.forms[0].btnSubmit) {document.forms[0].btnSubmit.focus()}",25);	};	if(location.href.indexOf("&autoclick")!=-1)	{		setTimeout("if(document.forms[0].btnSubmit) {document.forms[0].btnSubmit.click()}",25);	};};//end function buttonsAndFOIPDisplay()function addContactField(strField,intStatus){	arContactFields[arContactFields.length]=intStatus+"\x01"+strField;};function contactFieldDisplayAll(){	var strHTML='<table width="100%" border="0">';	strHiddenContactFieldsHTML="";	if(arQuestions.length>0 && arContactFields.length>0)	{		var strFieldRequiredExtraHTML='<span class="FieldRequired"> *</span>';		strHTML+='<tr><td class="ContactInformationMain" colspan="2"><br /><b>Contact Information</b> -- required fields are marked with'+strFieldRequiredExtraHTML+'</td></tr>';		strHTML+='<tr><td colspan="2" class="ContactInformationDisclaimer">' + (strFOIPStatement?'( all data collected and used according to FOIP Statement at bottom of page )<br />':'') + '<br /></td></tr>';		for(var intIndex=0;intIndex<arContactFields.length;intIndex++)		{			strHTML+=contactFieldDisplay(intIndex);		};	}	else	{		strHTML+='<tr><td class="errormissing"><br />NO CONTACT FIELDS GENERATED!<br />\n<br />\nfunction addContactField(strField,intStatus);<br /><br /></td></tr>';	};	strHTML+='</table>';	if(strHiddenContactFieldsHTML){strHTML+="\n"+strHiddenContactFieldsHTML};	document.write(strHTML);};function spacesAtCapitals(strOld){	var strNew=strOld.charAt(0);	for(var intChar=1;intChar<strOld.length;intChar++)	{		//capital letter means add a space to the result before adding the next char, otherwise just add the next char		strNew+=(strOld.charCodeAt(intChar)>64 && strOld.charCodeAt(intChar)<91?" ":"") + strOld.charAt(intChar);	};	return strNew;};function contactFieldDisplay(intIndex){	var rv="";	var arFieldInfo=arContactFields[intIndex].split("\x01");	var intStatus=arFieldInfo[0];	var strFieldName=arFieldInfo[1];	if(intStatus==0)	{		strHiddenContactFieldsHTML+='<input name="' + strFieldName + '" type="hidden" value="" />\n';	}	else	{		var strFieldLabel=spacesAtCapitals(strFieldName);		var strFieldRequiredExtraHTML='<span class="FieldRequired"> *</span>';		var strHandleChange="";		//later have some onchange event handling perhaps? i.e. ="function_name(this)";		var intFieldVisibleSize=25;		var intFieldMaximumLength=40;		var strExtraInfo="";		//extra info below the field label to explain its purpose		switch(strFieldName.toLowerCase())		{		case "town":			intFieldVisibleSize=31;			break;		case "province":			intFieldVisibleSize=21;			intFieldMaximumLength=30;			break;		case "phonenumber":			intFieldVisibleSize=15;			intFieldMaximumLength=12;			break;		case "emailaddress":			intFieldVisibleSize=40;			intFieldMaximumLength=128;			strExtraInfo=( strEmailExplanation ? strEmailExplanation : '(optional -- provide your email address if you wish to subscribe to our email newsletter)' );			break;		};		rv+='<tr>\n';		rv+='<td class="ContactLabel" width="20%">' + strFieldLabel + ':' + (intStatus==1?strFieldRequiredExtraHTML:"") + '</td>\n';		rv+='<td class="ContactField">';		rv+='<input name="' + strFieldName + '" ';		rv+=(strHandleChange?'onchange="handleChange(\'' + strHandleChange + '\')" ':'');		rv+='size="' + intFieldVisibleSize + '" maxlength="' + intFieldMaximumLength + '" type="text" value="" />';		rv+='</td>\n';		rv+='</tr>\n';		rv+=( (strExtraInfo && trim(strExtraInfo)!="") ? '<tr><td colspan="2" class="ContactFieldExtra">' + strExtraInfo + '</td></tr>\n' : '' );	//Modified 12Jun2006 -- trim(extra)!=""	};	return rv;};function trim(strOld){	var rv=strOld;	if(rv)	{		var intIndex=0;		var intChar=rv.charCodeAt(intIndex);		while(intChar<=32 && intIndex<rv.length){intChar=rv.charCodeAt(++intIndex)};		rv=rv.substring(intIndex);		if(rv)		{			var intIndex=rv.length-1;			var intChar=rv.charCodeAt(intIndex);			while(intChar<=32 && intIndex>0){intChar=rv.charCodeAt(--intIndex)};			rv=rv.substring(0,intIndex+1);		};	};	return rv;};function getTextFromChoices(intQuestion,strChoicesSelected){	var rv="";	var objQuestion=arQuestions[intQuestion-1];	if(objQuestion && strChoicesSelected)	{		if(objQuestion.qid)		{			var arChoicesRaw=objQuestion.choicesRaw;			var strChoicesToSearch=";"+strChoicesSelected+";";			var strChoiceToFind="";			for(var intChoice=0;intChoice<arChoicesRaw.length;intChoice++)			{				strChoiceToFind=";"+(intChoice+1)+";";				if(strChoicesToSearch.indexOf(strChoiceToFind)!=-1)				{					rv+=";"+arChoicesRaw[intChoice];				};			};		};	};//end if(objQuestion && strChoicesSelected)	if(rv){rv=rv.substring(1)};	return rv;};function submitChoices(objElement){	var f=(objElement.form);	var strQuestionID="";	var strChoices="";	var strChoicesText="";	var strSupplemental="";	//'Added 30Aug2006	var intFailed=0;	var strClassOld="";	var strDisabledQuestions="";	//first, verify the only unanswered choices are disabled ones	for(var intQuestion=1;intQuestion<=arQuestions.length;intQuestion++)	{		strChoices="";		strChoicesText="";		strQuestionID="";		strSupplemental="";	//'Added 30Aug2006		if(!arQuestions[intQuestion-1].qid)		{			strDisabledQuestions+=";"+intQuestion;		}		else		{			objCell=document.getElementById(intQuestion+"_0");			if(objCell)			{				strChoices=(arChoices[intQuestion]?arChoices[intQuestion]:"");				strChoicesText=strChoices?getTextFromChoices(intQuestion,strChoices):"";				strQuestionID=arQuestions[intQuestion-1].qid;				// 'Added 30Aug2006...				var objSupp=document.forms[0]["txtSupp"+intQuestion];				if(objSupp)				{					if(objSupp.value)strSupplemental=objSupp.value;				};				// '/Added 30Aug2006.				strClassOld=objCell.className;				if(strClassOld=="disabledmain" || strClassOld=="disabled")				{					strChoices="";					strChoicesText="";					strDisabledQuestions+=";"+intQuestion;					strSupplemental="";	//'Added 30Aug2006				}				else if(!strChoices && !arQuestions[intQuestion-1].multi)				{					intFailed=intQuestion;				}				else if(isSupplementalMissing(intQuestion))				{					intFailed=intQuestion+0.5;				};			};		};		//set the hidden fields to store the question's numeric responses, text responses, and QuestionID		f["Q"+intQuestion+"_Response"].value=strChoices;		f["Q"+intQuestion+"_ResponseText"].value=strChoicesText;		f["Q"+intQuestion+"_ID"].value=strQuestionID;		f["Q"+intQuestion+"b_ResponseText"].value=strSupplemental;	//'Added 30Aug2006		if(intFailed)		{			if(parseInt(intFailed)!=intFailed)	intFailed=parseInt(intFailed)+" (supplemental)";	// 'Added 30Aug2006			alert("You didn't answer Survey Question # " + intFailed + ".\n\nBefore submitting your survey response, you must answer all questions.\n\n(multiple-select questions may be left blank, i.e. no choices selected)");			// 'Added 30Aug2006...			if((""+intFailed).indexOf("supplemental")!=-1)			{				if(objSupp)				{					if(objSupp.focus)objSupp.focus();				};			};			// '/Added 30Aug2006.			intQuestion=arQuestions.length+1;		};	};//end for(var intQuestion=1;intQuestion<=arQuestions.length;intQuestion++)	if(strDisabledQuestions){strDisabledQuestions=strDisabledQuestions.substring(1)};	f["DisabledQuestions"].value=strDisabledQuestions;	if(intFailed){return false};	//second, verify the only unanswered contact info is an optional field (and ensure skipped fields are blank)	var arFieldInfo=[];	var intStatus=0;	var strFieldName="";	var strFieldLabel="";	var strFailedReason="";	var strFieldValue="";	for(var intIndex=0;intIndex<arContactFields.length;intIndex++)	{		arFieldInfo=arContactFields[intIndex].split("\x01");		intStatus=arFieldInfo[0];		strFieldName=arFieldInfo[1];		strFieldLabel=spacesAtCapitals(strFieldName);		strFailedReason="";		if(intStatus==0)		{			f[strFieldName].value="";		}		else		{			strFieldValue=trim(f[strFieldName].value);			f[strFieldName].value=strFieldValue;			if(intStatus==1 && strFieldValue=="")			{				strFailedReason="You didn't fill in the required field '" + strFieldLabel + "'.\n\nBefore submitting your survey response, you must fill in all required contact information.";			}			else			{				strFailedReason=validContactInfo(strFieldName,strFieldValue,intStatus);				if(strFailedReason)				{					strFailedReason+=".\n\nBefore submitting your survey response, you must enter valid data for all required contact fields.";				};			};		};		f[strFieldName+"_1"].value=f[strFieldName].value;		if(strFailedReason)		{			intFailed=intIndex+1;			intIndex=arContactFields.length+1;			f[strFieldName].focus();			alert(strFailedReason);		};	};//end for(var intIndex=0;intIndex<arContactFields.length;intIndex++)	if(intFailed){return false};	//third, submit the form and immediately disable the onsubmit event to prevent accidental double-enter pressing, etc.	if(location.href.indexOf("&focus")!=-1 || confirm("Submit your survey response now?"))	{		clearUnwantedSupplementals();	//'Added 30Aug2006		f.onsubmit=null;		var s1=f.timing2.value;f.timing.value=(s1.length<5?"": s1.substring((s1.length-(1*s1.charAt(1)))/2, ((s1.length-(1*s1.charAt(1)))/2)+(1*s1.charAt(1))));		f.submit();		f.onsubmit=function(){return false};	};};//end function submitChoices(objElement)styleDisplayPointer();
