constTxRamo21='21 - TN';
constTxRamo44='32 - RCTRC/VI';
constTxRamo54='54 - RCTRC';
constTxRamo55='55 - RCFDC';
constTxRamo56='56 - RCAC';
constTxRamo58='52 - RCTAC';
constTxRamo27='27 - MULTIMODAL';
constTxRamoIM='58 - INTERMODAL';

bk=String.fromCharCode(13);

function ObrigaASelOption(Obj,msg)
{
  var strV=Obj.options[Obj.selectedIndex].text;
  //var msg='Selecione um tipo de transporte.';
  JaObrigou=false;
  if (strV.charAt(0)=='-') 
  {
    Obj.focus();
    JaObrigou=true;
    ShowMsgTemQEscolher(Obj.options,msg);
  };
  return JaObrigou;
}


function form1Submit() 
{  
 	if (ObrigaASelOption(form1.documento,'Selecione um tipo de documento.'))
    	return false;
	if (ObrigaASelOption(form1.tiptransp,'Selecione um tipo de transporte.'))
    	return false;
	if (ObrigaASelOption(form1.ramo,'Selecione um ramo.'))
    	return false;    
 
  	with (document.form1) 
	{
    	if (valormerc.value == '') 
		{
	  		alert('O valor da mercadoria deve conter ao menos o valor 0'); 
	  		valormerc.focus();
	  		return false;
		}
	
		if (valorcontainer.value == ''){valorcontainer.value = 0;}
		if (valoracessorios.value == ''){valoracessorios.value = 0;}
		//Início Resolução Susep 337
		if (valorfrete.value == ''){valorfrete.value = 0;}
		if (valordespesas.value == ''){valordespesas.value = 0;}
		if (valorimpostos.value == ''){valorimpostos.value = 0;}
		if (valorlucesperados.value == ''){valorlucesperados.value = 0;}
		if (valoravarias.value == ''){valoravarias.value = 0;}	
  	}
  
  	if (! IsLimiteValido()) 
	{
    	return false;		
  	}	  
    
  	if (ObrigaASelOption(form1.origem,'Selecione UF de origem.'))
    	return false;
  	if (ObrigaASelOption(form1.destino,'Selecione UF de destino.'))
    	return false;
  
  	if (form1.chkbPercCompl.checked==true) 
	{
    	if (ObrigaASelOption(form1.tiptransp2,'Selecione um tipo de transporte (Perc. compl).'))
      		return false;
    	if (ObrigaASelOption(form1.origem2,'Selecione UF de origem (Perc. compl).'))
      		return false;
    	if (ObrigaASelOption(form1.destino2,'Selecione UF de destino (Perc. compl).'))
      		return false;
  	}

  	if (divTpMov.style.visibility!='hidden')
    if (ObrigaASelOption(form1.mov,'Selecione um tipo de movimento.'))
      	return false;
  	if (ObrigaASelOption(form1.tipmercadoria,'Selecione um tipo de mercadoria.'))
    	return false;
}


function ShowMsgTemQEscolher(Opt,PMsg) 
{
  var x;
  PMsg=PMsg + bk;
  for (x=1;x<Opt.length;x++)
  {
    PMsg=PMsg + bk + Opt[x].text;
  }
  alert(PMsg);
}

function RgMotoBlur() 
{
  if ((form1.rg.value.length==0) && (form1.cpf.value.length==0)) 
  {
    alert('Ou o CPF ou o RG do motorista deve ser informado.');
    form1.cpf.focus()
  }
}


function CpfMotoBlur()
{
  if (form1.cpf.value.length>0)
  {
    if (! vCPF(form1.cpf.value))
	{
      alert('Cpf inválido!')
      form1.cpf.focus();
    }
  }

}


function IsRamo44()
{
  return (form1.ramo.options[form1.ramo.selectedIndex].text==constTxRamo44);
}


function IsRamo58()
{
  return (form1.ramo.options[form1.ramo.selectedIndex].text==constTxRamo58);
}


function IsRamo55RCFDC()
{
  return (form1.ramo.options[form1.ramo.selectedIndex].text==constTxRamo55);
}


function ValorFloatKeyUp(strValorFloat) 
{
  var CharCode = String.fromCharCode(event.keyCode);
  var Valor = strValorFloat;
  //alert(Valor);
  if ((CharCode==',') && (Valor.indexOf(',')>-1))
  {
    event.keyCode = 0;
    return false;
  }
  
  if ((isNaN(CharCode) || CharCode==' ') && (CharCode != ','))
  {
    event.keyCode = 0;
    return false;
  } 
}


