/*##################################################################################
####################################################################################
####        ValidateContactUs                                                   ####
####        Validates the form field values before allowing the form to submit  ##*/
function ValidateContactUs(){
    var Valid = true;
    var Messages = "";
    var Pattern = "";
    
    if(jQuery("input#C_Name").val()){
        if(!validateName_NotStrict(jQuery("input#C_Name").val())){
            Valid = false;
            Messages += "<li>The <b>Name</b> does not appear to be correct.  Try something like <i>John Smith</i></li>";
        }
    } else {
        Valid = false;
        Messages += "<li>The <b>Name</b> is required</li>";
    }
    
    if(jQuery("input#C_Email").val()){
        if(!validateEmail(jQuery("input#C_Email").val())){
            Valid = false;
            Messages += "<li>The <b>Email</b> does not appear to be correct</li>";
        }
    } else {
        Valid = false;
        Messages += "<li>The <b>Email</b> is required</li>";
    }
    
    if(!jQuery('input#C_Address').val())
    {
    	Valid = false;
    	Messages += '<li>The <b>Address</b> is required</li>';
    }
    
    if(!jQuery('input#C_City').val())
    {
    	Valid = false;
    	Messages += '<li>The <b>City</b> is required</li>';
    }
    
    if(!jQuery('select#C_State').val())
    {
    	Valid = false;
    	Messages += '<li>The <b>State</b> is required</li>';
    }
    
    if(!jQuery('input#C_Zip').val())
    {
    	Valid = false;
    	Messages += '<li>The <b>Zip</b> is required</li>';
    }
    
    if(!jQuery('input#C_Phone').val())
    {
    	Valid = false;
    	Messages += '<li>The <b>Phone</b> is required</li>';
    }
    
    var CountChecks = 0;
    jQuery.each(
        jQuery('input.Check'),
        function(){
            if(jQuery(this).attr('checked')){
                CountChecks++;
            }
        }
    );
    if(CountChecks == 0){
        Valid = false;
        Messages += "<li>At least one BHI community must be selected</li>";
    }
    if(jQuery('input#C_Location_Other').attr('checked')){
        if(!jQuery('input#C_LocationOther').val()){
            Valid = false;
            Messages += '<li>Please enter the <b>Other</b> information you are interested in</li>';
        }
    }
    
    
    if(!Valid){
        jQuery("div#FormErrors")
            .show("slow")
            .html("<ul>" + Messages + "</ul>");
    }
    
    return Valid;
}



jQuery('window').ready(
    function(){
        jQuery('input#C_LocationOther').keyup(
            function(){
                if(jQuery(this).val()){
                    jQuery('input#C_Location_Other').attr('checked', 'checked');
                } else {
                    jQuery('input#C_Location_Other').attr('checked', '');
                }
            }
        );
    }
);
