function testJScript()
{
    if (document.getElementById)
    {
        $('#jsMessage').css({display: "none"});
        return true;
    }
    else
    return false;
}

function testFlash()
{
    version = swfobject.getFlashPlayerVersion();
    if (version['major'] < 9)
    {
        $('#flashMessage').css({display: "block"});
        return false;
    }
    else
    return true;
}

function testBrowser()
{
    if($.browser.opera)
    {
        $('#browserMessage').css({display: "block"});
        return false;
    }
    else
    return true;
}

function testCookies()
{
    if(document.cookie != "")
    return true;
    else
    {
        $('#cookiesMessage').css({display: "block"});
        return false;
    }
}

$(document).ready(function()
{   
    if(testJScript() && testFlash() && testBrowser() && testCookies())
    {
        $('#loginContent').css({display: "block"});
    }
    $('.inputFields input').keypress(function(event){
        if(event.keyCode == 13)
        {
            $("#formItself").trigger("submit");
        }
        return true;
    })
    
    focus();
});

function focus()
{
    var loginBox = document.getElementById('loginid');
    var loginSelect = document.getElementById('loginid_select');
    var passwordBox = document.getElementById('password');
    var emailBox = document.getElementById('email');

    try
    {
        // might be on password page
        if (emailBox)
        {
          emailBox.focus();

        }

        // demo version
        else if (loginSelect)
        {
            loginSelect.focus();

        }

        // focus on login box if nothing is in it
        else if (loginBox && loginBox.value.length == 0)
        {
            try
            {
                loginBox.focus();
            } catch (e)
            {
                if (passwordBox)
                {
                    passwordBox.focus();
                }
            }

        }

        else if (passwordBox)
        {
            passwordBox.focus();

        }

     } catch (e)
     {
     }


}
