﻿
/*
    Computer Science Group, LLC
    225-766-2397 office
    225-205-0263 cell
    darrell@computersciencegroup.com
    Copyright © 2008 Computer Science Group, LLC, All rights reserved.
*/

//textboxes
var ouserName;
var opassWord;

//pageLoad()
//08/17/2009
function pageLoad()
{
    var oTextBox;
    /****************************************************************************************/
    //09/11/2009
    //do this for all pages
    ocsgPage.initializePage();
    /****************************************************************************************/
    //
    //textboxes
    ouserName = new csgTextBox("userName");
    opassWord = new csgTextBox("passWord");
    //disable log in button unless user name/password entered
    disableLogInButtonIfNoUserNameAndPassword();
    //focus on user name
    focusOnUserName();
    /****************************************************************************************/
    //09/11/2009
    //do this for all pages
    ocsgPage.finishUpPageLoad();
    /****************************************************************************************/
}

//focusOnUserName()
//08/17/2009
function focusOnUserName()
{
    if ((!ouserName.textBox.value) && (!opassWord.textBox.value))
    {
        try { ouserName.textBox.focus(); }
        catch (e) {}
    }
}

//ocsgPage.textBoxOnKeyDown(<opTextBox>)
//08/17/2009
ocsgPage.textBoxOnKeyDown = function(opTextBox)
{
    var oBtn;
    if (window.event.keyCode  == 13)
    {
        oBtn = $get("btnLogIn");
        if (oBtn) { oBtn.focus(); }
        logIn();
    }
}

//ocsgPage.textBoxOnKeyUp(<opTextBox>)
//08/19/2009
ocsgPage.textBoxOnKeyUp = function(opTextBox) { disableLogInButtonIfNoUserNameAndPassword(); }

//disableLogInButtonIfNoUserNameAndPassword()
//08/19/2009
function disableLogInButtonIfNoUserNameAndPassword()
{
    var oBtn = $get("btnLogIn");
    if (oBtn)
    {
        if (ouserName.textBox.value == "")
        {
            oBtn.disabled = "disabled";
            return;
        }
        if (opassWord.textBox.value == "")
        {
            oBtn.disabled = "disabled";
            return;
        }
    }
    oBtn.disabled = "";
}

//onClick(<e>)
//08/17/2009
function onClick(e) { if (e.id == "btnLogIn") { logIn(); } }

//logIn()
//08/28/2009
function logIn()
{
    ocsgPage.setPostBackActionValue("login");
    document.form1.submit();
}