// JavaScript Document

var tag_div = '';

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];}}
}

//set player version here
var MM_contentVersion = 6;

//set sub version here
var release = "6,0,67,0";


//check for flash player
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
      var words = navigator.plugins["Shockwave Flash"].description.split(" ");
       for (var i = 0; i < words.length; ++i)
       {
      if (isNaN(parseInt(words[i])))
      continue;
      var MM_PluginVersion = words[i];
       }
   var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
   && (navigator.appVersion.indexOf("Win") != -1)) {
   document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
   document.write('on error resume next \n');
   document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
   document.write('</SCR' + 'IPT\> \n');
}

function writeFlash(swf,flashVarString,w,h,bgcolor,menu,mode,q,id){
if ( MM_FlashCanPlay ) {
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
+'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+release+'" '
+'width="'+w+'" height="'+h+'" id="'+id+'" align="">'
+'<param name="movie" value="'+swf+'">'
+'<param name="menu" value="'+menu+'"> '
+'<param name="quality" value="'+q+'"> '
+'<param name="wmode" value="'+mode+'"> '
+'<param name="bgcolor" value="'+bgcolor+'"> '
+'<param name="flashvars" value="'+flashVarString+'"> '
+'<embed src="'+swf+'" flashvars="'+flashVarString+'" menu="'+menu+'" quality="'+q+'" wmode="'+mode+'" '
+' bgcolor="'+bgcolor+'" width="'+w+'" height="'+h+'" name="'+swf+'" '
+' align="" type="application/x-shockwave-flash" '
+' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object> ');
} else {
//behaviour for if there is no flash player
document.write('You require Flash Player '+MM_contentVersion+' or later to use this site. ');
document.write('<em><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">');
document.write('Click here to install it now.</a></em>');


//this can be replaced by anything you want
//e.g. document.location.replace("text.html");

}
}

function fn_btn_over(botao,novo)
{
	var src_ini = botao.src;
	botao.onmouseover=function(){
			this.src = novo;
		}
	botao.onmouseout=function(){
			this.src = src_ini;
		}
}
function fn_btn_over_class(botao,novo)
{
	var src_ini = botao.className;
	botao.onmouseover=function(){
			this.className = novo;
		}
	botao.onmouseout=function(){
			this.className = src_ini;
		}
}

function add_zero(num) { return ((num <= 9) ? ("0" + num) : num); }

function mod_24(hour) { return (hour >= 24) ? hour - 24 : hour; }

