﻿// Set a global reference to the Flash object.
var spotlight = null;

function getFlashMovieObject(movieName)
{
    if (window.document[movieName]) 
    {
        return window.document[movieName];
    }
    if (document.embeds && document.embeds[movieName])
    {
        return document.embeds[movieName]; 
    }
    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    {
        return document.getElementById(movieName);
    }
}

function ensureFlash()
{
    // If the global Flash reference is not set, get it.
    if (!spotlight) spotlight = getFlashMovieObject("SpotlightNav");
    if (!spotlight) spotlight = getFlashMovieObject("spotlight");
}

function flashSearch(searchText)
{
    searchText = unescape(searchText);
    runSearch(searchText);
}

function menu_mouseOver(item)
{
    ensureFlash();
    
    // If it exists...
    if (spotlight)
    {
        // Get the name of the menu item...
        var menuName = item.Text.toLowerCase();
        
        // Set the proper state in Flash (1 = mouse over, 0 = mouse out) - so initialize to 0 in Flash.
        switch (menuName)
        {
            case "home":
                spotlight.SetVariable("homeOver", "1"); 
                break;
                
            case "products":
                spotlight.SetVariable("productsOver", "1"); 
                break;
                
            case "solutions":
                spotlight.SetVariable("solutionsOver", "1"); 
                break;
                
            case "resources":
                spotlight.SetVariable("resourcesOver", "1"); 
                break;
                
            case "support":
                spotlight.SetVariable("supportOver", "1"); 
                break;
                
            case "partners":
                spotlight.SetVariable("partnersOver", "1"); 
                break;
                
            case "company":
                spotlight.SetVariable("companyOver", "1"); 
                break;
        }
    }
}

function menu_mouseOut(item)
{
    ensureFlash();            
    
    // If it exists...
    if (spotlight)
    {
        // Get the name of the menu item...
        var menuName = item.Text.toLowerCase();
        
        // Set the proper state in Flash (1 = mouse over, 0 = mouse out) - so initialize to 0 in Flash.
        switch (menuName)
        {
            case "home":
                spotlight.SetVariable("homeOver", "0"); 
                break;
                
            case "products":
                spotlight.SetVariable("productsOver", "0"); 
                break;
                
            case "solutions":
                spotlight.SetVariable("solutionsOver", "0"); 
                break;
                
            case "resources":
                spotlight.SetVariable("resourcesOver", "0"); 
                break;
                
            case "support":
                spotlight.SetVariable("supportOver", "0"); 
                break;
                
            case "partners":
                spotlight.SetVariable("partnersOver", "0"); 
                break;
                
            case "company":
                spotlight.SetVariable("companyOver", "0"); 
                break;
        }
    }
}
