//<!--

function ChangePanelClass(idPrefix)
{
    var newCookieState;
    var box = document.getElementById(idPrefix + 'Box');
    var title = document.getElementById(idPrefix + 'Title');
    var slideId = "#" + idPrefix + "Slide";
    
    if (box != null && title != null)
    {
        if (title.className.match('tablet'))
        {
            title.className = "";
            box.className = "collapse box";
            newCookieState = "Open";
            
            $(slideId).slideDown('slow');
        }
        else if (box.className.match('box'))
        {
            $(slideId).slideUp('slow', function() 
            {
                title.className = "tablet";
                box.className = "collapse";
            });

            newCookieState = "Collapsed";
        }
        
        SetCookie(idPrefix + 'PanelState', newCookieState);
    }
}

function ChangeStarRating(rating, starsId)
{
    var starHolder = document.getElementById(starsId);
    if (starHolder != null)
    {
        starHolder.className = "stars rating" + rating;
    }
}

function GetHeight()
{
    if (window.innerHeight > 0)
    {
        return window.innerHeight;
    }
    else
    {
        return document.documentElement.clientHeight;
    }
}

function ResizeBody()
{
    var header = document.getElementById("Header");
    var body = document.getElementById("Body");
    var footer = document.getElementById("Footer");

    if (header != null && body != null && footer != null)
    {
        var height = GetHeight() - header.offsetHeight - footer.offsetHeight;

        if (height > body.offsetHeight)
        {
            body.style.height = height + "px";
        }
    }
}

function RunFunctions()
{
    ResizeBody();
    setTimeout('FadeLanguage(1)', 4000);
    
    if (typeof(ActivateAccordion) == 'function') ActivateAccordion();
    if (typeof(BingMapInit) == 'function') BingMapInit();
    if (CloseGITPanel) ChangePanelClass('GIT');
    if (CloseETPanel) ChangePanelClass('ET');
    //if (CloseRFEPanel) ChangePanelClass('RFE');
    if (typeof(SetHovers) == 'function') SetHovers();
    if (typeof(JobApplicationLoad) == 'function') JobApplicationLoad();
}

function SetCookie(cookieName, value)
{
    var expireDays = 15;
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() + expireDays);
    document.cookie = cookieName + "=" + escape(value) + ";expires=" + expireDate.toGMTString();
}

function FadeLanguage(indexId) 
{
    var length = $('#Languages li').length;
    var active = $('#Language' + indexId);
    var nextId = indexId + 1;
    if (nextId > length)
    {
        nextId = 1;
    }
    
    var next = $('#Language' + nextId);
    
    active.fadeOut(1000, function()
    {
        active.removeClass('active');
    });
    
    next.fadeIn(1000, function()
    {
        setTimeout('FadeLanguage(' + nextId + ')', 4000);        
    })
    .addClass('active');
}




/*Run window functions*/

window.onload = function()
{
    RunFunctions();
};

window.onresize = function()
{
    ResizeBody();
};



//-->
