function AbreJanela(url, width, height, nome, scrollbars) {
	var top; var left;
	top = ( (screen.height/2) - (height/1.55) )
	left = ( (screen.width/2) - (width/2) )
	window.open(url, nome,'width='+width+',height='+height+',scrollbars='+scrollbars+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top);
}

function navegacao(pag){
	var ind = location.href.indexOf("&pag=");
	var url;
	
	if(ind > -1)	
		url = location.href.substring(0,ind);
	else
		url = location.href;
		
	location.href = url + "&pag=" + pag		
}

function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
                    return true; 
                }
    }else{
        return false;
        }
}

function vEmail(campo){
	if(checkMail(campo.value))
		return true;
	else{
		alert('Email inválido');
		campo.focus();
		return false;	
	}	
}

function PesquisarRef(form, icForm){
	with(form){
		if(vField(txtRef,"Informe o referência"))
			location.href = "index.asp?pagina=busca&ref=" + txtRef.value;			
	}	
	if(icForm)
		return false;
}

function ImovelInserir(idImovel){
	var imovel = new DetalhesImovel();
  	imovel.Inserir('conteudoDetalhes',idImovel);
	imovel.Chat('videostreaming.com.br/casapraiaimoveis/livezilla.php');
	imovel.DominioArquivos('mongaguaimoveis.com.br');
}

/*---OBJETOS DE MANIPULACAO VIA AJAX--*/
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function getNewsletter(email_obj, nome_obj)
{
	var op ="exclui";
	
	if(document.getElementById('newsIncluir').checked)
		op="inclui";
	
	var email = document.getElementById(email_obj);
	var nome = document.getElementById(nome_obj);
	if ((email.value != "")&&(nome.value != ""))
	{
		if(vEmail(email)){
			xmlHttp=GetXmlHttpObject();
			xmlHttp.onreadystatechange=function()
				{
					if(xmlHttp.readyState==4)
						{
							alert(xmlHttp.responseText);
							email.value = "";
							nome.value = "";
						}
				}
			url = "insere_exclui_newsletter.asp?email="+email.value+"&acao="+op+"&nome="+nome.value;
		
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
	}
	else
	{
		alert('Informe o seu nome e seu email!');
		nome.focus();
	}
}
