//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}




function validaPecas()

{

	if (document.frmPecas.nomePeca.value.length <= 1)

	{

		alert("BUSCA DE PEÇAS\nPor favor informe o Código ou Nome da Peça.");

		document.frmPecas.nomePeca.focus();

		return false;

	}





}





function popUp(url,titulo,w,h,scrol){

	lado=(screen.width)?(screen.width-w)/2:100;

	cima=(screen.height)?(screen.height-h)/2:100;

	settings='width='+w+',height='+h+',top='+cima+',left='+lado+',scrollbars='+scrol;

	window.open(url,titulo,settings);

}



function validaContato()

{

	if (document.frmContato.Nome.value.length <= 2)

	{

		alert("C O N T A T O\nPor favor, informe SEU NOME.");

		document.frmContato.Nome.focus();

		return false;

	}

	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(frmContato.Email.value)))

   	{

		alert("C O N T A T O\nPor favor, informe um E-MAIL válido");

		document.frmContato.Email.focus();

		return false;

	}



	if (document.frmContato.Comentarios.value.length <= 6)

	{

		alert("C O N T A T O\nPor favor, descreva seus COMENTÁRIOS.");

		document.frmContato.Comentarios.focus();

		return false;

	}



}



function validaAgenda()

{

	if (document.frmAgenda.Nome.value.length < 3)

	{

		alert("Por favor, informe seu NOME");

		document.frmAgenda.Nome.focus();

		return false;

	}


	if (document.frmAgenda.ddd_Tel.value.length < 2)

	{

		alert("Informe seu o DDD do seu Telefone");

		document.frmAgenda.ddd_Tel.focus();

		return false;

	}

	if (document.frmAgenda.Telefone.value.length < 8)

	{

		alert("Por favor, informe corretamente seu TELEFONE");

		document.frmAgenda.Telefone.focus();

		return false;

	}


  var valido;
    var str = document.frmAgenda.Email.value;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if(filter.test(str))
      valido = true;
     else{
      alert("Por favor, informe um E-MAIL válido");
      valido = false;
          return valido;
    }


		if (document.frmAgenda.Modelo.value.length < 2)

	{

		alert("Informe o MODELO do seu veículo.");

		document.frmAgenda.Modelo.focus();

		return false;

	}

		if (document.frmAgenda.Entrada_Data.value.length < 8)

	{

		alert("Informe corretamente a DATA de ENTRADA do seu veículo em nossa oficina.");

		document.frmAgenda.Entrada_Data.focus();

		return false;

	}

		if (document.frmAgenda.Entrada_Hora.value.length < 5)

	{

		alert("Informe a HORA aproximada para ENTRADA do seu veículo em nossa oficina.");

		document.frmAgenda.Entrada_Hora.focus();

		return false;

	}
		if (document.frmAgenda.Tipo_Servico.value == "selecione")
	{
		alert("Informe o serviço a ser realizado no seu veículo em nossa oficina");
		document.frmAgenda.Tipo_Servico.focus();
		return false;
	}

	if (document.frmAgenda.Loja.value == "selecione")
	{
		alert("Informe a Loja que será efetuado o serviço");
		document.frmAgenda.Loja.focus();
		return false;
	}
}


function validaCadastro(){
	if (document.frmBolsa.Nome.value.length < 3)
	{
		alert("Por favor, informe seu NOME");
		document.frmBolsa.Nome.focus();
		return false;
	}
	if (document.frmBolsa.ddd.value.length < 2)
	{
		alert("Informe seu o DDD do seu Telefone");
		document.frmBolsa.ddd.focus();
		return false;
	}
	if (document.frmBolsa.Telefone.value.length < 3)
	{
		alert("Por favor, informe corretamente seu TELEFONE");
		document.frmBolsa.Telefone.focus();
		return false;
	}
 var valido1;
    var str = document.frmBolsa.Email.value;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
     if(filter.test(str))
      valido1 = true;
     else{
      alert("Por favor, informe um E-MAIL válido");
      valido1 = false;
          return valido1;
    }
	if (document.frmBolsa.Modelo.value.length < 3)
	{
		alert("Por favor, informe o MODELO do veículo");
		document.frmBolsa.Modelo.focus();
		return false;
	}
	if (document.frmBolsa.Local.value == "Selecione")
	{
		alert("Por favor, informe o LOCAL");
		document.frmBolsa.Local.focus();
		return false;
	}
}


