<!--

var digits = "0123456789";
var phoneNumberDelimiters = "()-x. ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;

function checkEnter(e){

	var characterCode;
	if(e && e.which){
		e = e;
		characterCode = e.which; 
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13){ 
	  	FirstNameField=document.getElementById('your-First-Name').value;
		if (FirstNameField=="") window.alert('Please Complete the Form to Continue');
		event.cancelBubble = true;
		event.returnValue = false;
		return false;
	}
	else{
		return true;
	}

}

function moreinfo_check(input) {
	if ((input) == "On") {o="Yes";}
	else {o="No Thanks";}
	return o;
}

function ProperCase(str) {return str.toLowerCase().replace(/^(.)|\s(.)/g,function($1) {return $1.toUpperCase();});}

function j_trim(str){
	var a=0;var b=str.length;while (a<=b){
	/*remove preceeding characters*/	
		for(i=str.length; i>=0; i--) while(str.charAt(0) == (".") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == (" ") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("	") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("'") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("\"") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("\\") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("\/") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("&") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("$") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("[") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("]") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("(") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == (")") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("!") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("@") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("%") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("^") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("*") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("`") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("+") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("=") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("|") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == (":") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == (";") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == (",") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("?") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("-") ) {str = str.substring(1);}
		for(i=str.length; i>=0; i--) while(str.charAt(0) == ("#") ) {str = str.substring(1);}
		/*remove trailing characters*/
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "." ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == " " ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "	" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "'" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "\"" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "\\" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "\/" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "&" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "$" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "]" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "[" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "(" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == ")" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "!" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "@" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "%" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "^" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "*" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "`" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "+" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "=" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "|" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == ":" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == ";" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "," ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "?" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "-" ){str = str.substring(0,str.length-1);}
		for(i=str.length; i>=0; i--) while(str.charAt(str.length-1) == "#" ){str = str.substring(0,str.length-1);}
		
	str=str.replace(/>/g, "");
  		while(str.match(">")) {
  			y= str.indexOf(">")
  			if ((y) > -1) str=(str.substr(y+1));
  		}

	str=str.replace(/</g, "");
  		while(str.match("<")) {
  			y= str.indexOf("<")
  			if ((y) > -1) str=(str.substr(y+1));
  		}

	str=str.replace(/=/g, "");
  		while(str.match("=")) {
  			y= str.indexOf("=")
  			if ((y) > -1) str=(str.substr(y+1));
  		}

	str=str.replace(/{/g, "");
  		while(str.match("{")) {
  			y= str.indexOf("{")
  			if ((y) > -1) str=(str.substr(y+1));
  		}

	str=str.replace(/}/g, "");
  		while(str.match("}")) {
  			y= str.indexOf("}")
  			if ((y) > -1) str=(str.substr(y+1));
  		}

	str=str.replace(/--'/g, "");
  		while(str.match("--'")) {
  			y= str.indexOf("--'")
  			if ((y) > -1) str=(str.substr(y+1));
  		}

	a=a+1;}
	str=ProperCase(str);
  return str;
}

function clearField(input,def_value) {
    if (input.value == (def_value)) input.value="";
}

function resetField(input,def_value) {
	input.value=j_trim(input.value);
	if ((input.value.toUpperCase()) == (def_value.toUpperCase())) input.value=(def_value);
    if (input.value == "") input.value=(def_value);
}

function setmyOptionValue(input) {
	/* used on select options to set the value on selection change*/
	input.value=input;
}

function removeOptions2(theSel){
while(theSel.options.length > 0)
theSel.options[theSel.options.length-1] = null;
theSel.options[theSel.length] = new Option('', '');
return;
}