function fn_hora_mundo() {
  var dt = new Date();
  var def = dt.getTimezoneOffset()/60;
  var gmt = (dt.getHours() + def);
  if(document.getElementById("local"))
  {
	      document.getElementById("local").innerHTML = (add_zero(dt.getHours()) + ":" + add_zero(dt.getMinutes()) + ":" + add_zero(dt.getSeconds()))+ '  ';
	      var ending = ":" + add_zero(dt.getMinutes()) + ":" +  add_zero(dt.getSeconds());
	      var rome =mod_24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
	      document.getElementById("rome").innerHTML = (add_zero(rome) + ending)+ '  ';
	      var isr =mod_24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
	      document.getElementById("Israel").innerHTML = (add_zero(isr) + ending)+ '  ';
	      var msw =mod_24(((gmt + 3) > 24) ? ((gmt + 3) - 24) : (gmt + 3));
	      document.getElementById("msw").innerHTML = (add_zero(msw) + ending)+ '  ';
	      var baku =mod_24(((gmt + 4) > 24) ? ((gmt + 4) - 24) : (gmt + 4));
	      document.getElementById("baku").innerHTML = (add_zero(baku) + ending)+ '  ';
	      var del =mod_24(((gmt + 5) > 24) ? ((gmt + 5) - 24) : (gmt + 5));
	      document.getElementById("del").innerHTML = (add_zero(del) + ending)+ '  ';
	      var dh =mod_24(((gmt + 6) > 24) ? ((gmt + 6) - 24) : (gmt + 6));
	      document.getElementById("dh").innerHTML = (add_zero(dh) + ending)+ '  ';
	      var kok =mod_24(((gmt +7 ) > 24) ? ((gmt +7 ) - 24) : (gmt + 7));
	      document.getElementById("kok").innerHTML = (add_zero(kok) + ending)+ '  ';
	      var ho =mod_24(((gmt + 8) > 24) ? ((gmt + 8) - 24) : (gmt + 8));
	      document.getElementById("ho").innerHTML = (add_zero(ho) + ending)+ '  ';
	      var tky =mod_24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));
	      document.getElementById("tky").innerHTML = (add_zero(tky) + ending)+ '  ';
	      var sdn =mod_24(((gmt + 10) > 24) ? ((gmt + 10) - 24) : (gmt + 10));
	      document.getElementById("sdn").innerHTML = (add_zero(sdn) + ending)+ '  ';
	      var mag =mod_24(((gmt + 11) > 24) ? ((gmt + 11) - 24) : (gmt + 11));
	      document.getElementById("mag").innerHTML = (add_zero(mag) + ending)+ '  ';
	      var wll =mod_24(((gmt + 12) > 24) ? ((gmt + 12) - 24) : (gmt + 12));
	      document.getElementById("wll").innerHTML = (add_zero(wll) + ending)+ '  ';
	      var _GMT =mod_24(((gmt) > 24) ? ((gmt) - 24) : (gmt));
	      document.getElementById("_GMT").innerHTML = (add_zero(_GMT) + ":" + add_zero(dt.getMinutes()) + ":" + add_zero(dt.getSeconds()))+ '  ';
	      var eniw =mod_24(((gmt+(24-12))>24)?((gmt+(24-12))-24):(gmt+(24-12)));
	      document.getElementById("eniw").innerHTML = (add_zero(eniw)+ending)+ '  ';
	      var sam =mod_24(((gmt+(24-11))>24)?((gmt+(24-11))-24):(gmt+(24-11)));
	      document.getElementById("sam").innerHTML = (add_zero(sam) + ending)+ '  ';
	      var haw =mod_24(((gmt+(24-10))>24)?((gmt + (24-10))-24):(gmt+(24-10)));
	      document.getElementById("Hawaii").innerHTML = (add_zero(haw) + ending)+ '  ';
	      var ala =mod_24(((gmt + (24-9)) > 24) ? ((gmt + (24-9)) - 24) : (gmt + (24-9)));
	      document.getElementById("alaska").innerHTML = (add_zero(ala) + ending)+ '  ';
	      var pacif =mod_24(((gmt + (24-8)) >= 24) ? ((gmt + (24-8)) - 24) : (gmt + (24-8)));
	      document.getElementById("pacif").innerHTML = (add_zero(pacif) + ending)+ '  ';
	      var mount =mod_24(((gmt + (24-7)) > 24) ? ((gmt + (24-7)) - 24) : (gmt + (24-7)));
	      document.getElementById("mount").innerHTML = (add_zero(mount) + ending)+ '  ';
	      var center =mod_24(((gmt + (24-6)) > 24) ? ((gmt + (24-6)) - 24) : (gmt + (24-6)));
	      document.getElementById("center").innerHTML = (add_zero(center) + ending)+ '  ';
	      var east =mod_24(((gmt + (24-5)) > 24) ? ((gmt + (24-5)) - 24) : (gmt + (24-5)));
	      document.getElementById("east").innerHTML = (add_zero(east) + ending)+ '  ';
	      var atl =mod_24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));
	      document.getElementById("atl").innerHTML = (add_zero(atl) + ending)+ '  ';
	      var bra =mod_24(((gmt + (24-3)) > 24) ? ((gmt + (24-3)) - 24) : (gmt + (24-3)));
	      bra = (bra >= 24) ? bra - 24 : bra;
	      document.getElementById("bra").innerHTML = (add_zero(bra) + ending)+ '  ';
	      var mid =mod_24(((gmt + (24-2)) > 24) ? ((gmt + (24-2)) - 24) : (gmt + (24-2)));
	      mid = (mid >= 24) ? mid - 24 : mid;
	      document.getElementById("mid").innerHTML = (add_zero(mid) + ending)+ '  ';
	      var azo =mod_24(((gmt + (24-1)) > 24) ? ((gmt + (24-1)) - 24) : (gmt + (24-1)));
	      azo = (azo >= 24) ? azo - 24 : azo;
	      document.getElementById("azo").innerHTML = (add_zero(azo) + ending)+ '  ';
	      setTimeout("fn_hora_mundo()", 1000);
	}
}

