$(document).ready(function(){jQuery.validator.addMethod("zipUSCAN",function(a,b){return this.optional(b)||a.match(/(^\d{5}(-\d{4})?$)|(^[A-Za-z]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}\d{1}?$)/)},"Please provide a valid zip or postal code"),jQuery.validator.addMethod("zipUS",function(a,b){return this.optional(b)||a.match(/(^\d{5}(-\d{4})?$)/)},"Please provide a valid zip"),jQuery.validator.addMethod("names",function(a,b){return this.optional(b)||a.match(/(^[A-Za-z -' \.]+$)/)&&!a.match(/(\.exe$)/)},""),jQuery.validator.addMethod("address",function(a,b){return this.optional(b)||!a.match(/(\.exe$)/)},""),jQuery.validator.addMethod("SAT",function(a,b){return a>=200&&a<=2400?1:0},"incorrect score"),jQuery.validator.addMethod("ACT",function(a,b){return a>=0&&a<=36?1:0},"incorrect score"),jQuery.validator.addMethod("phoneUS",function(a,b){return a=a.replace(/\s+/g,""),this.optional(b)||a.length>9&&a.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/)},"Please provide a valid phone number"),jQuery.validator.addMethod("phoneINT",function(a,b){return a=a.replace(/\s+/g,""),this.optional(b)||a.length>6&&a.match(/^\d{7,}$/)},"Please provide a valid phone number"),$("#modifysearch").validate(),$("#noresultsform").validate(),$("#school_searchbox").validate(),jQuery.validator.addMethod("degree_level",function(a,b){return graduate_degree=$("#program_type").val().indexOf("MS")!=-1||$("#program_type").val().indexOf("MCERT")!=-1||$("#program_type").val().indexOf("PHD")!=-1,no_bachelors=$("#education_level").val().indexOf("HS")!=-1||$("#education_level").val().indexOf("GED")!=-1||$("#education_level").val().indexOf("CRT")!=-1||$("#education_level").val().indexOf("AS")!=-1||$("#education_level").val().indexOf("INHS")!=-1||$("#education_level").val().indexOf("NONE")!=-1,graduate_degree&&no_bachelors?!1:!0},"Desired degree level not allowed given highest level of education")}),$.validator.addMethod("required-index0",function(a,b){return $(b).attr("selectedIndex")==0&&!a?!1:!0},"")
$(document).ready( function() {
    var education_level = "";
    var gradyear = "";
    var program_type = "";    
    
    $("#education_level").val(education_level);
    $("#gradyear").val(gradyear);
    $("#program_type").val(program_type);
    
    jQuery.validator.addMethod("degree_level",

            function(degree_level, element) {

                graduate_degree = ($('#program_type').val().indexOf('MS') != -1

                        || $('#program_type').val().indexOf('MCERT') != -1

                        || $('#program_type').val().indexOf('PHD') != -1);

                no_bachelors = ($('#education_level').val().indexOf('HS') != -1

                        || $('#education_level').val().indexOf('GED') != -1

                        || $('#education_level').val().indexOf('CRT') != -1

                        || $('#education_level').val().indexOf('AS') != -1

                        || $('#education_level').val().indexOf('INHS') != -1

                        || $('#education_level').val().indexOf('NONE') != -1);

                if(graduate_degree && no_bachelors) {

                    return false;

                } else {

                    return true;

                }

            },

            "Desired degree level not allowed given highest level of education");


    $('#program_type').change(function(){
        $('form').valid();
    });    
});



