
function validarCheck(form,nome,vai,tamanho,formularios) {
		//var objCheckBox = document.getElementById[nome][0].value;
		var objCheckBox = document.forms[form].elements[nome];
		var forme;
		var selecionadas = "";
		var sel = 0;
		var str = formularios+"";
		var var_array = str.split(",");
		var i;
		
		for(i=0; i < var_array.length; i++){
			forme = var_array[i];
			
			var objCheckBox = document.forms[forme].elements[nome];
			
			if(objCheckBox.checked){
				if(sel > 0)
					selecionadas += ","+objCheckBox.value;
				else
					selecionadas = objCheckBox.value;
				
				sel++;
			}
		}
		
		
		
		/*if(tamanho > 1){
			for (i=0; i < objCheckBox.length; i++) {
			   if (objCheckBox[i].checked) {
				   
				   //alert(objCheckBox[i].value);
					if(sel > 0){
						selecionadas += ","+objCheckBox[i].value;
					}
					else{
						selecionadas += objCheckBox[i].value;
					}
					sel++;
				}
			}
		}
		else{
			if(objCheckBox.checked){
				selecionadas = objCheckBox.value;
				sel++;
			}
		}*/
		
		//alert(selecionadas);
		document.getElementById(vai).value = selecionadas;
		
		//return false;
		
		if(sel == 0)
			return false;
		else
			return true;
	}

function VerificaEnter(form)
{
	if (event.keyCode == 13){
    	document.getElementById(form).submit();
	}
}


function validar_pesquisa (){
	/*if (document.getElementsByName('tipo_pesquisa')[0].checked==true){
		document.getElementById('select_condicao_imovel').name = ':select_condicao_imovel:integer:required';
		document.getElementById('select_tipo_imovel').name   = ':select_tipo_imovel:integer:required';
		document.getElementById('select_situacao_auto').name   = ':select_situacao_auto:integer';
		document.getElementById('select_marca_auto').name   = ':select_marca_auto:integer';
		document.getElementById('select_modelo_auto').name   = ':select_modelo_auto:integer';
	}
	else{
		document.getElementById('select_condicao_imovel').name = ':select_condicao_imovel:integer:';
		document.getElementById('select_tipo_imovel').name   = ':select_tipo_imovel:integer:';
		document.getElementById('select_situacao_auto').name   = ':select_situacao_auto:integer:required';
		document.getElementById('select_marca_auto').name   = ':select_marca_auto:integer:required';
		document.getElementById('select_modelo_auto').name   = ':select_modelo_auto:integer:required';
	}*/
	
	if (document.getElementsByName('tipo_pesquisa')[0].checked==true){
		document.getElementById('select_condicao_imovel').name = ':select_condicao_imovel:integer:';
		document.getElementById('select_tipo_imovel').name   = ':select_tipo_imovel:integer:';
		document.getElementById('select_situacao_auto').name   = ':select_situacao_auto:integer';
		document.getElementById('select_marca_auto').name   = ':select_marca_auto:integer';
		document.getElementById('select_modelo_auto').name   = ':select_modelo_auto:integer';
	}
	else{
		document.getElementById('select_condicao_imovel').name = ':select_condicao_imovel:integer:';
		document.getElementById('select_tipo_imovel').name   = ':select_tipo_imovel:integer:';
		document.getElementById('select_situacao_auto').name   = ':select_situacao_auto:integer:';
		document.getElementById('select_marca_auto').name   = ':select_marca_auto:integer:';
		document.getElementById('select_modelo_auto').name   = ':select_modelo_auto:integer:';
	}
}
/*
//modelo-auto select_modelo_auto
				var $m = jQuery.noConflict();
				function carregaModelo(marca){
					$m("#modelo-auto").load("ajaxCarregaModelo.php?marca_veiculo="+marca);        
					$m("#modelo-auto").ajaxError(function(request, settings){ $m("#modelo-auto").html("Falha ao recuperar os Modelos.");          });        
				}*/