function fn_converte_form(form){
    var firstvalue = 0;

	    for (var i = 0; i < form.elements.length; i++) {
         if (form.elements[i].value!='' && form.elements[i].value != null && form.elements[i].value.length != 0)
         {
          if(form.elements[i].type=="text")
          {
	          if (i == 1 && form.elements[2].value != "") return false;
	          firstvalue = form.elements[i].value / eval('form.'+form.elements[i].name+'_factor.value');
	          break;
          }
          }
	    }
	    if (firstvalue == 0) {
	       fn_limpa_form(form);
	       return false;
	    }
	    for (var i = 0; i < form.elements.length; i++)
	    {

	           if(form.elements[i].type=="text")
	           {
                   form.elements[i].value = fn_formata_valor((firstvalue * eval('form.'+form.elements[i].name+'_factor.value')), form.rsize.value);
	           }

	    }

    return true;
}
function fn_formata_valor(input, rsize) {
   var invalid = "**************************";
   var nines = "999999999999999999999999";
   var strin = "" + input;
   var fltin = parseFloat(strin);
   if (strin.length <= rsize) return strin;
   if (strin.indexOf("e") != -1 ||
       fltin > parseFloat(nines.substring(0,rsize)+".4"))
      return invalid.substring(0, rsize);
   var rounded = "" + (fltin + (fltin - parseFloat(strin.substring(0, rsize))));
   return rounded.substring(0, rsize);
}
function resetform(form) {
    clearform(form);
    form.elements[1].value = 1;
    convertform(form);
    return true;
}
function fn_limpa_form(form) {
    for (var i = 0; i < form.elements.length; i++)
    {
     if(form.elements[i].type=='text')
     form.elements[i].value = "";
    }
}
function fn_somente_numero(campo){
	var digits="0123456789"
	var campo_temp
	for (var i=0;i<campo.value.length;i++){
	  campo_temp=campo.value.substring(i,i+1)
	  if (digits.indexOf(campo_temp)==-1){
		    campo.value = campo.value.substring(0,i);
		    break;
	   }
	}
}
function fn_isEmpty(text){
	var	len = text.length, pos, newtext = "";
	for (pos=0; pos<len; pos++){ if (text.substring(pos, (pos+1)) != " "){ newtext = newtext + text.substring(pos, (pos+1)); } }
	if (newtext.length > 0) return false; else return true;
}
function fn_isEmail(text){
	var arroba = "@", ponto = ".", posponto = 0, posarroba = 0;
	if (text =="") return false;
	for (var indice = 0; indice < text.length; indice++){ if (text.charAt(indice) == arroba) { posarroba = indice; break; } }
	for (var indice = posarroba; indice < text.length; indice++){ if (text.charAt(indice) == ponto) { posponto = indice; break; } }
	if (posponto == 0 || posarroba == 0) return false;
	if (posponto == (posarroba + 1)) return false;
	if ((posponto + 1) == text.length) return false;
	return true;
}
function fn_campos(formulario){
	var campos = '';
   	for(i=0;i<formulario.elements.length;i++)
    {
     if(formulario.elements[i].disabled==false)
     {
	     if(formulario.elements[i].value!=undefined && formulario.elements[i].type!='checkbox' && formulario.elements[i].type!='radio')
	        campos += formulario.elements[i].name+'='+escape(formulario.elements[i].value)+'&';
	     else
	     {
	       if(formulario.elements[i].type=='checkbox' || formulario.elements[i].type=='radio')
	       {
	         if(formulario.elements[i].checked==true)
	         campos += formulario.elements[i].name+'='+formulario.elements[i].value+'&';
	       }
	     }
     }
    }
    return campos;
}
function fn_campo_atencao(campo,tipo)
{
 	if(tipo==1)
    {
	    document.getElementById(campo+'_1').style.border='1px solid #999999';
	    document.getElementById(campo+'_2').style.border='1px solid #999999';
	    document.getElementById(campo).style.color='#CC0000';
    }
    else
    {
	    document.getElementById(campo+'_1').style.border='none';
	    document.getElementById(campo+'_2').style.border='none';
	    document.getElementById(campo).style.color='#666666';
    }

}
function fn_cadastro(retorno,formulario,campos)
{
	var dados = campos.split('|');
    var x=0;
    var y=0;
    for (b=0;b<formulario.elements.length;b++)
    {
	    for(a=0;a<dados.length;a++)
	    {
            if(formulario.elements[b].type!='radio')
            {
                if(formulario.elements[b].type!='checkbox')
                {
	                if(formulario.elements[b].name==dados[a] && formulario.elements[b].disabled==false)
	                {
	                    if(fn_isEmpty(formulario.elements[b].value))
	                    {
	                         x+=1;
	                         document.getElementById(dados[a]).style.border='1px solid #999999';
	                         document.getElementById('L_'+dados[a]).style.color='#CC0000';
	                    }
	                    else
	                    {
	                      document.getElementById(dados[a]).style.border='1px solid #CCCCCC';
	                      document.getElementById('L_'+dados[a]).style.color='#666666';
	                    }
	                    if(dados[a]=='NM_TX_EMAIL')
	                    {
	                      if(fn_isEmail(formulario.elements[b].value)==false)
	                      {
	                         document.getElementById(dados[a]).style.border='1px solid #999999';
	                         document.getElementById('L_'+dados[a]).style.color='#CC0000';
	                         x+=1;
	                      }
	                      else
	                      {
	                        document.getElementById(dados[a]).style.border='1px solid #CCCCCC';
	                        document.getElementById('L_'+dados[a]).style.color='#666666';
	                      }
	                    }
	                }
                }
                else
                {

                    if(dados[a]=='NM_TX_IMP_EXP_1')
	                {
	                  if(formulario.NM_TX_IMP_EXP_1.checked==false && formulario.NM_TX_IMP_EXP_2.checked==false)
	                  {
	                        x+=1;
	                        document.getElementById('NM_TX_IMP_EXP_1').style.border='1px solid #999999';
	                        document.getElementById('NM_TX_IMP_EXP_2').style.border='1px solid #999999';
	                        document.getElementById('L_NM_TX_IMP_EXP_1').style.color='#CC0000';
                            document.getElementById('L_NM_TX_IMP_EXP_2').style.color='#CC0000';
	                  }
	                  else
	                  {
	                        document.getElementById('NM_TX_IMP_EXP_1').style.border='none';
	                        document.getElementById('NM_TX_IMP_EXP_2').style.border='none';
	                        document.getElementById('L_NM_TX_IMP_EXP_1').style.color='#666666';
                            document.getElementById('L_NM_TX_IMP_EXP_2').style.color='#666666';
	                  }
	                }
                }
            }
            else
            {
               if(dados[a]=='NM_CK_SEXO')
               {
                 if(formulario.NM_CK_SEXO[0].checked==false && formulario.NM_CK_SEXO[1].checked==false)
                 {
                   fn_campo_atencao('NM_CK_SEXO',1);
                   y++;
                 }
                 else
                  fn_campo_atencao('NM_CK_SEXO',0);
               }
               if(dados[a]=='NM_CK_DOOR')
               {
                 if(formulario.NM_CK_DOOR[0].checked==false && formulario.NM_CK_DOOR[1].checked==false)
                 {
                   fn_campo_atencao('NM_CK_DOOR',1)
                   y++;
                 }
                 else
                  fn_campo_atencao('NM_CK_DOOR',0)
               }
               if(dados[a]=='NM_CK_PERIGOSA')
               {
                 if(formulario.NM_CK_PERIGOSA[0].checked==false && formulario.NM_CK_PERIGOSA[1].checked==false)
                 {
                   fn_campo_atencao('NM_CK_PERIGOSA',1)
                   y++;
                 }
                 else
                  fn_campo_atencao('NM_CK_PERIGOSA',0)
               }
               if(dados[a]=='NM_CK_PERECIVEL')
               {
                 if(formulario.NM_CK_PERECIVEL[0].checked==false && formulario.NM_CK_PERECIVEL[1].checked==false)
                 {
                   fn_campo_atencao('NM_CK_PERECIVEL',1)
                   y++;
                 }
                 else
                  fn_campo_atencao('NM_CK_PERECIVEL',0)
               }
            }
	    }
   }
   if(x>0 || y>0)
   {
    	if(retorno!='')
        {
            document.getElementById(retorno).style.display='block';
            document.getElementById(retorno).innerHTML = 'Atenção! Preencha os campos obrigatórios.';
            document.getElementById('texto').scrollTop=0;
            return false;
        }
        else
        	alert('Atenção! Preencha os campos obrigatórios.');
   }
   return true;
}
function fn_carrega()
{

var cntr = (tag_div=='texto') ? document.getElementById(tag_div) : document.getElementById('aeroportos');
cntr.innerHTML='';
cntr.innerHTML='<div class="carregando">aguarde, carregando...</div>';

if (http_request.readyState == 4 || http_request.readyState == 0)
    {                //alert(http_request.status);
            if (http_request.status == 200)
	        {
               var texto = http_request.responseText;
               cntr.innerHTML  = texto;
               if(tag_div=='texto')
               fn_ini();
            }
    }

}
function fn_link(endereco,campos)
{

    http_request = false;

    if (window.XMLHttpRequest)
    {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
            http_request.overrideMimeType('text/xml');
    }
    else if (window.ActiveXObject)
    {
        try
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {}
        }
    }

    http_request.onreadystatechange = fn_carrega;
    http_request.open('POST', endereco, true);
    http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
    http_request.setRequestHeader("CharSet", "iso-8859-1")
    http_request.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
    http_request.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
    http_request.setRequestHeader("Pragma", "no-cache");
    campos = (campos!='') ? campos : null;
    http_request.send(campos);
}
function fn_limpa_campos(formulario){
    for(var i=0;i<formulario.elements.length;i++)
    {
     	if(formulario.elements[i].type=='text' || formulario.elements[i].type=='textarea')
        formulario.elements[i].value='';
        if(formulario.elements[i].type=='select-one')
        {
        	formulario.elements[i].selectedIndex=0;
            formulario.elements[i].value='';
        }
        if(formulario.elements[i].type=='radio' || formulario.elements[i].type=='checkbox')
        formulario.elements[i].checked=false;
    }
}
function fn_disabled(elemento,tipo,formulario)
{
   for(var i=0;i<formulario.elements.length;i++)
   {
   if(formulario.elements[i].name!=undefined)
   {
      var campo_txt = formulario.elements[i].name;
	     if(campo_txt.indexOf(elemento)!=-1)
	     {
	        formulario.elements[i].disabled=tipo;
         }
    }
   }
}
function fn_habilita_fcl_lcl(campo,formulario)
{
 if(campo.value=='FCL')
 {
  document.getElementById('fcl').style.display='block';
  document.getElementById('lcl').style.display='none';
  fn_disabled('FCL',false,formulario);
  fn_disabled('LCL',true,formulario);
  formulario.NM_TX_TIPO_CONTAINER.disabled=false;
 }
 else if(campo.value=='LCL')
 {
  document.getElementById('fcl').style.display='none';
  document.getElementById('lcl').style.display='block';
  fn_disabled('FCL',true,formulario);
  fn_disabled('LCL',false,formulario);
  formulario.NM_TX_TIPO_CONTAINER.disabled=true;
 }
 else
 {
  document.getElementById('fcl').style.display='none';
  document.getElementById('lcl').style.display='none';
  fn_disabled('FCL',true,formulario);
  fn_disabled('LCL',true,formulario);
  formulario.NM_TX_TIPO_CONTAINER.disabled=true;
 }
}
function fn_habilita_modal(campo,formulario)
{

 if(campo.value=='R')
 {
   document.getElementById('rodoviario').style.display='block';
   document.getElementById('maritimo').style.display='none';
   document.getElementById('aereo').style.display='none';
   document.getElementById('sea_air').style.display='none';
   fn_disabled('RODOVIARIO',false,formulario);
   fn_disabled('MARITIMO',true,formulario);
   fn_disabled('LCL',true,formulario);
   fn_disabled('FCL',true,formulario);
   fn_disabled('AEREO',true,formulario);
   fn_disabled('SEA_AIR',true,formulario);
   formulario.NM_TX_TIPO_CARGA.disabled=true;
 }
 else if(campo.value=='A')
 {
   document.getElementById('rodoviario').style.display='none';
   document.getElementById('maritimo').style.display='none';
   document.getElementById('aereo').style.display='block';
   document.getElementById('sea_air').style.display='none';
   fn_disabled('AEREO',false,formulario);
   fn_disabled('RODOVIARIO',true,formulario);
   fn_disabled('MARITIMO',true,formulario);
   fn_disabled('LCL',true,formulario);
   fn_disabled('FCL',true,formulario);
   fn_disabled('SEA_AIR',true,formulario);

   formulario.NM_TX_TIPO_CARGA.disabled=true;

 }
 else if(campo.value=='M')
 {
   document.getElementById('rodoviario').style.display='none';
   document.getElementById('maritimo').style.display='block';
   document.getElementById('aereo').style.display='none';
   document.getElementById('sea_air').style.display='none';
   fn_disabled('MARITIMO',false,formulario);
   fn_disabled('RODOVIARIO',true,formulario);

   fn_disabled('AEREO',true,formulario);
   fn_disabled('SEA_AIR',true,formulario);
   formulario.NM_TX_TIPO_CARGA.disabled=false;
 }
 else if(campo.value=='S')
 {
   document.getElementById('rodoviario').style.display='none';
   document.getElementById('maritimo').style.display='none';
   document.getElementById('aereo').style.display='none';
   document.getElementById('sea_air').style.display='block';
   fn_disabled('RODOVIARIO',true,formulario);
   fn_disabled('MARITIMO',true,formulario);
   fn_disabled('LCL',true,formulario);
   fn_disabled('FCL',true,formulario);
   fn_disabled('AEREO',true,formulario);
   fn_disabled('SEA_AIR',false,formulario);
   formulario.NM_TX_TIPO_CARGA.disabled=true;
 }
 else
 {
   document.getElementById('rodoviario').style.display='none';
   document.getElementById('maritimo').style.display='none';
   document.getElementById('aereo').style.display='none';
   document.getElementById('sea_air').style.display='none';
   fn_disabled('RODOVIARIO',true,formulario);
   fn_disabled('MARITIMO',true,formulario);
   fn_disabled('LCL',true,formulario);
   fn_disabled('FCL',true,formulario);
   fn_disabled('AEREO',true,formulario);
   fn_disabled('SEA_AIR',true,formulario);
   formulario.NM_TX_TIPO_CARGA.disabled=true;
 }
}
function fn_verifica_interna(){
	if(window.screen.width<900)
	{
		document.getElementById("interna").style.left='0px';
		document.getElementById("interna").style.marginLeft='0px'; 
	}
	else
	{
		document.getElementById("interna").style.left='50%';
		document.getElementById("interna").style.marginLeft='-500px'; 	
	}
}
function fn_verifica_principal(){
	if(window.screen.width<900)
	{
		document.getElementById("principal").style.left='0px';
		document.getElementById("principal").style.marginLeft='0px'; 
	}
	else
	{
		document.getElementById("principal").style.left='50%';
		document.getElementById("principal").style.marginLeft='-500px'; 	
	}
}




