// JavaScript Document
$(document).ready(function()
{

$(window).resize(function() {
	setNavTab('.level0.nav-active a, .level0.nav-sub-active a');
  
});
////////////////////////////////////////////////
// HERO SLIDER
////////////////////////////////////////////////
	if($('#heroSliderMain').cycle)
	{
	$('#heroSliderMain').cycle({ 
		fx:     'scrollRight', 
		speed:  1000, 
		timeout: 7000 , /// set time here set to 0 to stop
		pause:   1 ,
		pager:  '#sliderControls',
		pagerAnchorBuilder: function(index, el) 
		{
        return '<a href="#"><img src="images/10px.gif"></a>'; // whatever markup you want
    	}
	});
	}
	
	$("a[href='']").attr({
		href: '#',
		target: '' 
	});
	
	

/////////////////////////////////////////////////////
///// PROMO AREA
/////////////////////////////////////////////////////
if($("#accordion ul").zAccordion)
{	
		var accordion = $("#accordion ul").zAccordion({
	
			slideWidth: 810,
	
			width: 930,
	
			height: 179,
	
			timeout: 3000,
			auto: false,
	
			slideClass: "frame",
	
			slideOpenClass: "frame-open",
	
			slideClosedClass: "frame-closed",
	
			slidePreviousClass: "frame-previous",
	
			easing: "easeOutCirc",
	
			afterBuild: function() 
			{
	
				//$("#accordion").fadeIn(2000);
				$("#accordion").show();
	
			}
	
		});
}


/////////////////////////////////////////////////////
///// MOVE BTN
/////////////////////////////////////////////////////
$('.moveBtn').hover(
function()
{
	$(this).animate
	({
		//marginLeft: '+=10'
		opacity: 0.5
						
	})
},
function()
{
	$(this).animate
	({
		opacity: 1
						
	})
}


);

			/////////////////////////////////////////////////////
			///// SUB NAV TAB STUFF
			/////////////////////////////////////////////////////
			if($('.level0.nav-active a').length){
				setNavTab('.level0.nav-active a, .level0.nav-sub-active a');
			}
			
			
			$('#nav li a').mouseover(function()
			{
				setNavTab(this);

			});

			
			///// THIS THE TOP LEVEL NAV SHOWING THE SUBNAV
			$('#nav').children().children().mouseover(function()
			{
				$(this).children().show();
			});
			
			
			$('#nav').children().children().mouseleave(function()
			{
				$('#nav li ul').hide();
				

			});
			//////////////////////////////////////////
			
			///// THIS THE TOP LEVEL NAV SHOWING THE SUBNAV
			$('#nav li ul li a').mouseover(function()
			{
				$(this).siblings().show();
				$(this).siblings().css('margin-left', $(this).outerWidth());
			});
			
			$('#nav li ul li').mouseout(function()
			{
				$(this).children().next().hide();
			});
			
			$('#nav li ul li a').siblings().mouseover(function()
			{
				$(this).show();
				
			});
			
			
			
			
			$('#nav').children().children().mouseleave(function()
			{
				$('#nav li ul').hide();

			});
			//////////////////////////////////////////
			
			
			
			
			
			$('#header').mouseleave(function()
			{
				setNavTab('.level0.nav-active a, .level0.nav-sub-active a');
				$('#nav li ul').hide();

			});		
				
			
			// SUB NAV OVER
			$('#nav li ul').mouseover(function()
			{
				setNavTab($(this).prev('a'));

			});
			

			
			function setNavTab(who)
			{

					$("#navback").stop();
					var myX = $('#nav').position().left + $(who).position().left;
					var myWidth = $(who).parent().outerWidth();
					
					var gap = $(who).parent().outerWidth() - $(who).parent().width();
					gap = gap/2;
					
					$('#navback').animate
					({
						left: myX-gap,
						width: myWidth
						
					},200, function()
					{
						$('#navback').css('display', 'block');
					});
					
				
				
			}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});
