/** General Function List **/
function whichBrowser() {
	var ms = navigator.appVersion.indexOf("MSIE");
	var vers = navigator.appVersion.substring(ms+5, ms+6);
	if (ms>0) {
		if (vers == "4" || vers == "5" || vers == "6" || vers == "7") { return true; }
		else { return false; } //alert("earlier version");
	} //alert("not ms"); 
	return false;
}

function viewLayer(id) {
	var layer = document.getElementById(id).style;
	if (whichBrowser()) { layer.top=-20; layer.left=427; }
	else { layer.top=-36; layer.left=427; }	
	layer.visibility = "visible";
}

// Hide DIV layer
function hideLayer(id) {
	document.getElementById(id).style.visibility = "hidden";
}

// Change Opacity
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 imgHover(opacity,id) {
	changeOpac(opacity,"imgTable_"+id+"_id");
}

// Form functions
function bindSel() {
	var final_str = "";
	for(var i=0;i<document.forms[0].elements.length;i++) {
		if ((document.forms[0].elements[i].name).substring(0,4)=="chk_") {
			if(document.forms[0].elements[i].checked == true) {
				final_str = (final_str == "") ? (document.forms[0].elements[i].value) + "_1" : final_str + "@" + (document.forms[0].elements[i].value) + "_1";
			} else {
				final_str = (final_str == "") ? (document.forms[0].elements[i].value) + "_0" : final_str + "@" + (document.forms[0].elements[i].value) + "_0";
			}
		}
	}
	document.getElementById("up_selection_id").value = final_str;
	return true;
}

function focusCell(curr,total) {
	if (curr == "custHeader_id") {
		document.getElementById("custHeader_id").style.display="none";
		document.getElementById("custHeader_edit_id").style.display="table";
		document.getElementById("cust_area_id").focus();
		for(var i=0;i<total;i++) {
			document.getElementById("custQ"+i+"_id").style.display="table";
			document.getElementById("custQ"+i+"_edit_id").style.display="none";
		}
	} else {
		if (document.getElementById("custHeader_id").style.display) {
			document.getElementById("custHeader_id").style.display="table";
		}
		document.getElementById("custHeader_edit_id").style.display="none";
		for(var j=0;j<total;j++) {
			if (document.getElementById("custQ"+j+"_id").style.display && document.getElementById("custQ"+j+"_id").style.display != "") {
				document.getElementById("custQ"+j+"_id").style.display="table";
			}
			document.getElementById("custQ"+j+"_edit_id").style.display="none";
		}
		document.getElementById("custQ"+curr+"_id").style.display="none";
		if (document.getElementById("custQ"+curr+"_edit_id").style.display && document.getElementById("custQ"+curr+"_edit_id").style.display != "") {
			document.getElementById("custQ"+curr+"_edit_id").style.display="table";
		}
		document.getElementById("custQA_"+curr+"_id").focus();
	}
}

/****************************************************************
* Desc: clean(str) function is design to remove the unwanted characters from a given string
* Only the characters is between [ and ] will not remove from the original string.
* There a some characters [^*+.?] will need to escape if you don't want to remove them out.eg replace(/[\*\+\.\^]/g, '');
****************************************************************/

function escapeStr(str){
	var result = '';
	result = str.replace(/[^\* 0-9 A-Z a-z]/g, '');
	return result;
}


function confGeneral(i) {
	document.getElementById("cust_area_id").value = escapeStr(document.getElementById("cust_area_id").value);
	if (i != "") {
		if (document.getElementById("custQA_"+i+"_id").value && document.getElementById("custQA_"+i+"_id").value != "") {
			return true;
		} else {
			alert("You have not created any question yet.");
			return false;
		}
	} else {
		if (document.getElementById("cust_area_id").value && document.getElementById("cust_area_id").value != "") {
			return true;
		} else {
			alert("You have not created any heading yet.");
			return false;
		}
	}
}

function bindClass(num) {
	var final_str = "";
	var temp = "";
	for (var i=0;i<num;i++) {
		if (document.getElementById("seClass_"+i+"_id") && document.getElementById("seClass_"+i+"_id").value != "") {
			final_str = (final_str.length==0) ? document.getElementById("seClass_"+i+"_id").value : (final_str+"~"+document.getElementById("seClass_"+i+"_id").value);
		}
	}
	if (final_str=="") { return false; }
	else {
		document.getElementById("new_class_id").value = final_str;
		return true;
	}
}

// Radio button uncheck
function uncheck(name,index) {
	var temp = document.getElementsByName("rad_"+name);
	var tempID = document.getElementById("hid_rad_"+name+"_id");
	if (tempID.value == index) { temp[(index-1)].checked=false; tempID.value = ""; }
	else { tempID.value = index; }
}

function uncheckMix(name,index) {
	var temp = document.getElementsByName("rad_"+name);
	var tempID = document.getElementById("hid_rad_"+name+"_id");
	if (tempID.value.substring(3,4) == index) { temp[(index-1)].checked=false; tempID.value = tempID.value.substring(0,3)+"0"; }
	else { tempID.value = (document.getElementById("hid_rad_"+name+"_id").value.substring(0,3)+index); }
}

function mcCheckMix(name,opt_id) {
	var currID = document.getElementById("chk_"+name+"_"+opt_id+"_id");
	var digit_1 = document.getElementById("hid_rad_"+name+"_id").value.substring(0,1);
	var digit_2 = document.getElementById("hid_rad_"+name+"_id").value.substring(1,2);
	var digit_3 = document.getElementById("hid_rad_"+name+"_id").value.substring(2,3);
	var digit_4 = document.getElementById("hid_rad_"+name+"_id").value.substring(3,4);
	if (opt_id == 1 || opt_id == 2) {
		document.getElementById("chk_"+name+"_3_id").checked = false; digit_3 = "0";
		if (opt_id == 1) {
			digit_1 = (currID.checked) ? "1" : "0";
		}
		if (opt_id == 2) {
			digit_2 = (currID.checked) ? "1" : "0";
		}
	} else if (opt_id == 3) {
		document.getElementById("chk_"+name+"_1_id").checked = false; digit_1 = "0";
		document.getElementById("chk_"+name+"_2_id").checked = false; digit_2 = "0";
		digit_3 = (currID.checked) ? "1" : "0";
	}
	document.getElementById("hid_rad_"+name+"_id").value = digit_1 + digit_2 + digit_3 + digit_4;
}

function fbCheck(name,opt_id,total) { // ,extra
	var temp = document.getElementsByName("chk_"+name);
	var tempID = document.getElementById("hid_rad_"+name+"_id");
	
	if (tempID.value == "") {
		var chkArr = new Array();
		chkArr.length = total;
	} else {
		var chkArr = (tempID.value).split("@");
	}
	
/**	var curOld = document.getElementById("chk_old_"+name+"_"+opt_id+"_id");
	var oldTemp = (curOld == undefined) ? "" : curOld.value;
	var currID = document.getElementById("chk_"+name+"_"+opt_id+"_id"); **/

	 // Options array
	//	if ((tempID.value)=="") { chkArr.pop(); }
	
	var combinefb = new Array();

//	if (oldTemp == "") {
	for (var oli=0;oli<total;oli++) {
		if (oli == opt_id) {
			combinefb[oli] = document.getElementById("chk_"+name+"_"+oli+"_id").value;
		} else {
			combinefb[oli] = chkArr[oli]; // document.getElementById("chk_"+name+"_"+oli+"_id").value;
		}
	//	alert(document.getElementById("chk_old_"+name+"_"+oli+"_id").value);
	}
//	}
	
	document.getElementById("hid_rad_"+name+"_id").value = combinefb.join("@");
}

