function CheckIt(f) {
 var phone;
 phone = f.contact_phone_area.value + "-" + f.contact_phone_pre.value + "-" + f.contact_phone_suf.value;
 //if(f.check_phone2.value == 1) {
 //var phone2;
 //phone2 = f.contact_phone2_area.value + "-" + f.contact_phone2_pre.value + "-" + f.contact_phone2_suf.value;
 //}
 if (f.project_homeowner[0].checked == 0 && f.project_homeowner[1].checked == 0) {
 alert("Please select whether or not you own your home");
 return false;
 }
 else if (f.project_start[0].checked == 0 && f.project_start[1].checked == 0 && f.project_start[2].checked == 0) {
 alert("Please select when you plan to begin your project");
 return false;
 }
 else if (f.contact_fname.value == "")  {
 alert("Please enter your first name");
 return false;
 }
 else if (IsInvalidName(f.contact_fname.value)) {
 alert("Invalid first name");
 return false;
 }
 else if (f.contact_lname.value == "")  {
 alert("Please enter your last name");
 return false;
 }
 else if (IsInvalidName(f.contact_lname.value)) {
 alert("Invalid last name");
 return false;
 }
 else if (IsInvalidFirstLastName(f.contact_fname,f.contact_lname)) {
 alert("Invalid first and last name");
 return false;
 }
 //else if (f.contact_address.value == "")  {
 //alert("Please enter your street address");
 //return false;
 //}
 else if (f.contact_city.value == "")  {
 alert("Please enter your city");
 return false;
 }
 else if (f.contact_state.selectedIndex == 0){
 alert("Please select a state");
 return false;
 }
 else if (f.contact_zipcode == "") {
 alert("Please enter your zipcode");
 return false;
 }
 else if (!IsZip(f.contact_zipcode.value))  {
 alert("Invalid zipcode");
 return false;
 }
 else if (f.contact_phone_area.value == "" || f.contact_phone_pre.value == "" || f.contact_phone_suf.value == "")  {
 alert("Please enter your phone number");
 return false;
 }
 else if (IsInvalidPhone(phone) || !IsPhone(phone))  {
 alert("Invalid phone number");
 return false;
 }
 else if (f.contact_email.value == "")  {
 alert("Please enter your email address");
 return false;
 }
 else if (!IsEmail(f.contact_email.value)) {
 alert("Please enter a valid email address");
 return false;
 }
 else if(f.project_homeowner[1].checked == 1 && !confirm("Are you authorized by the home owner to complete this project?")) {
 alert("We're sorry, you must be authorized by the home owner in order to proceed");
 return false;
 }
 //else if (f.check_phone2.value == 1) {
 //if(f.contact_phone2_area.value == "" || f.contact_phone2_pre.value == "" || f.contact_phone2_suf.value == "")  {
 //alert("Please enter your second phone number");
 //return false;
 //}
 //else if (IsInvalidPhone(phone2) || !IsPhone(phone2))  {
 //alert("Invalid second phone number");
 //return false;
 //}
 //}
 return true;
}
function IsEmail(email) {
 var regExp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
 return regExp.test(email);
}
function IsInvalidName(strName) {
 var regExp = /[bcdfghjklmpqrstvwxz]{5,}|\d|bbb|ccc|ddd|fff|ggg|hhh|jjj|kkk|lll|mmm|nnn|ppp|qqq|rrr|sss|ttt|vvv|www|xxx|zzz/i;
 if(regExp.test(strName)) {return true;}
 if(strName.length == 1) {return true;}
 regExp = /[bcdfghjklmpqrstvwxz]{2,}/i;
 if(strName.length == 2 && regExp.test(strName)) {return true;}
 return false;
}
function IsInvalidFirstLastName(fn,ln) {
 if (fn.length <=1 && ln.length <=1){
 if (fn.toLowerCase() == "t" && ln.toLowerCase() == "t"){return false;}
 return true;
 }
 return false;
}
function IsZip(zipcode) {
 var regExp = /^(\d{5})$/;
 return regExp.test(zipcode);
}
function IsExt(ext) {
 var regExp = /^(\d{0,10})$/;
 return regExp.test(ext);
}
function IsPhone(phone) {
 var regExp = /^([1]?[ -]?[\(]?\d{3}[\)]?[ -]?\d{3}[ -]?\d{4})$/;
 return regExp.test(phone);
}
function IsInvalidPhone(strPhone) {
 var regExp = /000|111/;
 var valid;
 var strFormatedPh = "";
 var strTest = "";
 for (var nNdx = 0; nNdx <strPhone.length; nNdx++) {
 if (!isNaN(strPhone.charAt(nNdx)))
 strFormatedPh += strPhone.charAt(nNdx);
 if (strFormatedPh.length ==3 || strFormatedPh.length == 7)
 strFormatedPh += "-";
 }
 var strTest = new String(strFormatedPh.substr(0,7))
 if (regExp.test(strTest) || strFormatedPh.substr(0,1) == "1" || strFormatedPh.substr(0,3) == "877"  || strFormatedPh.substr(0,3) == "800") {
 return true;
 }
 if (regExp.test(strTest) || strFormatedPh.substr(0,1) == "1" || strFormatedPh.substr(0,1) == "0"){
 return true ;
 }
 regExp = /911|900|877|876|800|500|456|411/;
 strTest = strFormatedPh.substr(0,3)
 if (regExp.test(strTest)){
 return true ;
 }
 regExp = /411|911|611/;
 strTest = strFormatedPh.substr(4,3)
 if (regExp.test(strTest) || strFormatedPh.substr(4,1) == "1" || strFormatedPh.substr(4,1) == "0"){
 return true ;
 }
 regExp = /000-0000|222-2222|333-3333|444-4444|555-5555|666-6666|777-7777|888-8888|999-9999/;
 strTest = strFormatedPh.substr(4,8)
 if (regExp.test(strTest)){
 return true ;
 }
 return false;
}
function Comments_OnKeyPress() {
 if (document.forms[0].purchase_comments.value.length>= 200) {
 window.event.keyCode = 0;
 document.forms[0].purchase_comments.value = document.forms[0].purchase_comments.value.substr(0,200);
 alert("Comments must be 200 characters or less");
 }
}
function Comments_OnChange(f) {
 if (document.forms[0].purchase_comments.value.length>= 200) {
 document.forms[0].purchase_comments.value = document.forms[0].purchase_comments.value.substr(0,200);
 alert("Comments must be 200 characters or less");
 }
}

