function checkForm(){
                //change form to your form's name
                if (checkCart()!=false) { document.contact.submit(); }
}
function checkCart(){
                //change form to your form's name, field to the field's name,
                //and 'Message' to the text you want to show in the alert if not filled out
				var d = document.contact;
				if (checkValid(d.fullname,'First Name is required.')==false) {return (false);}
				else if (checkValid(d.address,'Your Address is required.')==false) {return (false);}
				else if (checkValid(d.city,'Your City is required.')==false) {return (false);}
				else if (checkValid(d.state,'Your State is required.')==false) {return (false);}
				else if (checkValidNumber(d.zip,'Your Zip is required.')==false) {return (false);}
				else if (checkValidNumber(d.phone,'Your Phone is required.')==false) {return (false);}
				else if (checkValidEmail(d.email,'A Valid Email is required.')==false) {return (false);}
                else { return true; }
}
function checkValid(field,text) {
                field.style.border = "1px solid #7f9db9"; //7f9db9 is the standard IE blue-gray border color
                field.style.background = "#fff";
                //tests for empty string, empty space, null, or -1 (usually for selects)
                if ((field.value == "") || (field.value == " ") || (field.value == null) || (field.value <= 0)){
                                field.style.border = "2px solid #f00";
                                field.style.background = "#fbb";
                                alert(text);
                                field.focus();
                                return (false);
                }
}
function checkValidNumber(field,text) {
                field.style.border = "1px solid #7f9db9"; //7f9db9 is the standard IE blue-gray border color
                field.style.background = "#fff";
                //tests for empty string, empty space, null
                if ((field.value == "") || (field.value == " ") || (field.value == null) || (isNaN(field.value)==true)){
                                field.style.border = "2px solid #f00";
                                field.style.background = "#fbb";
                                alert(text);
                                field.focus();
                                return (false);
                }
}
function checkValidRadio(field,text) {
                field.style.background = "#fff";
                //tests for empty string, empty space, null
                if (Radios(field.value) == null){
                                field.style.background = "#fbb";
                                alert(text);
                                field.focus();
                                return (false);
                }
}

function checkValidEmail(field,text) {
                // will ensure that the format of the email is at least: xx@yy.zz
                field.style.border = "1px solid #7f9db9"; //7f9db9 is the standard IE blue-gray border color
                field.style.background = "#fff";
                var e = field.value;
                var validEmail = true;
                var len = field.value.length;
                var at = field.value.indexOf("@");
                var dot = field.value.indexOf(".",at);

                if (e.indexOf("@")==-1 || e.indexOf("@")==0 || e.indexOf("@")==len) {validEmail = false;}
                if (e.indexOf(".")==-1 || e.indexOf(".")==0 || e.indexOf(".")==len) {validEmail = false;}
                if (e.indexOf("@",(at+1))!=-1) {validEmail = false;}
                if (e.substring(at-1,at)=="." || e.substring(at+1,at+2)==".") {validEmail = false;}
                if (e.indexOf(".",(at+2))==-1) {validEmail = false;}
                if (e.indexOf(" ")!=-1) {validEmail = false;}
                if (e.substring(0,at+1).length < 3)  {validEmail = false;}
                if (e.substring(at,dot+1).length < 4)  {validEmail = false;}
                if (e.substring(dot).length < 3)  {validEmail = false;}
                
                if ((e == "") || (e == " ") || (e == null) || (validEmail == false)){
                                field.style.border = "2px solid #f00";
                                field.style.background = "#fbb";
                                alert(text);
                                field.focus();
                                return (false);
                }
}
function Radios (btn) {
    var ndx = -1;
    for (var i=btn.length-1; i>-1; i--)
                { if (btn[i].checked) {ndx = i; i = -1;} }
    if (ndx > -1) {return btn[ndx].value;}
    else {return null;}
}