// Check box count and warning
// If quota is omitted, user can select up to all of the options provided.
function mcCheck(name,criteria,quota,opt_id) { // ,extra
	var temp = document.getElementsByName("chk_"+name);
	//var oeMC = "";
	
	var currID = document.getElementById("chk_"+name+"_"+opt_id+"_id");
	var curOld = document.getElementById("chk_old_"+name+"_"+opt_id+"_id");
	var oldTemp = (curOld == undefined) ? "" : curOld.value;
	var tempID = document.getElementById("hid_rad_"+name+"_id");
	var chkArr = (tempID.value).split("@"); // Options array
	if ((tempID.value)=="") { chkArr.pop(); }
	//if (extra == "openEn") { var tempOE = document.getElementById("chk_oe_"+name+"_"+opt_id+"_id"); oeMC = "~" + tempOE.value; }
	if (oldTemp != "") {
		for (var oli=0;oli<chkArr.length;oli++) {
			if (chkArr[oli] == oldTemp) {
				chkArr.splice(oli,1);
				break;
			}
		}
	}
	// check/ uncheck
	var checkThis = chkArr.in_array((currID.value)); // +oeMC
	if (quota == 1) {
		if (tempID.value == (currID.value)) { // +oeMC
			currID.checked=false;
			tempID.value = "";
		} else {
			for(var ci=0;ci<temp.length;ci++) {
				if (temp[ci].value == (tempID.value)) { temp[ci].checked = false; break; }
			}
			tempID.value = currID.value; // +oeMC
		}
	} else {
		if (checkThis != -1) {
			chkArr.splice(checkThis,1);
			tempID.value = chkArr.join("@");
		} else {
			if (quota == "") { // select up to as many of provided options 
				chkArr.push((currID.value)); tempID.value = chkArr.join("@"); // +oeMC
			} else if (criteria == "=") { // select EXACTLY # many options
				if (chkArr.length == quota) { currID.checked=false; alert("Please choose ONLY " + quota + " options"); }
				else { chkArr.push((currID.value)); tempID.value = chkArr.join("@"); } // +oeMC
			} else if (criteria == "<") { // select UP TO # many options
				if (chkArr.length == quota) { currID.checked=false; alert("You cannot choose more than " + quota + " options"); }
				else { chkArr.push((currID.value)); tempID.value = chkArr.join("@"); } // +oeMC
			}
		}
	}
	//if (extra == "openEn") { document.getElementById("chk_oe_"+name+"_"+opt_id+"_id").focus(); }
}

function chooseAction(cla,inp) {
	if (document.getElementById("classSession_id")) { document.getElementById("classSession_id").value = cla; }
	if (document.getElementById("inputSession_id")) { document.getElementById("inputSession_id").value = inp; }
	document.sessionUpdate.submit();
}

function deleteAction(cla,inp,cln) {
	var answer = false;
	
	var txt = "Do you really want to delete Class "+cln+"?\nThis will permanently delete any further access to the survey for this class.";
	answer = confirm(txt);
	
	if (answer) {
		if (document.getElementById("deleteSession_id")) { document.getElementById("deleteSession_id").value = cla; }
		if (document.getElementById("inputDelSession_id")) { document.getElementById("inputDelSession_id").value = inp; }	
		document.sessionDelete.submit();
	}
}

function back_submit(section) {
	var temp = document.getElementById("fn_area_id").value;
	if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 1"@" AND ws_survey_content.area ="Section 2"@'+temp; } // from 2 to 1
	else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 2"@" AND ws_survey_content.area ="Section 2A"@'+temp; } // from 2A to 2
	else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 2"@" AND ws_survey_content.area ="Section 2A"@" AND ws_survey_content.area ="Section 3"@'+temp; } // from 3 to 2A
	else if (section == 5) {
		document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 3"@" AND ws_survey_content.area ="Section 4"@'+temp;
		document.getElementById("fn_complete_id").value = "false";
	} // from 4 to 3
}

