var SITE = "http://"+window.location.host;

var idContato = '#contato';
var classRetornoContato = '.retornoContato';
var nomeAcaoContato = 'contato';

//FORMULÁRIO DE CONTATO 2
var idContato2 = '#contato2';
var classRetornoContato2 = '.retornoContato2';
var nomeAcaoContato2 = 'contato2';

//FORMULÁRIO DE CONTATO 3
var idContato3 = '#contato3';
var classRetornoContato3 = '.retornoContato2';
var nomeAcaoContato3 = 'contato3';

//PAGINAÇÃO 1
var classPaging1 = '.paging1';
var pagSize1 = 6;

//PAGINAÇÃO 2
var classPaging2 = '.paging2';
var pagSize2 = 3;

//PAGINAÇÃO 3
var classPaging3 = '.paging3';
var pagSize3 = 6;

//PAGINAÇÃO 4
var classPaging4 = '.paging4';
var pagSize4 = 6;


function resetar(){
	$('#contato')[0].reset();
}
$(document).ready(function (){
	
	$('.empreend').hover(function(){
		$('.imovLot').slideDown(300);
			
	},function(){
		$('.imovLot').slideUp(700);
	});
	
		DD_roundies.addRule('.c_menu_vitrine', '3px, 3px, 0px, 0px', true);
		DD_roundies.addRule('.c_cinza', '5px', true);

	$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});

	if(window.location != SITE+'/')
	{
		$(document).scrollTop(460);
	}

	$("#accordion h2:first").addClass('current');
	// initialize scrollable
	$(".scrollable").scrollable();

	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
	$("ul.tabs2").tabs("div.panes2 > .vitrine",{effect:'fade', rotate:true}).slideshow({autoplay:true, interval: 5000});
	//$("ul.tabsThumbs").tabs("div.result_thumbs > .abasThumb");
	$("ul.tabsThumbs").tabs("div.todasThumb > .result_thumbs");
	
	$('#cont_tip2').tooltip({
		effect: 'fade',
		offset: [10, 0],
		position: 'top center',
		relative: true,
		events: {
			def:     "click,''",
			tooltip: 'mouseenter,focus'
		}
	});
	
	
	$(".idorm").keydown(function(event) {
   if(event.shiftKey)
   {
        event.preventDefault();
   }

   if (event.keyCode == 46 || event.keyCode == 8)    {
   }
   else {
        if (event.keyCode < 95) {
          if (event.keyCode < 48 || event.keyCode > 57) {
                event.preventDefault();
          }
        } 
        else {
              if (event.keyCode < 96 || event.keyCode > 105) {
                  event.preventDefault();
              }
        }
      }
   });
	
	$('.btn_close2').click(function(){
		$('.window2').fadeOut('slow');
	});
	$('#cont_tip2').click(function(){
		$('.window2').fadeIn('slow');
	});	
	
	$('.cont_tip').tooltip({
		effect: 'fade',
		offset: [10, 0],
		position: 'top left',
		relative: true,
		events: {
			def:     "click,''",
			tooltip: 'mouseenter,focus'
		}
	});
	$('.cont_tip5').tooltip({
		effect: 'fade',
		offset: [10, 0],
		position: 'top center',
		relative: true,
		events: {
			def:     "click,''",
			tooltip: 'mouseenter,focus'
		}
	});
	$('.btn_fechar5').click(function(){
		$('.formImoveis').fadeOut('slow');
	});
	$('.cont_tip5').click(function(){
		$(document).scrollTop(460);
		$('.formImoveis').css('display','block');
		
		//$('.result_inp_foco').focus();
	});	
	
	$('.btn_close').click(function(){
		$('.toolBox').fadeOut('slow');
	});
	$('.cont_tip').click(function(){
		$('.toolBox').fadeIn('slow');
	});	
	
	$(idContato).submit(function(event){
		var dados = $(idContato).serialize();		
			
		$.ajax({
			header: {
				"Content-Type": "text/html;  charset=ISO-8859-1"
			},
			type: "get",
			data: "acao="+nomeAcaoContato+"&" + dados,
			url: SITE + "/formulario.php",
			dataType: "html",
			success: function(valor){
				// Preenche a tabela com os dados
				$(classRetornoContato).fadeIn('slow');
				$(classRetornoContato).html(valor);
				$(classRetornoContato).delay(4000).fadeOut('slow');
				return true;
			}
		});		
		
		return false;
	});
	
	
	//ENVIO DE CONTATO 2
	$(idContato2).submit(function(event){
		var dados = $(idContato2).serialize();		
			
		$.ajax({
			header: {
				"Content-Type": "text/html;  charset=ISO-8859-1"
			},
			type: "get",
			data: "acao="+nomeAcaoContato2+"&" + dados,
			url: SITE + "/formulario.php",
			dataType: "html",
			success: function(valor){
				// Preenche a tabela com os dados
				$(classRetornoContato2).fadeIn('slow');
				$(classRetornoContato2).html(valor);
				$(classRetornoContato2).delay(4000).fadeOut('slow');
				return true;
			}
		});		
		
		return false;
	});
	$(idContato3).submit(function(event){
		var dados = $(idContato3).serialize();		
			
		$.ajax({
			header: {
				"Content-Type": "text/html;  charset=ISO-8859-1"
			},
			type: "get",
			data: "acao="+nomeAcaoContato3+"&" + dados+"&url=" + window.location,
			url: SITE + "/formulario.php",
			dataType: "html",
			success: function(valor){
				// Preenche a tabela com os dados
				$(classRetornoContato3).fadeIn('slow');
				$(classRetornoContato3).html(valor);
				$(classRetornoContato3).delay(4000).fadeOut('slow');
				return true;
			}
		});		
		
		return false;
	});
	
	$('.imovelUl li img').click(function(){
		
		var imgGd = $(this).attr('title');
		
		$('.imgGrande').html('<img src="../arquivos/imoveis/fotos/'+imgGd+'" alt="" />')
		
	});
	
	$('.ev_lateral a img').click(function(){
		
		var imgGd = $(this).attr('id');
		
		$('.ev_interna_img').html('<img src="../arquivos/eventos/fotos/'+imgGd+'" alt="" />')
		
	});
	
	$('#indiqueImovel').submit(function(event){
		
		var dados = $('#indiqueImovel').serialize();
		
		var dados2 = window.location;
		
		$.ajax({
				header: {
					"Content-Type": "text/html;  charset=ISO-8859-1"
				},
				type: "get",
				data: "acao=indiqueImovel&" + dados +"&url=" +dados2,
				url: SITE + "/ajax.php",
				dataType: "html",
				success: function(valor){
					// Preenche a tabela com os dados
					$('.retornoIndique').html(valor);
					return true;
				}
			});
		
		
		return false;
		
	});
	
	$('#terreno').submit(function(event){
		
		var dados = $('#terreno').serialize();
		
		$.ajax({
				header: {
					"Content-Type": "text/html;  charset=ISO-8859-1"
				},
				type: "get",
				data: "acao=terreno&" + dados,
				url: SITE + "/ajax.php",
				dataType: "html",
				success: function(valor){
					// Preenche a tabela com os dados
					$('.retornoTerreno').fadeIn('slow');
					$('.retornoTerreno').html(valor);
					$('.retornoTerreno').delay(2000).fadeOut('slow');
					return true;
				}
			});
		
		
		return false;
		
	});
	
});
