
// ***************************************************
//
//  Javascript Functions for the Navigation Bar
//       
// ***************************************************


// --------------------------------------------------
//  Preloading navigation buttons and tabs
// --------------------------------------------------
function preloadNavButtons() 
{
    
    // 06-23-2003: fantico: addresssing some spelling and pre-loading issues with gifs.

    var arrayOfPreloadedImages = new Array();
    
    
    arrayOfPreloadedImages[0] = new Image();
    arrayOfPreloadedImages[0].src = "/images/home.gif";
    arrayOfPreloadedImages[1] = new Image();
    arrayOfPreloadedImages[1].src = "/images/home_over.gif";    
    
    arrayOfPreloadedImages[2] = new Image();
    arrayOfPreloadedImages[2].src = "/images/lightbox.gif";
    arrayOfPreloadedImages[3] = new Image();
    arrayOfPreloadedImages[3].src = "/images/lightbox_over.gif";
    
    arrayOfPreloadedImages[4] = new Image();
    arrayOfPreloadedImages[4].src = "/images/inbox.gif";
    arrayOfPreloadedImages[5] = new Image();
    arrayOfPreloadedImages[5].src = "/images/inbox_over.gif";
    
    arrayOfPreloadedImages[6] = new Image();
    arrayOfPreloadedImages[6].src = "/images/admin.gif";
    arrayOfPreloadedImages[7] = new Image();
    arrayOfPreloadedImages[7].src = "/images/admin_over.gif";
    
    arrayOfPreloadedImages[8] = new Image();
    arrayOfPreloadedImages[8].src = "/images/options.gif";
    arrayOfPreloadedImages[9] = new Image();
    arrayOfPreloadedImages[9].src = "/images/options_over.gif";
    
    arrayOfPreloadedImages[10] = new Image();
    arrayOfPreloadedImages[10].src = "/images/help.gif";
    arrayOfPreloadedImages[11] = new Image();
    arrayOfPreloadedImages[11].src = "/images/help_over.gif";
    
    arrayOfPreloadedImages[12] = new Image();
    arrayOfPreloadedImages[12].src = "/images/logout.gif";
    arrayOfPreloadedImages[13] = new Image();
    arrayOfPreloadedImages[13].src = "/images/logout_over.gif";
    
    // 06-23-2003: fantico: BEGIN addresssing some spelling and pre-loading issues with gifs.
    arrayOfPreloadedImages[13] = new Image();
    arrayOfPreloadedImages[13].src = "/images/cp_archive.gif";
    arrayOfPreloadedImages[14] = new Image();
    arrayOfPreloadedImages[14].src = "/images/cp_archive_over.gif";
    
    arrayOfPreloadedImages[15] = new Image();
    arrayOfPreloadedImages[15].src = "/images/cp_collaborate.gif";
    arrayOfPreloadedImages[16] = new Image();
    arrayOfPreloadedImages[16].src = "/images/cp_collaborate_over.gif"; 
    
    arrayOfPreloadedImages[17] = new Image();
    arrayOfPreloadedImages[17].src = "/images/cp_send.gif";
    arrayOfPreloadedImages[18] = new Image();
    arrayOfPreloadedImages[18].src = "/images/cp_send_over.gif";
    // 06-23-2003: fantico: END addresssing some spelling and pre-loading issues with gifs.
    
    arrayOfPreloadedImages[19] = new Image();
    arrayOfPreloadedImages[19].src = "/images/cart.gif";
    arrayOfPreloadedImages[20] = new Image();
    arrayOfPreloadedImages[20].src = "/images/cart_over.gif";                   

    arrayOfPreloadedImages[21] = new Image();
    arrayOfPreloadedImages[21].src = "/images/pickup.gif";
    arrayOfPreloadedImages[22] = new Image();
    arrayOfPreloadedImages[22].src = "/images/pickup_over.gif";

    // 06-23-2003: fantico: BEGIN addresssing some spelling and pre-loading issues with gifs.
    arrayOfPreloadedImages[23] = new Image();
    arrayOfPreloadedImages[23].src = "/images/mp_archive.gif";
    arrayOfPreloadedImages[24] = new Image();
    arrayOfPreloadedImages[24].src = "/images/mp_archive_over.gif";
    
    arrayOfPreloadedImages[25] = new Image();
    arrayOfPreloadedImages[25].src = "/images/mp_collaborate.gif";
    arrayOfPreloadedImages[26] = new Image();
    arrayOfPreloadedImages[26].src = "/images/mp_collaborate_over.gif"; 
    
    arrayOfPreloadedImages[27] = new Image();
    arrayOfPreloadedImages[27].src = "/images/send.gif";
    arrayOfPreloadedImages[28] = new Image();
    arrayOfPreloadedImages[28].src = "/images/send_over.gif";           
    // 06-23-2003: fantico: END addresssing some spelling and pre-loading issues with gifs.
}


  //preloadNavButtons();


