// JavaScript Document
function wGLBflash(id,w,h,src,bg,q,t)
{
	
	var object = '';
	object += '<object id="' + id + 'home" type="application/x-shockwave-flash" data="' + src + '" width="'+ w +'" height="'+ h +'" tabindex="0" title=""><param name="movie" value="' + src + '" /><param name="flashvars" value="' + q + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="bgcolor" value="' + bg + '" />';
	if(t) object += '<param name="wmode" value="transparent" />';
	object += '</object>';
	
	var cnt=document.getElementById(id)
	cnt.innerHTML  = object;
	//document.write(object);
}

// Função para iniciarmos o Ajax no browser do cliente.
function openAjax() {
	var ajax;
	try{
		ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers decentes, como: Firefox, Safari, dentre outros.
	}catch(ee){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
		}catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
			}catch(E){
				ajax = false;
			}
		}
	}
	return ajax;
}

function comboBusca(id,arquivo,querystring){
	//limpa o select
	var c = document.getElementById(id)
	while(c.options.length>0)c.options[0]=null
	c.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ")
	//alert(arquivo)
	//Monta a url com a uf
	//window.top.location.href = arquivo + '?rnd=' + Math.random() + querystring;
	
	
	req = null; 
	// Procura por um objeto nativo (Mozilla/Safari) 
	if (window.XMLHttpRequest) 
	{ 
		req = new XMLHttpRequest(); 
		req.open("GET",arquivo + '?rnd=' + Math.random() + querystring,true); 
		req.onreadystatechange = processReqChange; 
		req.send(null); 
	} 
	// Procura por uma versão ActiveX (IE) 
	else if (window.ActiveXObject) 
	{ 
		req = new ActiveXObject("Microsoft.XMLHTTP"); 
	
		if (req) 
		{ 
			req.open("GET",arquivo + '?rnd=' + Math.random() + querystring,true); 
			req.onreadystatechange = processReqChange; 
			req.send(); 
		} 
	} 	
	
	//xmlhttp.open("GET", arquivo + '?rnd=' + Math.random() + querystring,true);

	function processReqChange() {
		if (req.readyState==4){
			//limpa o select
			var c=document.getElementById(id)
			while(c.options.length>0)c.options[0]=null
			//Transforma a lista de cidades JSON em Javascript
			var aColaboradores=eval(req.responseText)
			//popula o select com a lista de cidades obtida
			for(var i=0;i<aColaboradores.length;i++){
				var mytool_array = aColaboradores[i].split("|");
				//aColaboradores[i]=unescape(aColaboradores[i])
				c.options[c.options.length]=new Option(mytool_array[1],mytool_array[0])
			}
		}
	}
}



					// Função que realiza a busca instantânea
function verificacad(t) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var termo = document.getElementById('emailajax').value; // Pega o termo digitado no campo de texto.
		//alert(termo);
		var exibeResultado = document.getElementById('retornomsg'); // div que exibirá o resultado da busca.
		if(termo != "" && termo != null && termo.length >= 3) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", "ajax-verificacad.asp?t=" + t +"&q=" + termo, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					exibeResultado.innerHTML = "Verificando e-mail...";
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						resultado = unescape(resultado); // Resolve o problema dos acentos
						
						exibeResultado.innerHTML = resultado;
						
							if ((document.getElementById('retornomsg').style.display == "none") && (resultado != '')) {
								document.getElementById('retornomsg').style.display = "block";
							}else {
								document.getElementById('retornomsg').style.display = "none";
							}	
						
					} else {
						exibeResultado.innerHTML = "Erro: consulte o suporte da expertu.com.br";
						document.getElementById('retornomsg').style.display = "block";

					}
				}
				
			}
			ajax.send(null); // submete
		} 
	}
}



