var survey1 = "";
// test browser to set appropriate equivalent to getElementById
if (document.layers)
   document.getElementById = NN4GetLayerById;
else if (document.all && !document.getElementById)
   document.getElementById = IE4GetElementById;
//***********
// Parameters used for color hinting the questions as the user navigates through the survey
//*********** 
var origColor = 'black';
var alrtColor = '#E24D0B';
var fadeColor = 'gray';  
var overColor = 'brown';
var doneColor = 'darkgray';
var wasThis = origColor;
// the following values are more likely to vary, depending on the style preferences for the installation
var btnColor = '#844746';
var bkgColor = 'white';
var taColor = "#EEEEEE";
var LowBgColor='#803C3D';			// Background color when mouse is not over
var LowSubBgColor='#803C3D';		// Background color when mouse is not over on subs
var fontElementId = "inner"; 
/////////////////////////////////////////////
// Javascript Functions used by survey pages
//////////////////////////////////////////////
function getNewWin (l) {
// test to see if this is a form submission that requires a form check first
	if (l) {	
		// alert("so far ...");
		if (!formCheck(l)) return;
		// alert("so good ...");
	}
// else continue if not a form check or if the form check returns not false (true)
	var h = screen.height; // Get the height of the screen
	var win_height = h - 80; // leave some room for offset
	var branch_id="";
	var survey_id="";
	var lert="";
	for (i=0; i<document.theSurvey.branch_id.length; i++) {
		if(document.theSurvey.branch_id.options[i].selected) {
			branch_id = document.theSurvey.branch_id.options[i].value;
			break;
		}
	}
	if (branch_id=="") lert=lert+ccConv(swtchBr(l));	
	for (i=0; i<document.theSurvey.survey_id.length; i++) {
		if(document.theSurvey.survey_id.options[i].selected) {
			survey_id = document.theSurvey.survey_id.options[i].value;
			break;
		}
	}
	if (survey_id=="") lert=lert+ccConv(swtchVer(l));	
	if (lert!="") {
		alert(lert);
		return;
	}	
	var loc_id = l;
	//var url = loc_id + '/dsurvey.php?branch_id=' + branch_id + '&survey_id=' + survey_id + '&loc_id=' + loc_id;
	var url = 'dsurvey.php?branch_id=' + branch_id + '&survey_id=' + survey_id + '&loc_id=' + loc_id;
	survey1 = window.open(url,'survey','width=745,height='+win_height+',left=2,top=2,screenX=2,screenY=2,scrollbars=yes,status=no');
	if (window.opener && !window.opener.closed) window.close(); 
	else history.go(-1);
}
//***********
// Required functions used throughout this code to handle browser specific dependencies
//***********
// Functional equivalent to getElementById for IE4 browsers
function IE4GetElementById(id) {
   return document.all[id];
}
// Functional equivalent to getElementById for NN4 browsers
function NN4GetLayerById(id)  {
	for (var i = 0; i < document.theSurvey.elements.length; i++) {
		if (document.theSurvey.elements[i].name && id == document.theSurvey.elements[i].name) return document.theSurvey.elements[i];
	}
}
//DO NOT MODIFY BELOW
function instructions_popup() {
	reWin=window.open('http://www.countingopinions.com/instructions/cookies.htm#<? echo $loc_id; ?>','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=600,top=1,left=1')
}
function dLoader() { // execute on page load for welcome page
	window.focus();
	if (!document.cookie) {
		where_to = confirm("Your browser must be configured to allow Session Cookies\n before you will be able to respond to the Survey.\n\nClick OK for instructions on configuring your Browser,\n otherwise select Cancel to continue.");
		if (where_to) instructions_popup();
	} else {
		var kill_time = new Date("January 1, 1970");
		var kill_string = "dSurvey=1;expires=" + kill_time.toGMTString();
		document.cookie = kill_string;
	}
}
/* Module Set Cookie (string, string, int) -- http://www.w3schools.com/js/js_cookies.asp */
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
/* Module Get Cookie (string) -- http://www.w3schools.com/js/js_cookies.asp */
function getCookie(c_name){
	if(document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return false;
}
//****************
// The following functions control the styles used on various questions and their options 
// depending on the current status of a question (is it answered, active, skipped, new, etc.)
//****************
function switchOn(x) {
	wasThis = x.style.color;
	if (wasThis==fadeColor) x.style.color=doneColor;
	else x.style.color=overColor;
}
function switchOff(x) {
	x.style.color=wasThis;
}
function chkPrev(x) {
	var y = parseInt(getID(x, 'q'))
	for (i=0; i<Qarray.length; i++) {
//		alert(i + " " + y);
		if (Qarray[i]==y) { 
			var z = i;
			break;
		}
	}
//	for (i=startQ; i<y; i++) {
	for (i=0; i<z; i++) {
		var c = 'q' + i;
		if (document.getElementById(c).style.color!=fadeColor)
		document.getElementById(c).style.color = alrtColor;
	}
}
function getIndex(input) {
 	var index = -1, i = 0, found = false;
	while (i < document.theSurvey.elements.length && index == -1)
		if (document.theSurvey.elements[i] == input)index = i;
		else i++;
	return index;
}
function restoreDefault(StypeItem) {   
	for (var i = 0; i < StypeItem.length; i++) {     
		 if (StypeItem.options[i].defaultSelected == true) {        
		 StypeItem.options[i].selected=true      }   
	}
}
function getID(qname,bg) {
	s=qname.indexOf(bg) + bg.length;
	e=qname.indexOf("_",s);
	if (e<0) e=qname.length;
	// alert("S: " + s + " E: " + e + " Name: " + qname + "_");
	return qname.substring(s,e);
}
function setTextArea(it,ta) {
	it.style.color=fadeColor;
	var y = parseInt(getID(ta, 'q'));
	for (i=0; i<Qarray.length; i++) {
		if (Qarray[i]==y) { 
			var x = 'q' + i;
			break;
		}
	}
	document.getElementById(x).style.color = fadeColor;
	wasThis = fadeColor;
   	chkPrev(ta);
}
function setRadioButtons(it,rb) {
	it.style.color=fadeColor;
	var y = parseInt(getID(rb, 'q'))
	for (i=0; i<Qarray.length; i++) {
		if (Qarray[i]==y) { 
			var x = 'q' + i;
			break;
		}
	}
	document.getElementById(x).style.color = fadeColor;
	wasThis = fadeColor;
   	chkPrev(rb);
	// check 'part' number 3 (n/a) for this question to see if already set
	whereIs = rb.indexOf("p");
	cb = rb.substring(0,whereIs+1);
	cb = cb + "3";
	cbFld = eval("document.theSurvey." + cb);
	if (cbFld) {
	 	if (cbFld.checked) {
			it.checked=false;
			return;	
		}
	}
	//	setFld= enum("opener.document.theSurvey." + rb);
	//	setFld.value = it.value;
	if (document.all || document.getElementById) {
		var btn=eval("document.theSurvey." + rb);
   		var x = btn.length;
   		for (var i=0; i<x; i++) {
   			if (btn[i].checked) btn[i].style.backgroundColor=btnColor;
  			else btn[i].style.backgroundColor=bkgColor;
   		}
   	}
    // loops to ensure that all radio button type question parts for current questionID
    // are selected, and then can 'fade' the related question text cell
    // if partNo > 1 then loop down the index of elements first else just loop up
   	var doFade=1;
   	var qIndex=getIndex(it);
   	var questionID=parseInt(getID(rb,"q"));
	var partNO = parseInt(getID(rb,"p"));
    if (partNO>1) {
       for (var j=qIndex-1; j>-1; j--) {
            prevElement=document.theSurvey.elements[j];
            prevQ=prevElement.name;
            if (questionID == parseInt(getID(prevQ,"q"))) {
            	prevT=prevElement.type;
            	if (prevT=="radio" && prevElement.checked) doFade++;
            } else break;
        }
     }
     // now do forward loop to checked items in other 'parts' of the same questionID
	 totalElements=it.form.length;
     for (var i=qIndex+1; i<totalElements; i++) {         		       	
        nxtElement=document.theSurvey.elements[i];
        nxtQ=nxtElement.name;
        if (questionID == getID(nxtQ,"q")) {
            nxtT=nxtElement.type;
            if (nxtT=="radio" && nxtElement.checked) doFade++;
        } else break;
    }   	
   	if (doFade>1) {
		// fade the question text cell if all Radio Button 'parts' of a question are completed
		var x = 'q' + questionID;
		document.getElementById(x).style.color = fadeColor;
   		chkPrev(rb);
	}
}
function setCheckButtons(it,cb) {
	if (it.checked) {
		it.style.color=btnColor;
		var y = parseInt(getID(cb, 'q'))
	for (i=0; i<Qarray.length; i++) {
		if (Qarray[i]==y) { 
			var x = 'q' + i;
			break;
		}
	}
		document.getElementById(x).style.color = fadeColor;
		wasThis = fadeColor;
		chkPrev(cb);
	}	else it.style.color=bkgColor;
	// check if it's an Applicable -- Not/Applicable checkbox
	if (cb.indexOf("_a")<0) return;
	else {
		totalElements=it.form.length;
		if (it.checked) {
   			it.style.backgroundColor=btnColor;
			qIndex=getIndex(it);
   			questionID=getID(cb,"q");
			partNO = getID(cb,"p");
            // loops to uncheck radio buttons for the current questionID
            // and dim those previous fields
            // if partNo > 1 then loop down the index of elements first else just loop up
            if (partNO>1) {
            	for (j=qIndex-1; j>-1; j--) {
            		prevElement=document.theSurvey.elements[j];
            		prevQ=prevElement.name;
            		if (questionID == getID(prevQ,"q")) {
            			prevT=prevElement.type;
            			if (prevT=="radio" && prevElement.checked) {
            				prevElement.checked=false;
            				prevElement.style.backgroundColor=bkgColor;
            			}
            		} else break;
            	}
            }
            // now do forward loop to reset checked items for the same questionID
            for (i=qIndex+1; i<totalElements; i++) {         		       	
            		nxtElement=document.theSurvey.elements[i];
            		nxtQ=nxtElement.name;
            		if (questionID == getID(nxtQ,"q")) {
            			nxtT=nxtElement.type;
            			if (nxtT=="radio" && nxtElement.checked) {
            				nxtElement.checked=false;
            				nxtElement.style.backgroundColor=bkgColor;
            			}
            		} else break;
              }
  			// loop to restore default settings?
  		}
   	}  	
}
function setSelectItem(it,sl) {
	var slist=eval("document.theSurvey." + sl);
	var y = parseInt(getID(sl, 'q'))
	for (i=0; i<Qarray.length; i++) {
		if (Qarray[i]==y) { 
			var x = 'q' + i;
			break;
		}
	}
   if (slist.selectedIndex && slist.selectedIndex!=0) {
		document.getElementById(x).style.color=fadeColor;
		wasThis = fadeColor;
		slist.options[slist.selectedIndex].style.color=fadeColor;
	} else {
		document.getElementById(x).style.color=alrtColor;
		//	wasThis = alrtColor;
	}	 
	chkPrev(sl);
}
function setSelectItemOther(it,sl) {
	var slist=eval("document.theSurvey." + sl);
	var y = parseInt(getID(sl, 'q'))
	for (i=0; i<Qarray.length; i++) {
		if (Qarray[i]==y) { 
			var x = 'q' + i;
			break;
		}
	}
	if (slist.selectedIndex && slist.selectedIndex!=0) {
		document.getElementById(x).style.color=fadeColor;
		wasThis = fadeColor;
		slist.options[slist.selectedIndex].style.color=fadeColor;
	} else {
		document.getElementById(x).style.color=alrtColor;
		//	wasThis = alrtColor;
	}	 
	chkPrev(sl);
	var temp = new Array();
	temp = slist.name.split('_');
	var q_name = temp[0] + "_" + temp[1] + "_tB_OTHER";
	var div_name = "div_" + q_name; 
	if(slist.options[slist.selectedIndex].value > 100) {
		html = "Other:&nbsp;<input type=\"text\" id=\"" + q_name + "\" name=\"" + q_name + "\" size=\"32\">";
	} else {
		html = "";
	}
	document.getElementById(div_name).innerHTML = html;
}
//*********
// the following routines are used strictly for debugging purposes
//*********
function viewValues() {
	var alrtVar = "";
	for (var i=0; i < document.theSurvey.length; i++) {
		alrtVar = " | " + document.theSurvey.options[i].name + ": " + document.theSurvey.options[i].value;
	}
	alert(alrtVar);	
}
function validate(f) {
	for (var i=0;i<f.length;i++) {
		current = f.elements[i];
		if (current.type=="radio") {
			alert(current.name + "[" + i + "]: " + current.checked);
		}
	}
}
function gotoCustomerURL (tURL,tMail,rURL,rMail,rlocID,oname,ourl,brName,dFr,fURL) {
	var w = screen.width; // Get the width of the screen
	var url = tURL + '?url=' + rURL + '&email=' + rMail + '&to=' + tMail + '&loc=' + rlocID + '&on=' + oname + '&ou=' + ourl + '&br=' + brName + '&fr=' + dFr + '&furl=' + fURL;
	var win_width = w - 80; // leave some room for offset
	survey1 = window.open(url,'Library','left=6,top=6,width='+win_width+',screenX=6,screenY=6,scrollbars=yes,status=no');
	window.close(); 
}
function formCheck(l) {
//	Form Check to validate that user has selected a choice in all select lists
	var brnch = true;
	var srvy = true;
	var lert="";
	if(document.theSurvey.branch_id.options[0].selected && document.theSurvey.branch_id.length>1) {
//		alert("Location check: " + document.theSurvey.branch_id.length);
		lert=lert + "\n" + swtchBr(l) + "\n";
		document.theSurvey.branch_id.focus();
		brnch = false;
	}
	if(document.theSurvey.survey_id.options[0].selected && document.theSurvey.survey_id.length>1) {
//		alert("Version check: " + document.theSurvey.survey_id.length);
		lert=lert + "\n" + swtchVer(l) + "\n";
		srvy = false;
		if (brnch) document.theSurvey.survey_id.focus();
	} 
// return setting
	if (brnch && srvy) return true;
	alert(lert);
	return false;
} 
function swtchBr(l) {
	switch (l) {
		case 'fr_CA': 
			return ("Veuillez indiquer l’emplacement/succursale!\n\n"); 
			break;
		case 'es': 
			return ("Indique el centro/la sucursal!\n\n"); 
			break;
		case 'zh_CN':
			return ("\u8BF7\u6807\u660E\u5728\u54EA\u4E00\u5BB6\u56FE\u4E66/\u9986\u5206\u9986\n\n");	
			break;	
		case 'zh_HK':
			return ("\u8ACB\u6A19\u660E\u5728\u54EA\u4E00\u5BB6\u5716\u66F8/\u9928\u5206\u9928\n\n");	
			break;		
		case 'pa_PK':
			return ("\u0A15\u0A3F\u0A30\u0A2A \u0A3E\u0A15 \u0A30\u0A15 \u0A47\u0A38\u0A25\u0A3E/ \u0A28\u0A2C\u0A30\u0A3E\u0A02 \u0A1A\u0A26 \u0A3E\u0A28\u0A3E \u0A2E\u0A26\u0A71\u0A38\u0A4B\n\n");
			break;		
		case 'ru':
			return ("\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442, \u0430\u0443\u043A\u0430\u0436\u0438\u0442 \u0435\u043C\u0435\u0441\u0442 \u043E\u0440\u0430\u0441\u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438 / \u044F\u0444\u0438\u043B\u0438\u0430 \u043B\u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438\n\n");
			break;		
		default: return ("Please indicate the Location/Branch!\n\n");
	}
}
function swtchVer(l) {
	switch (l) {
	   	case 'fr_CA': 
	   		return ("Veuillez indiquer la version du sondage!\n\n"); 
	   		break;
	   	case 'es': 
	   		return ("Indique la versi\u00F3n de la encuesta!\n\n"); 
	   		break;
		case 'zh_CN':
			return ("\u8BF7\u6807\u660E\u9009\u7528\u54EA\u4E00\u7248\u672C\u7684\u8C03\u67E5\u95EE\u5377\n\n");	
			break;	
		case 'zh_HK':
			return ("\u8ACB\u6A19\u660E\u9078\u7528\u54EA\u4E00\u7248\u672C\u7684\u8ABF\u67E5\u554F\u5377\n\n");	
			break;			   	
		case 'pa_PK':
	   		return ("\u0A15\u0A3F\u0A30\u0A2A \u0A3E\u0A15 \u0A30\u0A26\u0A71\u0A38 \u0A4B\u0A38\u0A30\u0A35\u0A47\u0A16 \u0A23\u0A26 \u0A3E\u0A30\u0A42\u0A2A\u0A3E\u0A02\u0A24 (Version) \u0A30\u0A15\u0A3F\u0A39\u0A5C \u0A3E\u0A39\u0A48\n\n"); 
	   		break;
		case 'ru':
	   		return ("\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442, \u0430\u0443\u043A\u0430\u0436\u0438\u0442 \u0435\u0432\u0435\u0440\u0441\u0438 \u044E\u043E\u043F\u0440\u043E\u0441\u0430\n\n"); 
	   		break;
	   	default: return ("Please indicate the Version of the survey!\n\n");
	}
}
function swtchemWarn(l) { // invalid email warning
	switch (l) {
	   	case 'fr_CA': 
	   		return ("Adresse de courriel invalide. Veuillez r&#65533;essayer!\n\n"); 
	   		break;
	   	case 'es': 
	   		return ("Indique la versi\u00F3n de la encuesta!\n\n"); 
	   		break;
		case 'zh_CN':
			return ("\u8BF7\u6807\u660E\u9009\u7528\u54EA\u4E00\u7248\u672C\u7684\u8C03\u67E5\u95EE\u5377\n\n");	
			break;	
		case 'zh_HK':
			return ("\u8ACB\u6A19\u660E\u9078\u7528\u54EA\u4E00\u7248\u672C\u7684\u8ABF\u67E5\u554F\u5377\n\n");	
			break;			   	
		case 'pa_PK':
	   		return ("u0a28\u0a21\u0a35\u0a21\u0a1c\u0a3f\u0a2c \u0a08-\u0a2e\u0a47\u0a32 \u0a73\u0a48\u0a5b\u0a30\u0a48\u0a3e\u0a02\u0a38. \u0a15\u0a3f\u0a30\u0a2a\u0a21 \u0a15\u0a30 \u0a15\u0a47 \u0a2b\u0a3f\u0a30 \u0a15\u0a4b\u0a38\u0a3f\u0a33\u0a38\u0a33 \u0a15\u0a30\u0a28\u0a21!\n\n"); 
	   		break;
		case 'ru':
	   		return ("\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442, \u0430\u0443\u043A\u0430\u0436\u0438\u0442 \u0435\u0432\u0435\u0440\u0441\u0438 \u044E\u043E\u043F\u0440\u043E\u0441\u0430\n\n"); 
	   		break;
	   	default: return ("Invalid Email address. Please try again!\n\n");
	}
}
function dEmailChk(t,l) {
	if(t.value && t.value!='') {
		if(!emChk(t.value)){
			alert(swtchemWarn(l));
			t.focus;
		}
	}
}
function emChk(e) {
  	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; // valid
    if (!e || e=='') return true;
  	if (!reg1.test(e) && reg2.test(e)) return true;
	else return false;
}
function swtchpzWarn(l) { // invalid postal/zip warning
	switch (l) {
	   	case 'fr_CA': 
	   		return ("Code postal invalide. Veuillez r&#65533;essayer!\n\n"); 
	   		break;
	   	case 'es': 
	   		return ("Indique la versi\u00F3n de la encuesta!\n\n"); 
	   		break;
		case 'zh_CN':
			return ("\u8BF7\u6807\u660E\u9009\u7528\u54EA\u4E00\u7248\u672C\u7684\u8C03\u67E5\u95EE\u5377\n\n");	
			break;	
		case 'zh_HK':
			return ("\u8ACB\u6A19\u660E\u9078\u7528\u54EA\u4E00\u7248\u672C\u7684\u8ABF\u67E5\u554F\u5377\n\n");	
			break;			   	
		case 'pa_PK':
	   		return ("\u0a28\u0a3e\u0a35\u0a3e\u0a1c\u0a3f\u0a2c \u0a5b\u0a3f\u0a71\u0a2a/ \u0a2a\u0a4b\u0a38\u0a1f\u0a32 \u0a15\u0a4b\u0a21\u0964 \u0a15\u0a3f\u0a30\u0a2a\u0a3e \u0a15\u0a30 \u0a15\u0a47 \u0a2b\u0a3f\u0a30 \u0a15\u0a4b\u0a36\u0a3f\u0a36 \u0a15\u0a30\u0a28\u0a3e!\n\n"); 
	   		break;
		case 'ru':
	   		return ("\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442, \u0430\u0443\u043A\u0430\u0436\u0438\u0442 \u0435\u0432\u0435\u0440\u0441\u0438 \u044E\u043E\u043F\u0440\u043E\u0441\u0430\n\n"); 
	   		break;
	   	default: return ("Invalid Zip/Postal code. Please try again!\n\n");
	}
}
function dpzChk(t,l) {
	if(t.value && t.value!='') {
		if(!pzChk(t.value)){
			alert(swtchpzWarn(l));
			t.focus;
		}
	}
}
function pzChk(pz) {
	pre = /^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i; //Cdn postal code
	zre1 = /^\D*(\d{5})$/; // regular sip
	zre2 = /^\D*(\d{5})\D*(\d{4})\D*$/; // zip+4 version
	if (!pz || pz=='') return true;
	if (pre.test(pz) || zre1.test(pz) || zre2.test(pz)) return true;
	else return false;
}
function swtchConfrmem(l) { // invalid email confirmation
	switch (l) {
	   	case 'fr_CA': 
	   		return ("Adresse de courriel invalide. Choisir Annuler pour rectifier!\n\n"); 
	   		break;
	   	case 'es': 
	   		return ("Indique la versi\u00F3n de la encuesta!\n\n"); 
	   		break;
		case 'zh_CN':
			return ("\u8BF7\u6807\u660E\u9009\u7528\u54EA\u4E00\u7248\u672C\u7684\u8C03\u67E5\u95EE\u5377\n\n");	
			break;	
		case 'zh_HK':
			return ("\u8ACB\u6A19\u660E\u9078\u7528\u54EA\u4E00\u7248\u672C\u7684\u8ABF\u67E5\u554F\u5377\n\n");	
			break;			   	
		case 'pa_PK':
	   		return ("\u0a28\u0a3e\u0a35\u0a3e\u0a1c\u0a3f\u0a2c \u0a5b\u0a3f\u0a71\u0a2a/ \u0a2a\u0a4b\u0a38\u0a1f\u0a32 \u0a15\u0a4b\u0a21\u0964 \u0a20\u0a40\u0a15 \u0a15\u0a30\u0a28 \u0a32\u0a08 \u0a15\u0a48\u0a02\u0a38\u0a32 \u0a1a\u0a41\u0a23\u0a4b!\n\n"); 
	   		break;
		case 'ru':
	   		return ("\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442, \u0430\u0443\u043A\u0430\u0436\u0438\u0442 \u0435\u0432\u0435\u0440\u0441\u0438 \u044E\u043E\u043F\u0440\u043E\u0441\u0430\n\n"); 
	   		break;
	   	default: return ("Invalid Email Address. Select Cancel to fix!\n\n");
	}
}
function swtchConfrmpz(l) { // invalid postal/zip confirmation
	switch (l) {
	   	case 'fr_CA': 
	   		return ("Code postal invalide. Choisir Annuler pour rectifier!\n\n"); 
	   		break;
	   	case 'es': 
	   		return ("Indique la versi\u00F3n de la encuesta!\n\n"); 
	   		break;
		case 'zh_CN':
			return ("\u8BF7\u6807\u660E\u9009\u7528\u54EA\u4E00\u7248\u672C\u7684\u8C03\u67E5\u95EE\u5377\n\n");	
			break;	
		case 'zh_HK':
			return ("\u8ACB\u6A19\u660E\u9078\u7528\u54EA\u4E00\u7248\u672C\u7684\u8ABF\u67E5\u554F\u5377\n\n");	
			break;			   	
		case 'pa_PK':
	   		return ("\u0a28\u0a3e\u0a35\u0a3e\u0a1c\u0a3f\u0a2c \u0a08-\u0a2e\u0a47\u0a32 \u0a10\u0a21\u0a30\u0a48\u0a71\u0a38\u0964 \u0a20\u0a40\u0a15 \u0a15\u0a30\u0a28 \u0a32\u0a08 \u0a15\u0a48\u0a02\u0a38\u0a32 \u0a1a\u0a41\u0a23\u0a4b!\n\n"); 
	   		break;
		case 'ru':
	   		return ("\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442, \u0430\u0443\u043A\u0430\u0436\u0438\u0442 \u0435\u0432\u0435\u0440\u0441\u0438 \u044E\u043E\u043F\u0440\u043E\u0441\u0430\n\n"); 
	   		break;
	   	default: return ("Invalid Zip/Postal code. Select Cancel to fix!\n\n");
	}
}
function dpzemChk(f,l) {
	if ((!pzChk(f.postal_code.value) && !confirm(swtchConfrmpz(l))) || (!emChk(f.respondent_email.value) && !confirm(swtchConfrmem(l)))) return false;
	else return true;
}
function demChk(f,l) {
	if (!emChk(f.respondent_email.value)) return false;
	else return true;
}
function dpzChk(f,l) {
	if (!pzChk(f.postal_code.value)) return false;
	else return true;
}
function ccConv(str) {
	return str.replace(/&#(\d+);/g, function (search, match) { return "\\u" + parseInt(match, 10).toString(16); });
	//if (str.CharAt(0)=='&') return str;
	//var n = '';
	//for (i=0; i<=str.length; i++) {
	//	n = n + charCodeAt(str.charAt(i));
	//}
	//return n;
}