function RollOver(input){

	document.getElementById('ex'+input.id).style.visibility = "visible";
	$('#ex'+input.id).fadeOut(0);
	$('#ex'+input.id).fadeIn("fast");
	
	document.getElementById('i'+input.id).style.visibility = "visible";
	$('#i'+input.id).fadeOut(0);
	$('#i'+input.id).fadeIn("fast");

}

function RollOut(input){
	$('#ex'+input.id).fadeOut("fast");

	$('#i'+input.id).fadeOut("fast");				
	
}

function chngSrcOver(input){
	document.getElementById(input.id).src = 'images/gallery/'+input.id+'_over.jpg';
}

function chngSrcOut(input){
	document.getElementById(input.id).src = 'images/gallery/'+input.id+'.jpg';
}
			
		


$(document).ready(function() {
	
	
	var counter = 0;
	var totaltumbs = $("#tumbs > li").size() - 1;
	var max = Math.floor(totaltumbs/7) * 7;
	
	$('#tumbs').width($('#tumbMenu').width() * $('#tumbs li').length);
	
	for( var i = 0; i < totaltumbs + 1; ++i ) {
        if ($('#tumb'+i).hasClass('selectedsketch')){
			counter=i;
		}
    }
	
	var current = Math.floor(counter/7) * 7;
	
	chkarrows();
	
	if (totaltumbs > 6){
		$('#menuMask').scrollTo($('#tumb'+current), 0);	
	}

	
	
	$('#arrowLeft').click(function () {
		current -= 7;
		newScroll(current);
		return false;
	});	
	
	$('#arrowRight').click(function () {
		current += 7;
		newScroll(current);
		return false;
	});	
	
	
	
	
	
	
	function newScroll(count) {
		chkarrows();
		var next_image = ($('#tumb'+count));
		$('#menuMask').scrollTo(next_image, 1000, {easing:'easeInOutCubic'});	
	}
	
	
	function chkarrows() {
		
		
		if (current == 0) {
			$('#arrowLeft').hide();
		} else {
			$('#arrowLeft').show();
		}
		
		if (current == max) {
			$('#arrowRight').hide();
		} else {
			$('#arrowRight').show();
		}
		
		if (max == 0) {
			$('#arrowRight').hide();
			$('#arrowLeft').hide();
		}
	}
	
	
	
	var usaLeft = 1;
	
	$('#arrowBlack_left').click(function () {
		usaLeft = 1;
		$('#arrowBlack_left').hide();
		$('#arrowBlack_right').show();
		usaScroll(usaLeft);
		return false;
	});	
	
	$('#arrowBlack_right').click(function () {
		usaLeft = 0;
		$('#arrowBlack_right').hide();
		$('#arrowBlack_left').show();
		usaScroll(usaLeft);
		return false;
	});	
	
	function usaScroll(pos) {
	
		if (pos == 0) {
			var next_x = 567;
			//document.getElementById("page2").style.marginLeft = 0;
		} else {
			var next_x = 0;
			//document.getElementById("page2").style.marginLeft = 10;
		}

		$('#usaMask').scrollTo(next_x, 1000, {easing:'easeInOutCubic'});	
	}
	
	
})
	
	

