
$(document).ready(function(){

// prepare Options Object
var options = {
    target:     '#login_error',
    url:        'includes/ajax/logIn.php',
    beforeSubmit: validate23,
    success:    function() {
       setTimeout('delayer()', 500);
        }
};
// pass options to ajaxForm
$('#loginForm').ajaxForm(options);
 });

 function validate23() {
 //$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
    //$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
    //$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
    //$("#TB_load").show();
    $('#login_error').empty();
    var answer = $("#login_error");
         if (answer.is(':hidden')) {
         $('#login_error').fadeIn();
         
        //return false;
         //$("#TB_overlay").hide();
         }
    // fieldValue is a Form Plugin method that can be invoked to find the
    // current value of a field
    //
    // To validate, we can capture the values of both the username and password
    // fields and return true only if both evaluate to true

    var usernameValue = $('input[@name=email]').fieldValue();
    var passwordValue = $('input[@name=password]').fieldValue();

    // usernameValue and passwordValue are arrays but we can do simple
    // "not" tests to see if the arrays are empty
    if (!usernameValue[0] || !passwordValue[0]) {
        alert('Please enter a value for Username, and Password');
        return false;
    }
    else
        return true;
}

function delayer(){
var suc;
suc = document.getElementById('login_error').innerHTML;
//alert(suc);
if (suc == 'Success') {
setTimeout('window.location = "my_account.php"', 000);
}else{
 alert('We could not verify your login credentials. Please check your username and password and try again.');
}
}