function prev_ValidateRegistrationForm_Sjodin(form_id) {

	/*window.alert("validate running...");*/
	l=form_id.elements.length;
	/*window.alert("there are "+l+" form elements on this page");*/
	
for(i=0; i<l; i++) {
	valid=true;
	if ((form_id.elements[i].type) != "hidden") {
	/*if ((form_id.elements[i].type) != "hidden") {*/
		/*window.alert("beginning of non-hidden element value check");*/
  		var k = form_id.elements[i].name;
		var x = form_id.elements[i].value;
		var y = form_id.elements[i].id;
		var z = form_id.elements[i].title;
		/* if the id does not equal the name, the field is required */
		if ((y) != (k)) {
		/* if the value equals the id, the submitted value is the default value*/
		if ((x) == "") {
   		window.alert('Please '+ (z));
		form_id.elements[i].focus();
		valid = false;
		return valid;
		}

		if ((x) == (y)) {
   		window.alert('Please '+ (z));
		form_id.elements[i].focus();
		valid = false;
		return valid;
		}
		}
		/* if the field is not required and the value is the default then clear the value */

		if ((x) == (z)) {
			/*window.alert("beginning of match find");
			window.alert(x);*/
		  var yy= z.indexOf("Select")
		  if ((yy) != -1) {
			  cc=document.getElementById(k)
			  /*cc=stringObject.valueOf(form_id.elements[24].name;)*/
			  removeOptions2(cc);
			  }
		  else {
			  form_id.elements[i].value="";
			  }
			/*window.alert("end of match find");*/
		}
		else {
		/* if the field is named email perform valid email address syntax check*/
		if ((k) == "Email") checkEmail(x);
		if (valid == false) {alert("The email address you entered appears to be invalid.  Please verify.");form_id.elements[i].focus();return valid;}
		/*set the form values to proper case */
		g=ProperCase(x);
		form_id.elements[i].value=(g);
		/* proper case the field title*/
		/* substring check */
		u=" Execute If Select Insert Drop Update Function Return";
		t=ProperCase(z);
		t=t+u;
		/*skip field check for address, company, user password, city fields*/
		/*dont_check = false*/
		/*if ((k) == "Address" || (k) == "Company" || (k) == "User Password" || (k) == "City") dont_check = true;*/
		/*end of field skip */
		/*if ((dont_check) = false) {*/
		/*create array of values from title for element, each word in title is put into invalid entry list*/
		var mySplitResult = t.split(" ");
		r=mySplitResult.length;
			for(s=0; s<r; s++) {
				var a1 = mySplitResult[s];
				var b1 = g.indexOf(a1);
				var a2=a1.toUpperCase();
				/* if submitted value is found in the element title send alert*/
				if ((b1) != -1) {window.alert("The value "+a2+" is not permitted in this field. Please Revise. ERROR NO.#7001-1140-22403:FIELD Violation");form_id.elements[i].focus();valid=false;return valid;}
			}
		/*}*/
		/* end of check entry for default values*/
		/*check element named confirm, set value to no thanks for non selection */
		/* checkboxs that are not checked to not have a value*/
		/* this checks to see if the checkbox is checked and sets the value to 'no thanks' then checks the box*/
		/* resulting in a vlaue of 'no thanks' be passsed when the user unselects the box*/
		if ((k) == "Confirm") {
			//HideDiv('divFormPopUp');
			moreinfo_check(g);
			form_id.elements[i].checked=true;
			form_id.elements[i].value=o;
			}
	/*window.alert(form_id.elements[i].value);*/
		}
	}
	}

return valid;
}

