$(document).ready(function(){ 
    
    $(document).pngFix();


    // initialize scrollable items (wide banners and column galleries).
    var root=$(".scrollable").scrollable({circular: true, mousewheel: false}).navigator().autoscroll({interval: 5750});
    window.api = root.data("scrollable");
    $(".mediaPickerLink").click(function () { 
      $(".bannerOverlay").addClass("displayBlock"); 
    });
    
    $(".hideOverlay").click(function () { 
      $(".bannerOverlay").removeClass("displayBlock"); 
        //var playercopy = $(".inlineVideo").html();
        //$(".inlineVideo").html("");
        //$(".inlineVideo").html(playercopy);
     });



        
    //Tabs Primary
    
    //$(".tabs_primary ul li").hover (
    $(".tabs_primary ul li").click (
    
        function() {
            
            var find = "#"+this.id+"_list";
            
            //We need to check if the target div exists
            
            if($(find).length > 0) {
            
                $(".tabs_primary ul li a.active").removeClass("active");
            
                $(this).find("a").addClass("active");
            
                $(".show").removeClass("show");
            
                $(find).addClass("show");
            
            }
        
        },
        function() {
        
            //Do nothing
        
        }
    
    );
    
    //Tabs Secondary
    
    
    //Tabs Tertiary
    
    $(".tabs_tertiary ul li a.active").parent().addClass("over");
    
    if($(".tabs_tertiary ul li a.active").length > 0) {
    
        $(".box_tertiary .show").removeClass("show");
        
        var active_id = $(".tabs_tertiary ul li a.active").parent().attr("id");
        
        //Build our find query
        var find = "#"+active_id+"_list";
        
        //Find it and add the class!
        $(find).addClass("show");
    
    }
    
    $(".tabs_tertiary ul li").hover (
    
        function() {
        
            var find = "#"+this.id+"_list";
            
            if($(find).length > 0) {
        
                $(".tabs_tertiary ul li a.active").removeClass("active");
                
                $(".tabs_tertiary ul li.over").removeClass("over");
                
                $(this).addClass("over");
                
                $(".tabs_tertiary ul li a.active").removeClass("active");
                
                $(this).find("a").addClass("active");
                
                //Remove all classes of show
                $(".box_tertiary .show").removeClass("show");
            
                //Add show to find
                $(find).addClass("show");
                
            }
        
        },
        function() {
        
            if(!$(this).find("a.active").length > 0) {
            
                $(this).removeClass("over");
                
            }
            
        }
        
    );
    
    //Navigation Secondary
    
    $(".navigation_secondary ul li").hover (
    
        function() {
            
            $(this).find("ul").addClass("show");
            
            $(this).find("ul li ul").removeClass("show");
        
        },
        function() {
        
            $(this).find("ul").removeClass("show");
        
        }
    
    );
    
    $(".navigation_secondary ul li ul").hover (
    
        function() {
            
            $(this).parent().addClass("over");
        
        },
        function() {
        
            $(this).parent().removeClass("over");
        
        }
    
    );
    
    //Home Flash using SWF Object
    
   /* if($('#home_flash').length > 0) {

            var flashvars = {};
            flashvars.xmlpath = "http://www.kzink.com/NSC/flash/NevadaFlashContent.xml";
            //var params = {};
            //params.allowscriptaccess = "always";
            
                var params = { 
                        allowscriptaccess: "always", 
                        wmode: "transparent" 
                }; 


            //params.wmode = "transparent";
            var attributes = {};
            swfobject.embedSWF("/NevadaStateHome.swf", "home_flash", "974", "305", "9.0.0", false, flashvars, params, attributes);
        
    }
*/

$(".hideUntilLoaded").removeClass("hideUntilLoaded"); 

///files/flash/NevadaStateHome.swf
///flash.xml
    
});
 
function countDown(upcomingText,txtMonth,txtDate,completionText){
//Countdown script distributed by http://www.hypergurl.com
 
var today=new Date()
 
//Enter the date for your countdown. Month first then day. Example 6th month 26th day. 
var countdown=new Date(today.getFullYear(), txtMonth, txtDate)
 
//Enter your message here! Change words below to suit
var beforedayText=upcomingText;
var ondaytext=completionText;
 
var monthtext=new Array("Jan","Feb","Mar","April","May","June","July","Aug","Sep","Oct","Nov","Dec")
countdown.setMonth(countdown.getMonth()-1) //change to 0-11 month format
var showdate="("+monthtext[countdown.getMonth()]+" "+countdown.getDate()+")" 
 
var one_day=1000*60*60*24
var calculatediff=""
 
calculatediff=Math.ceil((countdown.getTime()-today.getTime())/(one_day))
if (calculatediff<0){ 
var nextyeartoday=new Date()
nextyeartoday.setFullYear(today.getFullYear()+1)
calculatediff=Math.ceil((nextyeartoday.getTime()-today.getTime())/(one_day)+calculatediff)
}
 
var pluraldayornot=(calculatediff==1)? "day" : "days"
if (calculatediff>0)
    document.write("<b>"+calculatediff+" "+pluraldayornot+" "+beforedayText+" "+showdate+"!</b>")
else if (calculatediff==0)
    document.write("<b>"+ondaytext+" "+showdate+"!</b>")
}







    function navPrimaryPopDown(currentPosition){
        $(".activeMenuLink").html("yes");
        /*Collapses all popup layers.*/
        $(".navigation_primary_popdown").each( function(){
            $(this).removeClass("navigation_primary_popdown_show");
        });
        /*Swaps in the hover image on the current menu link.*/
        /*Shows the current popup menu.*/
        $("#navigation_primary_popdown"+currentPosition).addClass("navigation_primary_popdown_show");
    }
    
    function navPrimaryPopDownRemove(currentPosition){
        $(".activeMenuLink").html("no");
        setTimeout('removeMenu()', 1000);
    }
    
    
    function removeMenu(){
        testActive=$(".activeMenuLink").html()
        if ( testActive!="yes" ){
            $(".navigation_primary_popdown").each( function(){
                $(this).removeClass("navigation_primary_popdown_show");
            });
        }
    }
    
    
    function activeMenuLink(state){
        $(".activeMenuLink").html(state)
        if (state=="no") {
            setTimeout('removeMenu()', 1000);
        }
    }
