/**
 *	Top Ten Scroller
 *	@library jQuery
 */
 
 
 /** 
  *	scroll()
  *	Take element, and the new position
  *	if it's diffferent then scroll it
  */
 function scroll(element, newLocation){
 
 	var currentLocation = $(element).css('left');
 	
 	if(currentLocation != newLocation){
	 	$(element).animate({
	 		left: newLocation
	 	}, 600);
 	}
 	
 }
 
 
 /**
  *	scrollTastic()
  */
 function scrollTastic(){
 	$('.scroll-inner li:last-child').addClass('last');
 	
 	/* Click next; show 6-10 results */
 	$('div.navigation.next a').click(function(){
 		var element = $(this).parent().parent().find('.scroll-inner');
 		
 		var currentLocation = $(element).css('left');
 		
 		/* Scroll to where? the beginning or the end? */
 		if(currentLocation == '-610px'){
 			var newLocation = "0px"; /* Beginning */
 		} else{
 			var newLocation = "-610px"; /* End */
 		}
 		
 		scroll(element, newLocation); /* 610px is hardcoded in the CSS */
 		return false;
 	});
 	
 	/* Click previous show 1-5 */
 	$('div.navigation.previous a').click(function(){
 		
 		var element = $(this).parent().parent().find('.scroll-inner');
 		
 		var currentLocation = $(element).css('left');
 		
 		/* Scroll to where? the beginning or the end? */
 		if(currentLocation == '0px'){
 			var newLocation = "-610px"; /* End */
 		} else{
 			var newLocation = "0px"; /* Beginning */
 		}
 		
 		scroll(element, newLocation);
 		return false;
 	});
 }
 
 /**
  *	linkUp()
  *	when a top 10 item's <li> is clicked
  *	make it all of it a link (NOTE: in HTML (for SEO)
  *	the game name is a link)
  */
 function linkUp(){
 	$('div.scroll-inner li').click(function(){
 		var link = $(this).find('a').attr('href');
 		window.location = link;
 	});
 }
 
 /** 
  *	document.ready (onload)
  */
 $(document).ready(function(){
 
 	scrollTastic();
 	linkUp();
 	
 	
 });