
currentPromoId = 1;
maxPromos = 8;

 
 $(window).load(function() {	
	
		$('.control').hover(
				  function () {
				  
				   cid = $(this).attr("id");
				   				   
				   if (cid != 'control'+currentPromoId) {
				  					  				  
					$(this).animate({
						width: '77px',
					    height: '41px',
							  }, 200); 
						
					$('img', this).fadeIn(100);	
					
					}
							    
							  
				  }, 
				  function () {
				  
				  cid = $(this).attr("id");
				  
				    if (cid != 'control'+currentPromoId) {
				  
					$(this).animate({
						width: '64px',
					    height: '36px',
							  }, 200);   
							  
					$('img', this).fadeOut(100);	
					
					}	  
					  										  
				  }
				);
				
				$('#entirePromos').hover(
				  function () {
				  					  				  			
					$('#parr').fadeIn(300);	   
					$('#narr').fadeIn(300);	 
							  
				  }, 
				  function () {
				  
					$('#parr').fadeOut(300);	   
					$('#narr').fadeOut(300);	
					  										  
				  }
				);
				
		nextPromo(currentPromoId);

		
});
 
function nextPromo(n) {

			switchPromo(n, false);
													
			if ( (parseInt(n)+1) > maxPromos) {
			
				n = 0;
				
			
			}
						
		 	openNextPromo = setTimeout("nextPromo("+(parseInt(n)+1)+")", 5000);
			
		}
 
 function switchPromo(id, human) {
 	
 	n = id;
 
 	
 	if (human == true) {
 	
 	slideshow(0);
 	clearTimeout(openNextPromo);
 	
 	}
 	
 	if (currentPromoId != id) {
 		
 	$('#thumb'+currentPromoId).hide();	
 		
 	$('#control'+currentPromoId).animate({
						width: '64px',
					    height: '36px',
							  }, 200);   	
 	
 	$('#promo'+currentPromoId).fadeOut(500);
 	
 	$('#promo'+id).fadeIn(500);
 	
 	$('#thumb'+id).fadeIn(100);
 	
 	$('#control'+id).animate({
						width: '77px',
					    height: '41px',
							  }, 200); 
 	
 	
 	}
 	
 	currentPromoId = id;
 	
}

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

function slideshow(node) {

	if (node == 0) {
	
		clearTimeout(openNextPromo);
		
		$('#rem_off').hide();
		$('#rem_on').fadeIn(500);
	
	}
	
	if (node == 1) {
	
		nextPromo(currentPromoId);
		
		$('#rem_on').hide();
		$('#rem_off').fadeIn(500);
	
	}

}

function changeSlide(side) {

	newSlide = currentPromoId + side;
	
	if (newSlide < 1) newSlide = maxPromos;
	
	if (newSlide > maxPromos) newSlide = 1;
	
	switchPromo(newSlide, true);

}
