$(document).ready(function(){

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

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

 });

 function validate2() {
    $('#login_error').empty();
    var answer = $("#login_error");
         if (answer.is(':hidden')) {
         $('#login_error').fadeIn();
         }
    // 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=user_id]').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 = "cashier.php"', 000);
}
else {
}
}
function delayer2(){
var suc;
suc = document.getElementById('login_error').innerHTML;
//alert(suc);
if (suc == 'Success') {
setTimeout('window.location = "invite_Friends.php"', 000);
}
}