$(document).ready(function(){

	$('#bg').bgResize({
		imagewidth:1680,
		imageheight:1000
	});
	
	$('#bg').cycle({ 
		fx:      'fade', 
		speed:    2000, 
		timeout:  6500
	});
	
	$('#big-callout').cycle({ 
		fx:      'fade', 
		speed:    2000, 
		timeout:  6500
	});

//LOGIN	
	$('#login-show').click(function(){
		$('#register').hide();
		$('#login').slideDown();
	});
	$('#login-hide').click(function(){
		$('#login').slideUp();
	});
	
//REGISTER	
	$('#register-show').click(function(){
		$('#login').hide();
		$('#register').slideDown();
	});
	$('#register-hide').click(function(){
		$('#register').slideUp();
	});
	
//NAV
	$('.show-sub').hover(
		function(){
			$(this).children('.sub').slideDown(100);
			$(this).children('a').css({backgroundPosition: '10px 10px', height: '80px'});
		},
		function(){
			$(this).children('.sub').slideUp(225);
			$(this).children('a').animate({
				height: 20}, 225);
			$(this).children('a').css({backgroundPosition: '-110px 10px'});
		}
	);
	
	$('#products-li, #resources-li').hover(
		function(){
			$(this).css({height: '80px'});
		},
		function(){
			$(this).animate({
				height: 20}, 225);
		}
	);
	
//LINKS NAV

	setTimeout ( linksStart, 1500 );
	
	function linksStart(){
		
		$('.link1').addClass('openLink');
		
		$('.link1').parent().animate({ 
			paddingLeft: "0px"
		}, 300 );
		
		$('.link1').children('span:not(.link-img)').fadeIn();
		
		var t=setTimeout("$('.link1').children('.link-img').slideDown();", 300);
		
	}

	$('#callouts ul li a').click(function(){
		
		//IF LINK IS ALREADY OPEN BEHAVE LIKE A LINK
		if($(this).hasClass('openLink')){}
		
		//OPEN AND CLOSE LINKS
		else {
			
			//CLOSE OPEN LINKS
			$('.openLink').parent().animate({ 
				paddingLeft: "175px"
			}, 300 );
			
			$('.openLink').children('span:not(.link-img)').fadeOut();
			
			$('.openLink').children('.link-img').slideUp();
			
			$('.openLink').removeClass('openLink');
			
			//OPEN THE LINK CLICKED ON
			$(this).addClass('openLink');
			
			$(this).parent().animate({ 
				paddingLeft: "0px"
			}, 300 );
			
			$(this).children('.link-img').slideDown();
			
			$(this).children('span:not(.link-img)').fadeIn();
			
			return false;
		
		}
	
	});
	
//FEATURED PRODUCTS NAV
//	$('#featured-images ul').cycle({ 
//		fx:     'scrollRight', 
//		speed:  'normal',
//		timeout: 0,
//		pager:  '#featured-products-nav',
//		pagerAnchorBuilder: function(idx, slide) { 
//			// return selector string for existing anchor 
//			return '#featured-products-nav li:eq(' + idx + ') a'; 
//		} 
//	});
	
//LOGGED IN DIV
	var loggedHeight = $('#logged-in').height();
	$('#logged-in').height(31);
	
	$('.announce-control').toggle(
		function(){
			$(this).parent().parent().animate({
				height: loggedHeight
			});
			$(this).text('Close Announcements');
		},
		function(){
			$(this).parent().parent().animate({
				height: 31
			});
			$(this).text('Open Announcements');
		}
	);
						   
});