function fn_ini(){

	if(document.getElementById("interna"))
	{
		fn_verifica_interna();
		setInterval(fn_verifica_interna,3000);	
	}
	if(document.getElementById("principal"))
	{
		fn_verifica_principal();
		setInterval(fn_verifica_principal,3000);	
	}
	fn_hora_mundo();
    MM_preloadImages('images/btn_cancelar_over.jpg','images/btn_calcular_over.jpg','images/btn_enviar_over.jpg','images/btn_entrar_over.jpg');
    var var_conteudo = document.getElementById('conteudo');
	var tag_input = document.getElementsByTagName('input');
	for(i=0;i<tag_input.length;i++)
	{
		if(tag_input[i].getAttribute('id')=='BTN_ENTRAR')
		fn_btn_over(tag_input[i],'images/btn_entrar_over.jpg');
		if(tag_input[i].getAttribute('id')=='BTN_VOLUME')
		fn_btn_over_class(tag_input[i],'calcular-over');
		if(tag_input[i].getAttribute('id')=='BTN_VOLUME' || tag_input[i].getAttribute('id')=='BTN_MASSA' || tag_input[i].getAttribute('id')=='BTN_DISTANCIA')
		fn_btn_over_class(tag_input[i],'calcular-over');
        if(tag_input[i].getAttribute('id')=='BTN_ENVIAR')
		fn_btn_over_class(tag_input[i],'enviar-over');
        if(tag_input[i].getAttribute('id')=='BTN_CANCELAR')
		fn_btn_over_class(tag_input[i],'cancelar-over');
	}
	if(document.getElementById('BTN_CURRICULO'))
	{
	   document.getElementById('BTN_CURRICULO').onclick = function(){
		   var campos = fn_campos(document.fOportunidades);
	                                                      tag_div = 'texto';
	                                                      if(fn_cadastro('retorno',document.fOportunidades,'NM_TX_NOME|NM_VL_IDADE|NM_TX_ENDERECO|NM_TX_BAIRRO|NM_TX_CIDADE|NM_TX_CEP|NM_TX_ESTADO|NM_TX_TEL_RESIDENCIAL|NM_CK_SEXO|NM_TX_ESTADO_CIVIL|NM_TX_ESCOLARIDADE|NM_TX_INSTITUICAO|NM_TX_CURSO|NM_VL_ANO_CONCLUSAO|NM_TX_EMAIL|'))
                                                          {
                                                            document.fOportunidades.submit();
                                                            fn_limpa_campos(document.fOportunidades);
                                                          }  
	   }
	}
    if(document.getElementById('BTN_ENVIAR'))
    {
	    document.getElementById('BTN_ENVIAR').onclick =
	                                                 function ()
	                                                 {
                                                      if(document.getElementById('msg'))
                                                      {
                                                       document.getElementById('msg').innerHTML='';
                                                       document.getElementById('msg').style.display='none';
                                                      }
                                                      if(document.getElementById('fOportunidades'))
                                                      {
	                                                      var campos = fn_campos(document.fOportunidades);
	                                                      tag_div = 'texto';
	                                                      if(fn_cadastro('retorno',document.fOportunidades,'NM_TX_NOME|NM_VL_IDADE|NM_TX_ENDERECO|NM_TX_BAIRRO|NM_TX_CIDADE|NM_TX_CEP|NM_TX_ESTADO|NM_TX_TEL_RESIDENCIAL|NM_CK_SEXO|NM_TX_ESTADO_CIVIL|NM_TX_ESCOLARIDADE|NM_TX_INSTITUICAO|NM_TX_CURSO|NM_VL_ANO_CONCLUSAO|NM_TX_EMAIL|'))
                                                          {
                                                            fn_limpa_campos(document.fOportunidades);
                                                            fn_link('oportunidades.php',campos);
                                                          }
                                                      }
                                                      if(document.getElementById('fContato'))
                                                      {
	                                                      var campos = fn_campos(document.fContato);
	                                                      tag_div = 'texto';
	                                                      if(fn_cadastro('retorno',document.fContato,'NM_TX_NOME|NM_TX_EMAIL|NM_TX_TELEFONE|NM_TX_EMPRESA|'))
	                                                      {
                                                            fn_limpa_campos(document.fContato);
                                                            fn_link('customer.php',campos);
                                                          }
                                                      }
                                                      if(document.getElementById('fCotacao'))
                                                      {
	                                                      var campos = fn_campos(document.fCotacao);
	                                                      tag_div = 'texto';
	                                                      if(fn_cadastro('retorno',document.fCotacao,'NM_TX_EMPRESA|NM_TX_CNPJ|NM_TX_CONTATO|NM_TX_TELEFONE|NM_TX_EMAIL|NM_TX_MODAL|NM_TX_LOCAL_ORIG|NM_TX_CIDADE_ORIG|NM_TX_PAIS_ORIG|NM_TX_LOCAL_DEST|NM_TX_CIDADE_DEST|NM_TX_PAIS_DEST|NM_CK_DOOR|NM_TX_CEP_ORIG|NM_TX_CEP_DEST|NM_TX_TIPO_CARGA|NM_TX_TIPO_CONTAINER|NM_VL_QUANTIDADE_FCL|NM_TX_VOLUME_FCL|NM_TX_DIMENSOES_FCL|NM_VL_PESO_BRUTO_FCL|NM_VL_QUANTIDADE_LCL|NM_TX_VOLUME_LCL|NM_TX_DIMENSOES_LCL|NM_VL_PESO_BRUTO_LCL|NM_VL_QUANTIDADE_AEREO|NM_TX_VOLUME_AEREO|NM_TX_DIMENSOES_AEREO|NM_TX_PESO_BRUTO_AEREO|NM_VL_QUANTIDADE_RODOVIARIO|NM_TX_VOLUME_RODOVIARIO|NM_TX_DIMENSOES_RODOVIARIO|NM_VL_PESO_BRUTO_RODOVIARIO|NM_VL_QUANTIDADE_SEA_AIR|NM_TX_VOLUME_SEA_AIR|NM_TX_DIMENSOES_SEA_AIR|NM_VL_PESO_BRUTO_SEA_AIR|NM_CK_PERIGOSA|NM_TX_IMO|NM_TX_UN|NM_CK_PERECIVEL|NM_TX_REEFER|NM_TX_TEMPERATURA|NM_TX_DESCRICAO|NM_TX_IMP_EXP_1|NM_TX_IMP_EXP_2'))
                                                          {
                                                            fn_limpa_campos(document.fCotacao);
                                                            fn_link('cotacao.php',campos);
                                                          }
                                                      }


                                                      if(document.getElementById('fOnline'))
                                                      {


	                                                      if(fn_cadastro('retorno',document.fOnline,'NM_TX_EMPRESA|NM_TX_CNPJ|NM_TX_CONTATO|NM_TX_TELEFONE|NM_TX_EMAIL|NM_TX_MODAL|NM_TX_LOCAL_ORIG|NM_TX_CIDADE_ORIG|NM_TX_PAIS_ORIG|NM_TX_LOCAL_DEST|NM_TX_CIDADE_DEST|NM_TX_PAIS_DEST|NM_CK_DOOR|NM_TX_CEP_ORIG|NM_TX_CEP_DEST|NM_TX_TIPO_CARGA|NM_TX_TIPO_CONTAINER|NM_VL_QUANTIDADE_FCL|NM_TX_VOLUME_FCL|NM_TX_DIMENSOES_FCL|NM_VL_PESO_BRUTO_FCL|NM_VL_QUANTIDADE_LCL|NM_TX_VOLUME_LCL|NM_TX_DIMENSOES_LCL|NM_VL_PESO_BRUTO_LCL|NM_VL_QUANTIDADE_AEREO|NM_TX_VOLUME_AEREO|NM_TX_DIMENSOES_AEREO|NM_TX_PESO_BRUTO_AEREO|NM_VL_QUANTIDADE_RODOVIARIO|NM_TX_VOLUME_RODOVIARIO|NM_TX_DIMENSOES_RODOVIARIO|NM_VL_PESO_BRUTO_RODOVIARIO|NM_VL_QUANTIDADE_SEA_AIR|NM_TX_VOLUME_SEA_AIR|NM_TX_DIMENSOES_SEA_AIR|NM_VL_PESO_BRUTO_SEA_AIR|NM_CK_PERIGOSA|NM_TX_IMO|NM_TX_UN|NM_CK_PERECIVEL|NM_TX_REEFER|NM_TX_TEMPERATURA|NM_TX_DESCRICAO|NM_TX_IMP_EXP_1|NM_TX_IMP_EXP_2'))
                                                          {
                                                            document.fOnline.submit();
                                                            fn_limpa_campos(document.fOnline);
                                                          }
                                                      }
                                                   }


    }
        var nome_form = (document.getElementById('fCotacao')) ? document.fCotacao : document.fOnline;

        if(document.getElementById('fCotacao') || document.getElementById('fOnline'))
        {

         fn_habilita_modal(nome_form.NM_TX_MODAL,nome_form);
         fn_habilita_fcl_lcl(nome_form.NM_TX_TIPO_CARGA,nome_form);

         if(nome_form.NM_CK_DOOR[0].checked==true)
         {
          document.getElementById('div_cep').style.display='block';
          nome_form.NM_TX_CEP_ORIG.disabled=false;
          nome_form.NM_TX_CEP_DEST.disabled=false;
         }
         if(nome_form.NM_CK_PERECIVEL[0].checked==true)
         {
          document.getElementById('div_perecivel').style.display='block';
          nome_form.NM_TX_REEFER.disabled=false;
          nome_form.NM_TX_TEMPERATURA.disabled=false;
         }
         if(nome_form.NM_CK_PERIGOSA[0].checked==true)
         {
          document.getElementById('div_perigosa').style.display='block';
          nome_form.NM_TX_IMO.disabled=false;
          nome_form.NM_TX_UN.disabled=false;
         }
        }
}


