
	// ##############################################################
	// #                                                            # 
	// #   W2N.Imóvel - Sistema para Imobiliárias e Corretores      # 
	// #                                                            # 
	// ##############################################################
	// #                                                            # 
	// #   W2N - SOLUÇÕES WEB				   www.w2nimovel.com    # 
	// #                                                            # 
	// #   Programador:	Marcelo Santos                              # 
	// #   Site:		www.w2n.com.br                              # 
	// #   E-mail:		comercial@w2n.com.br                        # 
	// #   MSN:			agenciaw2n@hotmail.com                      # 
	// #   GMAIL:		agenciaw2n@gmail.com		                # 
	// #   SKYPE:		agenciaw2n                                  # 
	// #   Telefone:	SP (11) 4063-1884                           # 
	// #				   (11) 7164-5020 (cel)                     # 
	// #				PR (41) 4063-8344                           # 
	// #                                                            # 
	// #   Versão: 2.0                                              #
	// #   Data: 18/03/2007                                         #  
	// #                                                            # 
	// #   Este é um sistema desenvolvido e vendido pela W2N,       # 
	// #   caso você tenha comprado de outra pessoa,			    # 
	// #   você não terá acesso a suporte e nem das atualizações.   #	
	// #                                                            # 
	// #   Não tire o copyright do autor deste sistema              #	
	// #                                                            # 
	// ##############################################################


	var xmlhttp;

	function getAjax(Metodo, Endereco, Funcao, Parametros){

		xmlhttp = getObjAjax();

		if(xmlhttp != null || Endereco.length > 0){

			xmlhttp.onreadystatechange = Funcao;

			if(Metodo=="post" && !Parametros==false && Parametros!= ""){
				xmlhttp.open("POST", Endereco, true);
				xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
				xmlhttp.send(Parametros);
			}else{
				xmlhttp.open("GET", Endereco, true);
				xmlhttp.send(null);
			}

		}

	}


	function getObjAjax() {

		objXML = null;

		var arrXml = new Array(
			'Msxml2.XMLHTTP.5.0',
			'Msxml2.XMLHTTP.4.0',
			'Msxml2.XMLHTTP.3.0',
			'Msxml2.XMLHTTP',
			'Microsoft.XMLHTTP');

		try {
			objXML = new XMLHttpRequest();
		} catch (e) {
			for (var i = 0; i < arrXml.length; i++) {
				try {
					objXML = new ActiveXObject(arrXml[i]);
				} catch (ee) {
					objXML = null;
				}
			}
		}

		return objXML;

	}

	function ajaxTipoImovel(vFinalidade){

		var c_tipoimovel = document.getElementById("tipo_imovel_br");
		while( c_tipoimovel.options.length > 0 ) c_tipoimovel.options[0]=null;
		c_tipoimovel.options[0]=new Option("","")
		
		getAjax('get', 'ajax.asp?tipo=tipoimovel&finalidade='+vFinalidade, FunajaxTipoImovel);

	}

	function FunajaxTipoImovel(){

		if(xmlhttp.readyState==4){ 
			if(parseInt(xmlhttp.status)==200){ 
				var c_tipoimovel = document.getElementById("tipo_imovel_br");
				while( c_tipoimovel.options.length > 0 ) c_tipoimovel.options[0]=null;
				var jsTipo = eval((xmlhttp.responseText));
				for(var i=0;i<jsTipo.length;i++){
					jsTipo[i]=unescape(jsTipo[i])
					arrjsTipo=jsTipo[i].split( "|" );
					c_tipoimovel.options[c_tipoimovel.options.length]=new Option(arrjsTipo[1],arrjsTipo[0]);
				}
			}
		}

	}

	function ajaxTipoImovelPro(vFinalidade){

		var c_tipoimovel = document.getElementById("tipo_imovel_pro");
		while( c_tipoimovel.options.length > 0 ) c_tipoimovel.options[0]=null;
		c_tipoimovel.options[0]=new Option("","")
		
		getAjax('get', 'ajax.asp?tipo=tipoimovel&finalidade='+vFinalidade, FunajaxTipoImovelPro);

	}

	function FunajaxTipoImovelPro(){

		if(xmlhttp.readyState==4){ 
			if(parseInt(xmlhttp.status)==200){ 
				var c_tipoimovel = document.getElementById("tipo_imovel_pro");
				while( c_tipoimovel.options.length > 0 ) c_tipoimovel.options[0]=null;
				var jsTipo = eval((xmlhttp.responseText));
				for(var i=0;i<jsTipo.length;i++){
					jsTipo[i]=unescape(jsTipo[i])
					arrjsTipo=jsTipo[i].split( "|" );
					c_tipoimovel.options[c_tipoimovel.options.length]=new Option(arrjsTipo[1],arrjsTipo[0]);
				}
			}
		}

	}

	function ajaxCidade(vCidade){

		var c_bairro = document.getElementById("bairro");
		while( c_bairro.options.length > 0 ) c_bairro.options[0]=null;
		c_bairro.options[0]=new Option("","")
		
		getAjax('get', 'ajax.asp?tipo=bairro&cidade='+vCidade, FunajaxCidade);

	}

	function FunajaxCidade(){

		if(xmlhttp.readyState==4){ 
			if(parseInt(xmlhttp.status)==200){ 
				var c_bairro = document.getElementById("bairro");
				while( c_bairro.options.length > 0 ) c_bairro.options[0]=null;
				var jsBairro = eval((xmlhttp.responseText));
				for(var i=0;i<jsBairro.length;i++){
					jsBairro[i]=unescape(jsBairro[i])
					arrjsBairro=jsBairro[i].split( "|" );
					c_bairro.options[c_bairro.options.length]=new Option(arrjsBairro[1],arrjsBairro[0]);
				}
			}
		}

	}

	function flash(arquivo, largura, altura){

		document.writeln('<object type="application/x-shockwave-flash" data="' + arquivo + '" width="' + largura + '" height="' + altura + '">');
		document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
		document.writeln('<param name="movie" value="' + arquivo + '" />');
		document.writeln('<param name="menu" value="false" />');
		document.writeln('<param name="quality" value="high" />');
		document.writeln('<param name="wmode" value="transparent" />');
		document.writeln('<param name="bgcolor" value="#ffffff" />');
		document.writeln('</object>');

	}


	function AbreJanela(link, x, y, s) {

		var t = (screen.height - y) / 2;
		var e = (screen.width - x) / 2;

		window.open(link,'','width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=' + t + '');

	}




	function OnlyNumbers(objeto){

		texto = objeto.value;

		for ( i=0; i < texto.length; i++ ) {
			charAtual = texto.substring(i,1+i);
			if(isNaN(charAtual)){
				objeto.value = objeto.value.replace( charAtual , "" );
			}
		}

	}



	function $(campo){
		return document.getElementById(campo);
	}






