﻿
/*

$(document).ready(function(){
    //the background image of the menu item after Home should be the arrow without the top border when Home is selected
    $(".navonfirst").next().css("background", "#F3F3F3 url('/images/menu-background-arrow.png') no-repeat scroll left top");
    
    //if this is a top level element right below an active sub-menu, the background image needs to be changed to the arrow without a top border line
    $(".navoff").filter(shouldChangeBackgroundToSingleArrow).css("background", "#F3F3F3 url('/images/menu-background-arrow.png') no-repeat scroll left top");
    
    //when the top level element on the nav bar is not active, but one of it's child menu items is active, it's background is wrong.  The code below fixes that
    $(".navoff").filter(shouldChangeBackgroundToWhite).each(changeUnselectedTopLevelElementBackgroundAndBorder);
    
    //sets the bottom border of "Getting a Prescription" when it's selected
    $('.subnavofffirst').filter(nextIsNewSection).each(changeGettingPrescriptionBorder);
    $('.subnavonfirst').filter(nextIsNewSection).each(changeGettingPrescriptionBorder);
    
    //when a menu item without a submenu is selected, the bottom border needs to be set and the next elements arrow needs to be changed
    $('.navon').filter(isTopLevelWithoutSubMenu).css("border-bottom", "1px solid #D6D6D6");
    $('.navon').filter(isTopLevelWithoutSubMenu).next().css("background", "#F3F3F3 url('/images/menu-background-arrow.png') no-repeat scroll left top");
});

var shouldChangeBackgroundToSingleArrow = function(i){return ($(this).prev().is(".subnavofflast") || $(this).prev().is(".subnavonlast") );}
var shouldChangeBackgroundToWhite = function(i){return ($(this).next().is(".subnavonfirst") || $(this).next().is(".subnavofffirst") );}
var nextIsNewSection = function(i){return $(this).next().is(".navoff");}
var isTopLevelWithoutSubMenu = function(i){return ($(this).next().is(".navoff") || $(this).next().is(".navofflast")) ;}

var changeGettingPrescriptionBorder = function(i){
            $(this).css("border-bottom", "1px solid #D6D6D6");
            $(this).next().css("background", "#F3F3F3 url('/images/menu-background-arrow.png') no-repeat scroll left top");
        }
        
var changeUnselectedTopLevelElementBackgroundAndBorder = function(i){
            $(this).css("background", "#FFFFFF url('/images/menu-background-arrow.png') no-repeat");
            $(this).css("border-top", "1px solid #D6D6D6");
        }
        
        
       
*/



var pageName=pageName?pageName:false;
$(document).ready(function(){

        if(typeof(pageName)!="undefeined"&&pageName=="home"){
            $($("#nav > div")[0]).css('display', 'none');
        }
        
        
        var notSub=function(i){
            return !this.className.match('sub');
        }
        
        var i=0;
        
        $('#nav > div').filter(notSub).each(function(){
            i++;
            $(this).addClass('nav_'+i);
            
            
        });

});