function jumpto(url){
window.location=url
}

function isSpecialCharacters(string) {

   if (!string) return false;
   var iChars = "*~|\"<>[]{}`\;&=+^\\";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
	    return false;
   }
   return true;
}                      
function validateInputs(formName) {

	var whichForm = formName;
	var x = 0;
	var y = 0;
	var z = 0;
	var totalPar = 0;
	var formValidates = true;
	var strNote, strTmp1, strTmp2, strTmp3;

	while ((x < whichForm.elements.length) && (formValidates)) {
		//check to make sure the input is not empty, unless its name is Optional
		if ((whichForm.elements[x].value=="") && (whichForm.elements[x].title != "Optional")) {
			alert("Please Provide the Required Information For " + whichForm.elements[x].title + ".");
			whichForm.elements[x].focus();
			formValidates = false;
		}
		if (((whichForm.elements[x].name=="email") || (whichForm.elements[x].name=="Email")) && (whichForm.elements[x].value!="")) {		
			var str=whichForm.elements[x].value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(str))
				testresults=true
			else{
				alert("Please Provide a Valid E-mail Address.")
				whichForm.elements[x].focus();
				formValidates=false
			}
		}
		//if the input is a password input, check for confirmation
		if (whichForm.elements[x].name =="Password") {
			//catch value of Password input
			var passwd = whichForm.elements[x].value;
		}
		if (whichForm.elements[x].name =="VerifyPassword") {
			//catch value of Verify Password input and compare
			var vPasswd = whichForm.elements[x].value;
			if (vPasswd != passwd) {
				alert("Password verification does not match. Enter again.");
				whichForm.elements[x].focus();
				formValidates = false;
			}
		}		
	    if ((whichForm.elements[x].value !="") && (isSpecialCharacters(whichForm.elements[x].value) == false) && (whichForm.elements[x].title != "Optional") && (whichForm.elements[x].name !="f1")) {
	        alert("Invalid Character(s) Entered. " + whichForm.elements[x].name + ".");
	        whichForm.elements[x].focus();
			
	        return false;
	    }




        x++;
	}
	while ((y < whichForm.elements.length) && (formValidates)) {
		//replace single quotes in form value
		while (whichForm.elements[y].value.indexOf("'") > 0) {
			strNote = whichForm.elements[y].value;
			strTmp1 = strNote.substring(0,strNote.indexOf("'"));
			strTmp2 = strNote.substring(strNote.indexOf("'")+1,strNote.length);
			strTmp3 = strTmp1 + "&rsquo;" + strTmp2;
			whichForm.elements[y].value = strTmp3;
		}
		y++;
	}
	while ((z < whichForm.elements.length) && (formValidates)) {
		//replace less than characters to break any HTML tags in form value
		while (whichForm.elements[z].value.indexOf("<") > -1) {
			strNote = whichForm.elements[z].value;
			strTmp1 = strNote.substring(0,strNote.indexOf("<"));
			strTmp2 = strNote.substring(strNote.indexOf("<")+1,strNote.length);
			strTmp3 = strTmp1 + "&lt;" + strTmp2;
			whichForm.elements[z].value = strTmp3;
		}
		z++;
	}		
	return formValidates;
}