//EFEITOS ---------------------------------------------------------------------------------------------
function movercima(id,de,ate,time){
 if (document.getElementById){
   var picture= document.getElementById(id);
       if (de>ate){
        picture.style.top= de+"px";
        de-=time;
        setTimeout('movercima(\"'+id+'\",'+de+','+ate+','+time+')',ate);
       }      
    }
}
function moverbaixo(id,de,ate,time){
 if (document.getElementById){
   var picture= document.getElementById(id);
       if (de<ate){
        picture.style.top= de+"px";
        de+=time;
        setTimeout('moverbaixo(\"'+id+'\",'+de+','+ate+','+time+')',ate);
       }      
    }


/*  if (document.layers){
   var picture=document.id;
       if (de<ate){
        picture.top= de;
        de+=time;
        setTimeout('moveit('+de+')',ate);
       }      
    }
if (document.all)
  {
   var picture=document.all.image1.style;
       if (spot<400)
      {
        picture.left= spot;
        spot+=5;
        setTimeout('moveit('+spot+')',100);
       }      
    }*/	
}
//EFEITOS ---------------------------------------------------------------------------------------------
/*function setLyr(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	//if (lyr == 'testP') newY -= 50;
	var x = new getObj(lyr);
	//serversistes/testes/teste1.html
	x.style.top = newY + 20 + 'px';
	x.style.left = newX + 'px';
}*/


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}



function exibirimagem(arquivo,querystring,id){
	var arrayPageSize = getPageSize();
	var overlay = document.getElementById('overlay');
	overlay.style.height =  parseInt(0+arrayPageSize[1]) +"px";
	overlay.style.visibility = "visible";
	overlay.style.zindex = "1";
	var ajaxampliar = document.getElementById('ajaxampliar');
	ajaxampliar.style.visibility = "visible";
	ajaxinteligente(arquivo,querystring,id);

}

function fecharagora (){
	var overlay = document.getElementById('overlay');
	overlay.style.visibility = "hidden";
	var ajaxampliar = document.getElementById('ajaxampliar');
	ajaxampliar.style.visibility = "hidden";
	//ajaxampliar.style.height = "1px";
}	

//************ VIDEOS *****************
function exibirvideo(arquivo,querystring,id){
	var arrayPageSize = getPageSize();
	var overlay = document.getElementById('overlay');
	overlay.style.height =  parseInt(0+arrayPageSize[1]) +"px";
	overlay.style.visibility = "visible";
	overlay.style.zindex = "1";
	var ajaxampliar = document.getElementById('ajaxampliar');
	ajaxampliar.style.visibility = "visible";
	//ajaxapliando(arquivo,'','ajaxampliar');
	ajaxgaleria(arquivo,querystring,id);
	//createcontrol('ajaxampliar', 'ajaxampliar', 'ajaxampliar', '330', '300', 'http://coruja/m/expertu2006/web/joaoclementino/novo/img/video01.flv', 'playervideo.swf', 'transparent');
	
	//w3Opacity.fading('overlay',0,60,500);
	//ajaxgaleria(arquivo,querystring,id);
	//w3Opacity.fading(id,0,100,500);
}
function fecharvideos(){
	var overlay = document.getElementById('overlay');
	overlay.style.visibility = "hidden";
	overlay.style.height = "1px";
	var ajaxampliar = document.getElementById('ajaxampliar');
	ajaxampliar.style.visibility = "hidden";
	ajaxampliar.style.height = "1px";
	ajaxinteligente('ajax-videos.asp','','ajaxampliar');
}	
//************ VIDEOS *****************

function vergaleria (arquivo,querystring,id){
	var arrayPageSize = getPageSize();
	var overlay = document.getElementById('overlay');
	overlay.style.height =  parseInt(0+arrayPageSize[1]) +"px";
	overlay.style.visibility = "visible";
	overlay.style.zindex = "1";
	var ajaxampliar = document.getElementById('ajaxampliar');
	ajaxampliar.style.visibility = "visible";
	ajaxgaleria(arquivo,querystring,id);

}


