/* slider */

var zindex = 21;
var fr = 1;
function slideShow() {
	$('#gallery .gallery-show').css("display","none");
	$('#gallery .gallery-show:first').css("display", "block" );
	$('#ctrl-nav').mouseover(function() { $('#ctrl-nav').show(); });
	$('#gallery').mouseover(function() { $('#ctrl-nav').show(); });
	$('#gallery').mouseout(function() { $('#ctrl-nav').hide(); });
	$('#slider').mouseout(function() { $('#ctrl-nav').hide(); });
	$('#arrowb').click(function() { gallery(-1); });
	$('#arrowf').click(function() { gallery(1); });
	//gallery(1);
	setInterval('gallery(0)',3500);
}
function gallery(mode) {
	if( $(".gallery-show").is(":animated") ) return;
	if (mode == 0) if ($('#ctrl-nav').is(':visible')) return;
	if(zindex>9990) {
		zindex = 20;
		$('#gallery img').css("z-index",zindex);
	}
	zindex++;
	var current = ($('#gallery .gallery-show.show')?  $('#gallery .gallery-show.show') : $('#gallery .gallery-show:first'));
	if (mode == 1 || mode == 0)
	{
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery .gallery-show:first') :current.next()) : $('#gallery .gallery-show:first'));
	if (fr == 1) {
	next = $('#gallery .gallery-show:nth-child(2)');
	fr = 0;
	}
	next.css("z-index",zindex);
	next.css({display: 'block',opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000, upd);
	}
	else if (mode == -1)
	{
	var prev = ((current.prev().length) ? ((current.prev().hasClass('caption'))? $('#gallery .gallery-show:last') :current.prev()) : $('#gallery .gallery-show:last'));
	prev.css("z-index",zindex);
	prev.css({display: 'block',opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000, upd);
	}
	function upd() {
	current.css({display: 'none'}).removeClass('show');
	}
}


/* start */


		$(document).ready(function(){	
		$(window).load(function () { slideShow(); });
		
		});


