var i=1;
$(document).ready(function(){
	$("#r1").fadeOut(0);
	$("#r2").fadeOut(0);
	$("#r3").fadeOut(0);
	$("#r4").fadeOut(0);
	$("#r5").fadeOut(0);
	
	$("div.submit").fadeOut(0);
	$("div#next").click(function(){
		i++;
		if (i==5){
			i=1;
			$("#block").animate({"left": "0px"}, 1000);
		}else{
			$("#block").animate({"left": "-=980px"}, 1000);
		}
	});
	
	$("div#prev").click(function(){
		i--;
		if (i==0){
			i=4;
			$("#block").animate({"left": "-2940px"}, 1000);
		}else{
			$("#block").animate({"left": "+=980px"}, 1000);
		}
	});
	
	
	$("#submit").click(function(){
		txt_name=document.getElementById('txt_name').value;
		txt_email=document.getElementById('txt_email').value;
		txt_mess=document.getElementById('txt_mess').value;
		
		if (txt_name!="" || txt_email!="" || txt_mess!=""){
			$.post("mail.php", { email: txt_email, mess: txt_mess, name: txt_name},
  			function(data){
				$("div#err").fadeOut(0);
    			$("div#suc").fadeIn(300);
				//alert (data);
  			});	
		}else{
			$("div#suc").fadeOut(0);
    		$("div#err").fadeIn(300);
		}
	});
});

function next_block() {
	i++
	if (i==3){
		i=0;
		$("#block").animate({"left": "0px"}, 1000);
	}else{
		$("#block").animate({"left": "-=980px"}, 1000);
	}
}
function rs (id) {
	if (id=="r1") {
		$("#r1").fadeOut(100);
	}
	if (id=="r2") {
		$("#r2").fadeOut(100);
	}
	if (id=="r3") {
		$("#r3").fadeOut(100);
	}
	if (id=="r4") {
		$("#r4").fadeOut(100);
	}
	if (id=="r5") {
		$("#r5").fadeOut(100);
	}
}
function r (id) {
	if (id=="r1") {
		$("#r1").fadeIn(100);
	}
	if (id=="r2") {
		$("#r2").fadeIn(100);
	}
	if (id=="r3") {
		$("#r3").fadeIn(100);
	}
	if (id=="r4") {
		$("#r4").fadeIn(100);
	}
	if (id=="r5") {
		$("#r5").fadeIn(100);
	}
}
//setInterval(next_block, 12000);
