/**
 * @author martinhochreiter
 */

$(document).ready( function() {
	

	children = $("#images").children("div");
	pos =  Math.floor( children.length  / 2 ) - 1;

	element = eval($("#images div:eq("+ pos +")"));
	
	$("#images_wrapper").scrollTo( element, 1000, {axis:'x', offset:-25,margin:true} );
	
	$("#thumbs a").click( function(){
		
		rel = $('#'+ $(this).attr("rel") );
		$("#images_wrapper").scrollTo( rel,800,{axis:'x', offset:-25,margin:true} );
		
		return false;
	});
	
	$("#next").mouseover( function(){
		scrollL = window.setInterval(scrollLeft, 8 );
	}).mouseout( function(){
		clearInterval(scrollL);
	});
	
	$("#prev").mouseover( function(){
		scrollR = window.setInterval(scrollRight, 8 );
	}).mouseout( function(){
		clearInterval(scrollR);
	});
		
});

function scrollLeft(){
	
	$("#images_wrapper").scrollTo( '+=8px' );
	
}

function scrollRight(){
	
	$("#images_wrapper").scrollTo( '-=8px' );
	
}