function fn_location(path)
{
	window.location=path;
}
function fn_pesquisa()
{
 campo = document.getElementById('busca');

 if(campo.style.display=="block")
 {
  campo.style.display = "none";
  document.getElementById('btn_pesquisa').src = "../cadastros/images/btn_pesquisa.gif";
 }
 else
 {
  campo.style.display = "block";
  document.getElementById('btn_pesquisa').src = "../cadastros/images/btn_pesquisa_1.gif";
  document.fPesquisa.nm_busca.focus();
 }
}

function ck_todos(formulario,campo) {

         for (b=0;b<formulario.elements.length;b++)
         {
            if(formulario.elements[b].type == "checkbox" && formulario.elements[b].name.substring(0,3) == "ck_")
            {

                 formulario.elements[b].checked  =  campo.checked;

            }

         }

}

function fn_pagina(nrpagina)
{
 document.fPagina.nm_pagina.value = nrpagina;
 document.fPagina.submit();
}

function fn_envia()
{
	var x = 0;

          for (b=0;b<document.fCadastro.elements.length;b++)
         {
            if(document.fCadastro.elements[b].type == "checkbox" && document.fCadastro.elements[b].name.substring(0,3) == "ck_")
            {
              if(document.fCadastro.elements[b].name!='ck_total')
              {
               if(document.fCadastro.elements[b].checked)
               x++;
              }

            }
         }

 if(x>0)
 document.fCadastro.submit();
 else
 alert('Selecione um registro!');
}

function fn_mti() {
	
	if(document.fConsulta.login.value!='' && document.fConsulta.senha.value!='')
	{
		acesso=window.open('about:blank','WebTracking','location=1,top=0,left=0,resizable=1,toolbar=1,scrollbars=1,menubar=1,width='+window.screen.width+',height='+window.screen.height+',status=1');		
		document.fConsulta.target='WebTracking';
        document.fConsulta.submit();
		document.fConsulta.senha.value='';
		acesso.focus();
	}
	else
		alert('Preencha os campos.');	

	
}





window.onload=fn_ini;