function DataMask(campo) {

  var atualiza = campo.value;

  if (event.keyCode > 47 && event.keyCode < 58) {

     if ((atualiza.length == 2) || (atualiza.length == 5)) {

        campo.value = campo.value + '/';

     }

  }

  else {

    event.keyCode = 0;

  }

}



function HoraMask(campo) {

  var atualiza = campo.value;

  if (event.keyCode > 47 && event.keyCode < 58) {

     if (atualiza.length == 2) {

        campo.value = campo.value + ':';

     }

  }

  else {

    event.keyCode = 0;

  }

}



function soNumeros(campo) {

  var atualiza = campo.value;

  if (event.keyCode > 47 && event.keyCode < 58) {

     campo.value = atualiza;

  }

  else {

    event.keyCode = 0;

  }

}



function validaPecas()

{



	if (document.frmPecas.Quantidade.value.length < 1)

	{

		alert("Informe a QUANTIDADE deste item que deseja adquirir");

		document.frmPecas.Quantidade.focus();

		return false;

	}

	if (document.frmPecas.Nome.value.length < 3)

	{

		alert("Por favor, informe seu NOME");

		document.frmPecas.Nome.focus();

		return false;

	}



	if (document.frmPecas.ddd.value.length < 2)

	{

		alert("Informe seu o DDD do seu Telefone");

		document.frmPecas.ddd.focus();

		return false;

	}

	if (document.frmPecas.Telefone.value.length < 8)

	{

		alert("Por favor, informe corretamente seu TELEFONE");

		document.frmPecas.Telefone.focus();

		return false;

	}



		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(frmPecas.Email.value)))

   	{

	alert("Por favor, informe um E-MAIL válido");

		document.frmPecas.Email.focus();

		return false;

	}

}



function validaSeguro()