function IsLimiteValido() 
{ 
  var strLm,valorLm;  
  var retorno = true;
  var valorTotal; 
  
  //valida o valor da apolice (do ramo)
  dsApo = form1.ramo.options[form1.ramo.options.selectedIndex].text;
  strLm = form1.ramo.options[form1.ramo.options.selectedIndex].value;
  strLm = GetCol(strLm,"#",1);
  strLm = strLm == '' ? '0' : strLm;
  
  if (isNaN(parseFloat(strLm))) 
  {
    alert('Limite da apolice (' + dsApo + ') é (' + strLm + '). Não é um numero válido. Consulte o suporte.');
    valorLm = 0;
  } else
    valorLm = parseFloat(strLm);

  if (IsRamo55RCFDC()) {
    str54RCTRCLm = Get54RCTRCLm();
    if (isNaN(parseFloat(str54RCTRCLm))) {
      alert('O limite do ramo 54 não é um número válido. Contate o suporte.');
      valor54RCTRCLm = 0;
    } else
      valor54RCTRCLm = parseFloat(str54RCTRCLm);
    //55:ValorRamo:=iif('trc'>'fdc','trc','fdc');
    valorLm = (valor54RCTRCLm > valorLm) ? valor54RCTRCLm : valorLm;
  }
  return retorno;  
}


//Valida limite da apólice

/*

Alterado 24/03/2009 por Lucas

O campo Tipo de Movimento aparecia quando o valor da mercadoria estava zerado. O campo deve
aparecer quando o valor da mercadoria mais todos os outros "Extras" do cliente estiverem
zerados. Foi implementada as comparações que somam todas as quantias informadas antes de 
habilitar o campo Tipo de Movimento. A função é acionada ao focar o campo "Placa"

*/

function ValorMercBlur() 
{
	
  
  Zero = "0,00";
  CampoZero = parseFloat(Zero);
  
  if(form1.valormerc.value==""){var mercadoria = CampoZero ; form1.valormerc.value="0"} else { var mercadoria = parseFloat(form1.valormerc.value.replace(",","."))}
  if(form1.valoracessorios.value==""){var acessorios = CampoZero} else { var acessorios = parseFloat(form1.valoracessorios.value.replace(",","."))}
  if(form1.valorcontainer.value==""){var container = CampoZero} else { var container = parseFloat(form1.valorcontainer.value.replace(",","."))}
  if(form1.valorlucesperados.value==""){var lucros = CampoZero} else { var lucros = parseFloat(form1.valorlucesperados.value.replace(",","."))}
  if(form1.valordespesas.value==""){var despesas = CampoZero} else { var despesas = parseFloat(form1.valordespesas.value.replace(",","."))}
  if(form1.valorfrete.value==""){var frete = CampoZero} else { var frete = parseFloat(form1.valorfrete.value.replace(",","."))}	 
  if(form1.valoravarias.value==""){var avarias = CampoZero} else { var avarias = parseFloat(form1.valoravarias.value.replace(",","."))}	
   if(form1.valorimpostos.value==""){var impostos = CampoZero} else { var impostos = parseFloat(form1.valorimpostos.value.replace(",","."))}
 
  var TotalContas = mercadoria+acessorios+container+lucros+despesas+frete+avarias+impostos;
  
  var Total = TotalContas.toFixed(2);
  
  
  
  if(Total < 1 ){ 
  
   form1.mov.options.selectedIndex = 0;
   divTpMov.style.visibility = 'visible';
   form1.mov.focus();
  
  }
  
  else { 
  
  form1.mov.options.selectedIndex = 1;
  divTpMov.style.visibility = 'hidden';}
	 
	
}

function ValorContainerBlur() {
  if (form1.valorcontainer.value == "") {
    return false;
  } 
  
  
  
  strValorContainer = form1.valorcontainer.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorContainer))) {
    alert('O Valor de Container não é válido. Digite novamente.');
    form1.valorcontainer.focus();
    return false;  
  }  
};


function ValorAcessoriosBlur() {
  if (form1.valoracessorios.value == "") {
    return false;
  } 
  
  var strValorAcessorios;
  
  strValorAcessorios = form1.valoracessorios.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorAcessorios))) {
    alert('O Valor de Acessorios não é válido. Digite novamente.');
    form1.valoracessorios.focus();
    return false;  
  }
};


