<!--//--><![CDATA[//><!--

var highlightMenu = true;
var textResizing = true;
var expandingMenu = false
var tabs = true;

var total = 5;
var currentPage = 0;
var thisPage = 0;
var width = 648;
var ScrollTime = 5000;
var scrollTimer = '';

$(document).ready(function(){
    // <li> Hover for IE6 and below
	if($.browser.msie && $.browser.version < "7") {
	    $("#nav li").hover(function() {
	        $(this).addClass("hover");
	    }, function(){
	        $(this).removeClass("hover");
	    });
	}
		
	$("#nav a").each(function(){
        // Add active class to current page link in the menu
        if (highlightMenu) {
            if (location.href.indexOf(this.href) != -1) $(this).parent().addClass("active");
        }
        
        // Expand lists when the user tabs through menu items
        $(this).focus(function() {
            $(this).parents('li').addClass('hover');
        });
        // Collapse lists again when the link loses focus
        $(this).blur(function() {
            $(this).parents('#nav li').removeClass('hover');
        });
    });
    
    // Text resizing
    if(textResizing){
        changeTextSize(readCookie('style'));
        $('#widgets a').click(function(){
           changeTextSize(this.id);
           return false;
        });
    }
    
    if(expandingMenu){
        var navid = "" + $.query.get('n');    
        $("#vNav ul.subnav").hide();    

        if(navid != ""){
            $("#vNav li#" + navid).parents("ul.subnav").show();
            $("#vNav li#" + navid).children("ul.subnav").show();
        }
           
        $("#vNav li.navdrop > a").next("ul.subnav").children("li").children("a").each(function(){      
            $(this).attr("href", $(this).attr("href") + "?n=" + $(this).parent("li").parent("ul").parent("li").attr("id"));
        });
        
        $("#vNav li.navdrop > a").click(function() {
            $(this).next("ul.subnav").slideToggle();
            return false;
        });
    }    
    
    if(tabs){
        $('div.tabContainer').each(function(container){
            $(container).find('ul.tabLinks li a').each(function(){                  
                $(this).click(function() {
                    target = ($(this).attr('href').substr($(this).attr('href').lastIndexOf('#')+1, $(this).attr('href').length));
                    
                    $('div.tabContainer div.tabcontent').hide();
                    $('div.tabContainer ul.tabLinks a').removeClass('selected');
                    
                    $('div#'+target).toggle();
                    $(this).addClass('selected');
                    
                    return false;
                })
            });
        });
    }
    
    if($('div#slider') != null) {       
        $('a#leftBtn').hide();
        scrollTimer = self.setInterval('autoScroll()', 5000);        
        $("div#slider table td:nth-child(1)").find("div.strapLine").fadeIn('slow');
    
        $('a#rightBtn').click(function() {
            scrollTimer = window.clearInterval(scrollTimer);
            $('a#leftBtn').show();        		
            currentPage++;
            moveCarousel();
            scrollTimer = self.setInterval('autoScroll()', ScrollTime);
            return false;
        });

        $('a#leftBtn').click(function() {
            scrollTimer = window.clearInterval(scrollTimer);
            $('a#leftBtn').show();        		
            currentPage--;
            moveCarousel();
            scrollTimer = self.setInterval('autoScroll()', ScrollTime);
            return false;
        });    
    }             
});


function autoScroll() {
    if (currentPage == total - 1) {
        currentPage = 0;
    } else {
        currentPage++;
    }
    moveCarousel();
}

function moveCarousel() {   
    $('div#slider table').animate({left: -(width * currentPage)}, 2000, function(){
        $("div#slider table td:nth-child("+(currentPage+1)+")").find("div.strapLine").fadeIn();
    });       
    
    if (currentPage == 0) {
        $('a#leftBtn').hide();
        $('a#rightBtn').show();
    } else if (currentPage == total - 1) {
        $('a#rightBtn').hide();
        $('a#leftBtn').show();
    } else {          
        $('a#rightBtn').show();
        $('a#leftBtn').show();
    }
}