﻿/// <reference path="../Assets/js/jquery-1.3.2.js" />

$("#SignIn").hide();


$.validator.addMethod("IsValidPW", function(value) { return tools.alphanumeric(value); }, 'Please enter a valid password');

$().ready(function() {


var validator = $("#SignUpForm").bind("invalid-form.validate", function() {
    $("#Error").html("Oops, there were " + validator.numberOfInvalids() + " problems with the information you entered. <br>Please correct the highlighted fields.").show();
}).validate({
    debug: true,
    errorElement: "em",
    //errorContainer: $("#warning, #Error"),
    errorPlacement: function(error, element) {
        error.appendTo(element.parent("td").next("td"));
    },
    success: function(label) {
        label.html("&nbsp;").addClass("success");
    },
    submitHandler: function() {
        $("#SignUpForm, #SignUpForm input").unbind();
        $("#SignUpForm").submit();
    },
    rules: { 
        zEmail: {
            required: true,
            minlength: 6,
            maxlength: 320 //,
           // email: true
        },
        zPassword: {
            required: true,
            minlength: 6,
            maxlength: 20,
            IsValidPW: true

        } 
    },
    messages: { 
        zEmail: "Required",
        zPassword: {
            required: "Required",
            minlength: "Your password must be at least 5 characters long"
        } 
    }

});

$(".input, select").blur(function() {
    $(this).valid();
});


$(".input").focus(function() { $(this).addClass("focus"); }).blur(function() { $(this).removeClass("focus"); });
    
});

$().keyup(function(e) {
    if (e.keyCode == 13) {
        $("#SignUpForm").submit();
    }
});
