﻿// JScript File

function globalInitialize()
{
    if ($('.searchBox').length)
    {
        //Create search box focus & blur events
        $('.searchBox').focus(function() { if ($(this).val() == "Search ...") { $('.searchBox').val(""); } });    
        $('.searchBox').blur(function() { if ($(this).val() == "") { $('.searchBox').val("Search ..."); } });    
    }
    
    if ($('#rotatingBanners').length)
    {    
        //Start rotating header Banners.
        $('#rotatingBanners').cycle({ timeout: 8000, speed:2000, sync:1, before: onBefore });   
    }
    
    var slidesAdded = false; 
    
    function onBefore(curr, next, opts) 
    {                          
        // make sure we don't call addSlide before it is defined         
        
        if (!opts.addSlide || slidesAdded)             
        {
            //alert("not defined");
            return;                  
        }
        
        // add slides for images 3 - 8         
        // slides can be a DOM element, a jQuery object, or a string         
        for (var i=0; i < dhtmlBanners.length; i++)
        {
            //Force the image to download in 8 seconds, and not all at once.
            //timeoutDuration = 8000 * (i + 1);
            
            opts.addSlide(dhtmlBanners[i]);
            
            slidesAdded = true;     
        }; 
    }
            
    if ($('ul.primaryMenu').length)    
    {
        //Used for Primary Menu Drop Downs.
	    $('ul.primaryMenu li').hover(
		    function() 
		    { 
		        //Hover On
		        $('ul.primaryMenuPanel', this).css('display', 'block'); 
		    },
		    function() 
		    {
		        //Hover Off 
		        $('ul.primaryMenuPanel', this).css('display', 'none'); 
	        }
	    );
    }
    	
    if ($('ul.howCanWeHelp').length)   
    { 	
	    //Used for Primary Menu Drop Downs.
	    $('ul.howCanWeHelp li').hover(
		    function() 
		    { 
		        //Hover On
		        $('ul.howCanWeHelpPanel', this).css('display', 'block'); 
		    },
		    function() 
		    {
		        //Hover Off 
		        $('ul.howCanWeHelpPanel', this).css('display', 'none'); 
	        }
	    );
	}
	 
	if ($('#siteSearchBox').length)   
    {    
        $('#siteSearchBox').keydown(function(event) 
        {
            if (event.keyCode == '13') 
            {
                //Redirect Search Term to Search Page.
                submitSiteSearch();
                return false;
            }
        });
    }
    
    if ($('#mycarousel').length)  
    {
        jQuery('#mycarousel').jcarousel();
    }
    
    //PNG FIX
    // !!!
    //Works but requries more customization
    // !!!
    /*
    $(function(){$(document).pngFix();});
    */
}    

function submitSiteSearch()
{
    $("#siteSearchBox").css("color", "#cccccc");
    window.location = "/searchresults.aspx?s=" + $('#siteSearchBox').val();
}

