zcount=slidecount;
var position = 1;
var maxw = 0;
function arrowCheck(){
	if(position==1){
		$("#arrow_left").hide();
		$("#arrow_right").css('margin-left',53);
	}else{
		$("#arrow_left").show();
		$("#arrow_right").css('margin-left',0);
	}
	if(position==slidecount){
		$("#arrow_right").hide();
		//
	}else{
		//
		$("#arrow_right").show();
	}
}
function getSlide(direction){
	old = position;
	if(position>1&&direction==-1||position<slidecount&&direction==1){
		position+=direction;
	}else{
		return;
	}	
	
	arrowCheck();
	if(direction==-1){//reveal
		start = 0;
		slide_to_animate = old;
		end = maxw;
	}else{//layover
		start = 600;
		slide_to_animate = position;
		end = 0;
	}
	//$("#slide"+old+" h3").hide();
	$("#slide"+slide_to_animate+" h3").hide();
	$("#slide"+slide_to_animate)
		.css('left', start)
		.animate({ 
	        'left': end
	      }, 250, 'swing', function(){
				$(this).children("h3").show();
		}
	);
	
	
}

$(document).ready(function(){
	$('#content div[id^=slide]')
		.css('position', 'absolute')
		.css('height', '490px')
		.css('background-color', '#EAECEA')
		.hide();//hide while loading
	
	
	$("#arrows").css('z-index',20);
	$("#arrow_left").mouseup(function(){
		getSlide(-1);
	});
	$("#arrow_right").mouseup(function(){
		getSlide(1);
	});
	$("#arrow_right, #arrow_left").css('cursor', 'pointer');
	arrowCheck();
});

$(window).load(function(){
	counter=0;
	$('#content div[id^=slide]').each(function(){
		if($(this).width()>maxw){
			maxw = $(this).width();
		}
		counter++;
		if(counter>1){
			$(this).css('left', '-2000em');
		}
		$(this).css('z-index', $(this).attr('id').substring('slide'.length));
	});
	$("#content").css('width', maxw+'px').css('height', '490px').css('overflow',"hidden");
	$('#content div[id^=slide]').css('width', maxw).show();
});
