// JavaScript Document
$(document).ready(function()
{
	function mainmenu()
	{
		$("ul li.over-menu").css({cursor: "pointer"})
		$("ul#sub").css({display: "none"});
		$("li.over-menu").hover(function(){
			$(this).removeClass("over-menu").addClass("selected");
			$(this).find('ul:first').css({visibility: "visible"}).show();
		},
		function()
		{
			$(this).removeClass("selected").addClass("over-menu");
			$(this).find('ul:first').hide();
		});	
		
		$("ul li.selected").css({cursor: "pointer"})
		$("ul#sub").css({display: "none"});
		$("li.selected").hover(function(){
			$(this).find('ul:first').css({visibility: "visible"}).show();
		},
		function()
		{
			$(this).find('ul:first').hide();
		});	
		
		$("ul li.selected-imovel").css({cursor: "pointer"})
		$("ul#sub-select").css({display: "none"});
		$("li.selected-imovel").hover(function(){
			$(this).find('ul#sub-select').css({visibility: "visible"}).slideDown(400);
			$('div#s1').css({visibility: "hidden"});
			$('div#s3').css({visibility: "hidden"});
			$("a.link-imovel").css({color: "#ffffff"});
		},
		function()
		{
			$("a.link-imovel").css({color: "#203a6d"});
			$('div#s1').css({visibility: "visible"});
			$('div#s3').css({visibility: "visible"});
			$(this).find('ul#sub-select').fadeOut(300);
		}
		);		
	}
	
	//envia o formulário
	$('select.style01').change(function () {
    	this.form.submit();
    });
	
	$("#setor").change(function()
	{ 
		if($(this).val() == "Vereadores")
		{
			$("#vereador1").show();
			$("#vereador2").show();
		}
		else
		{
			$("#vereador1").hide();
			$("#vereador2").hide();
		}
	});
	
	//função para trocar imagem
	$(".img-mini").click(function()
	{
		$('.img-mini-noticia').removeClass("bg-mini");
		$(".img-ampli-noticia").attr("src",$(this).attr("srcBig"));
		$(this).parent('div').addClass("bg-mini");
		return false;
	})
	
	//when user hovers over plans the mainnavbottom is shown
	$('.orca').live('mouseover mouseenter', function()
    {
       $(this).next(".orca-active").show(); 
    });
    
    $('.orca-active').live('mouseout mouseleave', function()
	{
	   $(this).hide(); 
	});


	//ampliar imagem
	$("ul.thumb li div").hover(function() {
			$(this).css({'z-index' : '10'});
			$(this).find('img').addClass("hover").stop()
				.animate({
					marginTop: '-90px', 
					marginLeft: '-80px', 
					top: '50%', 
					left: '50%', 
					width: '120px', 
					height: '100px',
					padding: '0' 
				}, 200);
			
			} , function() {
			$(this).css({'z-index' : '0'});
			$(this).find('img').removeClass("hover").stop()
				.animate({
					marginTop: '0', 
					marginLeft: '0',
					top: '5px', 
					left: '5px', 
					width: '50px', 
					height: '40px', 
					padding: '5px'
				}, 400);
		});
	
	
	//mostra a div de detalhes das caracteristicas	
/*$(".ul-caract li").hover(function(){
		$(this).find(".box-caract").show("fast");
	},
	function()
	{
		$(this).find(".box-caract").hide("fast");
	});*/	
		
	
	$("#box1,#box2,#box3,#box4").hover(function(){
		$(this).removeClass("ext-box").addClass("ext-box-sel");
	},
	function()
	{
		$(this).removeClass("ext-box-sel").addClass("ext-box");
	});	
	
	$("#acessaCliente").toggle(function(){
		$(this).parent("td").removeClass("acesso-cliente").addClass("acesso-cliente-ativo");
		$("#login-panel").show();
	},
	function()
	{
		$(this).parent("td").removeClass("acesso-cliente-ativo").addClass("acesso-cliente");
		$("#login-panel").hide();
	});	
	
	
	$("#acessar").click(function()
	{ 
		$("#acesso").hide('slow');
		$("#login").show('slow');
		$("#mensagem-login").hide('slow');
	});
	
	$("#close").click(function()
	{ 
		$("#login").hide('slow');
		$("#acesso").show('slow');
		$("#mensagem-login").hide('slow');
	});
	
	
	$('input[type="text"],textarea').focus(function() {
		if (this.value == this.defaultValue){ 
	    	this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
		
	});
	$('input[type="text"],textarea').blur(function() {
		if ($.trim(this.value) == ''){
	    	this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});

	$('.bordas').focus(function() {
		$(this).addClass('bordasFocus');
	});
	$('.bordas').blur(function() {
		$(this).removeClass('bordasFocus');
	});
	
	
	$('.bg-input-contato').focus(function() {
		$(this).addClass('bg-input-sel');
	});
	$('.bg-input-contato').blur(function() {
		$(this).removeClass('bg-input-sel');
	});
	
	
	$(".no-border a").hover(function(){
		var rel = $(this).attr("rel");
		
		$(this).parent().removeClass("no-border").addClass("border n"+rel);
	},
	function()
	{
		var rel = $(this).attr("rel");
		$(this).parent().removeClass("border n"+rel).addClass("no-border");
	});	
	
	
	$(".banner-ini").hover(function(){
		var id = $(this).attr("id");

		$("#sel-"+id).fadeIn(400);
	
	});	

	$("#sel-b1").mouseleave(function(){
			$(this).fadeOut(400);		
	});
	
	$("#sel-b2").mouseleave(function(){
			$(this).fadeOut(400);		
	});
	
	$("#sel-b3").mouseleave(function(){
			$(this).fadeOut(400);		
	});
	
	
	//Altera cor de fundo do input
	$('.muda-focus').focus(function() {
		var alter1 = $(this).attr("tdalter1");
	    var alter2 = $(this).attr("tdalter2");
		
		$(this).parent().removeClass(alter1).addClass(alter2);
		
	});
	$('.muda-focus').blur(function() {
	   var alter1 = $(this).attr("tdalter1");
	   var alter2 = $(this).attr("tdalter2");
	   
	   $(this).parent().removeClass(alter2).addClass(alter1);
	});
	
	//muda o fundo da visualização dos lançamentos
	$('.img-prod-sel-zamac').hover(
		function() {
			$(this).removeClass("img-prod-sel-zamac").addClass("img-prod-hover-zamac");	
			$(this).parent().css('background-color','#e3e9f1');
		},
		function() {
			 $(this).removeClass("img-prod-hover-zamac").addClass("img-prod-sel-zamac");
			 $(this).parent().css('background-color','#e3e9f1');
		}
	);
	

	//muda o fundo da visualização do produto
	$('.img-prod-sel').hover(
		function() {
			$(this).removeClass("img-prod-sel").addClass("img-prod-hover");	
			$(this).parent().css('background-color','#ef6b00');
			$(this).parent().css('border','5px solid #ef6b00');
		},
		function() {
			 $(this).removeClass("img-prod-hover").addClass("img-prod-sel");
			 $(this).parent().css('background-color','#007A3D');
			 $(this).parent().css('border','5px solid #f2f2f2');
		}
	);
	
	$("#tipo_pessoa").change(function(){
			var op = $(this).val();
			
			if(op == "Física"){
				$("#PessoaJuridica").hide();
				$("#tbl-juridica").hide();
				$("#PessoaFisica").show();
			}
			else{
				if(op == "Jurídica"){
					$("#PessoaFisica").hide();
					$("#PessoaJuridica").show();
					$("#tbl-juridica").show();
				}
				else{
					$("#PessoaFisica").hide();
					$("#PessoaJuridica").hide();
					$("#tbl-juridica").hide();
				}
			}
			
	});
	
	//muda o fundo da visualização das thumbs dos produtos
	$('.gal-sel').hover(
		function() {
			$(this).removeClass("gal-sel").addClass("gal-hover");	
			$(this).parent().css('background-color','#bca681');
		},
		function() {
			 $(this).removeClass("gal-hover").addClass("gal-sel");
			 $(this).parent().css('background-color','#ffffff');
		}
	);
	
	/**
	* Div flutuante 1.0
	*
	* @author Fabiano Muchalski
	*
	**/
	$('.lnk-album').hover(function(){
		
		var alter = $(this).attr("value");
		
		var y_fixo = $('.info-album').offset().top;
		var d_fixo = $("#right-album").offset().top;
		
		if(d_fixo >= y_fixo){
			$('.ab-'+alter).show();
			$('.info-album').animate({
	            top: 0+"px"
	            },{duration:500,queue:false}
	        );
		}
		else{
			var result = y_fixo - d_fixo;
			$('.ab-'+alter).show();
			$('.info-album').animate({
	            top: result+10+"px"
	            },{duration:500,queue:false}
	        );
		}
	},
	function()
	{
		var alter = $(this).attr("value");
		$('.ab-'+alter).hide();
	});
	
	//Menu e submenu de departamentos
	//submenu de categorias
	$(".abre-sub").hover(function(){
		var valor = $(this).attr("value");
		var ul = "#submenu-" + valor; 
		$(ul).show();
	},
	function()
	{
		var valor = $(this).attr("value");
		var ul = "#submenu-" + valor; 
		$(ul).hide();
	});	
	
	//executa a função
	mainmenu();	
})
