﻿/* ----------------------------------------------
 * Browse through all layers looking for the one 
 * with a specific ID. If found show it. If the 
 * layer is a sibling hide it.
 *  A.Carey, 04.2008
 * ---------------------------------------------- */
function showItem(first6Id, boxID){
    var aDivs = document.getElementsByTagName("div");
    
    for(iCount = 0; iCount < aDivs.length; iCount++){
        if(aDivs[iCount].id.substr(0,6) == first6Id && aDivs[iCount].id == boxID){
            aDivs[iCount].style.display = "block";
        }
        else if(aDivs[iCount].id.substr(0,6) == first6Id){
            aDivs[iCount].style.display = "none";
        }
    }

    return false;
}

/* ----------------------------------------------
 * 
 * M. Pine, 10.2008
 * ---------------------------------------------- */
 
 
    function LinkTo(Url)
    {
        window.location = Url;
    }
    function NewWindow(Url, WinName, W, L)
    {
        var left = 0;
        var screenWidth = screen.width;
        if (parseInt(navigator.appVersion)>3) {
             if (navigator.appName=="Netscape") {
              winW = window.innerWidth;
             }
             if (navigator.appName.indexOf("Microsoft")!=-1) {
              winW = document.body.offsetWidth;
             }
        }
        left = (screenWidth / 2) - (W / 2);
        Win1 = window.open(Url, WinName, 'width='+W+',height='+L+',toolbar=1,menubar=1,resizable=1,scrollbars=1,location=1,left='+left+',top=80');
        setTimeout("ScreenFade()",2000);
    }
    function ScreenFade()
    {
        DarkenPage();
        ShowMessagePanel();
        check();
    }

    function ShowMessagePanel()
    {
        var msg_panel = document.getElementById('msg_panel');
        var msg_panel_shadow = document.getElementById('msg_panel_shadow');
        var page_screen = document.getElementById('page_screen');
        
        // w is a width of the newsletter panel
        w = 300;
        // h is a height of the newsletter panel
        h = 125;
        if (parseInt(navigator.appVersion)>3) {
             if (navigator.appName=="Netscape") {
              winW = window.innerWidth;
              winH = window.innerHeight;
             }
             if (navigator.appName.indexOf("Microsoft")!=-1) {
              winW = document.body.offsetWidth;
              winH = document.body.offsetHeight;
              //alert("winH: " + winH + " winW: " + winW);
             }
        }
        
        // get the x and y coordinates to center the newsletter panel
        xc = (Math.round((winW/2)-(w/2)))-150;
        yc = (Math.round((winH/2)-(h/2)))-200;
        
        //alert("left: " + xc + " top: " + yc);
        
        //Shadow Lead
        var sl = 5;
        
        // show the newsletter panel
        //msg_panel.style.left = xc + "px";
        //msg_panel.style.top  = yc + "px";
        //msg_panel_shadow.style.left = (xc + sl) + "px";
        //msg_panel_shadow.style.top  = (yc + sl) + "px";
        msg_panel.style.display = 'block';
        msg_panel_shadow.style.display = 'block';
        msg_panel.style.zIndex = "2011";
        msg_panel_shadow.style.zIndex = "2010";
        page_screen.style.zIndex = "10";
    }

    function BackToRMAnalytics()
    {
        // hide the newsletter panel
        var msg_panel = document.getElementById('msg_panel');
        var msg_panel_shadow = document.getElementById('msg_panel_shadow');
        msg_panel.style.display = 'none';
        msg_panel_shadow.style.display = 'none';
        // lighten the page again
        LightenPage();
    }

    // this function puts the dark screen over the entire page
    function DarkenPage()
    {
        if (parseInt(navigator.appVersion)>3) {
             if (navigator.appName=="Netscape") {
              winW = window.innerWidth;
              winH = window.innerHeight;
             }
             if (navigator.appName.indexOf("Microsoft")!=-1) {
              winW = document.body.offsetWidth;
              winH = document.body.offsetHeight;
             }
        }

        var page_screen = document.getElementById('page_screen');
        page_screen.style.height = winH + 'px';
        page_screen.style.display = 'block';
    }

    // this function removes the dark screen and the page is light again
    function LightenPage()
    {
        var page_screen = document.getElementById('page_screen');
        page_screen.style.display = 'none';
    }

    function check() {
        if (Win1)
        {
            if (Win1.closed) 
            {
            //alert('Window is closed.');
            BackToRMAnalytics();
            } else 
            {
                setTimeout("check()",1);
            }
        }
    }
    function popScreenOn(screenName)
    { 
        var screen = document.getElementById(screenName);
        screen.style.display = 'block';
        DarkenPage();
    }
    function popScreenOff(screenName)
    {
        var screen = document.getElementById(screenName);
        screen.style.display = 'none';
        LightenPage()
    }
    
    function helpBox(action, place, content)
    {
        var strFunction;
        if (action == "show")
        {
            strFunction = "showHelp('" + place + "', '" + content + "')";
            setTimeout(strFunction, 500);
        }
        if (action == "hide")
        {
            strFunction = "hideHelp('" + place + "')";
            setTimeout(strFunction, 500);
        }
    }

    function showHelp(placeName, helpContentName)
    {
        var helpBoxPlace = document.getElementById(placeName);
        var helpBoxContent = document.getElementById(helpContentName);
        helpBoxPlace.innerHTML = helpBoxContent.innerHTML;
    }

    function hideHelp(placeName)
    {
        var helpBoxPlace = document.getElementById(placeName);
        helpBoxPlace.innerHTML = "";
    }
