function checkForm()
{
        var errMsg = '';
        errFields = [];
		var hasError = false;
		var hasRegError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var phoneReg = /^[\d]{3}-[\d]{3}-[\d]{4}$/;
        
		$('.label').css('color',null);	
		//Validate Fields
		//First name
		var fNameVal = $("#fname").val();
		//Is it blank?
		if(fNameVal == '') {
			errMsg += "Please enter your first name<br>";
			errFields.push('fname');
			hasError = true;
		}else if (/[\d]+/.test(fNameVal)){
		    //If it's not blank does it contain only letters
            errMsg += "First Name can only contain letters<br>";
            hasRegError = true;
        }
        //Last name
		var lNameVal = $("#lname").val();
		if(lNameVal == '') {
			errMsg += "Please enter your last name<br>";
			errFields.push('lname');
			hasError = true;
		}else if (/[\d]+/.test(lNameVal)){
            errMsg += "Last Name can only contain letters<br>";
            hasRegError = true;
        } 
        //email       
        var emailVal = $("#email").val();
		if(emailVal == '') {
			errMsg += "Please enter your email<br>";
			errFields.push('email');
			hasError = true;
		}else if(!emailReg.test(emailVal)) {
		    errMsg += "Email is an invalid format.<br>(Ex:example@example.com)<br>";
		    hasRegError = true;
		}
		//Phone
	    var phoneVal = $("#phone").val();
		if(phoneVal == '') {
			errMsg += "Please enter your phone number<br>";
			errFields.push('phone');
			hasError = true;
		}else if (!phoneReg.test(phoneVal)) {
            errMsg += "Phone Number is an invalid format.<br>(Ex: xxx-xxx-xxxx)<br>";
            hasRegError = true;
        }
        //Business name
        var bnameVal = $("#bname").val();
        //Street
        var streetVal = $("#street").val();
        //City
        var cityVal = $("#city").val();
        //State
        var stateVal = $("#state").val();
        //Zip
        var zipVal = $("#zip").val();
        //Comments
        var commentsVal = $("#comments").val();
      
        //if all required fields have been filled in
    	if(errFields.length == 0) {
    	    //check for format errors
    	   if (hasRegError) {
                //add the button to unblock the form to the error message
                errMsg += "<br><input type=\"button\" id=\"closeErrMsg\" onclick=\"$('#form1').unblock();\" value=\"OK\" />"
                //block the form
                $('#form1').block({
                    //the message to display
                    message: errMsg, 
                    //styles for the message box
                    css: { border: '3px solid #a00', width: '300px' }
                });
                
                return false;
                
            } else {
                //if no errors have been detected submit the form via ajax call
                $.post("Scripts/sendMail.php",
                    {submit: 1, fname: fNameVal, lname: lNameVal, bname: bnameVal, phone: phoneVal, email: emailVal, street: streetVal, city: cityVal, state: stateVal, zip: zipVal, comments: commentsVal},
                   	function(data)
                    {
                   	    if(data == 1) {
                            //block out the form and display the confirmation message
                       	    errMsg = "You're email has been sent!<br>";
                            errMsg += "<input type=\"button\" id=\"jump\" onclick=\"window.location ='default.htm'\" value=\"OK\" />";
                       	    $('#form1').block({
                            message: errMsg, 
                            css: { border: '3px solid #a00', width: '300px' }
                            });
                        } else {
                            return alert('There was an error sending your email!');
                        }
                    });
            }
        } else {
            //add the button to unblock the form to the error message
            errMsg += "<br><input type=\"button\" id=\"closeErrMsg\" onclick=\"$('#form1').unblock();\" value=\"OK\" />"
            for (var i = 0; i<errFields.length; i++) {
                $('.'+errFields[i]).css('color','red');
            }
            //block the form
            $('#form1').block({
                //the message to display
                message: errMsg, 
                //styles for the message box
                css: { border: '3px solid #a00', width: '300px' }
            });

            return false;
        }      
				
	return false;
}