// JavaScript Document

//Place cursor in first form field
function placecursor(){
document.inqForm.Name.focus();
}
//Start form validation (Check for name and email)
function check_form(f) {
if(f.Name.value.length < 1){
alert("You have left the name field blank.");
f.Name.focus(); 
f.Name.style.border = "1px dotted #f00";
return false;
}
// check the first email address ( the exclamation means "not" )
if(!check_email(f.Email.value)){
alert("Invalid email detected.");
f.Email.focus(); 
f.Email.style.border = "1px dotted #f00";
f.Name.style.border = "1px solid #ccc";
return false;
}
//Check phone number has been entered
if(f.Area_Code.value.length < 3){
alert("Please check the area code");
f.Area_Code.focus(); 
f.Area_Code.style.border = "1px dotted #f00";
f.Name.style.border = "1px solid #ccc";
f.Email.style.border = "1px solid #ccc";
return false;
}
if(f.Prefix.value.length < 3){
alert("Please check the phone number prefix");
f.Prefix.focus(); 
f.Prefix.style.border = "1px dotted #f00";
f.Name.style.border = "1px solid #ccc";
f.Area_Code.style.border = "1px solid #ccc";
f.Email.style.border = "1px solid #ccc";
return false;
}
if(f.Tel_Number.value.length < 4){
alert("Please check the phone number");
f.Tel_Number.focus(); 
f.Tel_Number.style.border = "1px dotted #f00";
f.Name.style.border = "1px solid #ccc";
f.Email.style.border = "1px solid #ccc";
f.Prefix.style.border = "1px solid #ccc";
f.Email.style.border = "1px solid #ccc";
return false;
}
}

// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){ 
return (false);
}	
} 
if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);		
} 
}
} 


function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}