// JavaScript Document
$(function(){

	$("#planta_imovel .nextPage").click(function(){
		var qtd = $("#total_plantas").val();
		var tam_geral = qtd * 166;
		var tem = $("#planta_imovel #content .items").css("left");
		if (tem == "" || tem == "auto") tem = "0";
		//alert(tem);
		var pos = parseInt(tem.replace("px",""));
			
		var tam = (166 * 4) - tam_geral;	
		//alert(tam);	
		if (pos <= 0 && pos > tam){
			pos = pos - 166;
		} 
		//$("#planta_imovel #content .items").css("left", pos+"px");
		$("#planta_imovel #content .items").animate({ 
			left: pos
		}, 500 );
	});
	
	$("#planta_imovel .prevPage").click(function(){
		var qtd = $("#total_plantas").val();
		var tam_geral = qtd * 166;
		var tem = $("#planta_imovel #content .items").css("left");
		if (tem == "" || tem == "auto") tem = "0";
		//alert(tem);
		var pos = parseInt(tem.replace("px",""));
			
		var tam = tam_geral  - (166 * 4);	
		//alert(tam);	
		if (pos < 0 && pos < tam){
			pos = pos + 166;
		} 
		//$("#planta_imovel #content .items").css("left", pos+"px");
		$("#planta_imovel #content .items").animate({ 
			left: pos
		}, 500 );
	});
	
	//Obras em andamento
	$("#obra_imovel .nextPage").click(function(){
		var qtd = $("#total_obras").val();
		var tam_geral = qtd * 166;
		var tem = $("#obra_imovel #content .items").css("left");
		if (tem == "" || tem == "auto") tem = "0";
		//alert(tem);
		var pos = parseInt(tem.replace("px",""));
			
		var tam = (166 * 4) - tam_geral;	
		//alert(tam);	
		if (pos <= 0 && pos > tam){
			pos = pos - 166;
		} 
		//$("#planta_imovel #content .items").css("left", pos+"px");
		$("#obra_imovel #content .items").animate({ 
			left: pos
		}, 500 );
	});
	
	$("#obra_imovel .prevPage").click(function(){
		var qtd = $("#total_obras").val();
		var tam_geral = qtd * 166;
		var tem = $("#obra_imovel #content .items").css("left");
		if (tem == "" || tem == "auto") tem = "0";
		//alert(tem);
		var pos = parseInt(tem.replace("px",""));
			
		var tam = tam_geral  - (166 * 4);	
		//alert(tam);	
		if (pos < 0 && pos < tam){
			pos = pos + 166;
		} 
		//$("#planta_imovel #content .items").css("left", pos+"px");
		$("#obra_imovel #content .items").animate({ 
			left: pos
		}, 500 );
	});



//Carroseu/
	$("#carrousel .nextPage").click(function(){
		var qtd = $("#total_carrousel").val();
		var tam_geral = qtd * 196;
		var tem = $("#carrousel .scroll .items").css("left");
		if (tem == "" || tem == "auto") tem = "0";
		//alert(tem);
		var pos = parseInt(tem.replace("px",""));
			
		var tam = (196 * 4) - tam_geral;	
		//alert(tam);	
		if (pos <= 0 && pos > tam){
			pos = pos - 196;
		} else{ 
			//pos = 0;
			//alert(pos);
		}
		//$("#planta_imovel .scroll .items").css("left", pos+"px");
		$("#carrousel .scroll .items").animate({ 
			left: pos
		}, 500 );
	});
	
	$("#carrousel .prevPage").click(function(){
		var qtd = $("#total_carrousel").val();
		var tam_geral = qtd * 196;
		var tem = $("#carrousel .scroll .items").css("left");
		if (tem == "" || tem == "auto") tem = "0";
		//alert(tem);
		var pos = parseInt(tem.replace("px",""));
			
		var tam = tam_geral  - (196 * 4);	
		//alert(tam);	
		if (pos < 0 && pos < tam){
			pos = pos + 196;
		}else{ //pos = 0;
		} 
		//$("#planta_imovel .scroll .items").css("left", pos+"px");
		$("#carrousel .scroll .items").animate({ 
			left: pos
		}, 500 );
	});
	

});
