$(document).ready(function() {
    $('input[type="text"]').focus(function() {
        if (this.value == this.defaultValue){ 
            this.value = '';
        }
        if(this.value != this.defaultValue){
            this.select();
        }
    });
    $('input[type="text"]').blur(function() {
        if ($.trim(this.value) == ''){
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });
    
    // Pulled from cavtel.com validation
    $("#form").submit(function() {
        var address = $("#address").val();
        var city = $("#city").val();
        var state = $("#state option:selected").val();
        var zip = $("#zip").val();
        
        var isError = false;
        var errorMsg = "";

        if (address == null || address == "" || address == "Address") {
            isError = true;
            errorMsg += "Please enter your address.\r\n";
        }

        if (city == null || city == "" || city == "City") {
            isError = true;
            errorMsg += "Please enter your city.\r\n";
        }

        if (state == null || state == "") {
            isError = true;
            errorMsg += "Please select your state.\r\n";
        }

        if (zip == null || zip == "" || zip == "Zip") {
            isError = true;
            errorMsg += "Please enter your zip code.\r\n";
        }

        // We've gathered all our errors, proceed.
        if(!isError){
            //GOOGLE ANALYTICS TRACKING
            //pageTracker._trackPageview("/baltimore/check/"); 
            return true;
        }else{
            alert(errorMsg);
            return false;
        }
    });
});