// JavaScript Document
<!--
window.defaultStatus="..:: Sucesso Rent a Car ::..";
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;

function right(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
		return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
		    alert("Desenvolvido por Andre Christian (81)8112631\n\n        www.shoppingmotors.com.br ");
		    return false;
		 }
		 return true;
}
/*************************************************/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
   if (restore) selObj.selectedIndex=0;
 }
// ***************************************************************************/
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];}
}
// ***********************************************************************
// IMPRIMIR VEÍCULO
// ***********************************************************************
function PrintVeiculo(Id){
  retorno = confirm('Deseja Imprimir com as fotos?');
  if (retorno){
      var URL = "modulos/PrintVeiculo.php?Id="+Id;
  } else {
      var URL = "modulos/PrintVeiculo.php?Id="+Id+"&Fotos=N";
  }

  //var width  = screen.width-7;
  var width  = 720;
  var height = screen.height-88;
  var left = (screen.width/2) - width/2; //"0";
  var top = "0";
  var styleStr = 'toolbar=NO,location=NO,directories=NO,status=YES,menubar=NO,scrollbars=YES,resizable=NO,copyhistory=YES,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  window.open(URL,"Visualizar", styleStr)
}
// ***********************************************************************
// INDIQUE
// ***********************************************************************
function Indique(Id,Carro){
  var URL = "modulos/Indique.php?Id="+Id+"&Carro="+Carro;
  //var width  = screen.width-7;
  var width  = 490;
  var height = 270;
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  var styleStr = 'toolbar=NO,location=NO,directories=NO,status=YES,menubar=NO,scrollbars=NO,resizable=NO,copyhistory=YES,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  window.open(URL,"Indique", styleStr)
}
// ***********************************************************************
// ENTRA FOCO
// ***********************************************************************
   function EntraFoco(NomeForm,NomeComp){
      Str = 'document.'+NomeForm+'.'+NomeComp+'.style.backgroundColor = "#F8F8F8";';
	  eval(Str);
      Str = 'document.'+NomeForm+'.'+NomeComp+'.style.borderColor = "#B3CE13";';
      eval(Str);
   }

// ***********************************************************************
// SAI FOCO
// ***********************************************************************
   function SaiFoco(NomeForm,NomeComp){
      Str = 'document.'+NomeForm+'.'+NomeComp+'.style.backgroundColor = "#FFFFFF";';
      eval(Str);
      Str = 'document.'+NomeForm+'.'+NomeComp+'.style.borderColor = "#7F9DB9";';
      eval(Str);
   }
   ////////////////////////////////////// INDICAÇÃO SUBMIT
   function FrmIndique_submit() {
      if (validaIndique()) {
           return true;
      }
      return false;
   }
// ***********************************************************************
// VALIDADA INDIQUE
// ***********************************************************************
   function validaIndique() {
     var erro='';
     if (document.Frm.Nome.value.length<=3){
	    erro=erro+'Digite seu nome;\n';
        document.Frm.Nome.style.borderColor = "#FF0000";
	 }
     if (document.Frm.NomeAmigo.value.length<=3){
	    erro=erro+'Digite o nome do(a) amigo(a);\n';
        document.Frm.NomeAmigo.style.borderColor = "#FF0000";
	 }
	 var email = document.Frm.Email.value;
	 if (ValidaMail(email) == false) {
	       erro+= 'Informe um email válido;\n';
	       document.Frm.Email.style.borderColor = "#FF0000";
	 }
     email = document.Frm.EmailAmigo.value;
	 if (ValidaMail(email) == false) {
	       erro+= 'Informe um email válido;\n';
	       document.Frm.EmailAmigo.style.borderColor = "#FF0000";
	 }
     if (document.Frm.Msg.value.length >= 250){
	    erro=erro+'A Mensagem deve conter no máximo 250 caracteres;\n';
	     document.Frm.Msg.style.borderColor = "#FF0000";
	 }
     if (erro!==''){
	    alert('Verifique o(s) seguinte(s) erro(s) no Formulário: \n\n'+erro);
        return false;
     } else {
        return true;
	 }
}

  //////////////////////////////////////////////////   PROPOSTA SUBMIT
   function FrmProposta_submit() {
      if (validaProposta()) {
           return true;
      }
      return false;
   }
// ***********************************************************************
// VALIDADA PROPOSTA
// ***********************************************************************
function validaProposta() {
     var erro='';
     if (document.Frm.Nome.value.length<=3){
	    erro=erro+'Digite seu nome;\n';
        document.Frm.Nome.style.borderColor = "#FF0000";
	 }
     if (document.Frm.Cidade.value.length<=3){
	    erro=erro+'Digite sua Cidade / UF;\n';
        document.Frm.Cidade.style.borderColor = "#FF0000";
	 }
	 var email = document.Frm.Email.value;
	 if (ValidaMail(email) == false) {
	       erro+= 'Informe um email válido;\n';
	       document.Frm.Email.style.borderColor = "#FF0000";
	 }
     if (document.Frm.TipoContato.value == 'Fone'){
        if (document.Frm.DDD.value.length<2){
           erro=erro+'Digite o DDD;\n';
	       document.Frm.Msg.style.borderColor = "#FF0000";
        }
        if (document.Frm.Fone.value.length<9){
           erro=erro+'Digite seu telefone;\n';
	       document.Frm.Msg.style.borderColor = "#FF0000";
        }
	 }
     if (document.Frm.Msg.value.length<=3){
	    erro=erro+'Digite sua proposta/mensagem;\n';
	     document.Frm.Msg.style.borderColor = "#FF0000";
	 }
     if (erro!=''){
	    alert('Verifique o(s) seguinte(s) erro(s) no Formulário: \n\n'+erro);
        return false;
     } else {
        return true;
	 }
}

