/*
	Screengrab09 Profile Scroller
	Patrick Hamann 2009
	Scroll that shit!
	
	Stop stealing my code carl !
*/

$(document).ready(function(){ 

	// set scrollTo defaults
	$.scrollTo.defaults.axis = 'x';
	$('div.scroller').scrollTo( 0 ); 
	$.scrollTo( 0 );
	
	// enumeration
	/*
	var $links = $('div.names a');
	var $thumbs = $('div.scroller a');
	var $scroller = $('div.scroller');
	*/ 
	 
	//Default all thumbs to 0.5 opacity
	$('div.scroller a').fadeTo(0, 0.5);
	
	// Apply scrollTo on link hover
	$('div.names a').each( function(i) {
		$(this).hover( function() {
			var id = $(this).attr('class');
			$('div.scroller').stop().scrollTo($('a.p' + id), 1200);
			$('div.scroller a').fadeTo(0, 0.5);
			$('a.p' + id).fadeTo('normal', 1);
			
		}, function() {
			$('div.scroller').stop();
			var id = $(this).attr('class');
			$('div.scroller a').stop()
			$('a.p' + id).fadeTo('normal', 0.5);
		});
	});
	
	//Apply effects on thumbnail hover
	$('div.scroller a').each( function(i) {
		$(this).hover( function() {
			$('div.scroller a').fadeTo(0, 0.5);
			$(this).fadeTo('normal', 1);
			var id = $(this).attr('class').split('p')[1];
			$('div.names a.' + id).addClass('active');		
		}, function() {
			$('div.scroller a').stop();
			$('div.scroller a').fadeTo(0, 0.5);
			var id = $(this).attr('class').split('p')[1];
			$('div.names a.' + id).removeClass('active');
		});
	});
	
	//Apply serialScroll to the next and prev buttons
	$('div.scroller').serialScroll({
		items:'a',
		prev:'div.arrows a.prev',
		next:'div.arrows a.next',
		step: 8,
		offset:0, 
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:false, 
		jump: false 
	});
	
	//Next & Prev buttons hover opactiy
	$('div.arrows a').fadeTo(0, 0.25);
	
	$('div.arrows a').hover( function(){
		$(this).fadeTo('normal', 1);
	}, function() {
		$(this).fadeTo('normal', 0.25);
	});
		
}); 
