﻿// JScript File

    function viewVideo(videoFileName)
    {
        var videoWindow = window.open("", "MOvideo", "width=340, height=340");
        var doc = videoWindow.document;
        doc.open("text/html", "replace");
        doc.write("<HTML><HEAD><TITLE>Mossy Oak | Join The Obsession!</TITLE></HEAD><BODY topmargin='0' leftmargin='0' bgcolor='#000000'><embed src='" + videoFileName + "' autoplay='true' width='340' height='340' bgcolor='#000000' cache='true'></BODY></HTML>");
        //videoWindow.moveTo(500, 500);
    }
    // functions for lower level features pages tabs

    var t;
    var delayDuration = 1000;
    function newsOver()
    {
        // hide the div with the how to linkbuttons in it
        var howtoSubmenu = document.getElementById("howtoSubmenu");
        howtoSubmenu.style.display = 'none';
        
        var newsTab = document.getElementById("imgNews");
        var news = document.getElementById("newsSubmenu");
        turnTabOn(newsTab);
        news.style.display = 'block';
        showSubnavBackground();
    }
    
     function howtoOver()
    {
        // hide the div with the news links in it
        var news = document.getElementById("newsSubmenu");
        news.style.display = 'none';
        
        // show the div with the how to subnav linkbuttons in it
        var howtoSubmenu = document.getElementById("howtoSubmenu");
        howtoSubmenu.style.display = 'block';

        // show the bar with the graphic
        showSubnavBackground();

    }   
    
    function newsOut(pageName)
    {
        //alert(pageName);
        if (pageName != "News.aspx")
        {
          var newsTab = document.getElementById("imgNews");  //imgNews is the main News tab

          turnTabOff(newsTab);
          t = window.setTimeout('hideSubnavBackground()', delayDuration);
        }
        if (pageName == "HowToTips.aspx")
            howtoOver();
    }
    
    function howtoOut(pageName, howToTabID)
    {
        var howtoTab = document.getElementById(howToTabID);
        if (pageName == "News.aspx")
        {
            subNewsOver(pageName);
        }
        else if (pageName != "HowToTips.aspx")
        {
          t = window.setTimeout('hideSubnavBackground()', delayDuration);
        }  
        turnTabOff(howtoTab);  

            
    }
    
    function subNewsOver(pageName)
    {
        //alert(pageName);
        var newsTab = document.getElementById("imgNews");
        var news = document.getElementById("newsSubmenu");
        var howtoSubmenu = document.getElementById("howtoSubmenu");
        if (pageName != "News.aspx")
        {
            //show news subnav if hovering over the News tab or subnav news links unless we are on the News page
            // only show if the news tab is in the on image, otherwise the subnav will show if hovered from below
            
            turnTabOn(newsTab);
            news.style.display = 'block';
            howtoSubmenu.style.display = 'none';
            showSubnavBackground();
        }
    }
    
     function subHowtoOver(howtoTabID)
    {
        //alert(pageName);
        var howtoTab = document.getElementById(howtoTabID);
        var howtosubmenu = document.getElementById("howtoSubmenu");
        turnTabOn(howtoTab);
        howtosubmenu.style.display = 'block';
        showSubnavBackground();
    }   
    
    
    function subNewsOut(pageName)
    {

          var newsTab = document.getElementById("imgNews");
          turnTabOff(newsTab);
          t = window.setTimeout('hideSubnavBackground()', delayDuration);
          if (pageName == "HowToTips.aspx")
            howtoOver();

    }
    
    function subHowtoOut(howtoID, pageName)
    {
        if (pageName == "News.aspx")
        {
            newsOver();
        }
        else if (pageName != "HowToTips.aspx")
        {
          var howtoTab = document.getElementById(howtoID);
          turnTabOff(howtoTab);
          t = window.setTimeout('hideSubnavBackground()', delayDuration);
        }

    }
    
    function setNewsTabOn(newsTabPath)
    {
        var newsTab = document.getElementById("imgNews");
        newsTab.src = newsTabPath;
        showSubnavBackground();
    }
    
    function setHowToTabOn(howToTabPath, controlID)
    {
        var howToTab = document.getElementById(controlID);
        howToTab.src = howToTabPath;
        showSubnavBackground();
    }
    
    function turnTabOff(tabImage)
    {
        var picpath = tabImage.src;
        var picOff = picpath.replace("-on-", "-off-");
        tabImage.src = picOff;
    }
    
    function turnTabOn(tabImage)
    {
        
        var picpath = tabImage.src;
        var picOff = picpath.replace("-off-", "-on-");
        tabImage.src = picOff;
    }
    
    function showSubnavBackground()
    {
        var pathToSubnavImage = document.getElementById("imgSubnav");
        var newsBar = document.getElementById('subnavBar');
        stopHideSubnav(); // cancel time delayed hiding of the subnav
        newsBar.style.backgroundImage = "url(" + pathToSubnavImage.src + ")";
    }
    
    function hideSubnavBackground()
    {
        var news = document.getElementById('newsSubmenu');
        var howtosubmenu = document.getElementById('howtoSubmenu');
        var newsBar = document.getElementById('subnavBar');
        var pathToBlankImage = document.getElementById("imgBlank");
        //alert(pathToBlankImage.src);
        newsBar.style.backgroundImage = "url(" + pathToBlankImage.src + ")";
        news.style.display = 'none'; // news submenu links 
        howtosubmenu.style.display = 'none';    
    }
    
    function stopHideSubnav()
    {
        clearTimeout(t);
    }
    
    function toggleDiv(divname)
    {
        //alert(divname);
        var divToToggle = document.getElementById(divname);
        if(divToToggle.style.display == "none")
            divToToggle.style.display = "block";
        else
            divToToggle.style.display = "none";
    }
    
