// validação de formulários
var tam = 12;
function mudaFonte( tipo )
{
  if( tipo == 'mais' )
  {
    if( tam < 16 ) tam += 2 ;    			 
  }
  else
  {
    if( tam > 9 ) tam -= 2 ;
  }
  if( document.getElementById( 'mudaFonte' ) )
    mudaFonteRecursiva( tipo , document.getElementById( 'mudaFonte' ) ) ;

}

function mudaFonteRecursiva( tipo , domElement )
{		
  for( var i = 0 ; i < domElement.childNodes.length ; i++ )
  {
    mudaFonteRecursiva( tipo , domElement.childNodes.item( i )  ) ;
  }
  if( domElement.style )
    domElement.style.fontSize = tam+'px';
}

// validação de formulários
function ValidaMailing() {
  if (document.frmMailingList.email.value == "") {
    alert("Informe o seu e-mail!");
    document.frmMailingList.email.focus();
    return false;
  }

  if ((document.frmMailingList.email.value != "") && (document.frmMailingList.email.value.indexOf("@") < 1)) {
    alert("Informe corretamente seu e-mail!");
    document.frmMailingList.email.value = "";
    document.frmMailingList.email.focus();
    return false;
  }
}
//--------------------------------------------------------------
function ValidaAmigo() {

  if (document.Amigo.NmRemet.value == "") {
    alert("Informe o seu nome!");
    document.Amigo.NmRemet.focus();
    return false;
  }

  if (document.Amigo.MailRemet.value.indexOf("@") < 1) {
    alert("Informe corretamente seu e-mail!");
    document.Amigo.MailRemet.value = "";
    document.Amigo.MailRemet.focus();
    return false;
  }
  if (document.Amigo.NmDest.value == "") {
    alert("Informe o nome do destinatário!");
    document.Amigo.NmDest.focus();
    return false;
  }
  if (document.Amigo.MailDest.value.indexOf("@") < 1) {
    alert("Informe corretamente o e-mail do destinatário!");
    document.Amigo.MailDest.value = "";
    document.Amigo.MailDest.focus();
    return false;
  }
  }
//-------------------------------------------------------------- 
//--------------------------------------------------------------
function validaFaleconosco() {

  if (document.email.Nome.value == "") {
    alert("Informe o seu nome!");
    document.email.Nome.focus();
    return false;
  }

  if (document.email.Email.value.indexOf("@") < 1) {
    alert("Informe corretamente seu e-mail!");
    document.email.Email.value = "";
    document.email.Email.focus();
    return false;
  }
  if (document.email.Telefone.value == "") {
    alert("Informe seu telefone de contato!");
    document.email.Telefone.focus();
    return false;
  }
  if (document.email.Titulo.value == "") {
    alert("Informe um título para a mensagem!");
    document.email.Titulo.focus();
    return false;
  }  
  if (document.email.Texto.value == "") {
    alert("Escreva sua mensagem!");
    document.email.Texto.focus();
    return false;
  } 
  }
