function newsscoller(prev) {
	var current_image = $('#gallery li.selected').length ? $('#gallery li.selected') : $('#gallery li:first');
	var current_excerpt = $('#excerpt li.selected').length ? $('#excerpt li.selected') : $('#excerpt li:first');
	if (prev) {
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#gallery li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#excerpt li:last');
	} else {
		var next_image = (current_image.next().length) ? current_image.next() : $('#gallery li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#excerpt li:first');
	}
	$('#excerpt li, #gallery li').removeClass('selected');
	
	next_image.addClass('selected');
	next_excerpt.addClass('selected');

	$('#mask-gallery').scrollTo(next_image, 800);		
	$('#mask-excerpt').scrollTo(next_excerpt, 800);						
}
function goto(item) {
	$('#mask-gallery').scrollTo(item, 800);		
	$('#mask-excerpt').scrollTo(item, 800);	
	$(item).addClass('selected');					
}
$(document).ready(function() {
	$("#menu ul li").hover(
  		function () {
			$(this).find("div.menu_line span.no_active").animate({width: "140px"}, 500 );
  		},
  		function () {
    		$(this).find("div.menu_line span.no_active").animate({width: "2px"}, 750 );
  		}
	);
	$("#menu ul li").live("click",
		function() {
			$("div.menu_line span.active").removeClass().addClass("no_active").animate({width: "2px"}, 250 );
			$(this).find("div.menu_line span.no_active").removeClass().addClass("active");
		}
	);
	$("#projekty .left ul li a").live("click",
		function() {
			$("#projekty .left ul li a").removeClass();
			$(this).addClass("active");
		}
	);
	
	
	var $scrollerWindow = $("#main");
	var $speed = 1500;
	
	//$scrollerWindow.stop().scrollTo( $("#projekty"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
	
	function gotoHome() {
		$scrollerWindow.stop().scrollTo( $("#home"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
		return false;
	}
	function gotoError1() {
		$scrollerWindow.stop().scrollTo( $("#error1"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
		return false;
	}
	function gotoProjekty() {
		$scrollerWindow.stop().scrollTo( $("#projekty"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
		return false;
	}
	function gotoError2() {
		$scrollerWindow.stop().scrollTo( $("#error2"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
		return false;
	}
	function gotoError3() {
		$scrollerWindow.stop().scrollTo( $("#error3"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
		return false;
	}
	function gotoKontakt() {
		$scrollerWindow.stop().scrollTo( $("#kontakt"), $speed, {axis:'x',offset:{left: -20, top:0 }} );
		return false;
	}
	function noScroll() {
	}
	$(".gotoHome").live("click", gotoHome);
	$(".gotoError1").live("click", gotoError1);
	$(".gotoProjekty").live("click", gotoProjekty);
	$(".gotoError2").live("click", gotoError2);
	$(".gotoError3").live("click", gotoError3);
	$(".gotoKontakt").live("click", gotoKontakt);
	//$('.noScroll').live("click", noScroll);
	
	var speed = 5000;

	$('#mask-gallery, #gallery li').width($('#slider').width());	
	$('#gallery').width($('#slider').width() * $('#gallery li').length);
	$('#mask-gallery, #gallery li, #mask-excerpt, #excerpt li').height($('#slider').height());	
	$('#gallery li:first, #excerpt li:first').addClass('selected');
	
	goto('.item1');
	return false;
	
});
