﻿$(function() {

    $('.error').hide();

    $("input#Login").click(function() {
        var error = false;
        //Validation
        $('.error').hide();
        //alert("1");
        var username = $("input#ctl00_RightContent_RecentMembers_username").val();
        var password = $("input#ctl00_RightContent_RecentMembers_password").val();

        if (password == "") {
            $("label#password_error").show();
            $("input#password").focus();
            error = true;
        }

        if (username == "") {
            $("label#username_error").show();
            $("input#username").focus();
            error = true;
        }

        if (error) {
            return false;
        }
        //alert("2");
        //Post Data
        var dataString = 'email_address=' + username + '&password=' + password;
        $.ajax({
            type: "POST",
            url: "ProcessLogin.aspx",
            data: dataString,
            success: function(response) {
                // Replace the div's content with the page method's return.
                if (response == "Success") {
                    //alert("3");
                    window.location = window.location;
                } else {
                    //alert("4");
                    $("label#login_error").show();
                }
            }
        });

    });
});
  