var mikExp=/[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|\'\"\<\>]/;function minLength(field,val,msg){if(field.value.length<val){alert(msg);field.select();field.focus();return false;}
return true;}
function maxLength(field,val,msg){if(field.value.length>val){alert(msg);field.select();field.focus();return false;}
return true;}
function isZeroLead(field){var a="";a=field.value.charAt(0);if(a=="0"){alert('There is zero in starting position');field.select();field.focus();return false;}
return true;}
function isNumber(inputString,fieldString){flag=true;for(i=0;i<inputString.length;i++){if(isNaN(parseInt(inputString.charAt(i)))){if(inputString.charAt(i)!="."){flag=false;}}}
for(i=0;i<inputString.length;i++){if(inputString.charAt(i)=="."){flag=false;}}
if(flag==false){alert(fieldString);return false;}
return true;}
function isCNumber(inputString,fieldString){flag=true;for(i=0;i<inputString.length;i++){if(isNaN(parseInt(inputString.charAt(i)))){if(inputString.charAt(i)!="."){flag=false;}}}
if(flag==false){alert(fieldString);return false;}
return true;}
function echeck(str){emailStr=str.value;var checkTLD=1;var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;var emailPat=/^(.+)@(.+)$/;var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";var validChars="\[^\\s"+ specialChars+"\]";var quotedUser="(\"[^\"]*\")";var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;var atom=validChars+'+';var word="("+ atom+"|"+ quotedUser+")";var userPat=new RegExp("^"+ word+"(\\."+ word+")*$");var domainPat=new RegExp("^"+ atom+"(\\."+ atom+")*$");var matchArray=emailStr.match(emailPat);if(matchArray==null){alert("Your email address is not correct ");str.select();str.focus();return false;}
var user=matchArray[1];var domain=matchArray[2];for(i=0;i<user.length;i++){if(user.charCodeAt(i)>127){alert("Ths username contains invalid characters.");str.select();str.focus();return false;}}
for(i=0;i<domain.length;i++){if(domain.charCodeAt(i)>127){alert("Ths domain name contains invalid characters.");str.select();str.focus();return false;}}
if(user.match(userPat)==null){alert("The username doesn't seem to be valid.");str.select();str.focus();return false;}
var IPArray=domain.match(ipDomainPat);if(IPArray!=null){for(var i=1;i<=4;i++){if(IPArray[i]>255){alert("Destination IP address is invalid!");str.select();str.focus();return false;}}
return true;}
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("The domain name does not seem to be valid.");str.select();str.focus();return false;}}
if(checkTLD&&domArr[domArr.length-1].length!=2&&domArr[domArr.length-1].search(knownDomsPat)==-1){alert("The address must end in a well-known domain or two letter "+"country.");str.select();str.focus();return false;}
if(len<2){alert("This address is missing a hostname!");str.select();str.focus();return false;}
return true;}
function CheckBoxCheck(msg){flag=true;for(i=0;i<document.form1.elements.length;i++){if(document.form1.elements[i].type=="checkbox"){if(document.form1.elements[i].checked){flag=false;}}}
if(flag){alert(msg);return false;}else{return true;}}
function portionCheckBoxCheck(name,msg){bol=true;for(i=0;i<document.form1.elements.length;i++){if(document.form1.elements[i].type=="checkbox"){if(document.form1.elements[i].name==name){if(document.form1.elements[i].checked){bol=false;}}}}
if(bol){alert(msg);return false;}else{return true;}}
function checkUncheckAll(field){if(document.form1.field.checked){for(i=0;i<document.form1.elements.length;i++){if(document.form1.elements[i].type=="checkbox"){document.form1.elements[i].checked=true;}}}else{for(i=0;i<document.form1.elements.length;i++){if(document.form1.elements[i].type=="checkbox"){document.form1.elements[i].checked=false;}}}}
function alphabetCheck(fieldToCheck){var box=fieldToCheck;re=/^[a-zA-Z\ ]*$/;if(!re.exec(box.value)){alert("Only alphabetic characters or space allowed!");box.select();box.focus();return false;}
return true;}
function validTextMaker(textField){}
function finalCheck(finalField){return true;}
function removeLeadingAndTrailingChar(fieldToRemoveChar,removeChar){var returnString=fieldToRemoveChar.value;if(removeChar.length)
{while(''+returnString.charAt(0)==removeChar)
{returnString=returnString.substring(1,returnString.length);}
while(''+returnString.charAt(returnString.length-1)==removeChar)
{returnString=returnString.substring(0,returnString.length-1);}}
return returnString;}
function yearCheck(yearField){var year=yearField.value;myyear=parseInt(year);if(myyear<1947||myyear>2004){alert("Given year is not valid");yearField.select();yearField.focus();return false;}
return true;}
function isEmpty(form,msg){if(form.value.length<1){alert(msg);form.select();form.focus();return false;}
return true;}
function isEmpty_UserName(form,msg){if(form.value.length<1){alert(msg);form.select();form.focus();return false;}
if(form.value.search(mikExp)==-1){return true;}else{alert("Username is not in an allowable format. Please retry.");form.focus();return false;}
return true;}
function equalityCheck(firstField,secondField,msg){if(firstField.value!=secondField.value){alert(msg);secondField.select();secondField.focus();return false;}
return true;}
function IsNotNumeric(strString)
{var strValidChars="0123456789.'!''@''#'$''%''&''*''+''-''";var strChar;var blnResult=true;if(strString.length==0)return false;for(i=0;i<strString.length&&blnResult==true;i++)
{strChar=strString.charAt(i);if(strValidChars.indexOf(strChar)==-1)
{blnResult=false;}}
return blnResult;}
function alphabetCheck(fieldToCheck){var box=fieldToCheck;re=/^[a-zA-Z\ ]*$/;if(!re.exec(box.value)){alert("Your name is not correct");box.focus();return false;}
return true;}
function isNumbercheck(inputString){flag=true;for(i=0;i<inputString.length;i++){if(isNaN(parseInt(inputString.charAt(i)))){if(inputString.charAt(i)!="."){flag=false;}}}
for(i=0;i<inputString.length;i++){if(inputString.charAt(i)=="."){flag=false;}}
if(flag==false){return false;}
return true;}
bol=true;function submitMe(){document.form1.yourname.value=removeLeadingAndTrailingChar(document.form1.yourname,' ');if(!(bol=isEmpty(document.form1.yourname,"Enter Your Name"))){return false;}
document.form1.youremail.value=removeLeadingAndTrailingChar(document.form1.youremail,' ');if(!(bol=isEmpty(document.form1.youremail,"Enter your Email Address"))){return false;}
if(!(bol=echeck(document.form1.youremail))){return false;}
document.form1.security_code.value=removeLeadingAndTrailingChar(document.form1.security_code,' ');if(!(bol=isEmpty(document.form1.security_code,"Enter Security Code"))){return false;}
document.form1.yourcomm.value=removeLeadingAndTrailingChar(document.form1.yourcomm,'');if(!(bol=isEmpty(document.form1.yourcomm,"Enter Your Comments"))){return false;}
return true;}