{

		if (document.frmSeguro.nome.value.length < 3)

	{

		alert("Por favor, informe seu NOME");

		document.frmSeguro.nome.focus();

		return false;

	}

		if (document.frmSeguro.nascimento.value.length < 10)

	{

		alert("Informe a DATA de NASCIMENTO no formato dd/mm/aaaa");

		document.frmSeguro.nascimento.focus();

		return false;

	}

		if (document.frmSeguro.ecivil.value=='')

	{

		alert("Informe o ESTADO CIVIL");

		document.frmSeguro.ecivil.focus();

		return false;

	}

		if (document.frmSeguro.habilitacao.value.length < 4)

	{

		alert("Informe o ANO EM QUE FOI HABILITADO");

		document.frmSeguro.habilitacao.focus();

		return false;

	}

		if (document.frmSeguro.dddTel.value.length < 2)

	{

		alert("Informe o DDD do seu telefone");

		document.frmSeguro.dddTel.focus();

		return false;

	}

		if (document.frmSeguro.telefone.value.length < 8)

	{

		alert("Informe seu TELEFONE");

		document.frmSeguro.telefone.focus();

		return false;

	}

		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(frmSeguro.email.value)))

   	{

		alert("Por favor, informe um E-MAIL válido");

			document.frmSeguro.email.focus();

			return false;

	}

			if (document.frmSeguro.cepRes.value.length < 8)

	{

		alert("Informe o CEP DA RESIDÊNCIA corretamente");

		document.frmSeguro.cepRes.focus();

		return false;

	}

			if (document.frmSeguro.cepPer.value.length < 8)

	{

		alert("Informe o CEP DE PERNOITE corretamente");

		document.frmSeguro.cepPer.focus();

		return false;

	}

			if (document.frmSeguro.marca.value.length < 2)

	{

		alert("Informe a MARCA do seu veículo");

		document.frmSeguro.marca.focus();

		return false;

	}

			if (document.frmSeguro.modelo.value.length < 6)

	{

		alert("Informe o MODELO do seu veículo.\nCaso não saiba informar o Modelo, verifique no documento do veículo.\nEsta informação é muito importante para a avaliação correta do seu seguro.");

		document.frmSeguro.modelo.focus();

		return false;

	}

			if (document.frmSeguro.anoM.value.length < 2)

	{

		alert("Informe o ANO MODELO do seu veículos");

		document.frmSeguro.anoM.focus();

		return false;

	}

			if (document.frmSeguro.combustivel.value=='')

	{

		alert("Informe o tipo de COMBUSTÍVEL do seu veículo");

		document.frmSeguro.combustivel.focus();

		return false;

	}

			if (document.frmSeguro.portas.value=='')

	{

		alert("Informe quantas PORTAS possui seu veículo");

		document.frmSeguro.portas.focus();

		return false;

	}

			if (document.frmSeguro.combustivel.value=='')

	{

		alert("Informe o tipo de COMBUSTÍVEL do seu veículo");

		document.frmSeguro.combustivel.focus();

		return false;

	}

			if (document.frmSeguro.financiado.value=='')

	{

		alert("Informe se o seu veículo está FINANCIADO");

		document.frmSeguro.financiado.focus();

		return false;

	}

			if (document.frmSeguro.combustivel.value=='')

	{

		alert("Informe o tipo de COMBUSTÍVEL do seu veículo");

		document.frmSeguro.combustivel.focus();

		return false;

	}





		if (document.frmSeguro.possui_seguro.value=='')

	{

		alert("Informe se o seu veículo JÁ POSSUI SEGURO");

		document.frmSeguro.possui_seguro.focus();

		return false;

	}

			if (document.frmSeguro.possui_seguro.value=="Sim, o veículo já possui seguro.")

			{

					if (document.frmSeguro.qual_seguradora.value=='')

				{

					alert("Informe QUAL SEGURADORA seu veículo está segurado.");

					document.frmSeguro.qual_seguradora.focus();

					return false;

				}

					if (document.frmSeguro.apolice.value=='')

				{

					alert("Informe o NÚMERO DA APÓLICE.");

					document.frmSeguro.apolice.focus();

					return false;

				}

					if (document.frmSeguro.apolice_termino.value.length<10)

				{

					alert("Informe DATA FINAL DA APÓLICE de seu seguro atual.");

					document.frmSeguro.apolice_termino.focus();

					return false;

				}

					if (document.frmSeguro.bonus.value=='')

				{

					alert("Informe o BÔNUS que possui na apólice atual\nCaso não saiba coloque X.");

					document.frmSeguro.bonus.focus();

					return false;

				}



		}





		if (document.frmSeguro.anti_furto[0].checked)

	{

			if (document.frmSeguro.disp_anti_furto.value=='')

			{

				alert("informe qual o DISPOSITIVO ANTI-FURTO que utiliza em seu veículo.");

				document.frmSeguro.disp_anti_furto.focus();

				return false;

			}

	}

		if (document.frmSeguro.condutor_principal.value=='')

	{

		alert("Informe o NOME COMPLETO do PRINCIPAL CONDUTOR");

		document.frmSeguro.condutor_principal.focus();

		return false;

	}



		if (document.frmSeguro.principal_nasc.value.length < 10)

	{

		alert("Informe a DATA DE NASCIMENTO do PRINCIPAL CONDUTOR\nA data deve ser (dd/mm/aaa)");

		document.frmSeguro.principal_nasc.focus();

		return false;

	}

		if (document.frmSeguro.principal_ec.value=='')

	{

		alert("Informe O ESTADO CIVIL do PRINCIPAL CONDUTOR");

		document.frmSeguro.principal_ec.focus();

		return false;

	}

		if (document.frmSeguro.principal_1habil.value.length < 10)

	{

		alert("Informe a DATA DA PRIMEIRA HABILITAÇÃO do PRINCIPAL CONDUTOR\nA data deve ser (dd/mm/aaa)");

		document.frmSeguro.principal_1habil.focus();

		return false;

	}

		if (document.frmSeguro.profissao_condutor.value=='')

	{

		alert("Informe a PROFISSÃO do PRINCIPAL CONDUTOR");

		document.frmSeguro.profissao_condutor.focus();

		return false;

	}

		if (document.frmSeguro.tem_filhos[0].checked)

		{

					if (document.frmSeguro.idade_filhos.value=='')

						{

							alert("Informe a IDADE DOS FILHOS do principal condutor\nCaso mais de um filho(a) separe as idades com vírgula (ex: 09, 15..)");

							document.frmSeguro.idade_filhos.focus();

							return false;

						}

		}

			if (document.frmSeguro.carros_na_residencia.value=='')

	{

		alert("Informe QUANTOS CARROS HÁ NA RESIDÊNCIA do principal condutor.");

		document.frmSeguro.carros_na_residencia.focus();

		return false;

	}





		if (document.frmSeguro.de_acordo.checked==false)

	{

		alert("É necessário aceitar a DECLARAÇÃO DE RESPONSABILIDADE das informações.");

		document.frmSeguro.de_acordo.focus();

		return false;

	}

}