function ValidateRegistrationForm_Sjodin(form_id) {
	l=form_id.elements.length;
	fnamelength=0;
	lnamelength=0;
	companylength=0;
	titlelength=0;
	for(i=0; i<l; i++) {
		isitvalid=true;
		if ((form_id.elements[i].type) != "hidden") {
			var k = form_id.elements[i].name.toLowerCase();
			var x = form_id.elements[i].value.toLowerCase();
			var y = form_id.elements[i].id.toLowerCase();
			var z = form_id.elements[i].title.toLowerCase();
			var c = form_id.elements[i].type.toLowerCase();
		
			if ((k) == "fname") {var m = form_id.elements[i].value.toLowerCase();}
			if ((k) == "lname") {var n = form_id.elements[i].value.toLowerCase();}
			if ((k) == "company") {var a = form_id.elements[i].value.toLowerCase();}
			if ((k) == "title") {var b = form_id.elements[i].value.toLowerCase();}

			if ((m) && (n)){

				if ((m) == (n)) {
					window.alert("The value entered for First Name is the same as the value entered for the Last Name, please revise");
					form_id.elements[i].focus();
					isitvalid = false;
					return isitvalid;
				}

				fnamelength=m.length;
				lnamelength=n.length;
		
				if ((fnamelength < 2) && (lnamelength < 2)){
					window.alert("Please enter your complete last name");
					form_id.elements[i].focus();
					isitvalid = false;
					return isitvalid;
				}
			}

			if ((a)){
				companylength=a.length;
				if (companylength){
					if ((companylength < 2)){
						window.alert("Please enter your complete company name");
						form_id.elements[i].focus();
						isitvalid = false;
						return isitvalid;
					}
				}
			}
		
		 	if ((b)){
				titlelength=b.length;
				if (titlelength){
					if ( (titlelength < 2) ){
						window.alert("Please enter your full title");
						form_id.elements[i].focus();
						isitvalid = false;
						return isitvalid;
					}
				}
			}
		
			if ((y) == 'state' || (y) == 'thestate') form_id.elements[i].disabled=0;

			if ((y) != (k)) {
		
				if ((x) == (z) || (x) == '') {
		   			window.alert('Please '+ (ProperCase(z)));
					form_id.elements[i].focus();
					isitvalid = false;
					return isitvalid;
				}
				
				if ((c) == "select-multiple") {
					var themultiselectedArray = new Array();
					var selObj = document.getElementById(y);
					var selseed;
					var selcount = 0;
					for (selseed=0; selseed<selObj.options.length; selseed++) {
					  	if (selObj.options[selseed].selected) {
	      					themultiselectedArray[selcount] = selObj.options[selseed].value;
							selObj.options[selseed].selected = false;
	      					selcount++;
	    				}
	  				}
					var themultiselectedvalueid=y.replace("-sel", "");
					document.getElementById((themultiselectedvalueid)).disabled=0;
					document.getElementById((themultiselectedvalueid)).value = themultiselectedArray;
					x=document.getElementById((themultiselectedvalueid)).value;
				}
								
			} else {
				
				if ((x) == (z)) {
						//var yy = x.indexOf("select");
						if ( ((c) == "select-one") || ((c) == "select-multiple")){
				 		//if ((yy) != -1) {
							cc=document.getElementById(k);
							removeOptions2(cc);
						} else {
							form_id.elements[i].value="";
						}
					//}
				}
				
				if ((c) == "select-multiple") {
					var themultiselectedArray = new Array();
					var selObj = document.getElementById(y);
					var selseed;
					var selcount = 0;
					for (selseed=0; ((selseed) < (selObj.options.length)); selseed++) {
					  	if (selObj.options[selseed].selected) {
	      					themultiselectedArray[selcount] = selObj.options[selseed].value;
							selObj.options[selseed].selected = false;
	      					selcount++;
	    				}
	  				}
					var themultiselectedvalueid=y.replace("-sel", "");
					document.getElementById((themultiselectedvalueid)).disabled=0;
					document.getElementById((themultiselectedvalueid)).value = themultiselectedArray;
					x=document.getElementById((themultiselectedvalueid)).value;
				}
				
			}
		
			if ( ((k) == "phone") || ((k) == "telephone") ) {
		   		if (checkInternationalPhone(form_id.elements[i].value)==false){
					window.alert("Please Enter a Valid Phone Number:\n\nTelephone number requires a minimum of 10 digits.\nUse x (lower case) to designate an extension.\n\nExample: (555) 555-1212 x123\n\n")
					//form_id.elements[i].value=""
					form_id.elements[i].focus();
					isitvalid = false;					
					return isitvalid;
				}
		   }
			if ((k) == "email") {
				isitvalid = checkEmail(x);
				if (isitvalid == false) {
					alert("The email address you entered appears to be invalid.  Please verify.");
					form_id.elements[i].focus();
					return isitvalid;
				}
			}
			if ( ( (c) == "checkbox") &&  ( ((k) != "confirm" ) || ((k) != "confirm-req" ) )) {
				//theconfirmvalue=additionalinfo_check(x);
				//form_id.elements[i].checked=true;				
				//form_id.elements[i].value=theconfirmvalue;
			}
			if (((k) != "confirm" ) || ((c) != "select-multiple" ) || ((k) != "confirm-req" )) {
				g=ProperCase(x);
				t=ProperCase(z);
				if ( (g) != (t) ){
					var mySplitResult = t.split(" ");
					r=mySplitResult.length;
					for(s=0; ((s)<(r)); s++) {
						var a1 = mySplitResult[s];
						var b1 = g.indexOf(a1);
						var a2=a1.toUpperCase();
						if ((b1) != -1) {window.alert("The value "+a2+" is not permitted in this field. Please Revise. ERROR NO.#7001-1140-22403:FIELD Violation");form_id.elements[i].focus();isitvalid=false;return isitvalid;}
					}
				}
			}
			if ( ((k) == "confirm") || ((k) == "confirm-req")) {
				HideMyDiv('divFormPopUp');
				theconfirmvalue=moreinfo_check(x);
				form_id.elements[i].checked=true;
				form_id.elements[i].value=theconfirmvalue;
			}
		}
	}

	//window.alert("validation check complete.  form check: "+isitvalid);
	//return false;
	return isitvalid;
}