//-------------------------------------------------------------- 
function Anuncia() {

  if (document.Anunciar.Nome.value == "") {
    alert("Informe o seu nome!");
    document.Anunciar.Nome.focus();
    return false;
  }
  
  if ((document.Anunciar.Fone.value == "") | (document.Anunciar.Fone.value.length < 7)) {
    alert("Informe corretamente o seu Telefone!");
    document.Anunciar.Fone.value = "";
    document.Anunciar.Fone.focus();
    return false;
  }

  if ((document.Anunciar.Cel.value == "") | (document.Anunciar.Cel.value.length < 7)) {
    alert("Informe corretamente o seu Celular!");
    document.Anunciar.Cel.value = "";
    document.Anunciar.Cel.focus();
    return false;
  }

  if ((document.Anunciar.Email.value == "") | (document.Anunciar.Email.value.indexOf("@") < 1)) {
    alert("Informe corretamente seu e-mail!");
    document.Anunciar.Email.value = "";
    document.Anunciar.Email.focus();
    return false;
  }
  
  if (document.Anunciar.Veic.value == "") {
    alert("Informe o nome do Veículo!");
    document.Anunciar.Veic.focus();
    return false;
  }
  
  i = document.Anunciar.MarcaVeic.selectedIndex;
  if (document.Anunciar.MarcaVeic.options[i].value == "0") {
    alert("Informe a Marca do Veículo!");
    document.Anunciar.MarcaVeic.focus();
    return false;
  }

  if (document.Anunciar.Valor.value == "") {
    alert("Informe o Valor do Veículo!");
    document.Anunciar.Valor.focus();
    return false;
  }
  
  i = document.Anunciar.AnoModVeic.selectedIndex;
  if (document.Anunciar.AnoModVeic.options[i].value == "0") {
    alert("Informe o Ano do Modelo do Veículo!");
    document.Anunciar.AnoModVeic.focus();
    return false;
  }
  
  i = document.Anunciar.AnoVeic.selectedIndex;
  if (document.Anunciar.AnoVeic.options[i].value == "0") {
    alert("Informe o Ano do Veículo!");
    document.Anunciar.AnoVeic.focus();
    return false;
  }
  
  if (document.Anunciar.Cor.value == "") {
    alert("Informe a Cor do Veículo!");
    document.Anunciar.Cor.focus();
    return false;
  }

  i = document.Anunciar.Comb.selectedIndex;
  if (document.Anunciar.Comb.options[i].value == "0") {
    alert("Informe o Combustível do Veículo!");
    document.Anunciar.Comb.focus();
    return false;
  }
}
//-------------------------------------------------------------- 
function Solicitar(){

var form 		= document.solicitar
var Nome	 	= form.Nome
var Email	 	= form.Email
var Fone 		= form.Fone
var Cid		 	= form.Cid
var Veic 		= form.Veic
var MarcaVeic 	= form.MarcaVeic

if (Nome.value == "") {
   alert("Informe o Nome. ")
   Nome.focus();
   return false;
}

if ((Email.value == "") | (Email.value.indexOf("@") < 1)) {
   alert("Informe corretamente seu Email.")
   Email.value="";
   Email.focus();
   return false;
 }

if (Fone.value == "") {
   alert("Informe o Fone.")
   Fone.focus();
   return false;
}

if (Cid.value == "") {
   alert("Informe A Cidade.")
   Cid.focus();
   return false;
 }

if (Veic.value == "") {
   alert("Informe o Veiculo.")
   Veic.focus();
   return false;
 }
 
if (MarcaVeic.value == "0") {
   alert("Informe a Marca do Veiculo.")
   MarcaVeic.focus();
   return false;
 }
}
//--------------------------------------------------------------
function validaProposta() {

  if (document.frmProp.Nome.value == "") {
    alert("Informe o seu nome!");
    document.frmProp.Nome.focus();
    return false;
  }
  if (document.frmProp.Email.value.indexOf("@") < 1) {
    alert("Informe corretamente seu e-mail!");
    document.frmProp.Email.value = "";
    document.frmProp.Email.focus();
    return false;
  }
  if (document.frmProp.Telefone.value == "") {
    alert("Informe seu telefone de contato!");
    document.frmProp.Telefone.focus();
    return false;
  }
  if (document.frmProp.Texto.value == "") {
    alert("Escreva sua mensagem!");
    document.frmProp.Texto.focus();
    return false;
  } 
  }
//-------------------------------------------------------------- 
function ValidaBusca() {
  if (document.FrmBusca.Marca.value == "") {
    alert("Informe pelo menos a marca");
    document.FrmBusca.Marca.focus();
    return false;
  }
}

// obriga a selecionar checkbox para comparar carros

function validaCheckbox(form) {
var total = 0;
var max = form.Carro.length;
for (var idx = 0; idx < max; idx++) {
if (eval("document.frmPesqComparar.Carro[" + idx + "].checked") == true) {
    total += 1;
   }
}
if (total < 2) {
alert("Selecione, pelo menos, dois carros.");
return false;
}
}

// cria parâmetros para busca

function CreateString()
{
	document.FrmBusca.action='Pesq.asp?Veic='+document.getElementById("Veic").value+'&Mod='+document.getElementById("Mod").value+'&Marca='+document.getElementById("Marca").value+'&Ano='+document.getElementById("Ano").value+'&VI='+document.getElementById("VI").value+'&VF='+document.getElementById("VF").value+'&QtdCarPag='+document.getElementById("QtdCarPag").value
	document.FrmBusca.submit();	
}

function MudaQtd()
{
		document.FrmBusca.action='Pesq.asp?Veic='+document.getElementById("Veiculo").value+'&Mod='+document.getElementById("Mod").value+'&Marca='+document.getElementById("Marca").value+'&Ano='+document.getElementById("Ano").value+'&VI='+document.getElementById("VI").value+'&VF='+document.getElementById("VF").value+'&QtdCarPag='+document.getElementById("QtdCarPag").value
	
	document.FrmBusca.submit();
}

// funções do arquivo detalhes.asp
function DoPrinting(){
  if (!window.print){
  alert("Use o Netscape ou Internet Explorer \n nas versões 4.0 ou superior!")
  return
}
window.print()
}

// função Pop Up
function carregaPopUp(arquivoPop, alt,lag)
{
window.open(arquivoPop,'PopUP','scrollbars=no,width='+alt+',height='+lag+'');
}
//--------------------------------------------------------------
// transparencia para arquivos PNG
function correctPNG()
   {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }
window.attachEvent("onload", correctPNG);
//--------------------------------------------------------------