// ***********************************************************************
// VALIDA MAIL
// ***********************************************************************
function ValidaMail(mail) {
	if(mail.length < 5 || mail.indexOf("@") < 0 || mail.indexOf(".") < 0)
		return false;
	if (mail.indexOf(" ") > 0)
		return false;
	if (mail.charAt(0) == '@' || mail.charAt(0) == '.' || mail.charAt(mail.length-1)=='@' || mail.charAt(mail.length-1)=='.')
		return false;
	if (mail.indexOf("@")+1 == mail.indexOf("."))
		return false;
	return true;
}
// ***********************************************************************
// FORMATA FONE
// ***********************************************************************
function FormataFone(e, valor, nome) {
	var Str;
	if (valor.length == 4) {
		Str = 'document.Frm.'+nome+'.value = document.Frm.'+nome+'.value + "-" ;';
		eval(Str);
	}
	var tecla;
	if (!e) var e = window.event;
	if (e.keyCode) tecla = e.keyCode;
	else if (e.which) tecla = e.which;
	if (tecla == 13 || tecla == 46 || tecla == 37 || tecla == 39){ return true; }
	if (tecla > 47 && tecla < 58 ) return true;
	if (tecla == 8 || tecla == 9 || tecla == 13 || tecla == 46) return true;
	return false;
}
// ***********************************************************************
// FORMATA DDD
// ***********************************************************************
function FormataDDD(e, valor, nome, prox) {
	var Str;
	if (valor.length == 2) {
		if (nome == 'DDDCel'){
		  document.Frm.FoneCel.focus();
		} else {
		  document.Frm.Fone.focus();
		}
	
	}
	var tecla;
	if (!e) var e = window.event;
	if (e.keyCode) tecla = e.keyCode;
	else if (e.which) tecla = e.which;
	if (tecla == 13 || tecla == 46 || tecla == 37 || tecla == 39){ return true; }
	if (tecla > 47 && tecla < 58 ) return true;
	if (tecla == 8 || tecla == 9 || tecla == 13 || tecla == 46) return true;
	return false;
}

// ***********************************************************************
// SELECIONA TODOS OS CARROS
// ***********************************************************************
function SelectAll(Qtd){
   if (document.Frm.MarcaAll.checked == true){
        for ( i=1; i<=Qtd; i++){
           if(document.Frm.elements[i].type == "checkbox")
              document.Frm.elements[i].checked=1
        }
   } else {
        for ( i=1; i<=Qtd; i++){
           if(document.Frm.elements[i].type == "checkbox")
              document.Frm.elements[i].checked=0
        }
   }
}
// ***********************************************************************
// MY LIST SUBMIT
// ***********************************************************************
function MyList_Enviar(opcao,Qtd) {
      var erro = 0;

      //OPÇÃO: EXCLUIR SELECIONADA
	  if(opcao == 'E') {
         for ( i=1; i<=Qtd; i++){
            if(document.Frm.elements[i].type == "checkbox"){
              if (document.Frm.elements[i].checked == true){
                 erro = erro+1;
              }
            }
         }
         if (erro != 0){
            document.Frm.action = "libs/mylist.php?Op=del";
		    document.Frm.submit();
         } else {
            alert('É necessário selecionar um veículo da sua lista!');
         }
      }

      //OPÇÃO: COMPARAR SELECIONADA
	  if(opcao == 'C') {
         for ( i=1; i<=Qtd; i++){
           if(document.Frm.elements[i].type == "checkbox"){
              if (document.Frm.elements[i].checked == true){
                 erro = erro+1;
              }
           }
         }
         if (erro >= 2){
            document.Frm.action = "libs/Compara_Functions.php";
		    document.Frm.submit();
         } else {
            alert('É necessário selecionar no mínimo 2 veículos da sua lista!');
         }
      }

}
// ***********************************************************************
// IMPRIME O IFRAME DA COMPARACAO
// ***********************************************************************
function imprimirIFrame()
{
  frames["MyList_Compara"].focus();
  frames["MyList_Compara"].print();
}
// ***********************************************************************
// INCLUDE LISTA
// ***********************************************************************
function IncludeLista(Id){
    var URL = "libs/mylist.php?Op=inc&Id="+Id;
    var width  = 370;
    var height = 160;
    var left = (screen.width/2) - width/2;
    var top = (screen.height/2) - height/2;
    var styleStr = 'toolbar=NO,location=NO,directories=NO,status=NO,menubar=NO,scrollbars=NO,resizable=NO,copyhistory=YES,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
    window.open(URL,"Visualizar", styleStr)
}
// ***********************************************************************
// VISUALIZAR MINHA LISTA (INCLUDE)
// ***********************************************************************
function ViewMyList(){
      opener.location='../index.php?pg=MyList';
      self.close();
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// ***********************************************************************
// FORMATA PRECO
// ***********************************************************************
function FormataPreco(e, valor, nome) {
    var tecla;
	if (!e) var e = window.event;
	if (e.keyCode) tecla = e.keyCode;
	else if (e.which) tecla = e.which;
	//alert(tecla);
 	if ((tecla == 13) || (tecla == 9) || (tecla == 37) || (tecla == 39) || (tecla == 8) || (tecla > 47 && tecla < 58 ) )  {
        return true;
    } else {
       alert('Digite apenas números!');
       Str = 'document.Frm.'+nome+'.focus();';
       eval(Str);
       return false;
    }
}
 
//-->
