﻿/*--------------------------------------------------*

    *- Client: ICP Capital
    *- Agency: ASD Labs (asdlabs.com)
    *- Coder: Eugene Vasilchenko
    *- File Creation: 12/19/08
    *- Description: Main Javascript file
    
*--------------------------------------------------*/

//Global Variables
var boolOpenLogin = false;
var intervalId;
var inMotion = false;
var intCounter = 1;

//Either open or close the login based on current state
function LoginClicked()
{
    document.getElementById('error').style.visibility = 'hidden';
    
    //If the box is not already in the middle of being resized
    if(!inMotion)
    {
        //Open the login box if it's closed
        if(!boolOpenLogin)
        {
            clearInterval(intervalId);
		    intervalId = setInterval(OpenLoginBox,10);
		    boolOpenLogin = true;
		    inMotion = true;
		    //document.getElementById('login_title').innerHTML = "PLEASE LOGIN";
        }
        else //Close the login box if it's already open
        {
            clearInterval(intervalId);
		    intervalId = setInterval(CloseLoginBox,10);
		    boolOpenLogin = false;
		    inMotion = true;
        }
    }
}

//Open the login box
function CloseLoginBox()
{
    if(intCounter > 0)
    {
        document.getElementById('menuTopRightLoginArea').style.height = intCounter + 'px';
        
        intCounter -= 1;
    }
    else
    {
        clearInterval(intervalId);
        inMotion = false;
    }
}

//Close the login box
function OpenLoginBox()
{
    if(intCounter < 100)
    {
        document.getElementById('menuTopRightLoginArea').style.height = intCounter + 'px';
        
        intCounter += 1;
    }
    else
    {
        clearInterval(intervalId);
        inMotion = false;
        //document.getElementById('login_title').innerHTML = ">> LOGIN";
    }
}

function ClearUsername() 
{
    document.getElementById('username').value = "";
}

function AttemptLogin() 
{
    document.getElementById('error').style.visibility = 'visible';
}

// Highlight the current link in the navigation based on current page
function HighLightCurrentLink() 
{
    var fullPath = document.location.href;
    var links = document.links;

    //Loop through and change the color of the links which match the current url
    for (var i = 0; i < links.length; i++) 
    {
        if (fullPath == links[i].href) 
        {
            links[i].style.color = "#9c2a2f";
        }
    }
}