<!--

function checkcampos(form) {
    var erro_string = "";  
    if (form.codmarca.options[form.codmarca.options.selectedIndex].value == 0) { erro_string += "Selecione uma Marca \n"; }
    if (form.codmodelo.options[form.codmodelo.options.selectedIndex].value == 0) { erro_string += "Selecione um Modelo \n"; }
    if (erro_string == "")
    { return true;
    } else { alert(erro_string); return false; }    
}

function checkrevendas(form) {
    var erro_string = "";
    if (form.codrevenda.options[form.codrevenda.options.selectedIndex].value == 0) { erro_string += "Selecione uma Revenda \n"; }
    if (erro_string == "") { return true; } else { alert(erro_string); return false; }
}

function checkcampos3(form) {
    var erro_string = "";  
    if (form.codcategoria.options[form.codcategoria.options.selectedIndex].value == 0) { erro_string += "Selecione uma Categoria \n"; }    
    if (erro_string == "")
    { return true;
    } else { alert(erro_string); return false; }    
}

function checkformvalor(form) {
    var erro_string = "";      
    if (form.valorini.value.length < 1 & form.valorfin.value.length < 1) 
    { erro_string += "Digite valores Iniciais e Finais para uma busca por valor \n ";
    }    
    if (erro_string == "") { return true; } else { alert(erro_string); return false; }
}

function ir(form)  { form.submit(); }
function ir2(form) { if (vermarcados()) { form.submit(); } }

function addFavorite(url,title){    
    if (window.sidebar) 
    { window.sidebar.addPanel(title, url, ""); }
    else if (document.all) { window.external.AddFavorite(url, title); }
    else if (window.opera && window.print) { return true; }
}

        hoje = new Date()
        dia = hoje.getDate()
        dias = hoje.getDay()
        mes = hoje.getMonth()
        ano = hoje.getYear()
        if (dia < 10) dia = "0" + dia
        if (ano < 2000) ano = 1900 + ano

        function CriaArray (n) { this.length = n }
        NomeDia = new CriaArray(7)
        NomeDia[0] = "Domingo"
        NomeDia[1] = "Segunda-feira"
        NomeDia[2] = "Ter&ccedil;a-feira"
        NomeDia[3] = "Quarta-feira"
        NomeDia[4] = "Quinta-feira"
        NomeDia[5] = "Sexta-feira"
        NomeDia[6] = "S&aacute;bado"

        NomeMes = new CriaArray(12)
        NomeMes[0] = "Janeiro"
        NomeMes[1] = "Fevereiro"
        NomeMes[2] = "Mar&ccedil;o"
        NomeMes[3] = "Abril"
        NomeMes[4] = "Maio"
        NomeMes[5] = "Junho"
        NomeMes[6] = "Julho"
        NomeMes[7] = "Agosto"
        NomeMes[8] = "Setembro"
        NomeMes[9] = "Outubro"
        NomeMes[10] = "Novembro"
        NomeMes[11] = "Dezembro"

function WriteName() { document.write (NomeDia[dias]); }
function WriteDate() { document.write (dia + " de " + NomeMes[mes] + " de " + ano); }
function mostraano() { document.write (ano) }
function abrir(link) { window.open (link, "", "width=700,height=510,resizable,scrollbars=no,screenX=0,screenY=0,top=0,left=0"); }
function abrir2(link){ window.open (link, "", "width=420,height=300,resizable,scrollbars,screenX=40,screenY=40,top=40,left=40"); }

function barralat(){	
	if(window.screen.availWidth>1000){
		//if(navigator.appVersion.indexOf('MSIE 5.0')==-1) {
				document.getElementById('barralateral').style.display = 'block';
		//}
	}
}

function barralat2(){
	if(window.screen.availWidth>1000){
		//if(navigator.appVersion.indexOf('MSIE 5.0')==-1) {
		document.getElementById('2_barra_1024').src='figuras/rodape_1024.gif';
		document.getElementById('3_barra_1024').style.display = 'block';
		document.getElementById('4_barra_1024').style.backgroundImage="url('figuras/contorno_topo_1024.jpg')";
		document.getElementById('5_barra_1024').style.backgroundImage="url('figuras/fundo_site.gif')";
		if(document.getElementById('6_barra_1024')){
			document.getElementById('6_barra_1024').src='figuras/fundo_site.gif';
		}
		//}
	} else {
		document.getElementById('3_barra_1024').style.display = 'none';
	}
}

function buscar(tb,dest_sel,dest_inner,rel,rel2,rel3,sel)
{ zerar(dest_sel);
  d_sel = dest_sel;
  d_inn = dest_inner;
  d_ind = sel;
  //if (rel > 0)
  //{ 
  	var url = "";
    url = "buscar.php?tb="+ tb + "&rel=" + rel + "&rel2=" + rel2 + "&rel3=" + rel3 ;
    loadXMLDoc(url,dest_sel,dest_inner);
  //}  
}

function zerar(dest) { for (m=dest.options.length;m>=0;m--) { dest.options[m]=null; } }

function zerar2(temp,tabela)
{ tabela = tabela + ' ----------';
  for (m=temp.options.length;m>=0;m--) { temp.options[m]=null }
  temp.options[0] = new Option(tabela,'0');  	
}