function checkEmail(x) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(x)) {isitvalid = true;}
else {isitvalid = false;}
return isitvalid;
}

function checkField(input) {
	if (input.value){
		input.value=j_trim(input.value);
		document.getElementById(input.id).value=input.value;
	}
}

function checkPhone(myphone){
	if (checkInternationalPhone(myphone.value)==false){
		window.alert("Please Enter a Valid Phone Number:\n\nTelephone number requires a minimum of 10 digits.\nUse x (lower case) to designate an extension.\n\nExample: (555) 555-1212 x123")
		document.getElementById(myphone.id).value="";
	}
}

function checkInternationalPhone(strPhone){
	//window.alert(strPhone);
	var bracket=3;
	strPhone=trim(strPhone);
	if(strPhone.indexOf("+")>1){return false;}
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1;
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket) {return false;}
	var brchr=strPhone.indexOf("(");
 	//window.alert(strPhone);
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+4)!=")") {return false;}
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1) {return false;}
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	if(s.indexOf("x")!=-1 && s.charAt(11)!="x") {return false;}
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++) {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
return true;
}

function reset_count() {
	submitted = 0;
	return;
}

function resetField(input,def_value) {
	input.value=j_trim(input.value);
	if ((input.value.toUpperCase()) == (def_value.toUpperCase())) input.value=(def_value);
    if (input.value == "") input.value=(def_value);
}

function resetFieldNoTrim(input,def_value) {
	if ((input.value.toUpperCase()) == (def_value.toUpperCase())) input.value=(def_value);
    if (input.value == "") input.value=(def_value);
}

function removeOptions2(theSel){
	while(theSel.options.length > 0)
	theSel.options[theSel.options.length-1] = null;
	theSel.options[theSel.length] = new Option('', '');
	return;
}

function removeOptions(theSel){
	for(i=theSel.length; i>=0; i--){
		theSel.options[i] = null;
	}
	return;
}

function setmyOptionValue(input) {
	if (document.getElementById(input.id).checked==1) {
		document.getElementById(input.id).value="Yes";
	} else {
		document.getElementById(input.id).value="No";
	}
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
return returnString;
}

function trim(s){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++) {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
return returnString;
}

-->