function backSub(survey,section) {
	var temp = document.getElementById("fn_area_id").value;
	if (survey == "ws005") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="About Me"@" AND ws_survey_content.area ="Page 1"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Page 1"@" AND ws_survey_content.area ="Page 2"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Page 2"@" AND ws_survey_content.area ="Page 3"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Page 3"@" AND ws_survey_content.area ="Page 4"@'+temp; } // from 3 to 2
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Page 4"@" AND ws_survey_content.area ="Reading and me"@'+temp; } // from 3 to 2
		else if (section == 7) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Reading and me"@" AND ws_survey_content.area ="More about me"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	} else if (survey == "ws007") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="About Me"@" AND ws_survey_content.area ="This section is about YOU and SCHOOL"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about YOU and SCHOOL"@" AND ws_survey_content.area ="This section is about people WORKING TOGETHER at school"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about people WORKING TOGETHER at school"@" AND ws_survey_content.area ="This section is about TEACHERS and things that happen in your classes"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about TEACHERS and things that happen in your classes"@" AND ws_survey_content.area ="This section is about what you are TAUGHT at school"@'+temp; } // from 4 to 3
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about what you are TAUGHT at school"@" AND ws_survey_content.area ="This section is about the OTHER STUDENTS at your school"@'+temp; } // from 5 to 4
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about the OTHER STUDENTS at your school"@" AND ws_survey_content.area ="This section is about YOU"@'+temp; } // from 6 to 5
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about YOU"@" AND ws_survey_content.area ="This section is about things that happen OUTSIDE school"@'+temp; } // from 7 to 6
		else if (section == 9) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about things that happen OUTSIDE school"@" AND ws_survey_content.area ="This section is about HOW OFTEN some behaviours happen at school"'; // empty temp
			document.getElementById("review_id").value = "";
		}
		
		/** // Pilot's section setting
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="About Me"@" AND ws_survey_content.area ="This section is about what happens at school"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about what happens at school"@" AND ws_survey_content.area ="This section is about people working together at school"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about people working together at school"@" AND ws_survey_content.area ="This section is about teachers"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about teachers"@" AND ws_survey_content.area ="This section is about things that happen OUTSIDE school"@'+temp; } // from 4 to 3
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about things that happen OUTSIDE school"@" AND ws_survey_content.area ="This section is about what you are TAUGHT at school"@'+temp; } // from 5 to 4
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about what you are TAUGHT at school"@" AND ws_survey_content.area ="This section is about YOU"@'+temp; } // from 6 to 5
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about YOU"@" AND ws_survey_content.area ="This section is about HOW OFTEN some behaviours happen at school"@'+temp; } // from 7 to 6
		else if (section == 9) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about HOW OFTEN some behaviours happen at school"@" AND ws_survey_content.area ="This section is about HOW OFTEN students help each other"'; // empty temp
			document.getElementById("review_id").value = "";
		}
		**/
	} else if (survey == "ws008") { // eventually can be merged with ws007 after the "about teachers and things happen in classes" section are renamed
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="About Me"@" AND ws_survey_content.area ="This section is about YOU and SCHOOL"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about YOU and SCHOOL"@" AND ws_survey_content.area ="This section is about people WORKING TOGETHER at school"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about people WORKING TOGETHER at school"@" AND ws_survey_content.area ="This section is about TEACHERS"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about TEACHERS"@" AND ws_survey_content.area ="This section is about what you are TAUGHT at school"@'+temp; } // from 4 to 3
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about what you are TAUGHT at school"@" AND ws_survey_content.area ="This section is about the OTHER STUDENTS at your school"@'+temp; } // from 5 to 4
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about the OTHER STUDENTS at your school"@" AND ws_survey_content.area ="This section is about YOU"@'+temp; } // from 6 to 5
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about YOU"@" AND ws_survey_content.area ="This section is about things that happen OUTSIDE school"@'+temp; } // from 7 to 6
		else if (section == 9) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="This section is about things that happen OUTSIDE school"@" AND ws_survey_content.area ="This section is about HOW OFTEN some behaviours happen at school"'; // empty temp
			document.getElementById("review_id").value = "";
		}
	} else if (survey == "ws009") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (A)"@" AND ws_survey_content.area ="Safe and caring schools (B)"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (B)"@" AND ws_survey_content.area ="Safe and caring schools (C)"@'+temp; } // from 7 to 6
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (C)"@" AND ws_survey_content.area ="Safe and caring schools (D)"@'+temp; } // from 7 to 6
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (D)"@" AND ws_survey_content.area ="Safe and caring schools (E)"@'+temp; } // from 7 to 6
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (E)"@" AND ws_survey_content.area ="Safe and caring schools (F)"@'+temp; } // from 7 to 6
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (F)"@" AND ws_survey_content.area ="Safe and caring schools (G)"@'+temp; } // from 7 to 6
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (G)"@" AND ws_survey_content.area ="Safe and caring schools (H)"@'+temp; } // from 7 to 6
		else if (section == 9) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring schools (H)"@" AND ws_survey_content.area ="Safe and caring classrooms (A)"@'+temp; } // from 7 to 6
		else if (section == 10) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring classrooms (A)"@" AND ws_survey_content.area ="Safe and caring classrooms (B)"@'+temp; } // from 7 to 6
		else if (section == 11) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring classrooms (B)"@" AND ws_survey_content.area ="Safe and caring classrooms (C)"@'+temp; } // from 7 to 6
		else if (section == 12) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring classrooms (C)"@" AND ws_survey_content.area ="Safe and caring students (A)"@'+temp; } // from 7 to 6
		else if (section == 13) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring students (A)"@" AND ws_survey_content.area ="Safe and caring students (B)"@'+temp; } // from 7 to 6
		else if (section == 14) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring students (B)"@" AND ws_survey_content.area ="Safe and caring community connections (A)"@'+temp; } // from 7 to 6
		else if (section == 15) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Safe and caring community connections (A)"@" AND ws_survey_content.area ="Safe and caring community connections (B)"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	} else if (survey == "el001") { // Principal survey
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="My Pedagogical Leadership Context"@" AND ws_survey_content.area ="Leadership through Goal Setting"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Goal Setting"@" AND ws_survey_content.area ="Leadership through Strategic Resourcing"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Strategic Resourcing"@" AND ws_survey_content.area ="Leadership through Ensuring Curriculum Quality"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring Curriculum Quality"@" AND ws_survey_content.area ="Leadership through Ensuring the Quality of Teaching"@'+temp; } // from 3 to 2
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring the Quality of Teaching"@" AND ws_survey_content.area ="Leadership through Promoting Collaborative Teacher Learning and Development"@'+temp; } // from 3 to 2
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Promoting Collaborative Teacher Learning and Development"@" AND ws_survey_content.area ="Leadership through Ensuring a Safe and Orderly Environment"@'+temp; } // from 3 to 2
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring a Safe and Orderly Environment"@" AND ws_survey_content.area ="Leadership through Ensuring Educationally Powerful Connections with Families, Whanau and Community"@'+temp; } // from 3 to 2
		else if (section == 9) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring Educationally Powerful Connections with Families, Whanau and Community"@" AND ws_survey_content.area ="Effectiveness of Principal Leadership"@'+temp; } // from 3 to 2
		else if (section == 10) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Effectiveness of Principal Leadership"@" AND ws_survey_content.area ="About You"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	} else if (survey == "el002") { // Principal survey
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Goal Setting"@" AND ws_survey_content.area ="Leadership through Strategic Resourcing"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Strategic Resourcing"@" AND ws_survey_content.area ="Leadership through Ensuring Curriculum Quality"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring Curriculum Quality"@" AND ws_survey_content.area ="Leadership through Ensuring the Quality of Teaching"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring the Quality of Teaching"@" AND ws_survey_content.area ="Leadership through Promoting Collaborative Teacher Learning and Development"@'+temp; } // from 3 to 2
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Promoting Collaborative Teacher Learning and Development"@" AND ws_survey_content.area ="Leadership through Ensuring a Safe and Orderly Environment"@'+temp; } // from 3 to 2
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring a Safe and Orderly Environment"@" AND ws_survey_content.area ="Leadership through Ensuring Educationally Powerful Connections with Families, Whanau and Community"@'+temp; } // from 3 to 2
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leadership through Ensuring Educationally Powerful Connections with Families, Whanau and Community"@" AND ws_survey_content.area ="Effectiveness of Principal Leadership"@'+temp; } // from 3 to 2
		else if (section == 9) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Effectiveness of Principal Leadership"@" AND ws_survey_content.area ="Your Teaching Work and Experience"@'+temp; } // from 3 to 2
		else if (section == 10) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Your Teaching Work and Experience"@" AND ws_survey_content.area ="About You"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	} else if (survey == "ws003") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 1"@" AND ws_survey_content.area ="Section 2"@'+temp; } // from 2 to 1
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 2"@" AND ws_survey_content.area ="Section 2A"@'+temp; } // from 2A to 2
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 2"@" AND ws_survey_content.area ="Section 2A"@" AND ws_survey_content.area ="Section 3"@'+temp; } // from 3 to 2A
		else if (section == 5) { // from 4 to 3
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section 3"@" AND ws_survey_content.area ="Section 4"@'+temp;
			document.getElementById("fn_complete_id").value = "false";
		}
	}  else if (survey == "cs001" || survey == "cs002" || survey == "cs003") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="My child"@" AND ws_survey_content.area ="Section A: The school in general"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A: The school in general"@" AND ws_survey_content.area ="Section B: Teaching and learning"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B: Teaching and learning"@" AND ws_survey_content.area ="Section C: Reporting and assessment"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C: Reporting and assessment"@" AND ws_survey_content.area ="Section D: Catering to the needs of 11 - 13 year olds"@'+temp; } // from 3 to 2
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section D: Catering to the needs of 11 - 13 year olds"@" AND ws_survey_content.area ="Section E: Communication and participation"@'+temp; } // from 3 to 2
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section E: Communication and participation"@" AND ws_survey_content.area ="Section F: The school programme"@'+temp; } // from 3 to 2
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section F: The school programme"@" AND ws_survey_content.area ="Section G: Your comments"@'+temp; } // from 3 to 2
		else if (section == 9) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section G: Your comments"@" AND ws_survey_content.area ="Section H: Contact details"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "et001") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Adequacy of resourcing"@" AND ws_survey_content.area ="ORRS funded students"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="ORRS funded students"@" AND ws_survey_content.area ="Staffing and career paths"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Staffing and career paths"@" AND ws_survey_content.area ="NCEA"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="NCEA"@" AND ws_survey_content.area ="Government agencies"@'+temp; } // from 3 to 2
		else if (section == 6) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Government agencies"@" AND ws_survey_content.area ="Personal details"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "bc001") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Background Information"@" AND ws_survey_content.area ="Part A: Clustering"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Part A: Clustering"@" AND ws_survey_content.area ="Part B: Cluster Theory for Improvement"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Part B: Cluster Theory for Improvement"@" AND ws_survey_content.area ="Part C: Professional Learning - Leadership"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Part C: Professional Learning - Leadership"@" AND ws_survey_content.area ="Part D: Professional Learning - Teachers"@'+temp; } // from 3 to 2
		else if (section == 6) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Part D: Professional Learning - Teachers"@" AND ws_survey_content.area ="Part E: Maori Medium Education"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "pe001") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Background Information"@" AND ws_survey_content.area ="General Study Information"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="General Study Information"@" AND ws_survey_content.area ="Choice of Course, Institution, and Career"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Choice of Course, Institution, and Career"@" AND ws_survey_content.area ="Choice of Course, Institution, and Career - Continued"@'+temp; } // from 3 to 2
		else if (section == 5) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Choice of Course, Institution, and Career - Continued"@" AND ws_survey_content.area ="Prize Draw"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 4 to 3  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "cl020") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="About You - A"@" AND ws_survey_content.area ="About You - B"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="About You - B"@" AND ws_survey_content.area ="Your Learning"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Your Learning"@" AND ws_survey_content.area ="Relationships with Friends"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Relationships with Friends"@" AND ws_survey_content.area ="Relationships with Family"@'+temp; } // from 4 to 3
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Relationships with Family"@" AND ws_survey_content.area ="Leaving School"@'+temp; } // from 5 to 4
		else if (section == 7) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Leaving School"@" AND ws_survey_content.area ="Current Situation"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 6 to 5  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "cl120") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A1 - Activities since leaving school (Ask everyone)"@" AND ws_survey_content.area ="Section A2 - Activities since leaving school (Ask everyone)"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A2 - Activities since leaving school (Ask everyone)"@" AND ws_survey_content.area ="Section A3 - Activities since leaving school (Ask everyone)"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A3 - Activities since leaving school (Ask everyone)"@" AND ws_survey_content.area ="Section A4 - Activities since leaving school (Ask everyone)"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A4 - Activities since leaving school (Ask everyone)"@" AND ws_survey_content.area ="Section A5 - Activities since leaving school (Ask everyone)"@'+temp; }
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A5 - Activities since leaving school (Ask everyone)"@" AND ws_survey_content.area ="Section A6 - Activities since leaving school (Ask everyone)"@'+temp; }
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A6 - Activities since leaving school (Ask everyone)"@" AND ws_survey_content.area ="Section B1 - Those who are studying now"@'+temp; }
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B1 - Those who are studying now"@" AND ws_survey_content.area ="Section B2 - Those who are studying now"@'+temp; }
		else if (section == 9) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B2 - Those who are studying now"@" AND ws_survey_content.area ="Section B3 - Those who are studying now"@'+temp; }
		else if (section == 10) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B3 - Those who are studying now"@" AND ws_survey_content.area ="Section B4 - Those who are studying now"@'+temp; }
		else if (section == 11) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B4 - Those who are studying now"@" AND ws_survey_content.area ="Section B5 - Those who are studying now"@'+temp; }
		else if (section == 12) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B5 - Those who are studying now"@" AND ws_survey_content.area ="Section C - Anyone who studied after school"@'+temp; }
		else if (section == 13) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C - Anyone who studied after school"@" AND ws_survey_content.area ="Section D - Those who changed main course of study AND are studying now"@'+temp; }
		else if (section == 14) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section D - Those who changed main course of study AND are studying now"@" AND ws_survey_content.area ="Section E1 - Those who left a course without the completing qualification AND are not studying now"@'+temp; }
		else if (section == 15) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section E1 - Those who left a course without the completing qualification AND are not studying now"@" AND ws_survey_content.area ="Section E2 - Those who left a course without the completing qualification AND are not studying now"@'+temp; }
		else if (section == 16) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section E2 - Those who left a course without the completing qualification AND are not studying now"@" AND ws_survey_content.area ="Section E3 - Those who left a course without the completing qualification AND are not studying now"@'+temp; }
		else if (section == 17) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section E3 - Those who left a course without the completing qualification AND are not studying now"@" AND ws_survey_content.area ="Section F1 - Those who gained a qualification"@'+temp; }
		else if (section == 18) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section F1 - Those who gained a qualification"@" AND ws_survey_content.area ="Section F2 - Those who gained a qualification"@'+temp; }
		else if (section == 19) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section F2 - Those who gained a qualification"@" AND ws_survey_content.area ="Section F3 - Those who gained a qualification"@'+temp; }
		else if (section == 20) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section F3 - Those who gained a qualification"@" AND ws_survey_content.area ="Section G - Qualifications (Ask everyone)"@'+temp; }
		else if (section == 21) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section G - Qualifications (Ask everyone)"@" AND ws_survey_content.area ="Section H1 - Those who are working now"@'+temp; }
		else if (section == 22) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section H1 - Those who are working now"@" AND ws_survey_content.area ="Section H2 - Those who are working now"@'+temp; }
		else if (section == 23) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section H2 - Those who are working now"@" AND ws_survey_content.area ="Section H3 - Those who are working now"@'+temp; }
		else if (section == 24) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section H3 - Those who are working now"@" AND ws_survey_content.area ="Section H4 - Those who are working now"@'+temp; }
		else if (section == 25) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section H4 - Those who are working now"@" AND ws_survey_content.area ="Section I1 - Anyone who worked since leaving school"@'+temp; }
		else if (section == 26) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section I1 - Anyone who worked since leaving school"@" AND ws_survey_content.area ="Section I2 - Anyone who worked since leaving school"@'+temp; }
		else if (section == 27) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section I2 - Anyone who worked since leaving school"@" AND ws_survey_content.area ="Section I3 - Attitudes towards work (ask everyone)"@'+temp; }
		else if (section == 28) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section I3 - Attitudes towards work (ask everyone)"@" AND ws_survey_content.area ="Section J1 - Individual (Ask everyone)"@'+temp; }
		else if (section == 29) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section J1 - Individual (Ask everyone)"@" AND ws_survey_content.area ="Section J2 - Individual (Ask everyone)"@'+temp; }
		else if (section == 30) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section J2 - Individual (Ask everyone)"@" AND ws_survey_content.area ="Section K - Living arrangements (Ask everyone)"@'+temp; }
		else if (section == 31) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section K - Living arrangements (Ask everyone)"@" AND ws_survey_content.area ="Section L1 - Financial (Ask everyone)"@'+temp; }
		else if (section == 32) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section L1 - Financial (Ask everyone)"@" AND ws_survey_content.area ="Section L2 - Financial (Ask everyone)"@'+temp; }
		else if (section == 33) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section L2 - Financial (Ask everyone)"@" AND ws_survey_content.area ="Section M - News sources (Ask everyone)"@'+temp; }
		else if (section == 34) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section M - News sources (Ask everyone)"@" AND ws_survey_content.area ="Section N - Citizenship (Ask everyone)"@'+temp; }
		else if (section == 35) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section N - Citizenship (Ask everyone)"@" AND ws_survey_content.area ="Section O1 - Reflections, decisions and goals (Ask everyone)"@'+temp; }
		else if (section == 36) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section O1 - Reflections, decisions and goals (Ask everyone)"@" AND ws_survey_content.area ="Section O2 - Reflections, decisions and goals (Ask everyone)"@'+temp; }
		else if (section == 37) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section O2 - Reflections, decisions and goals (Ask everyone)"@" AND ws_survey_content.area ="Section P - Completed by interviewers only"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 6 to 5  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "vc001") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section A - About you"@" AND ws_survey_content.area ="Section B - Your VC class"@'+temp; } // from 1 to About Me
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section B - Your VC class"@" AND ws_survey_content.area ="Section C1 - Your VC class and your face-to-face classes"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C1 - Your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section C2 - Your VC class and your face-to-face classes"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C2 - Your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section C3 - Your VC class and your face-to-face classes"@'+temp; } // from 3 to 2
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C3 - Your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section C4 - Your VC class and your face-to-face classes"@'+temp; } // from 3 to 2
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C4 - Your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section C5 - Your VC class and your face-to-face classes"@'+temp; } // from 3 to 2
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C5 - Your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section C6 - Your VC class and your face-to-face classes"@'+temp; } // from 3 to 2
		else if (section == 9) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section C6 - Your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section D - Comparison of your VC class and your face-to-face classes"@'+temp; } // from 3 to 2
		else if (section == 10) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section D - Comparison of your VC class and your face-to-face classes"@" AND ws_survey_content.area ="Section E - Your overall views of school"@'+temp; } // from 3 to 2
		else if (section == 11) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Section E - Your overall views of school"@" AND ws_survey_content.area ="Prize Draw"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 6 to 5  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "ws001") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Demographic information"@" AND ws_survey_content.area ="Physical working environment and resources"@'+temp; } // from 2 to 1
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Physical working environment and resources"@" AND ws_survey_content.area ="Satisfaction with school"@'+temp; } // from 2 to 1
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Satisfaction with school"@" AND ws_survey_content.area ="School leadership"@'+temp; } // from 3 to 2
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="School leadership"@" AND ws_survey_content.area ="Professional development"@'+temp; } // from 4 to 3
		else if (section == 6) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Professional development"@" AND ws_survey_content.area ="School organisation"'; // empty temp
			document.getElementById("review_id").value = "";
		}
		// Custom Survey
		else if (section == 16) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Professional development"@" AND ws_survey_content.area ="School organisation"@'+temp; } // from 4 to 3
		else if (section == 17) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="School organisation"@" AND ws_survey_content.area ="Custom"'; // empty temp
			document.getElementById("review_id").value = "";
		}
		
		 // from 5 to 4  // document.getElementById("fn_complete_id").value = "false";
	}  else if (survey == "ee004") {
		if (section == 2) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="Confidential information"@" AND ws_survey_content.area ="A. Your involvement in E4E partnership(s)"@'+temp; } // from 2 to 1
		else if (section == 3) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="A. Your involvement in E4E partnership(s)"@" AND ws_survey_content.area ="B. Your involvement with students"@'+temp; } // from 3 to 2
		else if (section == 4) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="B. Your involvement with students"@" AND ws_survey_content.area ="C. Impacts and outcomes for students"@'+temp; } // from 4 to 3
		else if (section == 5) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="C. Impacts and outcomes for students"@" AND ws_survey_content.area ="D. Impacts and outcomes of your organisation~s involvement in E4E"@'+temp; } // from 5 to 4
		else if (section == 6) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="D. Impacts and outcomes of your organisation~s involvement in E4E"@" AND ws_survey_content.area ="E. Challenges"@'+temp; } // from 6 to 5
		else if (section == 7) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="E. Challenges"@" AND ws_survey_content.area ="F. Regional E4E Coordination"@'+temp; } // from 7 to 6
		else if (section == 8) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="F. Regional E4E Coordination"@" AND ws_survey_content.area ="G. Looking ahead"@'+temp; } // from 8 to 7
		else if (section == 9) { document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="G. Looking ahead"@" AND ws_survey_content.area ="H. Details about you and your organisation/business"@'+temp; } // from 9 to 8
		else if (section == 10) {
			document.getElementById("fn_area_id").value ='" AND ws_survey_content.area ="H. Details about you and your organisation/business"@" AND ws_survey_content.area ="I. Anything else"'; // empty temp
			document.getElementById("review_id").value = "";
		} // from 10 to 9  // document.getElementById("fn_complete_id").value = "false";
	}
}