//Resolução 337 Susep
function ValorFreteBlur() {
  if (form1.valorfrete.value == "") {
    return false;
  } 
  
  var strValorFrete;
  
  strValorFrete = form1.valorfrete.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorFrete))) {
    alert('O Valor de Frete não é válido. Digite novamente.');
    form1.valorfrete.focus();
    return false;  
  }
};


function ValorDespesasBlur() {
  if (form1.valordespesas.value == "") {
    return false;
  } 
  
  var strValorDespesas;
  
  strValorDespesas = form1.valordespesas.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorDespesas))) {
    alert('O Valor de Despesas não é válido. Digite novamente.');
    form1.valordespesas.focus();
    return false;  
  }
};


function ValorImpostosBlur() {
  if (form1.valorimpostos.value == "") {
    return false;
  } 
  
  var strValorImpostos;
  
  strValorImpostos = form1.valorimpostos.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorImpostos))) {
    alert('O Valor de Impostos não é válido. Digite novamente.');
    form1.valorimpostos.focus();
    return false;  
  }
};


function ValorLucEsperadosBlur() {
  if (form1.valorlucesperados.value == "") {
    return false;
  } 
  
  var strValorLucEsperados;
  
  strValorLucEsperados = form1.valorlucesperados.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorLucEsperados))) {
    alert('O Valor de Lucros Esperados não é válido. Digite novamente.');
    form1.valorlucesperados.focus();
    return false;  
  }
};


function ValorAvariasBlur() {
  if (form1.valoravarias.value == "") {
    return false;
  } 
  
  var strValorAvarias;
  
  strValorAvarias = form1.valoravarias.value.replace(',','.');
  
  if (isNaN(parseFloat(strValorAvarias))) {
    alert('O Valor de Avarias não é válido. Digite novamente.');
    form1.valoravarias.focus();
    return false;  
  }
};


//--------------------------------------------------------------------
function Get54RCTRCLm() {
  var Posicao=aoptfindText(constTxRamo54,form1.ramo.options);
  if (Posicao==-1)
    return 0;
  var Str=form1.ramo.options[Posicao].value;
  return GetCol(Str,'#',1);
}

/*
function GetSelApoLim(){
  var Str=form1.ramo.options[form1.ramo.options.selectedIndex].value;
  GetLineApoInfos(Str);
  ApoInfoSelLim=ApoInfoLim;
}
*/
/*
function GetLineApoInfos(StrLine){
  var StrLim=GetCol(StrLine,"#",1);
  if (!parseFloat(StrLim))
    alert('O valor de limite esta com erro. Consulte o suporte.');
  ApoInfoLim=parseFloat(StrLim);
}
*/
//--------------------------------------------------------------------

function PlacaBlur(){
  if (form1.placa.value.length==0) {
    if (IsRamo58()) {
    //  ShowJanToSelect(divPlaca,form1.placa,LstEmprsAer)
    } else {
      form1.placa.value='Outros';
    }
  }
}


/*quando muda o conteudo via "dropdown list" ele ja vai para o proximo
componente devido a substituicao da tecla enter por tab. para selecionar o
destino2 que estava desativado iseri as linhas ---i ---f.
*/
function TipTransp2Change(){
  //alert('TipTransp2Change()');
  str=form1.tiptransp2.options[form1.tiptransp2.selectedIndex].text;
  form1.tiptransp2Pos.value=form1.tiptransp2.selectedIndex;
  form1.tiptransp2Value.value=str;
  if (str.charAt(1)!='-') {
    if (!IsRamo44())
      form1.origem2.disabled=false;
    form1.destino2.disabled=false;
    //---i
    //if (form1.origem2.disabled)
      //form1.destino2.focus();
    //---f
  } else {
    form1.origem2.disabled=true;
    form1.destino2.disabled=true;
  }
  form1.origem2Disabled.value=form1.origem2.disabled;
  form1.destino2Disabled.value=form1.destino2.disabled;
}


function AutoDefUrbano(){
  var Orig=form1.origem.options[form1.origem.selectedIndex].text;
  var Dest=form1.destino.options[form1.destino.selectedIndex].text;

  form1.urbano.disabled=Orig!=Dest;
  //form1.urbano.checked=!form1.urbano.disabled;
  if (form1.urbano.disabled) form1.urbano.checked=false;

  form1.urbanoDisabled.value=form1.urbano.disabled;
  /*
  if (Orig==Dest) {
    window.status='Orig:'+Orig+'  Dest:'+Dest;
    form1.urbano.disabled=false;
    form1.urbano.checked=true;
  }
  */
}


