//=====================================================================================// IS STRING AN ALPHA STRING//=====================================================================================function isAlphabetic (s) {	var i;	for (i = 0; i < s.length; i++) {   		var c = s.charAt(i);		if (!isLetter(c)) { return false;}	}	return true;}//=====================================================================================//VALIDATE NAME//=====================================================================================function ValidateName(fld, allownumbers, msg1, msg2) {	var fldname = eval("document.forms[0]."+fld+".value");	if (fldname.length < 2) {		alert(msg1 + " is a required field.\n" + msg2);		return false;	}	var capLetters="ABCDEFGHIJKLMNOPQRSTUVWXYZ";	var c = fldname.charAt(0);	if (capLetters.indexOf(c) == -1) { 		fldname = c.toUpperCase() + fldname.substr(1,fldname.length);		var fldObj = eval("document.forms[0]."+fld);		fldObj.value = fldname;	}	if (fldname.indexOf(" ") !=-1) {		alert(msg1 + " can only be one word and/or cannot contain spaces.\n" + msg2);		return false;	}	switch (allownumbers) {	case "Y":		var okchars="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";		for (var i = 0; i < fldname.length; i++) {   			var c = fldname.charAt(i);			if (okchars.indexOf(c) == -1) { 				alert(msg1 + " cannot contain any special characters.\n" + msg2);				return false;			}		}		break;	default:		if (isAlphabetic(fldname)==false) {			alert(msg1 + " can only contain letters.\n" + msg2);			return false;		}		break;	} // end-switch	return true;}//=====================================================================================//VALIDATE EMAIL//=====================================================================================function ValidateEmail (emailStr) {	emailStr = emailStr.toLowerCase();	/* The following variable tells the rest of the function whether or not	to verify that the address ends in a two-letter country or well-known	TLD.  1 means check it, 0 means don't. */	var checkTLD=1;	/* The following is the list of known TLDs that an e-mail address must end with. */	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;	/* The following pattern is used to check if the entered e-mail address	fits the user@domain format.  It also is used to separate the username	from the domain. */	var emailPat=/^(.+)@(.+)$/;	/* The following string represents the pattern for matching all special	characters.  We don't want to allow special characters in the address. 	These characters include ( ) < > @ , ; : \ " . [ ] */	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";	/* The following string represents the range of characters allowed in a 	username or domainname.  It really states which chars aren't allowed.*/	var validChars="\[^\\s" + specialChars + "\]";	/* The following pattern applies if the "user" is a quoted string (in	which case, there are no rules about which characters are allowed	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com	is a legal e-mail address. */	var quotedUser="(\"[^\"]*\")";	/* The following pattern applies for domains that are IP addresses,	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal	e-mail address. NOTE: The square brackets are required. */	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;	/* The following string represents an atom (basically a series of non-special characters.) */	var atom=validChars + '+';	/* The following string represents one word in the typical username.	For example, in john.doe@somewhere.com, john and doe are words.	Basically, a word is either an atom or quoted string. */	var word="(" + atom + "|" + quotedUser + ")";	// The following pattern describes the structure of the user	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");	/* The following pattern describes the structure of a normal symbolic	domain, as opposed to ipDomainPat, shown above. */	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");	/* Finally, let's start trying to figure out if the supplied address is valid. */	/* Begin with the coarse pattern to simply break up user@domain into	different pieces that are easy to analyze. */	var matchArray=emailStr.match(emailPat);	if (matchArray==null) {	/* Too many/few @'s or something; basically, this address doesn't	even fit the general mould of a valid e-mail address. */		alert("SUBMISSION FAILED: Email address incorrect (check @ and periods)");		return false;	}	var user=matchArray[1];	var domain=matchArray[2];	// Start by checking that only basic ASCII characters are in the strings (0-127).	for (i=0; i<user.length; i++) {		if (user.charCodeAt(i)>127) {			alert("SUBMISSION FAILED: Email username contains invalid characters.");			return false;		}	}	for (i=0; i<domain.length; i++) {		if (domain.charCodeAt(i)>127) {			alert("SUBMISSION FAILED: Email domain name contains invalid characters.");			return false;		}	}	// See if "user" is valid 	if (user.match(userPat)==null) {	// user is not valid		alert("SUBMISSION FAILED: Email username is invalid.");		return false;	}	/* if the e-mail address is at an IP address (as opposed to a symbolic	host name) make sure the IP address is valid. */	var IPArray=domain.match(ipDomainPat);	if (IPArray!=null) {	// this is an IP address		for (var i=1;i<=4;i++) {			if (IPArray[i]>255) {				alert("SUBMISSION FAILED: Email destination IP address is invalid!");				return false;			}		}		return true;	}	// Domain is symbolic name.  Check if it's valid. 	var atomPat=new RegExp("^" + atom + "$");	var domArr=domain.split(".");	var len=domArr.length;	for (i=0;i<len;i++) {		if (domArr[i].search(atomPat)==-1) {			alert("SUBMISSION FAILED: Email domain name is invalid.");			return false;		}	}	/* domain name seems valid, but now make sure that it ends in a	known top-level domain (like com, edu, gov) or a two-letter word,	representing country (uk, nl), and that there's a hostname preceding 	the domain or country. */	if (checkTLD && domArr[domArr.length-1].length!=2 && 		domArr[domArr.length-1].search(knownDomsPat)==-1) {		alert("SUBMISSION FAILED: Email address must end in a well-known domain or two letter country.");		return false;	}	// Make sure there's a host name preceding the domain.	if (len<2) {		alert("SUBMISSION FAILED: Email address is missing a hostname!");		return false;	}	return true;}// VALIDATE MULTIPLE FIELDS CHECK BOX FUNCTIONfunction ValidateMultiFieldCheckBox(totfld, htag, m, fld, plusNum, msg1, msg2) {	for (var x = 1; x <= totfld; x++) {		var max = eval("document.forms[0]."+fld+x+".length");		if (max == null) {			if (eval("document.forms[0]."+fld+x+".checked")==false) {				alert(msg1+" "+(x + plusNum)+"\n"+msg2);				window.location.hash=htag+x;				return false;			}		} else {			var total = 0;			for (var i = 0; i < max; i++) {				if (eval("document.forms[0]."+fld+x+"[" + i + "].checked") == true) {				    total += 1;				}			}			if (total < m) {	//error not enough checked selections				alert(msg1+" "+(x + plusNum)+"\n"+msg2);				window.location.hash=htag+x;				return false;				}		}	}  // end-for loop	return true;	}// GET FIELD VALUE FUNCTIONfunction getFieldValue(field){   switch(field.type)   {      case "text" :      	return field.value;      case "textarea":      case "hidden" :         return field.value;      case "select-one" :         var i = field.selectedIndex;         if (i == -1)   return "";         else   return (field.options[i].value == "") ? field.options[i].text : field.options[i].value;      case "radio" :      case "checkbox" :         if (field.checked) { return field.value; } else { return ""; }      default :         if(field[0].type == "radio")         {            for (i = 0; i < field.length; i++)               if (field[i].checked)                  return field[i].value;            return "";         }         else if(field[0].type == "checkbox")         {            var allChecked = new Array();            for(i = 0; i < field.length; i++)               if(field[i].checked)                  allChecked[allChecked.length] = field[i].value;            return allChecked;         }         else            var str = "";            for (x in field) { str += x + "\n"; }            alert("I couldn't figure out what type this field is...\n\n" + field.name + ": ???\n\n\n" + str + "\n\nlength = " + field.length);         break;   }     return "";}//GET REF FUNCTIONfunction getRef(id){	var isDOM = (document.getElementById ? true : false); 	var isIE4 = ((document.all && !isDOM) ? true : false);	var isNS4 = (document.layers ? true : false);	var isDyn = (isDOM || isIE4 || isNS4);	 if (isDOM) return document.getElementById(id);	 if (isIE4) return document.all[id];	 if (isNS4) return document.layers[id];}//DISPLAY QUESTIONS FUNCTIONfunction displayAllQuestions() {	var f = document.forms[0];	var courseSystem = getFieldValue(f.CourseType);	f.CourseSystem.value = courseSystem;	//alert("COURSESYSTEM FIELD VALUE: " +f.CourseSystem.value);	questionsByCourseSystem();	var quesDisplay = getRef("Questions");	quesDisplay.style.display = "";	return;}//QUESTIONS BY COURSESYSTEM FUNCTIONfunction questionsByCourseSystem() {	var f = document.forms[0];	var questionSLN;	var questionCS;	var courseSystem = f.CourseSystem.value;	if (courseSystem=="ONLINE") {		//DISPLAY ONLINE AND HIDE BLENDED		questionSLN = getRef("SLN1");		questionCS = getRef("CS1");		questionSLN.style.display = "";		questionCS.style.display = "none";		questionSLN = getRef("SLN24");		questionSLN.style.display = "";		questionSLN = getRef("SLN25");		questionSLN.style.display = "";		questionSLN = getRef("SLN43");		questionCS = getRef("CS41");		questionSLN.style.display = "";		questionCS.style.display = "none";		questionSLN = getRef("SLN44");		questionCS = getRef("CS42");		questionSLN.style.display = "";		questionCS.style.display = "none";		//VERIFY NUMBERS ON ALL QUESTIONS AFTER 25 FOR ONLINE		questionSLN = getRef("SLN26");		questionSLN.innerHTML = "26";		questionSLN = getRef("SLN27");		questionSLN.innerHTML = "27";		questionSLN = getRef("SLN28");		questionSLN.innerHTML = "28";		questionSLN = getRef("SLN29");		questionSLN.innerHTML = "29";		questionSLN = getRef("SLN30");		questionSLN.innerHTML = "30";		questionSLN = getRef("SLN31");		questionSLN.innerHTML = "31";		questionSLN = getRef("SLN32");		questionSLN.innerHTML = "32";		questionSLN = getRef("SLN33");		questionSLN.innerHTML = "33";		questionSLN = getRef("SLN34");		questionSLN.innerHTML = "34";		questionSLN = getRef("SLN35");		questionSLN.innerHTML = "35";		questionSLN = getRef("SLN36");		questionSLN.innerHTML = "36";		questionSLN = getRef("SLN37");		questionSLN.innerHTML = "37";		questionSLN = getRef("SLN38");		questionSLN.innerHTML = "38";		questionSLN = getRef("SLN39");		questionSLN.innerHTML = "39";		questionSLN = getRef("SLN40");		questionSLN.innerHTML = "40";		questionSLN = getRef("SLN41");		questionSLN.innerHTML = "41";		questionSLN = getRef("SLN42");		questionSLN.innerHTML = "42";		questionSLN = getRef("SLN45");		questionSLN.innerHTML = "45";		questionSLN = getRef("SLN46");		questionSLN.innerHTML = "46";		questionSLN = getRef("SLN47");		questionSLN.innerHTML = "47";		questionSLN = getRef("SLN48");		questionSLN.innerHTML = "48";	}else{		//DISPLAY BLENDED AND HIDE ONLINE		questionSLN = getRef("SLN1");		questionCS = getRef("CS1");		questionSLN.style.display = "none";		questionCS.style.display = "";		questionSLN = getRef("SLN24");		questionSLN.style.display = "none";		questionSLN = getRef("SLN25");		questionSLN.style.display = "none";		questionSLN = getRef("SLN43");		questionCS = getRef("CS41");		questionSLN.style.display = "none";		questionCS.style.display = "";		questionSLN = getRef("SLN44");		questionCS = getRef("CS42");		questionSLN.style.display = "none";		questionCS.style.display = "";		//CHANGE NUMBERS ON ALL QUESTIONS	 AFTER 23 FOR BLENDED		questionSLN = getRef("SLN26");		questionSLN.innerHTML = "24";		questionSLN = getRef("SLN27");		questionSLN.innerHTML = "25";		questionSLN = getRef("SLN28");		questionSLN.innerHTML = "26";		questionSLN = getRef("SLN29");		questionSLN.innerHTML = "27";		questionSLN = getRef("SLN30");		questionSLN.innerHTML = "28";		questionSLN = getRef("SLN31");		questionSLN.innerHTML = "29";		questionSLN = getRef("SLN32");		questionSLN.innerHTML = "30";		questionSLN = getRef("SLN33");		questionSLN.innerHTML = "31";		questionSLN = getRef("SLN34");		questionSLN.innerHTML = "32";		questionSLN = getRef("SLN35");		questionSLN.innerHTML = "33";		questionSLN = getRef("SLN36");		questionSLN.innerHTML = "34";		questionSLN = getRef("SLN37");		questionSLN.innerHTML = "35";		questionSLN = getRef("SLN38");		questionSLN.innerHTML = "36";		questionSLN = getRef("SLN39");		questionSLN.innerHTML = "37";		questionSLN = getRef("SLN40");		questionSLN.innerHTML = "38";		questionSLN = getRef("SLN41");		questionSLN.innerHTML = "39";		questionSLN = getRef("SLN42");		questionSLN.innerHTML = "40";		questionSLN = getRef("SLN45");		questionSLN.innerHTML = "43";		questionSLN = getRef("SLN46");		questionSLN.innerHTML = "44";		questionSLN = getRef("SLN47");		questionSLN.innerHTML = "45";		questionSLN = getRef("SLN48");		questionSLN.innerHTML = "46";	}}//Variable to ensure the form is only submitted oncevar submitcount=0;//SUBMIT DOC FUNCTIONfunction SubmitDoc() {	if (ValidateForm() == false) { 		return false; 	} else { 		if (submitcount == 0) {     		submitcount++;     		document.forms[0].submit();     	} else {      		alert("This form has already been submitted.  Thanks!");      		return false;     	}	}}//VALIDATE FORM FUNCTIONfunction ValidateForm() {	var f = document.forms[0];	var CourseSystem = getFieldValue(f.CourseSystem);	var quesNumLabel;	if (ValidateName("FName","Y","Submission failed: First Name is required","")==false) {		f.FName.focus();		return false;	}	if (ValidateName("LName","Y","Submission failed: Last Name is required","")==false) {		f.LName.focus();		return false;	}	var email = f.Email.value;	if (ValidateEmail (email)==false) {		f.Email.focus();		return false;	}	var emailVerify = f.EmailVerify.value;	if (email != emailVerify) {		alert("Submission failed: The information entered in the email address fields does not match.  Please re-enter the email address.");		f.EmailVerify.focus();		return false;	}	if (getFieldValue(f.Workshop) == "" || getFieldValue(f.Workshop) == "SELECT") {		alert('Submission failed: Workshop is required');		f.Workshop.focus();		return false;	}	if (getFieldValue(f.Course) == "") {		alert('Submission failed: Course is required');		f.Course.focus();		return false;	}	if (CourseSystem == "ONLINE") {		if (getFieldValue(f.courseAnswer1) == "") {			alert('Submission failed: Question 1 is required');			location.hash = "courseQ1";			return false;		}	} else {		if (getFieldValue(f.courseAnswer2) == "") {			alert('Submission failed: Question 1 is required');			location.hash = "courseQ2";			return false;		}	}	if (getFieldValue(f.courseAnswer3) == "") {		alert('Submission failed: Question 2 is required');		location.hash = "courseQ3";		return false;	}	if (getFieldValue(f.courseAnswer4) == "") {		alert('Submission failed: Question 3 is required');		location.hash = "courseQ4";		return false;	}		if (ValidateMultiFieldCheckBox(20, "ccsQ", "1", "ccsAnswer", 3,	"Submission Failed: You must enter a response for Question",	"Please fill in the missing information and resubmit the form.") == false) { 		return false;	}	if (CourseSystem == "ONLINE") {		if (getFieldValue(f.ccsAnswer21) == "") {			alert('Submission failed: Question 24 is required');			location.hash = "ccsQ21";			return false;		}		if (getFieldValue(f.ccsAnswer22) == "") {			alert('Submission failed: Question 25 is required');			location.hash = "ccsQ22";			return false;		}	}	if (CourseSystem == "ONLINE") {		quesNumLabel = 25;	} else {		quesNumLabel = 23;	}	if (ValidateMultiFieldCheckBox(6, "idoQ", "1", "idoAnswer", quesNumLabel,	"Submission Failed: You must enter a response for Question",	"Please fill in the missing information and resubmit the form.") == false) { 		return false;	}	if (CourseSystem == "ONLINE") {		quesNumLabel = 31;	} else {		quesNumLabel = 29;	}	if (ValidateMultiFieldCheckBox(6, "fdQ", "1", "fdAnswer", quesNumLabel,	"Submission Failed: You must enter a response for Question",	"Please fill in the missing information and resubmit the form.") == false) { 		return false;	}	if (CourseSystem == "ONLINE") {		quesNumLabel = 37;	} else {		quesNumLabel = 35;	}	if (ValidateMultiFieldCheckBox(5, "diQ", "1", "diAnswer", quesNumLabel,	"Submission Failed: You must enter a response for Question",	"Please fill in the missing information and resubmit the form.") == false) { 		return false;	}	if (CourseSystem == "ONLINE") {		if (getFieldValue(f.loAnswer1) == "") {			alert('Submission failed: Question 43 is required');			location.hash = "loQ1";			return false;		}		if (getFieldValue(f.loAnswer3) == "") {			alert('Submission failed: Question 44 is required');			location.hash = "loQ3";			return false;		}	} else {		if (getFieldValue(f.loAnswer2) == "") {			alert('Submission failed: Question 41 is required');			location.hash = "loQ2";			return false;		}		if (getFieldValue(f.loAnswer4) == "") {			alert('Submission failed: Question 42 is required');			location.hash = "loQ4";			return false;		}	}	if (CourseSystem == "ONLINE") {		quesNumLabel = 46;	} else {		quesNumLabel = 44;	}	if (getFieldValue(f.loAnswer6) == "") {		alert('Submission failed: Question ' + quesNumLabel + ' is required');		location.hash = "loQ6";		return false;	}	quesNumLabel = quesNumLabel + 1	if (getFieldValue(f.loAnswer6) == "1") {		if (getFieldValue(f.loAnswer7) == "") {			alert('Submission failed: Question ' + quesNumLabel + ' is required');			location.hash = "loQ7";			return false;		}	}	if (getFieldValue(f.loAnswer7) == "2") {		if (getFieldValue(f.loAnswer8) == "") {			alert('Submission failed: MERLOT was not used in the classroom.  You must explain why not.');			f.loAnswer8.focus();			return false;		}	}	quesNumLabel = quesNumLabel + 1	if (getFieldValue(f.loAnswer7) == "1") {		if (getFieldValue(f.loAnswer9) == "") {			alert('Submission failed: MERLOT was used in the classroom.  Question ' + quesNumLabel + ' is required');			location.hash = "loQ9";			return false;		}	}}