var xml01;
var d_sel; //qual o select box que vai receber o retorno
var d_inn; //qual o innerHTML vai receber o retorno
var d_ind; //qual o indice do select que será marcado

function loadXMLDoc(url)
{ xml01=null;
  if (window.XMLHttpRequest) { xml01 = new XMLHttpRequest(); }
  else if (window.ActiveXObject) { xml01 = new ActiveXObject("Microsoft.XMLHTTP"); }
  if (xml01!=null)
  { xml01.onreadystatechange=state_Change
    xml01.open("GET",url,true);
    xml01.send(null);
  } else { alert("Your browser does not support XMLHTTP."); }
}

function state_Change()
{ if (xml01.readyState==4)
  { if (xml01.status==200) // if "OK"
    { monta();
    } else { alert("Problem retrieving XML data:" + xml01.statusText); }
  } else
  { d_sel.options[0] = new Option("carregando ...","0");
  	try
  	{ document.getElementById(d_inn).innerHTML = "carregando ..."; }
  	catch(err) { }
  }
}

function monta()
{     var response = xml01.responseXML.documentElement;
      
      x=response.getElementsByTagName("registro2"); 
      var txt = "";
    	for (i=0;i<x.length;i++)
      { xx=x[i].getElementsByTagName("label");
        xy=x[i].getElementsByTagName("codigo");
        xz=x[i].getElementsByTagName("selecionado");
        if (xz[0].firstChild.data == "S")
        { txt += "<input type=checkbox name="+xy[0].firstChild.data+" value=S checked>&nbsp;"+xx[0].firstChild.data+"<br>\n"; } else
        { txt += "<input type=checkbox name="+xy[0].firstChild.data+" value=S>&nbsp;"+xx[0].firstChild.data+"<br>\n"; }
      }
      if (x.length > 0) { document.getElementById(d_inn).innerHTML = txt; } 
      else 
      { try { document.getElementById(d_inn).innerHTML = "Selecione o tipo do veículo"; } 
        catch(err) { } 
      }
      
      x=response.getElementsByTagName("registro");
      sel = 0;
      for (i=0;i<x.length;i++)
      { xx=x[i].getElementsByTagName("label");
        xy=x[i].getElementsByTagName("codigo");
        d_sel.options[i] = new Option(xx[0].firstChild.data,xy[0].firstChild.data);
        if (xy[0].firstChild.data == d_ind) { sel = i; }
      }
      d_sel.options[sel].selected=true;
      
}


var quanti = 0;

function setcook(novo,marcou)
{ var cook = ""; 
  cook = unescape(document.cookie);
  if (marcou)
  { if (cook.length == 0) { cook = novo;  }
    else
    { var tmp = cook.split(";");
      var achou = "N";      
      for (i = 0; i < tmp.length; i++)
      { if (tmp[i] == novo) { achou = "S"; }
      }    
      if (achou == "N") { cook += ";" + novo; }
    }
  } else
  { var tmp = cook.split(";");
    var j = 0;
    cook = "";
    for (i = 0; i < tmp.length; i++)
    { if (tmp[i] != novo)
      { if (j == 0) { cook = tmp[i]; j++; } else { cook += ";" + tmp[i]; j++; }
      }
    }
  }	
  document.cookie = escape(cook);  
  quanti = cook.length;
}
function getcook()
{ var cook = ""; 
  cook = unescape(document.cookie); 
  //alert(cook); 
  quanti = cook.length;  
}

function vermarcados()
{ var cook = "";
  cook = unescape(document.cookie);
  quanti = cook.length;
  document.marcados.marcados.value = cook;
  if (quanti > 0) { return true; } else { return false; }
}

function checar() 
{ var total = document.marcados.elements.length; 
  cook = unescape(document.cookie);
  var tmp = cook.split(";"); 
  for (i = 0; i < total; i++)
  { var e = document.marcados.elements[i];
    var nome = e.name;
    nome = nome.substr(1,nome.length-1);    
    for (j = 0; j < tmp.length; j++)
    { if (nome == tmp[j]) { e.checked = true; }
    }
  }
}

function PrintPage() { if (window.print) window.print(); else alert("O script não conseguiu enviar o documento diretamente para impressão,Pressione Ctrl+P ou selecione Imprimir no menu Arquivo para imprimir esta página."); }

function outracat(){
	if(document.form1.codcidade.value=="0"){
		document.form1.novacidade.disabled=0;
		document.getElementById('campooutras').style.visibility="visible";
		document.getElementById('campooutras2').style.visibility="visible";
		document.form1.novacidade.focus();

	} else {
		document.form1.novacidade.disabled=1;		
		document.getElementById('campooutras').style.visibility="hidden";
		document.getElementById('campooutras2').style.visibility="hidden";
	}
}

function perguntarsj(link){ if(confirm('Apagar Veículo ?\n\nSe apagar este veículo, você precisará pagar novamente para anunciá-lo !')){ window.location = link ; } }
function podeapagar(link){ if(confirm('Apagar Veículo ?')){ window.location = link ; } }

//-->