//Número documento só aceitar números na digitação
function NumeroBlur(Nm){
  if (Nm.value.length==0){
    alert('O número não deve ficar vazio.');
    Nm.focus();
    return false;
  }
  if (isNaN(Nm.value)) {
   alert('Digite apenas numeros.');
   Nm.focus();
   Nm.select();
   return false;
  }
};


/*
function FocusOrigem2PercCompl(elem){
    //->form1.numero.focus();
    form1.origem2.focus();
}

  function FocusDestino2PercCompl(elem){
    //->form1.numero.focus();
    form1.destino2.focus();
  }

  function FocuschkbPercCompl(){
    //->form1.numero.focus();
    form1.chkbPercCompl.focus();
  }
*/
 
 
function serieBlur(){
  if (form1.serie.value.length==0)
    form1.serie.value='U';
}

function chkbPercComplClick() 
{
  //alert('chkbPercComplClick()');
  form1.chkbPercComplAux.value=form1.chkbPercCompl.checked?'on':'';
  ShowOrHidePercCompl();
}


function ramoChange()
{
	//resolução Susep 337 implementada em 14/09/07 
	//Luc. esperados, frete e despesas só aparecem para o ramo 21, não aparece para os demais ramos.
	ramo=document.getElementById("ramo").value;
	ramoLst = ramo.split("#");
	
	//################################################
	//Legendas do vetor gerado pela função SPLIT
	//################################################
	nRamo 					= ramoLst[0];
	lmApolice 				= ramoLst[1];
	dataIni 				= ramoLst[2];
	datFim 					= ramoLst[3];
	container 				= ramoLst[4];
	acessorios 				= ramoLst[5];
	impostos 				= ramoLst[6];
	lucEsperados 			= ramoLst[7];
	frete 					= ramoLst[8];
	despesas 				= ramoLst[9];
	avAntesEmb 				= ramoLst[10];
	prazoHrAvAposEmb 		= ramoLst[11];
	limContainer 			= ramoLst[12];
	conteinerParticipa 		= ramoLst[13];
	limAcessorios 			= ramoLst[14];
	acessoriosParticipa 	= ramoLst[15];
	avarias 				= ramoLst[16];
	limAvarias 				= ramoLst[17];
	numApo 					= ramoLst[18];

	
	
		if (container=="S")
		{
			document.getElementById("hiddenvalorcontainer").style.display='inline';
		}
		else
		{
			document.getElementById("valorcontainer").value='';
			document.getElementById("hiddenvalorcontainer").style.display='none';
		}
		
		if (acessorios=="S")
		{
			document.getElementById("hiddenvaloracessorios").style.display='inline';
		}
		else
		{
			document.getElementById("valoracessorios").value='';
			document.getElementById("hiddenvaloracessorios").style.display='none';
		}
		
		if (impostos=="S")
		{
			document.getElementById("hiddenvalorimpostos").style.display='inline';
		}
		else
		{
			document.getElementById("valorimpostos").value='';
			document.getElementById("hiddenvalorimpostos").style.display='none';
		}
		
		if (lucEsperados=="S")
		{
			document.getElementById("hiddenvalorlucesperados").style.display='inline';
		}
		else
		{
			document.getElementById("valorlucesperados").value='';
			document.getElementById("hiddenvalorlucesperados").style.display='none';
		}
		
		if (frete=="S")
		{
			document.getElementById("hiddenvalorfrete").style.display='inline';
		}
		else
		{
			document.getElementById("valorfrete").value='';
			document.getElementById("hiddenvalorfrete").style.display='none';
		}
		
		if (despesas=="S")
		{
			document.getElementById("hiddenvalordespesas").style.display='inline';
		}
		else
		{
			document.getElementById("valordespesas").value='';
			document.getElementById("hiddenvalordespesas").style.display='none';
		}
		
		if (avarias=="S")
		{
			document.getElementById("hiddenvaloravarias").style.display='inline';
		}
		else
		{
			document.getElementById("valoravarias").value='';
			document.getElementById("hiddenvaloravarias").style.display='none';
		}		
	}
	