function FormatarValor(objeto,teclapres,tammax,decimais) 
{
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax))
	{
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax))
	{
		vr	= objeto.value;
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( ",", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		tam	= vr.length;
		if (tam < tammax && tecla != 8)
		{
			tam = vr.length + 1 ;
		}
		if ((tecla == 8) && (tam > 1))
		{
			tam = tam - 1 ;
			vr = objeto.value;
			vr = vr.replace( "/", "" );
			vr = vr.replace( "/", "" );
			vr = vr.replace( ",", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
		}
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{
			if (decimais > 0)
			{
				if ( (tam <= decimais) )
				{ 
					objeto.value = ("0," + vr) ;
				}
				if( (tam == (decimais + 1)) && (tecla == 8))
				{
					objeto.value = vr.substr( 0, (tam - decimais)) + ',' + vr.substr( tam - (decimais), tam ) ;	
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) == "0"))
				{
					objeto.value = vr.substr( 1, (tam - (decimais+1))) + ',' + vr.substr( tam - (decimais), tam ) ;
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) != "0"))
				{
				    objeto.value = vr.substr( 0, tam - decimais ) + ',' + vr.substr( tam - decimais, tam ) ; 
				}
				if ( (tam >= (decimais + 4)) && (tam <= (decimais + 6)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 3) ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			 	if ( (tam >= (decimais + 7)) && (tam <= (decimais + 9)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 6) ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 10)) && (tam <= (decimais + 12)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 9) ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 13)) && (tam <= (decimais + 15)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 12) ) + '.' + vr.substr( tam - (decimais + 12), 3 ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			}
			else if(decimais == 0)
			{
				if ( tam <= 3 )
				{ 
			 		objeto.value = vr ;
				}
				if ( (tam >= 4) && (tam <= 6) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr(0, tam - 3) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 7) && (tam <= 9) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 10) && (tam <= 12) )
				{
			 		if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}

				if ( (tam >= 13) && (tam <= 15) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ) ;
				}			
			}
		}
	}
	else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46))
		{
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
}





	function validarFormContato(frm){

		if(frm.Nome.value==''){
			alert('Informe o Nome');
			frm.Nome.focus();
			return false;
		}

		if(frm.Email.value=='' || frm.Email.value.match(/(\w+)@(.+)\.(\w+)$/)==null){
			alert('Informe o E-mail');
			frm.Email.focus();
			return false;
		}

		if(frm.Telefone.value==''){
			alert('Informe o Telefone');
			frm.Telefone.focus();
			return false;
		}

		if(frm.Mensagem.value==''){
			alert('Informe sua Mensagem');
			frm.Mensagem.focus();
			return false;
		}

	}



	function validarFormCadastro(frm){

		if(frm.Nome.value==''){
			alert('Informe o Nome');
			frm.Nome.focus();
			return false;
		}

		if(frm.Email.value=='' || frm.Email.value.match(/(\w+)@(.+)\.(\w+)$/)==null){
			alert('Informe o E-mail');
			frm.Email.focus();
			return false;
		}

		if(frm.Telefone.value==''){
			alert('Informe o Telefone');
			frm.Telefone.focus();
			return false;
		}

		if(frm.Cidade.value==''){
			alert('Informe a Cidade');
			frm.Cidade.focus();
			return false;
		}

		if(frm.DesejaContato.value==''){
			alert('Informe por onde Deseja Contato');
			frm.DesejaContato.focus();
			return false;
		}

		if(frm.MelhorHorario.value==''){
			alert('Informe o Melhor Horário');
			frm.MelhorHorario.focus();
			return false;
		}

		if(frm.TipoImovel.value==''){
			alert('Informe o Tipo de Imóvel');
			frm.TipoImovel.focus();
			return false;
		}

		if(frm.Transacao.value==''){
			alert('Informe a Transação');
			frm.Transacao.focus();
			return false;
		}

		if(frm.Mensagem.value==''){
			alert('Informe os Detalhes do Imóvel');
			frm.Mensagem.focus();
			return false;
		}

	}


	function validarFormEncomenda(frm){

		if(frm.Nome.value==''){
			alert('Informe o Nome');
			frm.Nome.focus();
			return false;
		}

		if(frm.Email.value=='' || frm.Email.value.match(/(\w+)@(.+)\.(\w+)$/)==null){
			alert('Informe o E-mail');
			frm.Email.focus();
			return false;
		}

		if(frm.Telefone.value==''){
			alert('Informe o Telefone');
			frm.Telefone.focus();
			return false;
		}

		if(frm.DesejaContato.value==''){
			alert('Informe por onde Deseja Contato');
			frm.DesejaContato.focus();
			return false;
		}

		if(frm.MelhorHorario.value==''){
			alert('Informe o Melhor Horário');
			frm.MelhorHorario.focus();
			return false;
		}

		if(frm.Transacao.value==''){
			alert('Informe a Transação');
			frm.Transacao.focus();
			return false;
		}

		if(frm.Finalidade.value==''){
			alert('Informe a Finalidade');
			frm.Finalidade.focus();
			return false;
		}

		if(frm.TipoImovel.value==''){
			alert('Informe o Tipo de Imóvel');
			frm.TipoImovel.focus();
			return false;
		}

		if(frm.cidade.value==''){
			alert('Informe a Cidade');
			frm.cidade.focus();
			return false;
		}

		if(frm.PrecoMaximo.value==''){
			alert('Informe o Preço Máximo');
			frm.PrecoMaximo.focus();
			return false;
		}

		if(frm.Detalhes.value==''){
			alert('Informe os Detalhes do Imóvel');
			frm.Detalhes.focus();
			return false;
		}

	}


	function validarFormInformacoes(frm){

		if(frm.Nome.value==''){
			alert('Informe o Nome');
			frm.Nome.focus();
			return false;
		}

		if(frm.Email.value=='' || frm.Email.value.match(/(\w+)@(.+)\.(\w+)$/)==null){
			alert('Informe o E-mail');
			frm.Email.focus();
			return false;
		}

		if(frm.Telefone.value==''){
			alert('Informe o Telefone');
			frm.Telefone.focus();
			return false;
		}

		if(frm.DesejaContato.value==''){
			alert('Informe por onde Deseja Contato');
			frm.DesejaContato.focus();
			return false;
		}

		if(frm.MelhorHorario.value==''){
			alert('Informe o Melhor Horário');
			frm.MelhorHorario.focus();
			return false;
		}

		if(frm.Mensagem.value==''){
			alert('Informe sua Mensagem');
			frm.Mensagem.focus();
			return false;
		}

	}



	function validarFormIndique(frm){

		if(frm.Nome.value==''){
			alert('Informe o Seu Nome');
			frm.Nome.focus();
			return false;
		}

		if(frm.Email.value=='' || frm.Email.value.match(/(\w+)@(.+)\.(\w+)$/)==null){
			alert('Informe o Seu E-mail');
			frm.Email.focus();
			return false;
		}

		if(frm.NomeAmigo.value==''){
			alert('Informe o Nome do seu Amigo');
			frm.NomeAmigo.focus();
			return false;
		}

		if(frm.EmailAmigo.value=='' || frm.EmailAmigo.value.match(/(\w+)@(.+)\.(\w+)$/)==null){
			alert('Informe o E-mail do seu Amigo');
			frm.EmailAmigo.focus();
			return false;
		}

		if(frm.Mensagem.value==''){
			alert('Informe sua Mensagem');
			frm.Mensagem.focus();
			return false;
		}

	}


	function getFoto(titulo,descricao,foto){
		$("div_titulo_foto").innerHTML=titulo;
		$("div_foto").innerHTML='<img src="' + foto + '"><br><br>' + descricao;		
	}





	//FUNÇÔES RETIRADAS NO SITE elcio.com.br

	function mascara(o,f){
		v_obj=o;
		v_fun=f;
		setTimeout("execmascara()",1);
	}

	function execmascara(){
		v_obj.value=v_fun(v_obj.value);
	}

	function leech(v){
		v=v.replace(/o/gi,"0");
		v=v.replace(/i/gi,"1");
		v=v.replace(/z/gi,"2");
		v=v.replace(/e/gi,"3");
		v=v.replace(/a/gi,"4");
		v=v.replace(/s/gi,"5");
		v=v.replace(/t/gi,"7");
		return v
	}

	function soNumeros(v){
		return v.replace(/\D/g,"");
	}

	function telefone(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/^(\d\d)(\d)/g,"($1) $2");
		v=v.replace(/(\d{4})(\d)/,"$1-$2");
		return v
	}

	function cpf(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/(\d{3})(\d)/,"$1.$2");
		v=v.replace(/(\d{3})(\d)/,"$1.$2");
		v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2");
		return v
	}

	function cep(v){
		v=v.replace(/D/g,"");
		v=v.replace(/^(\d{5})(\d)/,"$1-$2");
		return v
	}

	function cnpj(v){
		v=v.replace(/\D/g,"");
		v=v.replace(/^(\d{2})(\d)/,"$1.$2");
		v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3");
		v=v.replace(/\.(\d{3})(\d)/,".$1/$2");
		v=v.replace(/(\d{4})(\d)/,"$1-$2");
		return v
	}

	// ##############################################################
	// #                                                            # 
	// #   W2N.Imóvel - Sistema para Imobiliárias e Corretores      # 
	// #                                                            # 
	// ##############################################################
	// #                                                            # 
	// #   W2N - SOLUÇÕES WEB				   www.w2nimovel.com    # 
	// #                                                            # 
	// #   Programador:	Marcelo Santos                              # 
	// #   Site:		www.w2n.com.br                              # 
	// #   E-mail:		comercial@w2n.com.br                        # 
	// #   MSN:			agenciaw2n@hotmail.com                      # 
	// #   GMAIL:		agenciaw2n@gmail.com		                # 
	// #   SKYPE:		agenciaw2n                                  # 
	// #   Telefone:	SP (11) 4063-1884                           # 
	// #				   (11) 7164-5020 (cel)                     # 
	// #				PR (41) 4063-8344                           # 
	// #                                                            # 
	// #   Versão: 2.0                                              #
	// #   Data: 18/03/2007                                         #  
	// #                                                            # 
	// #   Este é um sistema desenvolvido e vendido pela W2N,       # 
	// #   caso você tenha comprado de outra pessoa,			    # 
	// #   você não terá acesso a suporte e nem das atualizações.   #	
	// #                                                            # 
	// #   Não tire o copyright do autor deste sistema              #	
	// #                                                            # 
	// ##############################################################