// JavaScript Document

function abrirShadowBox(div, w, h){
	var divLigthBox = $('#'+div).html();
	Shadowbox.open({
		player:     'html',
        title:      '',
        content:    divLigthBox,
        height:     h,
        width:      w
	});
}

function aumentaZindex(){
	$('.topMenu span').css('z-index' , '999');
	$('.header2').css('z-index' , '1');
}
function diminuiZindex(){
	$('.topMenu span').css('z-index' , '1');
	$('.header2').css('z-index' , '999');
}


//exemplo de uso do noLetters: onKeyDown="return noLetters(event);"
function noLetters(e)
{
	var tecla;
	if(!e)
		e = window.event;
	
	// verificação cross-browser
	if(e.which)
		tecla = e.which;
	else if(e.keyCode)
		tecla = e.keyCode;

	if( (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) || tecla == 8 || tecla == 37 || tecla == 39 || tecla == 46 || tecla == 9 )
	{
		/*9: tab; 8 = backspace; 37 = seta pra esquerda; 39 = seta pra direita; 46 = delete*/
		return true;
	}
	else
	{
		return false;
	}
}

//formata uma data corretamente
function formataData( obj )
{
	if( parseInt(obj.value.length) == 2 )
		obj.value += "/";
	if( parseInt(obj.value.length) == 5 )
		obj.value += "/";
}

//formata o campo de telefone, colocando o DDD
function formataTelefoneDDD( obj )
{
    if( parseInt(obj.value.length) == 1 )
		obj.value = "(" + obj.value;
	if( parseInt(obj.value.length) == 4 )
		obj.value += ")-";
	if( parseInt(obj.value.length) == 10 )
		obj.value += "-";
}

//formata um cep corretamente
function formataCep( obj )
{
	if( parseInt(obj.value.length) == 5 )
		obj.value += "-";
}

// Abre uma janela popup com url, largura e altura customizadas
function openPopup( strUrl, width, height )
{
    window.open(strUrl, '', 'left=0,top=0,width='+ width +',height='+ height +',toolbar=0,scrollbars=1,status=0');
    return false;
}

// Abre link para busca de empreendimentos na home
function buscaEmpreendimentosHome(url, idPastaEmpreendimentos, comboEstados)
{
    location.href = url + '?idbuscahome=' + comboEstados.options[comboEstados.selectedIndex].value + "&idpastaempreendimentos=" + idPastaEmpreendimentos;
}


function CarregaGaleria(id){
	$.get("/galeria-de-imagens.aspx", { galeria: id },
	 function(data){
		$('#galerias').html(data);
	});   
}

$(document).ready(function(){
	//_______________________Transformar link para CHAT em popup__________________________________//

		var chat = $('[href*="http://www.bairronovo.com/intro_chat/intro_chat.html"]');
		chat.attr("onClick", "javascript:window.open('" + chat.attr("href") + "','chat','height=200,width=150');" );
		chat.attr("href", "javascript:void(0);" );
		
});