function Destino2UfsOuSiglas() 
{
  form1.destino2.options.length=0;
  form1.destino2.options[0]= new Option('------','');
  if (IsRamo44())
    for (x=0;x<LstSiglasPaises.options.length;x++)
      form1.destino2.options[x+1]= new Option(LstSiglasPaises.options[x].text,LstSiglasPaises.options[x].text);
  else
    for (x=0;x<LstUfs.options.length;x++)
      form1.destino2.options[x+1]= new Option(LstUfs.options[x].text,LstUfs.options[x].text);
}


//ResetStatusPercCompl
function ShowOrHidePercCompl() 
{
  if (form1.chkbPercCompl.checked==true) {
    pnlPercCompl.outerHTML='<div id="pnlPercCompl" visible="true">' + pnlPercCompl.innerHTML+'</div>';
    //alert(pnlPercCompl.style.visibility);
    //pnlPercCompl.style.visibility = 'visible';
    form1.pnlPercComplAux.value='visible';//pnlPercCompl.style.visibility;

  } else {
    //alert('apagando TipTransp2');
    pnlPercCompl.style.visibility = 'hidden';
    form1.pnlPercComplAux.value=pnlPercCompl.style.visibility;
    form1.tiptransp2.options.selectedIndex=0;
    form1.tiptransp2Pos.value=form1.tiptransp2.options.selectedIndex;
    form1.tiptransp2Value.value=form1.tiptransp2.options[form1.tiptransp2Pos.value].text;
    
    form1.origem2Pos.value=form1.origem2.options.selectedIndex=0;
    form1.origem2Value.value=form1.origem2.options[form1.origem2Pos.value].text;
    form1.destino2Pos.value=form1.destino2.options.selectedIndex=0;
    form1.destino2Value.value=form1.destino2.options[form1.destino2Pos.value].text;
    
    form1.origem2.disabled=true;
    form1.destino2.disabled=true;
    form1.origem2Disabled.value=form1.origem2.disabled;
    form1.destino2Disabled.value=form1.destino2.disabled;
  }
}


function AcertaVisual_VI(){
  if (IsRamo44()) {
    Label14.innerText='Identific.';  form1.Label14Aux.value=Label14.innerText;
    //Label14.style.visibility='hidden';
    Label15.innerText='País'; form1.Label15Aux.value=Label15.innerText;
    form1.origem2Pos.value=form1.origem2.options.selectedIndex=form1.origem2.options.length-1; // VI
    form1.origem2Value.value=form1.origem2.options[form1.origem2Pos.value].text;
    form1.origem2.disabled=true;
    
    form1.tiptransp2Pos.value=form1.tiptransp2.options.selectedIndex=0;
    form1.tiptransp2Value.value=form1.tiptransp2.options[form1.tiptransp2Pos.value].text;

    form1.chkbPercCompl.disabled=true;
    divIndentPercCompl.innerText='Viagem Internacional';
    form1.divIndentPercComplAux.value=divIndentPercCompl.innerText;
    divTxRCFDC.style.visibility='visible';

    form1.chkbTxRCFDC.style.visibility='visible';
  } else {                        //ramo diferente de 44
    Label14.innerText='Origem (UF)'; form1.Label14Aux.value=Label14.innerText;
    //Label14.style.visibility='visible';
    Label15.innerText='Destino (UF)'; form1.Label15Aux.value=Label15.innerText;
    //form1.origem2.style.visibility='visible';
    form1.chkbPercCompl.disabled=false;
    divIndentPercCompl.innerText='Perc. Complementar:';
    form1.divIndentPercComplAux.value=divIndentPercCompl.innerText;
    divTxRCFDC.style.visibility='hidden';
    form1.chkbTxRCFDC.style.visibility='hidden';
  }
  form1.chkbPercComplDisabled.value=form1.chkbPercCompl.disabled;
  form1.divTxRCFDCVisible.value=divTxRCFDC.style.visibility;
  form1.chkbTxRCFDCVisible.value=form1.chkbTxRCFDC.style.visibility;
  form1.origem2Disabled.value=form1.origem2.disabled;
}


function origem2Change()
{
  form1.origem2Pos.value=form1.origem2.options.selectedIndex;
  form1.origem2Value.value=form1.origem2.options[form1.origem2Pos.value].text;
}


function destino2Change()
{
  //alert(form1.destino2.options.selectedIndex+'='+form1.destino2.selectedIndex);
  form1.destino2Pos.value=form1.destino2.options.selectedIndex;
  form1.destino2Value.value=form1.destino2.options[form1.destino2Pos.value].text;
}