//-------------------------------------
//  em_loadHighlightedButton
//-------------------------------------
//
function em_loadHighlightedButton(selection) // the mouse selection
{ 
    // We store the pre-Highlighted button, for use
    // later with em_loadNormalButton
    document.em_originalButton = selection; //used for restore;

    // Place a meaningful label in the status bar,
    // rather than the URL.
    window.status = document[selection].alt;
    

    // load the mouse-over button
    //
    if (selection != null)
    {
        document[selection].src = "/images/" + selection + "_over.gif";
    }

    return true;
}





//-------------------------------------
//  em_reloadNormalButton
//-------------------------------------
//
function em_reloadNormalButton() 
{
    // empty the status bar of any URL info
    window.status = "";
    
    // reload the original button
    //
    if (document.em_originalButton != null)     //only reload if we remember the selection
    {   
        document.images[document.em_originalButton].src = "/images/" + document.em_originalButton + ".gif"; 
    }
}







//-------------------------------------
//  em_openHelpWindow
//-------------------------------------
//
function em_openHelpWindow(uri) 
{
 
    var features = "height=500,width=600,location=no,menubar=yes,toolbar=no,resizable=yes,scrollbars=yes";
    g_childWindow = window.open(uri, "help", features);
    g_childWindow.focus();
}



//-------------------------------------
//  em_nill
//-------------------------------------
//
function em_nill(){}


// ------- Functions for XMLHttpRequest Interface ---------

// global flag
var isIE = false;

 // global request and XML document objects
var req;

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url)
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    }
    // branch for IE/Windows ActiveX version
    else if (window.ActiveXObject)
    {
        isIE = true;
        req = getxmlhttp();
        if (req)
        {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
    return true;
}


function getxmlhttp() 
{ 
    var progIDs = ["MSXML2.xmlhttp.5.0","MSXML2.xmlhttp.4.0","MSXML2.xmlhttp.3.0","MSXML2.xmlhttp","Microsoft.xmlhttp"]; 
    for(var currentProgID = 0;currentProgID < progIDs.length;currentProgID++) 
    { 
    try 
    { 
        xml = new ActiveXObject(progIDs[currentProgID]);       
        return xml; 
    } 
    catch(e){} 
    } 
}


// handle onreadystatechange event of req object
function processReqChange()
{
    // only if req shows "loaded"
    if (req.readyState == 4)
    {
        // only if "OK"
        if (req.status == 200)
        {
            replaceData(req.responseText);
        }
        else if (req.status == 400)
        {
            if(req.responseText.search(/MediaPartner Session Expired/) != -1 )
            {
                window.location = window.location;
                return;
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

// -- Generic function that is used to open a url either in current window
// -- or in parent window if popup == true.
function navigateTo( url, popup) 
{
    if(popup == true)
    window.opener.location = url;
    else
    window.location = url;  

}
