﻿
var userInformation = null;    
var userInfoDataObject = null;
document.observe("dom:loaded", initPage);

function initPage() {
    userInformation = new UserInformation();
    cookieRedirect = readCookie("Redirect");
    if (cookieRedirect != '') {
        $('signInInProcess').show();
    }
}

function PerformSignIn() {
    $('EnterEmail').hide();
    $('EnterPassword').hide();
    $('BadCombination').hide();
    if ($('txtEmail').value == '' || $('txtEmail').value.indexOf('@') == -1 || $('txtEmail').value.indexOf('.') == -1) {
        $('EnterEmail').toggle();
        return;
    }
    if ($('txtPassword').value == '') {
        $('EnterPassword').toggle();
        return;
    }
    userInfoDataObject = userInformation.CheckLogin($('txtEmail').value, $('txtPassword').value);
    if (userInfoDataObject.Valid == true) {
        cookieRedirect = readCookie("Redirect");
        if (cookieRedirect != '') {
            window.location.href = cookieRedirect;
            return;
        }
        window.location.href = "myaccount/Dashboard.htm"
        return;
    } 
    $('BadCombination').toggle();
}