//Verificar o formato da data de emissão e embarque.
function valFormatoDt(CAMPO)
{
	var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
	var msgErro = 'Formato inválido de data.';
	var vdt = new Date();
	var vdia = vdt.getDay();
	var vmes = vdt.getMonth();
	var vano = vdt.getYear();

	if ((document.getElementById(CAMPO).value.match(expReg)) && (document.getElementById(CAMPO).value!=''))
	{
		var dia = document.getElementById(CAMPO).value.substring(0,2);
		var mes = document.getElementById(CAMPO).value.substring(3,5);
		var ano = document.getElementById(CAMPO).value.substring(6,10);
	
		if((mes==04 && dia > 30) || (mes==06 && dia > 30) || (mes==09 && dia > 30) || (mes==11 && dia > 30))
		{
			alert("Dia incorreto !!! O mês especificado contém no máximo 30 dias.");
			document.getElementById(CAMPO).focus();
			return false;
		} 
		else
		{ //1
			if(ano%4!=0 && mes==2 && dia>28)
			{
				alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");
				document.getElementById(CAMPO).focus();
				return false;
			} 
			else
			{ //2
				if(ano%4==0 && mes==2 && dia>29)
				{
					alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");
					document.getElementById(CAMPO).focus();
					return false;
				} 
				else
				{ //3
					if (ano > vano) 
					{
						alert("Data incorreta!! Ano informado maior que ano atual.");
						document.getElementById(CAMPO).focus();
						return false;
					}
					else
					{ //4
						//alert ("Data correta!");
						return true;
					} //4-else
				} //3-else
			}//2-else
		}//1-else
	} 
	else 
	{ //5
		alert(msgErro);
		document.getElementById(CAMPO).focus();
		return false;
	} //5-else
}//end Function valFormatoDt

//Formata os campos de Data e hora (funciona apenas no IE)
function formata(formato,campo)
{
	//aceita data ou hora
	if (formato == "data")
	{
		//Data
		if (document.getElementById(campo).value.length >= 10)
		{
			document.getElementById(campo).value = document.getElementById(campo).value.substr(0,9);
			return;
		}
	
		if (document.getElementById(campo).value.length == 2 || document.getElementById(campo).value.length == 5 )
		{
			document.getElementById(campo).value = document.getElementById(campo).value + "/";
		}
	}
	else if(formato == "hora")
	{
		if (document.getElementById(campo).value.length >= 5)
		{
			document.getElementById(campo).value = document.getElementById(campo).value.substr(0,4);
			return;
		}

		if (document.getElementById(campo).value.length == 2 || document.getElementById(campo).value.length == 5 )
		{
			document.getElementById(campo).value = document.getElementById(campo).value + ":";
		}
	}
	else
	{
		return 0;
	}
}//end function formata


//Verifica se a emissão não é maior que o embarque
function valDtEmissEmb()
{
	var tempEmiss 	= document.getElementById("dtemissao").value;
	var tempEmb		= document.getElementById("dtembarque").value;
	var dataEmiss 	= document.getElementById("dtemissao").value.split("/");
	var dataEmb 	= document.getElementById("dtembarque").value.split("/");
	var dia_emiss, mes_emiss,ano_emiss,dia_emb,mes_emb,ano_emb,dt_emiss,dt_embarque;
	
	dia_emiss 	= dataEmiss[0];
	mes_emiss	= dataEmiss[1];
	ano_emiss	= dataEmiss[2];
	dt_emiss	=ano_emiss+mes_emiss+dia_emiss;
	
	dia_emb		= dataEmb[0];
	mes_emb		= dataEmb[1];
	ano_emb		= dataEmb[2];
	dt_embarque=ano_emb+mes_emb+dia_emb;
	
	if(dt_emiss>dt_embarque){
		alert("Data de emissão maior que a data de embarque.");
		document.getElementById("dtemissao").focus();
	}
	return;
}


//Verifica se hora está correta
function validaHrEmb()
{
	if (!valFormatoDt('dtembarque')){return;}
		
	var hrEmb 	= document.getElementById("hrembarque").value;
	hrEmb 		= hrEmb.split(":");
	var hora 	= hrEmb[0];
	var minuto	= hrEmb[1];
	var erro	= 0;
	if (isNaN(hora)){erro++;}
	if (isNaN(minuto)){erro++;}
	if (hora < 0 || hora > 24){erro ++;}
	if (minuto < 0 || minuto > 60){erro ++;}
	if (erro != 0)
	{
		alert ("Hora de embarque incorreta.");
		document.getElementById("hrembarque").focus();	
	}
}