function ajaxinteligente(arquivo,querystring, id) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var exibeResultado = document.getElementById(id); // div que exibirá o resultado da busca.
		//alert(arquivo + ' ' + id);
		if(arquivo != "" && arquivo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", arquivo + '?rnd=' + Math.random() + querystring, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
			//alert(querystring);
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					exibeResultado.innerHTML = "<br /><div  style=\"background:#ffffff; width:125px;  border:solid 1px #666666; padding:2px; margin:2px; font: 11px; bold Arial, Helvetica, sans-serif; color:#666666;\"><img src=\"./imagens/loading.gif\"  align=\"absmiddle\">Carregando...</div>";
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						//resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						//resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}

function ajaxgaleria(arquivo,querystring, id) {
	
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var exibeResultado = document.getElementById(id); // div que exibirá o resultado da busca.
		if(arquivo != "" && arquivo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.

			ajax.open("GET", arquivo + '?rnd=' + Math.random() + querystring, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
			//alert(querystring);
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					exibeResultado.innerHTML = "<div  style=\"background:#ffffff; margin:0 auto; width:553px; height:300px;  border:solid 1px #666666; padding:2px; font: 11px; bold Arial, Helvetica, sans-serif; color:#666666;\"><img src=\""+ URLsite +"imagens/loading.gif\"  align=\"absmiddle\">Carregando...</div>";
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						//resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						//resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
						
						
						var arrayPageScroll = getPageScroll();
						var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);
						//alert(parseInt(lightboxTop));
						exibeResultado.style.top= parseInt(lightboxTop)+"px";
						//moverbaixo(id,parseInt(lightboxTop),parseInt(lightboxTop)+40,10);
						//moveit(0);
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}


// Função Para utilizar ajax geral
function ajaxdestaquehome(arquivo,querystring, id) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var exibeResultado = document.getElementById(id); // div que exibirá o resultado da busca.
		if(arquivo != "" && arquivo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", arquivo + '?rnd=' + Math.random() + querystring, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
			//alert(querystring);
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					exibeResultado.innerHTML = "<br /><div  style=\"background:#ffffff; width:553px; height:300px;  border:solid 1px #666666; padding:2px; margin:2px; font: 11px; bold Arial, Helvetica, sans-serif; color:#666666;\"><img src=\""+ URLsite +"imagens/loading.gif\"  align=\"absmiddle\">Carregando...</div>";
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						//resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						//resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}






function focusfile(){
	if(document.formcomenta.IDPCONT) document.formcomenta.submit.focus()
}




function contar(obj){
	var campo ;
	campo = obj.value;  
	if (campo.length > 300){
		 alert('Numero máximo de caracteres desse campo é de 300');
		obj.value = campo.slice(0,300);
	}
		campo = obj.value;
		ContaFrase();
	}
	function ContaFrase()
	{
		window.document.formcomenta.IDPCONT.value = window.document.formcomenta.comentario.value.length;
		return true;
}
//#CONTAR COMENTARIO#####################################################################################################
//#ENVIAR PÁGINA#####################################################################################################
function Enviarpagina(arquivo,id){
	
	
	
if	((document.frmIndique.Nome_amigo1.value == "") && (document.frmIndique.Email_amigo1.value != "")) {
	alert ("Por favor, digite o nome de seu 1º amigo.");
} else if ((document.frmIndique.Nome_amigo2.value == "") && (document.frmIndique.Email_amigo2.value != "")){
	alert ("Por favor, digite o nome de seu 2º amigo.");
} else if ((document.frmIndique.Nome_amigo3.value == "") && (document.frmIndique.Email_amigo3.value != "")) {
	alert ("Por favor, digite o nome de seu 3º amigo.");
} else if ((document.frmIndique.Nome_amigo1.value != "") && (!checkEmail(document.frmIndique.Email_amigo1, false))){ 
	alert("Por favor, digite um e-mail válido para o 1º amigo.");
} else if ((document.frmIndique.Nome_amigo2.value != "") && (!checkEmail(document.frmIndique.Email_amigo2, false))){ 
	alert("Por favor, digite um e-mail válido para o 2º amigo.");
} else if ((document.frmIndique.Nome_amigo3.value != "") && (!checkEmail(document.frmIndique.Email_amigo3, false))){ 
	alert("Por favor, digite um e-mail válido para o 3º amigo.");
} else if (((document.frmIndique.Email_amigo1.value == document.frmIndique.Email_amigo2.value) || (document.frmIndique.Email_amigo1.value == document.frmIndique.Email_amigo3.value) || (document.frmIndique.Email_amigo2.value == document.frmIndique.Email_amigo3.value)) && ((document.frmIndique.Email_amigo1.value != "" && document.frmIndique.Email_amigo2.value != "") || (document.frmIndique.Email_amigo1.value != "" && document.frmIndique.Email_amigo3.value != "") || (document.frmIndique.Email_amigo2.value != "" && document.frmIndique.Email_amigo3.value != ""))) {
	alert("Foram digitados e-mails iguais de amigos.");
} else if ((document.frmIndique.Nome_amigo1.value == "") && (document.frmIndique.Nome_amigo2.value == "") && (document.frmIndique.Nome_amigo3.value == "") && (document.frmIndique.Email_amigo1.value == "") && (document.frmIndique.Email_amigo2.value == "") && (document.frmIndique.Email_amigo3.value == "")) {
	alert("É necessário digitar o nome e o e-mail de pelo menos um amigo.");
} else if	(document.frmIndique.Nome_sujeito.value == "") { 
	alert ("Por favor, digite seu nome.");
} else if (!checkEmail(document.frmIndique.Email_sujeito, false)) {
	alert("O seu e-mail deve ser um endereço de e-mail válido, por favor redigite-o.");
}


//else document.frmIndique.submit();
 else {
		var url = "";
		url += "&Nome_amigo1=" +  document.frmIndique.Nome_amigo1.value;
		url += "&Nome_amigo2=" +  document.frmIndique.Nome_amigo2.value+"";
		url += "&Nome_amigo3=" +  escape(document.frmIndique.Nome_amigo3.value+"");
		
		url += "&Email_amigo1=" +  escape(document.frmIndique.Email_amigo1.value+"");
		url += "&Email_amigo2=" +  escape(document.frmIndique.Email_amigo2.value+"");
		url += "&Email_amigo3=" +  escape(document.frmIndique.Email_amigo3.value+"");
		
		url += "&Nome_sujeito=" +  escape(document.frmIndique.Nome_sujeito.value+"");
		url += "&Email_sujeito=" +  escape(document.frmIndique.Email_sujeito.value+"");
		url += "&Obs=" +  escape(document.frmIndique.Obs.value+"");
		url += "&indica=" +  escape(document.frmIndique.indica.value+"");
		url += "&titulo=" +  escape(document.frmIndique.titulo.value+"");
		//alert(url);
		//window.top.location.href="ajax-enviar.asp?c=2" + url;
		ajaxinteligente(URLsite + arquivo,'?c=2' + url, id);
	}
}

//#ENVIAR PÁGINA#####################################################################################################

//#  Breves lançamentos  #####################################################################################################
function EnviarInfo(arquivo,id){
	
	if(isEmpty(document.frmMaisInfo.nome.value) || !checkField(document.frmMaisInfo.nome.value))
	{
		warnInvalid(document.frmMaisInfo.nome,'O NOME está vazio ou contém caracteres inválidos!');
		return false;
	}

	if(isEmpty(document.frmMaisInfo.telefone.value) || !checkField(document.frmMaisInfo.telefone.value))
	{
		warnInvalid(document.frmMaisInfo.telefone,'A TELEFONE está vazia ou contém caracteres inválidos!');
		return false;
	}

	if(document.frmMaisInfo.contatop.options[document.frmMaisInfo.contatop.selectedIndex].value == "")
	{
		warnInvalid_SelectBox(document.frmMaisInfo.contatop,'Selecione a forma de contato!');
		return false;
	}

	var url = "";
		url += "&nome=" +  document.frmMaisInfo.nome.value;
		url += "&email=" +  document.frmMaisInfo.email.value;
		url += "&telefone=" + document.frmMaisInfo.telefone.value;
		url += "&Obs=" +  escape(document.frmMaisInfo.Obs.value+"");
		url += "&contatop=" + document.frmMaisInfo.contatop.value;
		//url += "&nome_corretor=" + document.frmMaisInfo.nome_corretor.value;
		url += "&news=" + document.frmMaisInfo.news.value;
		url += "&cod=" +  document.frmMaisInfo.empreendimento.value;
		//alert(url);
		//window.top.location.href="ajax-enviar.asp?c=2" + url;
		ajaxinteligente(URLsite + arquivo,'?c=2' + url, id);
		return true;

}

//######################################################################################################

//#ENVIAR PÁGINA#####################################################################################################
function EnviarComent(arquivo,id){
	d	= document.frmInteresse;
	if(isEmpty(d.nome.value) || !checkField(d.nome.value))
	{
		warnInvalid(d.nome,'O NOME está vazio ou contém caracteres inválidos!');
		return false;
	}
	if(isEmpty(d.email.value) && isEmpty(d.email.value))
	{
		warnInvalid(d.email,'O E-MAIL deve ser informado.');
		return false;
	}
	
	if(isEmpty(d.codigo_seguranca.value) || !checkField(d.codigo_seguranca.value))
	{
		warnInvalid(d.nome,'O Código segurança está vazio ou contém caracteres inválidos!');
		return false;
	}
	if(isEmpty(d.coment.value))
	{
		warnInvalid(d.coment,'O COMENTÁRIO está vazio ou contém caracteres inválidos!');
		return false;
	}

	var url = "";
		url += "&nome=" +  d.nome.value;
		url += "&email=" +  d.email.value;
		url += "&codigo_seguranca=" +  d.codigo_seguranca.value;
		url += "&coment=" + d.coment.value;
		url += "&cod=" +  d.codigo_post.value;
		//alert(url);
		//window.top.location.href="ajax-enviar.asp?c=2" + url;
		ajaxinteligente(URLsite + arquivo,'?c=2' + url, id);
		return true;

}

//#ENVIAR PÁGINA#####################################################################################################
function IndicarBens(arquivo,id){
	
	
	
if	((document.Indique_frm_Bens.Nome_amigo1.value == "") && (document.Indique_frm_Bens.Email_amigo1.value != "")) {
	alert ("Por favor, digite o nome de seu 1º amigo.");
} else if	(document.Indique_frm_Bens.Nome_sujeito.value == "") { 
	alert ("Por favor, digite seu nome.");
} else if (!checkEmail(document.Indique_frm_Bens.Email_sujeito, false)) {
	alert("O seu e-mail deve ser um endereço de e-mail válido, por favor redigite-o.");
}


//else document.frmIndique.submit();
 else {
		var url = "";
		url += "&Nome_amigo1=" +  document.Indique_frm_Bens.Nome_amigo1.value;
		url += "&Email_amigo1=" +  escape(document.Indique_frm_Bens.Email_amigo1.value+"");
		
		url += "&Nome_sujeito=" +  escape(document.Indique_frm_Bens.Nome_sujeito.value+"");
		url += "&Email_sujeito=" +  escape(document.Indique_frm_Bens.Email_sujeito.value+"");
		url += "&Obs=" +  escape(document.Indique_frm_Bens.Obs.value+"");
		url += "&cod=" +  document.Indique_frm_Bens.codigo_bens.value;
		//alert(url);
		//window.top.location.href="ajax-enviar.asp?c=2" + url;
		ajaxinteligente(URLsite + arquivo,'?c=1' + url, id);
	}
}

//#ENVIAR PÁGINA#####################################################################################################


//#ENVIAR PÁGINA#####################################################################################################

// Checa endereÃ§os de e-mail


//alert(encodeURI("amigos.asp?test=1& fulano=2"));
//alert(decodeURI(encodeURI("amigos.asp?test=1& fulano=2")));
//#ENVIAR PÁGINA#####################################################################################################


function selectdrop(sel_name, abbr_name)
{
	if(abbr_name!=''){
		if(sel_name.length > 0){
			var maxIndex = sel_name.length;
				for(var i=0; i<maxIndex; i++){
					if(abbr_name== sel_name.options[i].value){
						sel_name.selectedIndex = i;
						break;
					}
				}
			}
		}
	return true;    
}




// Checa endereÃ§os de e-mail

function checkEmail (theField, emptyOK)
{   //if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK;
	if (emptyOK == true) return true;
    if (!isEmail(theField.value, false)) return false;
	else return true;
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isEmail (s)
{   
    var i = 1;
	var contarroba = 0;
    var sLength = s.length;
	
	// procura Ã§, ', ^, Ã¡, Ã©, Ã­, Ã³, Ãº, Ã¢, Ãª, Ã®, Ã´, Ã»
    while ((i < sLength) && (s.charAt(i) != "Ã§") && (s.charAt(i) != "^") && (s.charAt(i) != "'") && (s.charAt(i) != "Ã¡") && (s.charAt(i) != "Ã©") && (s.charAt(i) != "Ã­") && (s.charAt(i) != "Ã³") && (s.charAt(i) != "Ãº") && (s.charAt(i) != "Ã¢") && (s.charAt(i) != "Ãª") && (s.charAt(i) != "Ã®") && (s.charAt(i) != "Ã´") && (s.charAt(i) != "Ã»")) 
    { i++
    }

    if (i < sLength) return false;
    else i = 1;

	// verifica se existe mais de um @
	
    while (i < sLength) 
    { if (s.charAt(i) == "@") contarroba=contarroba+1
		i++
	}
    if (contarroba > 1) return false;
    else i=1;
	
	// procura @
    while ((i < sLength) && (s.charAt(i) != "@")) 
    { i++
    
	}
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // procura .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // deve existir no mÃ­nimo um caractere depois do ponto
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
    
    
}
//alert(encodeURI("amigos.asp?test=1& fulano=2"));
//alert(decodeURI(encodeURI("amigos.asp?test=1& fulano=2")));
//#ENVIAR PÁGINA#####################################################################################################






function IrAoCorreio()
{
  open('http://www.correios.com.br/servicos/cep/cep_default.cfm','IrAoCorreio','location=no,resize=no, width=730,height=400,left=18,top=18,maximized=0,scrollbars=1');
}

/************************************************
* function verificaDataform
* Verifica se um campo data é válido.
* Input: Campo do formulário que contém a data
* Esta função pega o campo diretamente, pois assim
* pode dar uma resposta melhor ao usuário.
*************************************************/

function verificaDataform(data){
	var Date = new String(data);
	Day = "";
	Month = "";
	Year = "";
	i =  0;
	for (i=0;(i<Date.length) && (Date.charAt(i) != '/');i++)
		Day = Day + Date.charAt(i);
	i++;
	for (;(i<Date.length) && (Date.charAt(i) != '/');i++)
		Month = Month + Date.charAt(i);
	i++;
	for (;(i<Date.length);i++)
		Year = Year + Date.charAt(i);
	for(i=0;i<Date.length;i++){
		NroAsc = asc(Date.substring(i,i+1))
		if (!(NroAsc>=48 && NroAsc<=57) || !(NroAsc = 47) )  {
			return false;
		}
	}
	if(!isNumeric(Month)) {
		return false;
	}
	if (eval(Month) > 12){
		return false;
	}
	if(!isNumeric(Day)) {
		return false;
	}
	if (eval(Day) > 31){
		return false;
	}
	if(!isNumeric(Year)) {
		return false;
	}
	if(eval(Year) < 1900) {
		return false;
	}
	return true;
}


/************************************************
* function verificaCPF
* Verifica se um CPF é válido
* Input: cpf a ser verificado
************************************************/

function verificaCPF(cpf)
{
	var dac = "", inicio = 2, fim = 10, soma, digito, i, j
	for (j=1;j<=2;j++) {
		soma = 0
		for (i=inicio;i<=fim;i++) {
			soma += parseInt(cpf.substring(i-j-1,i-j))*(fim+1+j-i)
		}
		if (j == 2) { soma += 2*digito }
		digito = (10*soma) % 11
		if (digito == 10) { digito = 0 }
		dac += digito
		inicio = 3
		fim = 11
	}
	return (dac == cpf.substring(cpf.length-2,cpf.length))
}

/************************************************
* function verificaCGC
* Verifica se um CGC é válido
* Input: cgc a ser verificado
************************************************/

function verificaCGC(scgc) {
	cgc = trimtodigits(scgc);
	if ((cgc.indexOf("-") != -1) || (cgc.indexOf(".") != -1) || (cgc.indexOf("/") != -1)){
		return( false )
	}
	var df, resto, dac = ""
	df = 5*cgc.charAt(0)+4*cgc.charAt(1)+3*cgc.charAt(2)+2*cgc.charAt(3)+9*cgc.charAt(4)+8*cgc.charAt(5)+7*cgc.charAt(6)+6*cgc.charAt(7)+5*cgc.charAt(8)+4*cgc.charAt(9)+3*cgc.charAt(10)+2*cgc.charAt(11)
	resto = df % 11
	dac += ( (resto <= 1) ? 0 : (11-resto) )
	df = 6*cgc.charAt(0)+5*cgc.charAt(1)+4*cgc.charAt(2)+3*cgc.charAt(3)+2*cgc.charAt(4)+9*cgc.charAt(5)+8*cgc.charAt(6)+7*cgc.charAt(7)+6*cgc.charAt(8)+5*cgc.charAt(9)+4*cgc.charAt(10)+3*cgc.charAt(11)+2*parseInt(dac)
	resto = df % 11
	dac += ( (resto <= 1) ? 0 : (11-resto) )
	return (dac == cgc.substring(cgc.length-2,cgc.length))
}

/************************************************
* function verificaEmail
* Verifica se um email é válido
* Input: email a ser verificado
************************************************/

function verificaEmail(email) {
	var s = new String(email);
	// { } ( ) < > [ ] | \ /
	if ((s.indexOf("{")>=0) || (s.indexOf("}")>=0) || (s.indexOf("(")>=0) || (s.indexOf(")")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("[")>=0) || (s.indexOf("]")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0) )
		return false;
	if (vogalAcentuada(email))
		return false;
	// & * $ % ? ! ^ ~ ` ' "
	if ((s.indexOf("&")>=0) || (s.indexOf("*")>=0) || (s.indexOf("$")>=0) || (s.indexOf("%")>=0) || (s.indexOf("?")>=0) || (s.indexOf("!")>=0) || (s.indexOf("^")>=0) || (s.indexOf("~")>=0) || (s.indexOf("`")>=0) || (s.indexOf("'")>=0) )
		return false;
	// , ; : = #
	if ((s.indexOf(",")>=0) || (s.indexOf(";")>=0) || (s.indexOf(":")>=0) || (s.indexOf("=")>=0) || (s.indexOf("#")>=0) )
		return false;
	// procura se existe apenas um @
	if ( (s.indexOf("@") < 0) || (s.indexOf("@") != s.lastIndexOf("@")) )
		return false;
	// verifica se tem pelo menos um ponto após o @
	if (s.lastIndexOf(".") < s.indexOf("@"))
		return false;
	return true;
}

/************************************************
* function verificaCEP
* Verifica se o CEP está no formato correto
* Input: CEP a ser verificado
************************************************/

function verificaCEP (cep) {
	s = new String(cep);
	if ((s.length > 9) || (s.length < 5))
		return false;
	if (!isInteger(cep))
		return false;
	return true;
}

/************************************************
* function isInteger
* Verifica se um campo é inteiro, inclui dígitos de 0 a 9, vírgula, ponto, espaços e -
* Input: campo a ser verificado
************************************************/

function isInteger(s){
	var i;
	if (isEmpty(s)) 
		return false;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!isNumber(c)) return false;
	}
	return true;
}

/************************************************
* function isNumeric
* Verifica se um campo é numérico. Se contém apenas dígitos de 0 a 9
* Input: campo a ser verificado
************************************************/

function isNumeric(s){
	var i;
	if (isEmpty(s)) 
		return false;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}



// Verifica se o caracter é um dígito de 0 a 9
function isDigit (c)
{ return ((c >= "0") && (c <= "9")) }

// Verifica se uma string tem vogais acentuadas
function vogalAcentuada(s) {
	ls = s.toLowerCase();
	if ((ls.indexOf("á")>=0) || (ls.indexOf("à")>=0) || (ls.indexOf("ã")>=0) || (ls.indexOf("â")>=0) || (ls.indexOf("é")>=0) || (ls.indexOf("í")>=0) || (ls.indexOf("ó")>=0) || (ls.indexOf("õ")>=0) || (ls.indexOf("ô")>=0) || (ls.indexOf("ú")>=0) || (ls.indexOf("ü")>=0))
		return true;
}

// Gera uma string com os caracteres básicos na sequência de códigos ASC
function makeCharsetString(){
	var astr
	astr = ' !"#$%&\'()*+,-./0123456789:;<=>?@'
	astr+= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	astr+= '[\]^_`abcdefghijklmnopqrstuvwxyz'
	astr+= '{|}~'
	return astr
}



//Remove todos os caracteres excetos 0-9
function trimtodigits(tstring){
  s=""; 
  ts=new String(tstring);
  for (x=0;x<ts.length;x++){
   ch=ts.charAt(x);
	if (asc(ch)>=48 && asc(ch)<=57){
	  s=s+ch;
	}
  }
  return s;
}
/*inicio */


// Retorna o código ASC do caracter passada por parâmetro
function asc(achar){
	var n=0;
	var ascstr = makeCharsetString()
	for(i=0;i<ascstr.length;i++){
		if(achar==ascstr.substring(i,i+1)){
			n=i;
			break;
		}
	}
	return n+32
}
// Gera uma string com os caracteres básicos na sequência de códigos ASC
function makeCharsetString(){
	var astr
	astr = ' !"#$%&\'()*+,-./0123456789:;<=>?@'
	astr+= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	astr+= '[\]^_`abcdefghijklmnopqrstuvwxyz'
	astr+= '{|}~'
	return astr
}

// Verifica se uma string tem vogais acentuadas
function vogalAcentuada(s) {
	ls = s.toLowerCase();
	if ((ls.indexOf("á")>=0) || (ls.indexOf("à")>=0) || (ls.indexOf("ã")>=0) || (ls.indexOf("â")>=0) || (ls.indexOf("é")>=0) || (ls.indexOf("í")>=0) || (ls.indexOf("ó")>=0) || (ls.indexOf("õ")>=0) || (ls.indexOf("ô")>=0) || (ls.indexOf("ú")>=0) || (ls.indexOf("ü")>=0))
	return true;
}

// Verifica se o caracter pode fazer parte de um número: 0-9 , . ( ) - e espaço
function isNumber (c) { 
	return ((c >= "0") && (c <= "9") || (c=="-") || (c=="(") || (c==")") || (c==" ") || (c==".") || (c==",")) 
}

// Verifica se o caracter é um dígito de 0 a 9
function isDigit (c) { 
	return ((c >= "0") && (c <= "9")) 
}

/************************************************
* function checkField
* Verificação básica de um campo de formulário por "coisas bobas": & < > | \ /
* Input: campo a ser verificado
************************************************/

function checkField(s) {
	if ((s.indexOf("&")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0) )
		return false;
	return true;
}

/************************************************
* function isEmpty
* Verifica se um campo está vazio
* Input: campo a ser verificado
************************************************/

function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}


/************************************************
* function warnInvalid
* Gera um alert para o usuário e volta o foco para
* o campo que está com problema
* Input: theField - campo do formulário com problema
*        warnText - texto a ser mostrado no alert
************************************************/

function warnInvalid (theField, warnText)
{   theField.focus()
	theField.select()
	alert(warnText)
	return false
}

/************************************************
* function warnInvalid_SelectBox
* Gera um alert para o usuário e volta o foco para
* o campo que está com problema
* Esta função é específica para ser usada com campos Select, para outros campos, usar a warnInvalid
* Input: theField - campo do formulário com problema
*        warnText - texto a ser mostrado no alert
************************************************/
function warnInvalid_SelectBox (theField, s)
{
	theField.focus();
	alert(s);
	return false;
}


function openCentered(theURL,winName,winWidth,winHeight,features) {
  var w = (screen.width - winWidth)/2;
  var h = (screen.height - winHeight)/2 - 60;
  features = features+',width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
  window.open(theURL,winName,features);
}
function abrir(ft) {remote = window.open(ft,"","toolbar=0,width=100,height=100,scrollbars=yes,resizable=0,top=200,left=200");}


// Função de auto-tabulação
// Parâmetros:
// input - o elemento de formulário que está sendo utilizado 
// len - o tamanho do campo antes do tab automático (normalmente o maxlength)
// e - ? Sempre passar event
//
// Forma de utilização no HTML:
// <input onKeyUp="return autoTab(this, 3, event);">
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}

	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
			else i++;
		return index;
	}
	return true;
}

//#######################################################################################
//Desabilitar o botão direito
var message="Programa Leilões e Remate Leilões. © Copyright 2008 Todos os direitos reservados.";
/*
function clickIE() {
	if (document.all) {
		(message);
		return false;
	}
}
function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			(message);
			return false;
		}
	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}else{
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
}

document.oncontextmenu=new Function("alert(message); return false")*/
//#######################################################################################

//******* COLOCAR MASCARA ****************************
//MÁSCARA DE VALORES

function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); }
      else { // qualquer caracter...
        return true;
      }
    }
    else {
      return true;
    }
  }
//******* COLOCAR MASCARA ****************************
