/* Transparency-------------------------------------------------------------- */
/* modify transparency for browsers other than IE --------------------------- */
var contentTransparent = 0;
var currentOpacity = 1;
function toggleTransparency() {
    if (contentTransparent == 1) {
        raiseOpacity();
        document.getElementById('login_container').style.zIndex = 0;
        document.getElementById('content_container').style.zIndex = 1;
    }
    if (contentTransparent == 0) {
        document.getElementById('login_container').style.zIndex = 1;
        document.getElementById('content_container').style.zIndex = 0;
        lowerOpacity();
    }
}
function lowerOpacity() {
    currentOpacity -= .1;
    document.getElementById('content_container').style.opacity = currentOpacity;
    if (currentOpacity >= 0.5) {
        setTimeout("lowerOpacity()",10);    
    }
    else {
        contentTransparent =  1;
    }
}
function raiseOpacity() {
    currentOpacity += .1;
    document.getElementById('content_container').style.opacity = currentOpacity;
    if (currentOpacity <= 1) {
        setTimeout("raiseOpacity()",10);    
    }
    else {
        document.getElementById('content_container').style.zIndex = 0;
        contentTransparent =  0;
    }
}
/* Transparency IE -------------------------------------------------------------- */
var contentTransparentIE = 0;
var currentOpacityIE = 100;
function toggleTransparencyIE() {
    if (contentTransparentIE == 1) {
        raiseOpacityIE();
        document.getElementById('content_container').style.zIndex = 0;
    }
    if (contentTransparentIE == 0) {
        document.getElementById('content_container').style.zIndex = -1;
        lowerOpacityIE();
    }
}
function lowerOpacityIE() {
    document.getElementById('content_container').style.filter = 'alpha(opacity=50)';
    document.getElementById('portlet_content').style.filter = 'alpha(opacity=50)';
    document.getElementById('portlet_title_container').style.filter = 'alpha(opacity=50)';
    document.getElementById('portlet_header_bar').style.filter = 'alpha(opacity=50)';
    
    contentTransparentIE = 1;
}
function raiseOpacityIE() {
    document.getElementById('content_container').style.filter = 'alpha(opacity=100)';
    document.getElementById('portlet_content').style.filter = 'alpha(opacity=100)';
    document.getElementById('portlet_title_container').style.filter = 'alpha(opacity=100)';
    document.getElementById('portlet_header_bar').style.filter = 'alpha(opacity=100)';
    
    contentTransparentIE = 0;
}
    
/* Login -------------------------------------------------------------------- */
var loginHidden = 1;    //is the drop down currently hidden?
var menuSpeed = 10;     //how fast should the menu drop down?
var menuPosition = 0;   //what is the menu's position?
var moving = 0;         //is the menu animating?
function toggleLogin() {
    menuPosition = document.getElementById('login_container').offsetTop;
    if ((loginHidden == 1) && (moving == 0)){
        if (navigator.appName == 'Microsoft Internet Explorer') {
            
            //toggleTransparencyIE();
            document.getElementById('content_container').style.zIndex = 0;
            document.getElementById('login_container').style.zIndex = 1;
        }
        else {
            toggleTransparency();
        }
        showLogin();
    }
    if ((loginHidden == 0) && (moving == 0)){
        if (navigator.appName == 'Microsoft Internet Explorer') {
            //toggleTransparencyIE();
            document.getElementById('content_container').style.zIndex = 1;
            document.getElementById('login_container').style.zIndex = 0;
        }
        else {
            toggleTransparency();
        }
        hideLogin();
    }
}
function showLogin() {
    bottomOfUserChoices = parseInt(document.getElementById('user_choices').offsetHeight)-10;
    menuPosition += menuSpeed;
    document.getElementById('login_container').style.top = menuPosition+'px';
    if (menuPosition <= bottomOfUserChoices) {
        moving = 1;
        setTimeout("showLogin()",10)
    }
    else {
        loginHidden = 0;
        moving = 0;
    }
}
function hideLogin() {
    bottomOfLoginContainer = (parseInt(document.getElementById('user_choices').offsetHeight)+parseInt(document.getElementById('login_container').offsetHeight)+parseInt(document.getElementById('login_container_bottom').offsetHeight))
    menuPosition -= menuSpeed;
    document.getElementById('login_container').style.top = menuPosition+'px';
    if (menuPosition >= bottomOfLoginContainer*-1) {
        moving = 1;
        setTimeout("hideLogin()",10)
    }
    else {
        loginHidden = 1;
        moving = 0;
    }
}
/* Event Listeners ---------------------------------------------------------- */
function addEventListeners()
{
    bottomOfLoginContainer = (parseInt(document.getElementById('user_choices').offsetHeight)+parseInt(document.getElementById('login_container').offsetHeight)+parseInt(document.getElementById('login_container_bottom').offsetHeight))
    if (document.getElementById('login_container'))
    {
            document.onclick = getMousePosition;
    }
}
function getMousePosition(currentElement)
{
         if (navigator.appName == 'Microsoft Internet Explorer') 
         { 
             var mouseX = event.clientX + document.body.scrollLeft
             var mouseY = event.clientY + document.body.scrollTop
             var windowWidth = document.body.offsetWidth;
             var windowHeight =  document.body.offsetHeight;
         }
         else
         {
             var mouseX = parseInt(currentElement.pageX);
             var mouseY = parseInt(currentElement.pageY);
             var windowWidth = parseInt(window.innerWidth);
             var windowHeight = parseInt(window.innerHeight);
         }
         
         //check to see if user clicked outside 
         if (loginHidden == 0)
         {
             bottomOfLoginContainer = (parseInt(document.getElementById('user_choices').offsetHeight)+parseInt(document.getElementById('login_container').offsetHeight)+parseInt(document.getElementById('login_container_bottom').offsetHeight))
             leftOfLoginContainer = parseInt(windowWidth) - parseInt(document.getElementById('login_container').offsetWidth)
//alert(mouseX+" "+leftOfLoginContainer+" "+mouseY+" "+bottomOfLoginContainer );
             if (((mouseX <= leftOfLoginContainer) && (mouseX > 0)) || ((mouseY >= bottomOfLoginContainer) && (mouseY < windowHeight)))
             {
                 toggleLogin();
             }
         }
}
