$(function(){
	sites_menu_onclick = ['marco_imobiliaria'];
	$('.submenu').hide().css({'z-index':'999'});
	 function onMenu(){
		$(this).children().filter('a').addClass('destaque');
		$(this).children().filter('ul').show(); 
	}
	function outMenu(){
		$(this).children().filter('a').removeClass('destaque');
		$(this).children().filter('ul').hide(); 
	}
	function clickMenu(){
		$(this).children().filter('a').toggleClass('destaque');
		$(this).children().filter('ul').toggle(); 
		
	}
 	$('#topo ul > li,#geral ul > li').hover(onMenu,outMenu);
	if ($.inArray(cookie.get('hotsite'),sites_menu_onclick)==0)
	{
		$('#topo ul > li').unbind().click(clickMenu);
	}
        
	$('#operacao').change(function() {
		if (this.value==2) {
			select_cidades_venda = $('#cidade option');
			var options = $(select_cidades_aluguel).find('option');
			$('#cidade').find('option').remove().andSelf().append(options).prepend('<option value="-1">Selecione</option>');
			$('#cidade option')[0].selected = 'selected';
		}else if(this.value==1) {
			var options = $(select_cidades_venda).find('option');
			$('#cidade').find('option').remove().andSelf().append(options).prepend('<option value="-1">Selecione</option>');
		}
	});

	$('#cadastrar_newsletter').click(function() {
		var dados = $('#form_newsletter').serialize();
		$.ajax({
			url:baseUrl()+'ajax/cadastrarNewsletter',
			data:dados,
			success:function(response) {
				if(response.status == 'ok') {
					alert('E-mail cadastrado com sucesso.');
					$('#form_newsletter input[type=text]').attr('value', '');
				}else {
					var mesage = '';
					for(i in response.erros) {
						mesage += response.erros[i]+'\n'; 
					}
					alert(mesage);
				}
			}
		});
		return false;
	});
	
});