/** Finally string update before submittion
  * resp_str: responses from DB
  **/
function combineSub(resp_str) {
	// indMap str: current q_id list in form of #_#_#_# (delimited by _)
	//return true;	
	if (document.getElementById("fn_complete_id") && document.getElementById("fn_complete_id").value == "true") {
		return confirmSub(); 
	} else {
		var indMap = document.getElementById("indexMap_id").value;
		var indArr = indMap.split("_"); // index array - index of current survey area
		var RepArr = resp_str.split("_"); // response str array
		
		for (var i=0;i<indArr.length;i++) {
			RepArr[(indArr[i]-1)] = (document.getElementById("hid_rad_"+indArr[i]+"_id").value).replace(/_/g, "&&&");
		}
		// Warning for multiple responses
		var newRep_str = RepArr.join("_") + "#" + (document.getElementById("cur_q_num_id").value);
		document.getElementById("sur_response_id").value = newRep_str; // response str for submit
		//if (document.getElementById("fn_complete_id")) { document.getElementById("fn_complete_id").value = false; }
		
		if (getCookie("suy_id") == "ws005" && RepArr[1] == "" && getCookie("suy_schl_id") != 777) {
			alert("Please choose your year level.");
			return false;
		} else {
			return true;
		}
		
	}
}

// Confirmation before final Submittion
function confirmSub() {
	var answer = confirm("You cannot change your responses after this.\nDo you want to proceed?");
	if (answer) { return true; } else { return false; }
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function confMAcc() {
	var error = ""; var temp = "";
	if (isNaN(parseInt(document.getElementById("f_Dmonth_id").value))) { error = error + "Please use a valid number for the month (e.g., 5)\n"; }
	if (parseInt(document.getElementById("f_Dmonth_id").value,10) < 1 || parseInt(document.getElementById("f_Dmonth_id").value,10) > 12) { error = error + "Please use a number between 1 to 12 for the month\n"; }
	if (isNaN(parseInt(document.getElementById("f_Dday_id").value))) { error = error + "Please use a valid number for the day of month (e.g., 21)\n"; }
	if (parseInt(document.getElementById("f_Dday_id").value,10) < 1 || parseInt(document.getElementById("f_Dday_id").value,10) > 31) { error = error + "Please use a number between 1 to 31 for the day of month\n"; }
	if (error != "") { alert(error); return false; }
	else { return true; }
}

function calDatePopluate() {
	var selDate = (document.getElementById("calDate_id").value).split("-");
	document.getElementById("f_Dmonth_id").value = selDate[1];
	document.getElementById("f_Dday_id").value = selDate[2];
}

// Define in_array
Array.prototype.in_array = function(search_term) {
  var i = this.length;
  if (i > 0) {
	 do {
		if (this[i] === search_term) {
		   return i;
		}
	 } while (i--);
  }
  return -1;
}

function validateEmail() {
	var error = "";
	if ((document.getElementById("emailaddress_id").value).length > 60) { error = error + "Email address cannot be more than 60 characters.\n"; }
	if ((document.getElementById("emailaddress_id").value).indexOf("@") < 0) { error = error + "Invalid email address.\n"; }
	if (error != "") { alert(error); return false; }
	else { return true; }
}

function validateLogin() {
	var error = "";
	if (!checkSchlCode()) { error = error + "&#149; Please re-enter your school password.<br>"; }
	if ((document.getElementById("schlCode_id").value).length > 5) { error = error + "&#149; Please enter your school code again.<br>"; }
	if ((document.getElementById("emailaddress_id").value).length > 60) { error = error + "&#149; Email address cannot be more than 60 characters.<br>"; }
	if ((document.getElementById("emailaddress_id").value).indexOf("@") < 0) { error = error + "&#149; Invalid email address.<br>"; }
	if (document.getElementById("emailaddress_2_id").value != document.getElementById("emailaddress_id").value) { error = error + "&#149; The email and confirm email do not match. Please enter again.<br>"; }
	if (document.getElementById("ppl_pwd_id").value == "") { error = error + "&#149; A personal password is required.<br>"; }
	if (document.getElementById("ppl_pwd_2_id").value != document.getElementById("ppl_pwd_id").value) { error = error + "&#149; The personal password and confirm personal password do not match.<br>"; }
	if (error != "") { 
		document.getElementById("error_id").innerHTML = "<table border='1' cellpadding='4' cellspacing='0' width='350' style='border-color:#CF2623;border-collapse: collapse;' bgcolor='#F0EFE2'><tr><td><font style='color: #FF0000;'><b>"+error+"</b></font></td></tr></table>";
		return false; 
	}
	else {
		document.getElementById("error_id").innerHTML = "<font style='color: #FF0000;'>Please note that the survey is confidential. Your email address will<br>remain private and cannot be connected to your survey responses.</font>";
		return true;
	}
}

function displaySchlName() {
	var error = "";
	
//	schoolList = [":2226:Ramanui School",":2454:St Mary's School (Wanganui)",":1679:Rahotu School",":2650:Poukawa School",":2220:Pembroke School",":2403:Mosston School",":2410:Ohakune School",":2198:Midhirst School",":2197:Merrilands School",":2165:Eltham School",":2171:Hawera Primary School",":2551:Crownthorpe School",":2334:Arahunga School",":2546:Bledisloe School",":2248:Tawhiti School",":2691:Te Awa School",":2255:Turuturu School",":2256:Urenui School",":2480:Westmere School (Wanganui)",":2267:Whareorino School",":1000:Ahipara School",":1303:Harrisville School",":1022:Kaikohe Intermediate",":3:Kaitaia College",":1827:Miller Avenue School",":9:Northland College",":1059:Okaihau School",":1405:Orere School",":1065:Oromahoe School",":113:Paeroa College",":1073:Pakaraka School",":2054:Waikino School",":2079:Whakamarama School",":428:Whangamata Area School",":2418:Central Normal School",":1172:Cornerstone Christian School",":2358:Foxton Beach School",":2364:Hiwinui School",":4111:Huntley School",":2378:Keith Street School",":2397:Marton School",":2416:Our Lady of Lourdes School (P North)",":2945:Pahiatua School",":2419:Palmerston North Intermediate",":2424:Parkland School (P North)",":2669:Ruahine School",":2451:St Joseph's School (Feilding)",":2460:Takaro School",":2477:Wanganui Intermediate",":399:Central Southland College",":3724:Clutha Valley School",":3749:Heriot",":3973:Knapdale School",":3795:Outram School",":3808:Ravensbourne School",":3812:Rosebank School (Balclutha)",":1657:Silverstream (South) Primary School",":405:Southland Girls College",":3829:St Leonard's School (Dunedin)",":3836:Stirling School",":3837:Strath Taieri School",":2351:Te Kura Kaupapa Maori O Otepoti",":4027:Te Tipua School",":3864:Weston School",":3271:Addington School",":3324:Cotswold School",":3352:Glentunnel School",":3379:Hoon Hay School",":3415:Linwood North School",":3419:Loburn School",":3445:New Brighton Catholic School (Chch)",":3450:Oaklands School",":3451:Ohoka School",":3480:Rakaia School",":3483:Redcliffs School",":3509:Southbridge School",":3510:Southbrook School",":3512:Spreydon School",":3515:Springfield School",":3531:St Joseph's School (Papanui)",":4135:St Mark's School (Christchurch)",":3540:St Patrick's School (Kaiapoi)",":3543:St Teresa's School (Riccarton)",":3600:Woodend School",":159:Forest View High School",":165:Rangitahi College",":151:Western Heights High School",":1680:Aberdeen School",":2544:Awapuni School (Gisborne)",":1693:Bankwood School",":1700:Cambridge East School",":2550:Cobham School",":1708:David Henry School",":2562:Frasertown School",":1724:Glenholme School",":132:Hamilton Girls' High School",":2706:Hatea-A-Rangi",":112:Hauraki Plains College",":1736:Hauturu School",":1739:Hillcrest Normal School",":1751:Huntly School",":1753:Insoll Avenue School",":1788:Lake Rotoma School",":2595:Makauri School",":1798:Manaia School (Thames)",":2597:Mangapapa School",":1808:Marotiri School",":124:Matamata College",":1812:Matamata Intermediate",":1823:Melville Intermediate",":1824:Melville Primary School",":1825:Merivale School",":1677:Mohaka School",":1844:Ngahinapouri School",":1850:Ngatea School",":2624:Nuhaka School",":1855:Ohaupo School",":1879:Otumoetai School",":1883:Paeroa Central School",":1907:Puketaha School",":1933:Rotorua Intermediate School",":6976:Rototuna Primary School",":4125:South City Christian School",":1946:St Joseph's Catholic School (Fairfield)",":1953:St Joseph's Catholic School (Te Kuiti)",":1958:St Mary's Catholic School (Rotorua)",":1959:St Mary's Catholic School (Tauranga)",":1636:St Thomas More Catholic School",":1968:Strathmore School",":6742:Tahatai Coast School",":1989:Taupo School",":2001:Te Awamutu Intermediate School",":115:Te Kauwhata College",":3119:Te KKM o Kawakawa mai Tawhiti",":1971:Te Kura o Tahaaroa",":2047:Te Kura O Waharoa",":2017:Te Puna School",":577:Te Totara Primary School",":2701:Te Wharau School",":1589:TKKM O Toku Mapihi Maurea",":2046:Waerenga School",":2065:Waipahihi School",":1668:Wairoa Primary School",":2077:Westbrook School",":2093:Woodstock School",":1201:Aka Aka School",":6948:Albany Junior High School",":1202:Albany Primary School",":1204:Anchorage Park School",":1206:Arahoe School",":61:Baradene College",":1224:Beachlands School",":1244:Chelsea School",":1254:Colwill School",":1255:Conifer Grove School",":1655:Destiny School",":79:Edgewater College",":64:Epsom Girls' Grammar School",":1276:Flanshaw Road School",":1284:Glen Eden Intermediate",":1285:Glen Eden School",":1289:Glen Taylor School",":1293:Glendene School",":65:Glendowie College",":1294:Glendowie School",":30:Glenfield College",":1297:Good Shepherd School (Balmoral)",":1300:Greenmeadows Intermediate",":6920:Gulf Harbour School",":1307:Henderson Intermediate",":1313:Hillsborough School",":1018:Hurupaki School",":13:Kamo High School",":83:Kelston Boys",":84:Kelston Girls' College",":1331:Kelston School",":46:Liston College",":1388:Macleans Primary School",":1347:Mangere Central School",":1348:Mangere East School",":1350:Manuka Primary School",":1360:Marist Catholic School (Herne Bay)",":70:Marist College",":43:Massey High School",":1042:Matakohe School",":1370:Meadowbank School",":424:Michael Park School",":1391:Newmarket School",":1394:Northcote Intermediate",":1074:Pakiri School",":80:Pakuranga College",":1421:Papakura Central School",":95:Papatoetoe High School",":1430:Papatoetoe South School",":1435:Parkside School",":1436:Parnell School",":1447:Prospect School",":103:Pukekohe High School",":1453:Pukekohe North School",":6944:Randwick Park School",":1476:Royal Road School",":1479:Sandspit Road School",":1482:Silverdale School",":1215:Sir Douglas Bader Intermediate School",":8889:Southern Cross College",":8888:Southern Cross Junior School",":47:St Dominic's College (Henderson)",":1488:St Francis School (Pt.Chevalier)",":50:St Mary's College (Ponsonby)",":1518:Sunnynook School",":1524:Takapuna Normal Intermediate",":58:Tangaroa College",":1111:Te Kopuru School",":1113:Tikipunga Primary School",":1537:Titirangi School",":1115:Tomarata School",":4151:Waitakere S D A School",":1557:Waitakere School",":1559:Waiuku Primary School",":1562:Waterlea Public School",":1568:Westmere School (Auckland)",":1569:Weymouth Intermediate",":6763:Whangaparaoa College",":1571:Whangaparaoa School (Auckland)",":15:Whangarei Boys' High School",":16:Whangarei Girls' High School",":1129:Whangarei Intermediate",":1580:Yendarra School",":1195:Adventure School",":2806:Bellevue School (Newlands)",":2813:Boulcott School",":2827:Clyde Quay School",":2832:Discovery School",":2833:Dyer Street School",":2861:Houghton Valley School",":2876:Kelburn Normal School",":2887:Levin Intermediate",":2899:Mangaroa School",":2915:Miramar Central School",":2931:Northland School",":2957:Pinehaven School",":2999:St Anthony's School (Seatoun)",":3034:Tawa Intermediate",":3035:Tawa School",":3442:Aoraki Mount Cook School",":3184:Broadgreen Intermediate",":3308:Carew Peel Forest School",":327:Christchurch Boys High School",":290:Collingwood Area School",":3188:Dovedale School",":3335:Fairlie School",":2107:Geraldine Primary School",":343:Marian College",":289:Marlborough Girls' College",":293:Nayland College",":3472:Paroa School (Greymouth)",":3477:Pleasant Point Primary School",":287:Queen Charlotte College",":312:Rangiora High School",":496:Reefton Area School",":2978:Renwick School",":2981:Riverlands School",":3536:St Mary's School (Hokitika)",":1627:St Pauls School (Richmond)",":2109:Temuka Primary School",":326:Villa Maria College",":3573:Waimate Centennial School",":362:Waimate High School",":3192:Granity School",":147:Te Whanau-A-Apanui Area School",":6:Broadwood Area School",":297:Tapawera Area School",":18:Mangakahia Area School",":109:Coromandel Area School",":375:Roxburgh Area School",":2814:Brandon Intermediate",":1329:Kedgley Intermediate",":1942:St Andrew's Middle School (Hamilton)",":1351:Royal Oak Intermediate School",":3731:Dunedin North Intermediate",":2170:Hawera Intermediate",":2687:Taradale Intermediate",":1272:Farm Cove Intermediate",":2335:Aramoho School",":3041:Tinui School",":2868:Kahutara School",":256:Bishop Viard College",":57:Tamaki College",":243:Makoura College",":211:Campion College",":2588:Kowhai School",":1726:Goldfields School (Paeroa)",":4157:Westbridge Residential School",":300:Karamea Area School",":390:Lawrence Area School",":110:Mercury Bay Area School",":527:Twizel Area School",":370:Maniototo Area School",":188:Wanganui Girls' College",":1631:Southern Regional Health School",":1330:Kelston Intermediate",":2440:Ross Intermediate",":2161:Devon Intermediate",":1837:Mt Maunganui Intermediate",":1032:Kaurihohore School",":2333:Apiti School",":51:St Paul's College (Ponsonby)",":1483:Sir Keith Park School",":161:Benneydale School",":3839:Tahuna Normal Intermediate",":1794:Maketu School"];
	
	var decode = (document.getElementById("schlCode_id").value).replace(/v/gi,"0").replace(/f/gi,"1").replace(/j/gi,"2").replace(/y/gi,"3").replace(/c/gi,"4").replace(/x/gi,"5").replace(/k/gi,"6").replace(/m/gi,"7").replace(/q/gi,"8").replace(/s/gi,"9").replace(/h/gi,"").replace(/i/gi,"").replace(/n/gi,"");
	
	var start = schoolList.toString().indexOf(":"+decode+":");
	
	if (start != -1) {
		var rest = schoolList.toString().substring((start+1));
		var arrCode = rest.split(":",2);
		
		document.getElementById("schlshow_id").style.color = "#434141";
		document.getElementById("schlshow_id").innerHTML = (arrCode[1]).replace(",","");
	} else {
		document.getElementById("schlshow_id").innerHTML = "-- Incorrect School code --";
		document.getElementById("schlshow_id").style.color = "#FF0000";
	}
}

function checkSchlCode() {
//	schoolList = [":2226:Ramanui School",":2454:St Mary's School (Wanganui)",":1679:Rahotu School",":2650:Poukawa School",":2220:Pembroke School",":2403:Mosston School",":2410:Ohakune School",":2198:Midhirst School",":2197:Merrilands School",":2165:Eltham School",":2171:Hawera Primary School",":2551:Crownthorpe School",":2334:Arahunga School",":2546:Bledisloe School",":2248:Tawhiti School",":2691:Te Awa School",":2255:Turuturu School",":2256:Urenui School",":2480:Westmere School (Wanganui)",":2267:Whareorino School",":1000:Ahipara School",":1303:Harrisville School",":1022:Kaikohe Intermediate",":3:Kaitaia College",":1827:Miller Avenue School",":9:Northland College",":1059:Okaihau School",":1405:Orere School",":1065:Oromahoe School",":113:Paeroa College",":1073:Pakaraka School",":2054:Waikino School",":2079:Whakamarama School",":428:Whangamata Area School",":2418:Central Normal School",":1172:Cornerstone Christian School",":2358:Foxton Beach School",":2364:Hiwinui School",":4111:Huntley School",":2378:Keith Street School",":2397:Marton School",":2416:Our Lady of Lourdes School (P North)",":2945:Pahiatua School",":2419:Palmerston North Intermediate",":2424:Parkland School (P North)",":2669:Ruahine School",":2451:St Joseph's School (Feilding)",":2460:Takaro School",":2477:Wanganui Intermediate",":399:Central Southland College",":3724:Clutha Valley School",":3749:Heriot",":3973:Knapdale School",":3795:Outram School",":3808:Ravensbourne School",":3812:Rosebank School (Balclutha)",":1657:Silverstream (South) Primary School",":405:Southland Girls College",":3829:St Leonard's School (Dunedin)",":3836:Stirling School",":3837:Strath Taieri School",":2351:Te Kura Kaupapa Maori O Otepoti",":4027:Te Tipua School",":3864:Weston School",":3271:Addington School",":3324:Cotswold School",":3352:Glentunnel School",":3379:Hoon Hay School",":3415:Linwood North School",":3419:Loburn School",":3445:New Brighton Catholic School (Chch)",":3450:Oaklands School",":3451:Ohoka School",":3480:Rakaia School",":3483:Redcliffs School",":3509:Southbridge School",":3510:Southbrook School",":3512:Spreydon School",":3515:Springfield School",":3531:St Joseph's School (Papanui)",":4135:St Mark's School (Christchurch)",":3540:St Patrick's School (Kaiapoi)",":3543:St Teresa's School (Riccarton)",":3600:Woodend School",":159:Forest View High School",":165:Rangitahi College",":151:Western Heights High School",":1680:Aberdeen School",":2544:Awapuni School (Gisborne)",":1693:Bankwood School",":1700:Cambridge East School",":2550:Cobham School",":1708:David Henry School",":2562:Frasertown School",":1724:Glenholme School",":132:Hamilton Girls' High School",":2706:Hatea-A-Rangi",":112:Hauraki Plains College",":1736:Hauturu School",":1739:Hillcrest Normal School",":1751:Huntly School",":1753:Insoll Avenue School",":1788:Lake Rotoma School",":2595:Makauri School",":1798:Manaia School (Thames)",":2597:Mangapapa School",":1808:Marotiri School",":124:Matamata College",":1812:Matamata Intermediate",":1823:Melville Intermediate",":1824:Melville Primary School",":1825:Merivale School",":1677:Mohaka School",":1844:Ngahinapouri School",":1850:Ngatea School",":2624:Nuhaka School",":1855:Ohaupo School",":1879:Otumoetai School",":1883:Paeroa Central School",":1907:Puketaha School",":1933:Rotorua Intermediate School",":6976:Rototuna Primary School",":4125:South City Christian School",":1946:St Joseph's Catholic School (Fairfield)",":1953:St Joseph's Catholic School (Te Kuiti)",":1958:St Mary's Catholic School (Rotorua)",":1959:St Mary's Catholic School (Tauranga)",":1636:St Thomas More Catholic School",":1968:Strathmore School",":6742:Tahatai Coast School",":1989:Taupo School",":2001:Te Awamutu Intermediate School",":115:Te Kauwhata College",":3119:Te KKM o Kawakawa mai Tawhiti",":1971:Te Kura o Tahaaroa",":2047:Te Kura O Waharoa",":2017:Te Puna School",":577:Te Totara Primary School",":2701:Te Wharau School",":1589:TKKM O Toku Mapihi Maurea",":2046:Waerenga School",":2065:Waipahihi School",":1668:Wairoa Primary School",":2077:Westbrook School",":2093:Woodstock School",":1201:Aka Aka School",":6948:Albany Junior High School",":1202:Albany Primary School",":1204:Anchorage Park School",":1206:Arahoe School",":61:Baradene College",":1224:Beachlands School",":1244:Chelsea School",":1254:Colwill School",":1255:Conifer Grove School",":1655:Destiny School",":79:Edgewater College",":64:Epsom Girls' Grammar School",":1276:Flanshaw Road School",":1284:Glen Eden Intermediate",":1285:Glen Eden School",":1289:Glen Taylor School",":1293:Glendene School",":65:Glendowie College",":1294:Glendowie School",":30:Glenfield College",":1297:Good Shepherd School (Balmoral)",":1300:Greenmeadows Intermediate",":6920:Gulf Harbour School",":1307:Henderson Intermediate",":1313:Hillsborough School",":1018:Hurupaki School",":13:Kamo High School",":83:Kelston Boys",":84:Kelston Girls' College",":1331:Kelston School",":46:Liston College",":1388:Macleans Primary School",":1347:Mangere Central School",":1348:Mangere East School",":1350:Manuka Primary School",":1360:Marist Catholic School (Herne Bay)",":70:Marist College",":43:Massey High School",":1042:Matakohe School",":1370:Meadowbank School",":424:Michael Park School",":1391:Newmarket School",":1394:Northcote Intermediate",":1074:Pakiri School",":80:Pakuranga College",":1421:Papakura Central School",":95:Papatoetoe High School",":1430:Papatoetoe South School",":1435:Parkside School",":1436:Parnell School",":1447:Prospect School",":103:Pukekohe High School",":1453:Pukekohe North School",":6944:Randwick Park School",":1476:Royal Road School",":1479:Sandspit Road School",":1482:Silverdale School",":1215:Sir Douglas Bader Intermediate School",":8889:Southern Cross College",":8888:Southern Cross Junior School",":47:St Dominic's College (Henderson)",":1488:St Francis School (Pt.Chevalier)",":50:St Mary's College (Ponsonby)",":1518:Sunnynook School",":1524:Takapuna Normal Intermediate",":58:Tangaroa College",":1111:Te Kopuru School",":1113:Tikipunga Primary School",":1537:Titirangi School",":1115:Tomarata School",":4151:Waitakere S D A School",":1557:Waitakere School",":1559:Waiuku Primary School",":1562:Waterlea Public School",":1568:Westmere School (Auckland)",":1569:Weymouth Intermediate",":6763:Whangaparaoa College",":1571:Whangaparaoa School (Auckland)",":15:Whangarei Boys' High School",":16:Whangarei Girls' High School",":1129:Whangarei Intermediate",":1580:Yendarra School",":1195:Adventure School",":2806:Bellevue School (Newlands)",":2813:Boulcott School",":2827:Clyde Quay School",":2832:Discovery School",":2833:Dyer Street School",":2861:Houghton Valley School",":2876:Kelburn Normal School",":2887:Levin Intermediate",":2899:Mangaroa School",":2915:Miramar Central School",":2931:Northland School",":2957:Pinehaven School",":2999:St Anthony's School (Seatoun)",":3034:Tawa Intermediate",":3035:Tawa School",":3442:Aoraki Mount Cook School",":3184:Broadgreen Intermediate",":3308:Carew Peel Forest School",":327:Christchurch Boys High School",":290:Collingwood Area School",":3188:Dovedale School",":3335:Fairlie School",":2107:Geraldine Primary School",":343:Marian College",":289:Marlborough Girls' College",":293:Nayland College",":3472:Paroa School (Greymouth)",":3477:Pleasant Point Primary School",":287:Queen Charlotte College",":312:Rangiora High School",":496:Reefton Area School",":2978:Renwick School",":2981:Riverlands School",":3536:St Mary's School (Hokitika)",":1627:St Pauls School (Richmond)",":2109:Temuka Primary School",":326:Villa Maria College",":3573:Waimate Centennial School",":362:Waimate High School",":3192:Granity School",":147:Te Whanau-A-Apanui Area School",":6:Broadwood Area School",":297:Tapawera Area School",":18:Mangakahia Area School",":109:Coromandel Area School",":375:Roxburgh Area School",":2814:Brandon Intermediate",":1329:Kedgley Intermediate",":1942:St Andrew's Middle School (Hamilton)",":1351:Royal Oak Intermediate School",":3731:Dunedin North Intermediate",":2170:Hawera Intermediate",":2687:Taradale Intermediate",":1272:Farm Cove Intermediate",":2335:Aramoho School",":3041:Tinui School",":2868:Kahutara School",":256:Bishop Viard College",":57:Tamaki College",":243:Makoura College",":211:Campion College",":2588:Kowhai School",":1726:Goldfields School (Paeroa)",":4157:Westbridge Residential School",":300:Karamea Area School",":390:Lawrence Area School",":110:Mercury Bay Area School",":527:Twizel Area School",":370:Maniototo Area School",":188:Wanganui Girls' College",":1631:Southern Regional Health School",":1330:Kelston Intermediate",":2440:Ross Intermediate",":2161:Devon Intermediate",":1837:Mt Maunganui Intermediate",":1032:Kaurihohore School",":2333:Apiti School",":51:St Paul's College (Ponsonby)",":1483:Sir Keith Park School",":161:Benneydale School",":3839:Tahuna Normal Intermediate",":1794:Maketu School"];
	
	var decode = (document.getElementById("schlCode_id").value).replace(/v/gi,"0").replace(/f/gi,"1").replace(/j/gi,"2").replace(/y/gi,"3").replace(/c/gi,"4").replace(/x/gi,"5").replace(/k/gi,"6").replace(/m/gi,"7").replace(/q/gi,"8").replace(/s/gi,"9").replace(/h/gi,"").replace(/i/gi,"").replace(/n/gi,"");
	var start = schoolList.toString().indexOf(":"+decode+":");
	
	if (start != -1) {
		return true;
	} else {
		return false;
	}
}
// Disable enter key
function disEnterKey(e) {
     var key;
     if (window.event) { key = window.event.keyCode; } //IE
     else { key = e.which; } //Firefox
     if(key == 13) { return false; }
	 else { return true; }  
}

function setRadio(which){
	document.getElementById("e"+which+"_id").checked=true;
}

<!-- Float Key [Star Test] -->
// Detect user browser
var Nav = navigator, Ag = Nav.userAgent;
var bIE = (Ag.indexOf('MSIE') >= 0), bMacIE = false;
var bNC = (navigator.appName == "Netscape");
var bOpera = (Ag.indexOf('Opera') >= 0);
var bChrome = Ag.toLowerCase().indexOf('chrome') >= 0;
var nVer = 0, sTmp = "";
if (bIE) {
	sTmp = Ag.substring(Ag.indexOf("MSIE") + 5, Ag.length);
	nVer = Math.floor(sTmp.substring(0, sTmp.indexOf(";")));
	if (nVer >= 4 && !document.all) { nVer = 0; }
	if (Ag.indexOf("Mac") >= 0) { bMacIE = true; }
}
if (bNC) { nVer = Math.floor(Nav.appVersion.substring(0, Nav.appVersion.indexOf(" ")) ); }

bDynamic = (document.all || document.layers) ? true : false;
	
// Move functions
nMenuYPos = 0; // 103
nYDelta = 0; // 25
nPrevScrollPos = 0;

//alert(document.getElementById("floatingKey").style.top);

function Spy() {
    if (bNC && nVer >= 4) {
		if (window.pageYOffset < (nMenuYPos - nYDelta)) { nNeededPos = nMenuYPos; }
		else { nNeededPos = window.pageYOffset + nYDelta; }

		//	nCurrentPos = document.layers["floatingKey"].top;
		nCurrentPos = parseInt(document.getElementById("floatingKey").style.top,10);
		if (nNeededPos == nCurrentPos) { return; }

		nCurrentPos += Math.round((nNeededPos-nCurrentPos)/4);
		
		//	document.layers["floatingKey"].top = nCurrentPos;
		document.getElementById("floatingKey").style.top = nCurrentPos+"px";
	}

	if (bIE && nVer >= 4 && !bMacIE) {
		if (document.body.scrollTop < (nMenuYPos-nYDelta)) { nNeededPos = nMenuYPos; }
		else { nNeededPos = document.body.scrollTop + nYDelta; }
		nCurrentPos = document.all["floatingKey"].offsetTop;

		if (nNeededPos == nCurrentPos) { return; }

		nDelta = (nNeededPos-nCurrentPos)/6;
		if (nDelta > 0 && nDelta < 0.5) { nCurrentPos += nNeededPos - nCurrentPos; }
		else {
			if (nDelta < 0 && nDelta >= -0.5) { nCurrentPos --; }
			else { nCurrentPos += Math.round (nDelta); }
		}
		pnt = document.all ["floatingKey"].style;
		pnt.top = nCurrentPos;
	}
}

function moveSten(event) {
	if (bNC && nVer >= 4) {
	//	if (window.pageYOffset < (nMenuYPos - nYDelta)) { nNeededPos = nMenuYPos; }
	//	else { nNeededPos = window.pageYOffset + nYDelta; }

		//	nCurrentPos = document.layers["floatingSten"].top;
	//	alert("tesing1.");
		nCurrentPos = parseInt(document.getElementById("floatingSten").style.top,10);
	//	relativePos = parseInt(document.getElementById(("item8_"+id)).style.top,10);
	//	if (nNeededPos == nCurrentPos) { return; }

		nCurrentPos = event.clientY - 184;
		
		//	document.layers["floatingSten"].top = nCurrentPos;
		document.getElementById("floatingSten").style.top = nCurrentPos+"px";
	}

/**
	if (bIE && nVer >= 4 && !bMacIE) {
		if (document.body.scrollTop < (nMenuYPos-nYDelta)) { nNeededPos = nMenuYPos; }
		else { nNeededPos = document.body.scrollTop + nYDelta; }
		nCurrentPos = document.all["floatingSten"].offsetTop;

		if (nNeededPos == nCurrentPos) { return; }

		nDelta = (nNeededPos-nCurrentPos)/6;
		if (nDelta > 0 && nDelta < 0.5) { nCurrentPos += nNeededPos - nCurrentPos; }
		else {
			if (nDelta < 0 && nDelta >= -0.5) { nCurrentPos --; }
			else { nCurrentPos += Math.round (nDelta); }
		}
		pnt = document.all ["floatingSten"].style;
		pnt.top = nCurrentPos;
	} **/
}

function toggleSten(id,act) {
	if (act == "over") {
	//	if (document.getElementById("floatHeader_"+id) || document.getElementById("floatHeader_"+id).style) {
			document.getElementById("floatHeader_"+id).style.visibility="visible";//display="table";
	//	}
	} else if (act == "out") {
	//	if (document.getElementById("floatHeader_"+id) || document.getElementById("floatHeader_"+id).style) {
			document.getElementById("floatHeader_"+id).style.visibility="hidden";//display="none";
	//	}
	}
}

function ScriptStart() {
    if (bNC && nVer >= 4) { setInterval("Spy()",1); }
	if (bIE && nVer >= 4 && !bMacIE) { setInterval("Spy()",1); }
}
<!-- Float Key Ends -->

<!-- Freeze Table -->

var myRow=1;
var myCol=1;
var myTable;
var noRows;
var myCells,fID;

function setUp(){
	if(!myTable){myTable=document.getElementById("t1");}
 	myCells = myTable.rows[0].cells.length;
	noRows=myTable.rows.length;

	for( var x = 0; x < myTable.rows[0].cells.length; x++ ) {
		colWdth=myTable.rows[0].cells[x].offsetWidth;
		myTable.rows[0].cells[x].setAttribute("width",colWdth-4);

	} 
}


function right(up){
	if(up){window.clearTimeout(fID);return;}
	if(!myTable){setUp();}

	if(myCol<(myCells)){
		for( var x = 0; x < noRows; x++ ) {
			myTable.rows[x].cells[myCol].style.display="";
		}
		if(myCol >1){myCol--;}

		fID = window.setTimeout('right()',100);
	}
}
  
function left(up){
	if(up){window.clearTimeout(fID);return;}
	if(!myTable){setUp();}

	if(myCol<(myCells-1)){
		for( var x = 0; x < noRows; x++ ) {
			myTable.rows[x].cells[myCol].style.display="none";
		}
		myCol++
		fID = window.setTimeout('left()',100);
		
	}
}
  
function down(up){
	if(up){window.clearTimeout(fID);return;}
	if(!myTable){setUp();}

	if(myRow<(noRows-1)){
			myTable.rows[myRow].style.display="none";
			myRow++	;
		
			fID = window.setTimeout('down()',100);
	}	
}
 
function upp(up){
	if(up){window.clearTimeout(fID);return;}
	if(!myTable){setUp();}

	if(myRow<=noRows){
		myTable.rows[myRow].style.display="";
		if(myRow >1){myRow--;}
		fID = window.setTimeout('upp()',100);
	}	
}

<!-- Freeze Table Ends -->

window.history.forward();