function MM_swapImgRestore() { //v3.0
		  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}
		function MM_preloadImages() { //v3.0
		  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
			var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}
		
		function MM_findObj(n, d) { //v4.01
		  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		  if(!x && d.getElementById) x=d.getElementById(n); return x;
		}
		
		function MM_swapImage() { //v3.0
		  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
var divSubMenuOpen = null; //guarda nome do submenu aberto

function abreSubMenu(nome_da_div){
	document.getElementById(nome_da_div).style.visibility = "visible";
	document.getElementById("fechar_"+nome_da_div).style.visibility = "visible";
	divSubMenuOpen = nome_da_div ;
}

function fechaSubMenu(){
	if(divSubMenuOpen != null){
		document.getElementById(divSubMenuOpen).style.visibility = "hidden";
		document.getElementById("fechar_"+divSubMenuOpen).style.visibility = "hidden";
	}
}

function fechapromo(){

	document.getElementById("promo_verao_09").style.visibility = "hidden";
}

function Versao_Impressao(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function SubmeteContato(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	
	if( document.formContato.para.value == '' ){
		erro = 1;
		mesg+= "  - Para \n ";
	}
	if( document.formContato.nome.value == '' ){
		erro = 1;
		mesg+= " - Seu Nome \n ";
	}
	if( document.formContato.mail.value == '' ){
		erro = 1;
		mesg+= " - E-Mail \n ";
	}
	
	if( document.formContato.assunto.value == '' ){
			erro = 1;
			mesg+= " - Assunto \n ";
	}

	if( document.formContato.mensagem.value == '' ){
			erro = 1;
			mesg+= " - Mensagem \n ";
	}
	if( erro == 1){
		alert(mesg);
	}else{
		document.formContato.submit();
	}
}

function SubmeteFormLogin(){
	document.form_cad_login.submit();
}
function SubmeteBuscaAdm(){
	document.buscaAdmin.submit();
}

function SubmeteContatoGs(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	var d = document.formContatoGuia.mail.value.split('@');
	if (!(d[0]!='' && d[1]!='' && d.length==2)){
		
		erro = 1;
		mesg+= " - E-mail inválido \n ";
	}
	if( document.formContatoGuia.para.value == '' ){
		erro = 1;
		mesg+= "  - Para \n ";
	}
	if( document.formContatoGuia.nome.value == '' ){
		erro = 1;
		mesg+= " - Seu Nome \n ";
	}
	if( document.formContatoGuia.mail.value == '' ){
		erro = 1;
		mesg+= " - E-Mail \n ";
	}
	
	if( document.formContatoGuia.assunto.value == '' ){
			erro = 1;
			mesg+= " - Assunto \n ";
	}

	if( document.formContatoGuia.mensagem.value == '' ){
			erro = 1;
			mesg+= " - Mensagem \n ";
	}
	if( erro == 1){
		alert(mesg);
	}else{
		document.formContatoGuia.submit();
	}
}
function SubmeteSoliciteVisita(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	
	

	if( document.formSoliciteVisita.nome_empresa.value == '' ){
		erro = 1;
		mesg+= "  - Nome da Empresa \n ";
	}
	if( document.formSoliciteVisita.nome_responsavel.value == '' ){
		erro = 1;
		mesg+= " - Nome do Responsável \n ";
	}
	if( document.formSoliciteVisita.mail.value == '' ){
		
		erro = 1;
		mesg+= " - E-mail \n ";
		
	}else{
		
		var d = document.formSoliciteVisita.mail.value.split('@');
		if (!(d[0]!='' && d[1]!='' && d.length==2)){
			
			erro = 1;
			mesg+= " - E-mail inválido \n ";
		}	
		
	}
	
	if( document.formSoliciteVisita.cargo.value == '' ){
			erro = 1;
			mesg+= " - Cargo \n ";
	}
	
	if( document.formSoliciteVisita.telefone.value == '' ){
			erro = 1;
			mesg+= " - Telefone \n ";
	}
	
	if( document.formSoliciteVisita.estado.value == '' ){
			erro = 1;
			mesg+= " - Estado \n ";
	}
	
	if( document.formSoliciteVisita.cidade.value == '' ){
			erro = 1;
			mesg+= " - Cidade \n ";
	}
	
	if( document.formSoliciteVisita.mensagem.value == '' ){
			erro = 1;
			mesg+= " - Mensagem \n ";
	}
	if( erro == 1){
		alert(mesg);
	}else{
		document.formSoliciteVisita.submit();
	}
}

function SubmeteContatoFoneSimples(form1){
num_elementos = form1.length;
t = true;
var i=0;
	for (i=0;i<num_elementos && t; i++) {
		if (form1.elements[i].value=="Nome"){
			v = form1.elements[i].name.split(':');
			if (v.length == 4 && v[3] == 'required'){
				alert('Favor preencher o campo: '+form1.elements[i].title);
				form1.elements[i].focus();
				t = false;
			}
		}
		if (form1.elements[i].value=="E-mail"){
			v = form1.elements[i].name.split(':');
			if (v.length == 4 && v[3] == 'required'){
				alert('Favor preencher o campo: '+form1.elements[i].title);
				form1.elements[i].focus();
				t = false;
			}
		}
		if (form1.elements[i].value=="Mensagem"){
			v = form1.elements[i].name.split(':');
			if (v.length == 4 && v[3] == 'required'){
				alert('Favor preencher o campo: '+form1.elements[i].title);
				form1.elements[i].focus();
				t = false;
			}
		}
	}
	
	if (t == true){
		t = validaForm(form1);
	}
return t;

	/*var mesg = "Favor preencher: \n";
	var erro = 0;
	var i = form;
	
	alert(i);
	
	if( document.formContatoFoneSimples0.nome.value == '' || document.formContatoFoneSimples0.nome.value == 'Nome'  ){
		erro = 1;
		mesg+= " - Seu Nome \n ";
	}
	if( document.formContatoFoneSimples0.mail.value == '' || document.formContatoFoneSimples0.mail.value == 'E-mail' ){
		erro = 1;
		mesg+= " - E-Mail \n ";
	}


	if( document.formContatoFoneSimples0.mensagem.value == '' || document.formContatoFoneSimples0.mensagem.value == 'Mensagem'){
			erro = 1;
			mesg+= " - Mensagem \n ";
	}
	if( erro == 1){
		alert(mesg);
	}else{
		document.formContatoFoneSimples0.submit();
	}*/
}

function SubmeteRestrito(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	

	if(( document.formRestrita.login.value == '') || (document.formRestrita.login.value == 'Login'  )){
		erro = 1;
		mesg+= " - Seu Login \n ";
	}
	if(( document.formRestrita.senha.value == '') || (document.formRestrita.senha.value == 'Senha') ){
		erro = 1;
		mesg+= " - Sua Senha \n ";
	}
	
	
	if( erro == 1){
		alert(mesg);
	}else{
		document.formRestrita.submit();
	}
}
function SubmeteFinanceiroLogin(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	

	if( document.formFinanceiroLogin.login.value == '') {
		erro = 1;
		mesg+= " - Seu Login \n ";
	}
	if( document.formFinanceiroLogin.senha.value == ''){
		erro = 1;
		mesg+= " - Sua Senha \n ";
	}
	
	
	if( erro == 1){
		alert(mesg);
	}else{
		document.formFinanceiroLogin.submit();
	}
}

function SubmeteNewsLetter(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	

	if(( document.formNewsLetter.nome.value == '') || (document.formNewsLetter.nome.value == 'Nome'  )){
		erro = 1;
		mesg+= " - Seu Nome \n ";
	}
	if(( document.formNewsLetter.email.value == '') || (document.formNewsLetter.email.value == 'E-mail') ){
		erro = 1;
		mesg+= " - Seu E-mail \n ";
	}
	
	
	if( erro == 1){
		alert(mesg);
	}else{
		document.formNewsLetter.submit();
	}
}

function SubmeteFoneSimples(){

	var mesg = "Favor preencher: \n";
	var erro = 0;
	
/*
	if(( document.formFoneSimples.palavraChave.value == '') || (document.formFoneSimples.palavraChave.value == 'Digite aqui o que você procura!'  )){
		erro = 1;
		mesg+= " - O que você procura! \n ";
	}
	if(( document.formFoneSimples.onde.value == '') || (document.formFoneSimples.onde.value == 'Digite aqui o local que você procura!') ){
		erro = 1;
		mesg+= " - O local que procura! \n ";
	}
	*/
	
	if( erro == 1){
		alert(mesg);
	}else{
		document.formFoneSimples.submit();
	}
}
function SubmeteInserirComent(){
	
	
		document.formComentP.submit();
	
	
}
	
// limitador de caractere
var limite=400;

function soma(id,idexibe) {
   

     var str=new String(str);  
    var mais_um=eval(document.getElementById(id).value.length-1);
    mais_um++;
   
    if (document.getElementById(id).value.length>limite)  { 
   
        str = document.getElementById(id).value;
       
       document.getElementById(id).value=str.substring(0,(str.length - 1));
       
    alert("Você deve digitar no máximo "+limite+" caracteres");
	
   
	
   
    }else { 
   
		
        idexibe.innerHTML=(limite-mais_um);
		 
		 
   
    }
    document.getElementById(id).focus();

}



// verifica largura imagem publicidade
function valida_dimensoes() {

		var largura = document.getElementById("arquivo").width;
		var altura = document.getElementById("arquivo").height;
		
		alert(document.getElementById("arquivo").title);
		if (largura > 800 || altura > 600 )
		{
			alert("A imagem é "+largura+"x"+altura+" está fora do padrão requerido");
		}
		else 
		{
			alert("O arquivo foi Aceito... \n Localização:\n Tamanho:  Bytes \n Dimensões :"+largura+"x"+altura)
		}


}



	//<![CDATA[
	// Função de carregamento, testando a compatibilidade do navegador 
	/*function load() {
	//alert('teste');
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("googleMap"));
			// Passa as coordenadas para baixo quando o mapa é movido
			GEvent.addListener(map, "moveend", function() {
				var center = map.getCenter();
				document.getElementById("message").innerHTML = center.toString();}
			);
	
			// Passagem do posicionamento X, Y e Zoom para a API usando PHP
			map.setCenter(new GLatLng([var.latitude;noerr;htmlconv=no],[var.longitude;noerr;htmlconv=no]), 15);
			// Inclui controles de zoom e rotação no mapa
			
			
			map.addControl(new GSmallMapControl());
			
			//map.addControl(new GMapTypeControl());

   
   
			// Adiciona o balão de texto com a frase passada por PHP 
			map.openInfoWindow(map.getCenter(),document.createTextNode("mapa no guia Simples"));
			
			
		}
	}
	//]]>*/

