function getHTTPObject()
{
  var xmlhttp;
  if (typeof XMLHttpRequest != 'undefined')
  {
   xmlhttp = new XMLHttpRequest();
  }
  else
  {
   xmlhtttp = new ActiveXObject("Microsoft.XMLHttp");
   if (!xmlhttp)
   {
    xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
  }
  return xmlhttp;
}

function respostaAjax(serverPage)
{
  var xmlhttp;
  if (typeof XMLHttpRequest != 'undefined')
  {
   xmlhttp = new XMLHttpRequest();
  }
  else
  {
   xmlhtttp = new ActiveXObject("Microsoft.XMLHttp");
   if (!xmlhttp)
   {
    xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
  }
  xmlhttp.open("GET", serverPage, false);
  xmlhttp.send(null);
  return xmlhttp.responseText;
}

function runajax(objID, serverPage)
{
  var xmlhttp;
  if (typeof XMLHttpRequest != 'undefined')
  {
   xmlhttp = new XMLHttpRequest();
  }
  else
  {
   xmlhtttp = new ActiveXObject("Microsoft.XMLHttp");
   if (!xmlhttp)
   {
    xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
  }
  var obj = document.getElementById(objID);
  xmlhttp.open('GET', serverPage, true);
  xmlhttp.onreadystatechange = function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function carrega_pagina_div(div_id, page_name, img_wait, msg_wait)
{
  //
  var obj_div = document.getElementById(div_id);
  if (obj_div)
  {
    //
    obj_div.innerHTML = '<center>' + '<br />' + '<br />' + img_wait + '<br />' + '<br />' + '<font style=font-family:tahoma;font-size:10px;color:' + color_opac + ';>' + msg_wait + '<font />' + '</center />';
    //
    runajax(div_id, page_name);
  }
}

function runajax_control(objID, serverPage, id_control, function_control)
{
  var obj_control = document.getElementById(id_control);
  if (obj_control) {obj_control.style.display = 'none';}
  var xmlhttp;
  if (typeof XMLHttpRequest != 'undefined')
  {
   xmlhttp = new XMLHttpRequest();
  }
  else
  {
   xmlhtttp = new ActiveXObject("Microsoft.XMLHttp");
   if (!xmlhttp)
   {
    xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
  }
  var obj = document.getElementById(objID);
  xmlhttp.open('GET', serverPage, true);
  xmlhttp.onreadystatechange = function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      obj.innerHTML = xmlhttp.responseText;
      if (obj_control) {obj_control.style.display = 'block';}
      if (function_control) {setTimeout(function_control, 300);}
    }
  }
  xmlhttp.send(null);
}

function respostaAjax_ocult(serverPage)
{
  var xmlhttp;
  if (typeof XMLHttpRequest != 'undefined')
  {
   xmlhttp = new XMLHttpRequest();
  }
  else
  {
   xmlhtttp = new ActiveXObject("Microsoft.XMLHttp");
   if (!xmlhttp)
   {
    xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
  }
  var objID = 'div_runajax_ocult';
  if (document.getElementById(objID))
  {
    var obj = document.getElementById(objID);
    xmlhttp.open('GET', serverPage, true);
    xmlhttp.onreadystatechange = function()
    {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {
        obj.innerHTML = xmlhttp.responseText;
      }
    }
    xmlhttp.send(null);
  }
}

function status_config_set()
{
  if (set_config)
  {
    exibe_ajax_process(carregado_ok_config_dinamico_msg_ajax, color_true, true, 5);
  }
  else
  {
    exibe_ajax_process(carregado_no_config_dinamico_msg_ajax, color_false, true, 5);
  }
}

function config_set()
{
  var objID = 'div_runajax_ocult';
  var obj = document.getElementById(objID);
  if (set_config)
  {
    exibe_ajax_process(carregado_ok_config_dinamico_msg_ajax, color_true, true, 5);
    obj.innerHTML = '';
    get_valor_remessa();
  }
  else
  {
    var obj_submit = document.getElementById('div_submit');
    var obj_pac = document.getElementById('div_pac');
    var obj_ibp = document.getElementById('div_ibp');
    var obj_menu_ibp = document.getElementById('div_menu_ibp_header');
    if (document.getElementById(objID))
    {
      var capture_config = obj.innerHTML;
      capture_config = trim(capture_config.replace('\n', ''));
      if (capture_config == '1')
      {
        if (obj_submit) {obj_submit.style.display = 'block';}
        if (obj_pac) {obj_pac.style.display = 'block';}
        if (obj_ibp) {obj_ibp.style.display = 'block';}
        if (obj_menu_ibp) {obj_menu_ibp.style.display = 'block';}
        exibe_ajax_process(carregado_ok_config_dinamico_msg_ajax, color_true, true, 3);
        obj.innerHTML = '';
        get_valor_remessa();
      }
      else
      {
        if (obj_submit) {obj_submit.style.display = 'none';}
        if (obj_pac) {obj_pac.style.display = 'none';}
        if (obj_ibp) {obj_ibp.style.display = 'none';}
        if (obj_menu_ibp) {obj_menu_ibp.style.display = 'none';}
        exibe_ajax_process(carregando_config_dinamico_msg_ajax, color_bas);
        var serverPage = '_config.php?type=ajax';
        respostaAjax_ocult(serverPage);
        setTimeout("config_set()", 15000);
      }
    }
  }
}

function get_valor_remessa()
{
  var intervalo = 1000;
  var tipo_ped = ped_tipo_prioritario.split("&")
  for (i=0; i < tipo_ped.length; i++)
  {
    setTimeout("get_remessa_valor('" + tipo_ped[i] + "', '0', '0', 1)", intervalo);
    intervalo = intervalo + 180000;
  }
  
}

function get_remessa_valor(ped_tipo, fr_ar, fr_mp, passagem)
{
  //
  var obj_submit = document.getElementById('div_submit');
  var obj_pac = document.getElementById('div_pac');
  var obj_ibp = document.getElementById('div_ibp');
  //
  if (passagem == 1)
  {
    if (obj_submit) {obj_submit.style.display = 'none';}
    if (obj_pac) {obj_pac.style.display = 'none';}
    if (obj_ibp) {obj_ibp.style.display = 'none';}
  }
  //
  var serverPage = '_get_valor_remessa.php?ped_tipo=' + ped_tipo + '&fr_ar=' + fr_ar + '&fr_mp=' + fr_mp;
  //
  var http = getHTTPObject();
  //
	http.open("GET", serverPage, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
  //
  function handleHttpResponse()
  {
		if (http.readyState == 4)
		{
			var resultado = http.responseText;
      if (resultado)
      {
        if (passagem == 1)
        {
          if (obj_submit) {obj_submit.style.display = 'block';}
          if (obj_pac) {obj_pac.style.display = 'block';}
          if (obj_ibp) {obj_ibp.style.display = 'block';}
          get_remessa_valor(ped_tipo, '1', '0', 2)
          return true;
        }
        else if (passagem == 2)
        {
          get_remessa_valor(ped_tipo, '0', '1', 3)
          return true;
        }
        else if (passagem == 3)
        {
          get_remessa_valor(ped_tipo, '1', '1', 4)
          return true;
        }
        else
        {
          return true;
        }
      }
      else
      {
        if (passagem == 1)
        {
          if (obj_submit) {obj_submit.style.display = 'block';}
          if (obj_pac) {obj_pac.style.display = 'block';}
          if (obj_ibp) {obj_ibp.style.display = 'block';}
        }
        return false;
      }
    }
  }
}

function alert_process (exibe, timer)
{
  if (timer) {timer = timer;} else {timer = 1;}
  if (exibe == true)
  {
    exibe_ajax_process(processando_msg_ajax, color_bas, true, timer, 'central');
  }
  else if (exibe == false)
  {
    exibe_ajax_process(processado_ok_msg_ajax, color_true, true, timer, 'ajax_process');
  }
}

function alert_sub_rigth_process (exibe, timer)
{
  if (timer) {timer = timer;} else {timer = 1;}
  if (exibe == true)
  {
    exibe_ajax_process(processando_msg_ajax, color_bas, true, timer, 'sub_rigth_central');
  }
  else if (exibe == false)
  {
    exibe_ajax_process(processado_ok_msg_ajax, color_true, true, timer, 'sub_rigth_ajax_process');
  }
}

function exibe_ajax_process(msg, color, hide, timer, id)
{
  if (msg) {msg = msg;} else {msg = msg_default;}
  if (color) {color = color;} else {color = color_default;}
  if (hide) {hide = hide;} else {hide = false;}
  if (timer) {timer = timer;}  else {timer = timer_default;}
  if (id) {id = id;} else {id = 'ajax_process';}
  if (document.getElementById(id))
  {
    document.getElementById(id).style.color = color;
    document.getElementById(id).innerHTML = msg;
    document.getElementById(id).style.visibility = 'visible';
    if (hide)
    {
      var timer_ms = timer * 1000;
      setTimeout("oculta_ajax_process('" + id + "')", timer_ms);
    }
  }
}

function oculta_ajax_process(id)
{
  if (id) {id = id;} else {id = 'ajax_process';}
  if (document.getElementById(id))
  {
    document.getElementById(id).style.color = color_default;
    document.getElementById(id).innerHTML = "";
    document.getElementById(id).style.visibility = 'hidden';
  }
}

contenido_textarea = "";
function limita_textarea (field, num_caracteres_permitidos, id_field_control)
{
	//
  if (id_field_control)
  {
    //
    id_field_control = id_field_control;
  }
  else
  {
    //
    id_field_control = "num_caracteres_digitados";
  }
  //
  num_caracteres = field.value.length
  //
	if (num_caracteres <= num_caracteres_permitidos)
  {
		//
    contenido_textarea = field.value;
	}
  else
  {
		//
    field.value = contenido_textarea;
	}
  //
  if (document.getElementById(id_field_control))
  {
  	//
    if (num_caracteres >= num_caracteres_permitidos)
    {
  		//
      document.getElementById(id_field_control).style.color="#ff0000";
  	}
    else
    {
  		//
      document.getElementById(id_field_control).style.color="#000000";
  	}
  }
  //
	cuenta(field, id_field_control);
}

function cuenta(field, id_field_control)
{
  //
  if (document.getElementById(id_field_control))
  {
    //
    document.getElementById(id_field_control).value = field.value.length;
  }
}

function show_win_page(win_id, pos, page, title, w, h, modal, minimize)
{
  //
  if (modal & modal == true)
  {
    modal = true;
  }
  else
  {
    modal = false;
  }
  //
  if (minimize & minimize == true)
  {
    minimize = true;
  }
  else
  {
    minimize = false;
  }
  //
  //lista de classes disponiveis
  class_name = "dialog";
  class_name = "mac_os_x";
  //verifica o navegador e versao e define a classe da janela
  if (navigator.appVersion.indexOf('MSIE')!= -1)
  {
    var temp = navigator.appVersion.split('MSIE');
    var versao = parseFloat(temp[1]);
//    alert ('Você está usando a versão ' + versao + ' do IE.');
    if (versao >= 7)
    {
      class_name = "mac_os_x";
    }
    else
    {
      class_name = "dialog";
    }
  }
  else
  {
//    alert ('Você não está usando IE');
    if(navigator.userAgent.indexOf('Firefox')!= -1)
    {
      var temp = navigator.userAgent.indexOf('Firefox') + 8;
      var versao = navigator.userAgent.substring(temp, temp + 6);
//      alert('Você está usando a versão ' + versao + ' do Firefox');
      class_name = "mac_os_x";
    }
    else
    {
//      alert ('Você não está usando IE nem Firefox');
      if(navigator.userAgent.toLowerCase().indexOf("chrome") > -1)
      {
//        alert('Você está usando o Google Chrome');
        class_name = "mac_os_x";
      }
      else
      {
//        alert ('Você não está usando IE, nem Firefox e nem Chrome');
        class_name = "dialog";
      }
    }
  }
  //
  if (pos == 'tl' | pos == 'tr')  //top + left ou top + right numa janela normal
  {
    //
    t = 20;
  }
  else if (pos == 'tlp' | pos == 'trp')  //top + left  ou top + right a partir de um parent
  {
    //
    t = 5;
  }
  //
  if (pos == 'bl')
  {
    ref_h = 600;
    //
    if (window.innerHeight) //if browser supports window.innerWidth
    {
      c_h = window.innerHeight;
      //
      if (c_h > ref_h)
      {
        b_h = ref_h;
      }
      else
      {
        b_h = c_h;
      }
    }
    else if (document.all) //else if browser supports document.all (IE 4+)
    {
      c_h = document.body.clientHeight;
      if (c_h > ref_h)
      {
        b_h = ref_h;
      }
      else
      {
        b_h = c_h;
      }
    }
    else
    {
      b_h = ref_h;
    }
    t = b_h - h - 40;
    if (t < 0) {t = ref_h - h;}
  }
  //
  if (pos == 'tr')
  {
    ref_w = 800;
    //
    if (window.innerWidth) //if browser supports window.innerWidth
    {
      c_w = window.innerWidth;
      //
      if (c_w > ref_w)
      {
        dif_w = c_w - ref_w;
      }
      else
      {
        dif_w = ref_w - c_w;
      }
      //
      dif_w_2 = (dif_w / 2) + 20;
    }
    else if (document.all) //else if browser supports document.all (IE 4+)
    {
      c_w = document.body.clientWidth;
      if (c_w > ref_w)
      {
        dif_w = c_w - ref_w;
      }
      else
      {
        dif_w = ref_w - c_w;
      }
      //
      dif_w_2 = (dif_w / 2) + 5;
    }
    else
    {
      c_w = 0;
      dif_w = 0;
      dif_w_2 = 0;
    }
    //
    l = c_w - w - dif_w_2;
    if (l < 0) {l = 0;}
  }
  else if (pos == 'tl')
  {
    ref_w = 800;
    //
    if (window.innerWidth) //if browser supports window.innerWidth
    {
      c_w = window.innerWidth;
      //
      if (c_w > ref_w)
      {
        dif_w = c_w - ref_w;
      }
      else
      {
        dif_w = ref_w - c_w;
      }
      //
      dif_w_2 = (dif_w / 2);
    }
    else if (document.all) //else if browser supports document.all (IE 4+)
    {
      c_w = document.body.clientWidth;
      if (c_w > ref_w)
      {
        dif_w = c_w - ref_w;
      }
      else
      {
        dif_w = ref_w - c_w;
      }
      //
      dif_w_2 = (dif_w / 2);
    }
    else
    {
      c_w = 0;
      dif_w = 0;
      dif_w_2 = 0;
    }
    //
    l = dif_w_2;
    if (l < 0) {l = 0;}
  }
  else if (pos == 'trp')
  {
    if (window.innerWidth) //if browser supports window.innerWidth
    {
      c_w = window.innerWidth;
    }
    else if (document.all) //else if browser supports document.all (IE 4+)
    {
      c_w = document.body.clientWidth;
    }
    //
    l = c_w - w - 5;
    if (l < 0) {l = 5;}
  }
  else if (pos == 'bl')
  {
    //
    l = 0;
  }
  else if (pos == 'tlp')
  {
    //
    l = 5;
  }
  else if (pos == 'out')
  {
    //
    t = -5000;
    //
    l = -5000;
  }
  else
  {
    //
    if (document.getElementById(win_id))
    {
      //
      win = document.getElementById(win_id);
      //
      win.showCenter(modal);
    }
    else
    {
      //
      win = new Window
      (
        {
        id: win_id,
        className: class_name,
        title: title,
        width:w,
        height:h,
        url: page,
        resizable: false,
        maximizable: false,
        draggable: false,
        showEffectOptions: {duration:1.5},
        destroyOnClose: true,
        recenterAuto:true
        }
      )
      ;
      //
      win.showCenter(modal);
      //
      if (minimize)
      {
        //
        win.minimize();
      }
    }
    //
    return true;
  }
  //
  if (document.getElementById(win_id))
  {
    //
    win = document.getElementById(win_id);
    //
    win.show(modal);
  }
  else
  {
    //
    var win = new Window
    (
      {
      id: win_id,
      className: class_name,
      title: title,
      top:t,
      left:l,
      width:w,
      height:h,
      url: page,
      resizable: false,
      maximizable: false,
      draggable: false,
      showEffectOptions: {duration:1.5},
      destroyOnClose: true
      }
    )
    ;
    //
    win.show(modal);
    //
    if (minimize)
    {
      //
      win.minimize();
    }
  }
  //
  return true;
}

function trim (inputstring)
{
  //remove espacos precedentes e posteriores da string transmitida
  // remove tambem os espacos consecutivos e os substitui por um espaco unico
  // se algo alem de uma string for transmitido (objeto nulo, sob medida, etc), retorna a string entrada
  if (typeof inputstring != "string")
  {
    // se algo alem de uma string for transmitido (objeto nulo, sob medida, etc), retorna a string entrada
    return inputstring;
  }
  var retvalue = inputstring;
  var ch = retvalue.substring(0, 1);
  while (ch == " ")
  {
    //verifica a existencia de espacos no inicio da string
    retvalue = retvalue.substring(1, retvalue.length);
    ch = retvalue.substring(0, 1);
  }
  ch = retvalue.substring(retvalue.length - 1, retvalue.length);
  while (ch == " ")
  {
    //verifica a existencia de espacos no final da string
    retvalue = retvalue.substring(0, retvalue.length - 1);
    ch = retvalue.substring(retvalue.length - 1, retvalue.length);
  }
  while (retvalue.indexOf("  ") != -1)
  {
     //procura espacos multiplos na string e substitui por um unico
     //observe que "  " sao 2 espacos (diferente de " ", que eh um espaco)
     retvalue = retvalue.substring(0, retvalue.indexOf("  ")) + retvalue.substring(retvalue.indexOf("  ") + 1, retvalue.length);
  }
  //retorna a string "trim" ao usuario
  return retvalue;
}


function go(loc)
{
  window.location.href = loc;
}

function click()
{
  if (document.all) //else if browser supports document.all (IE 4+)
  {
    if (event.button==2||event.button==3)
    {
      oncontextmenu='return false';
    }
  }
}
document.onmousedown=click
document.oncontextmenu = new Function("return false;")


// funcao de protecao dos dados na tela - inicio
  if (document.all) //else if browser supports document.all (IE 4+)
  {
    io=document.all;
    ae=document.getElementById;
    if(io)
    {
      if(ae)
      {
        document.onselectstart=cu;
        document.ondragstart=cu;
        document.oncontextmenu=cu
      }
      else
      {
      document.onmousedown=cv
      }
    }
    if(ae&&!io)
    {
      document.onmousedown=cu;
      document.onmouseup=nr;
      document.oncontextmenu=cu
    }
    if(document.layers)
    {
      window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
      window.onmousedown=nr;window.onmouseup=omu
    }
  }
  function cu()
  {
    return false
  }
  function omu(e)
  {
    if(e.which==1)
    {
      window.releaseEvents(Event.MOUSEMOVE);
      window.onmousemove=null
    }
  }
  function nr(e)
  {
    if(e.which==1)
    {
      window.captureEvents(Event.MOUSEMOVE);
      window.onmousemove=cu
    }
    if(e.which==3)
    {
      return false
    }
  }
  function cv()
  {
    vp=event.button;
    if(vp==2||vp==3)
    {
      alert(unescape("This function is not available."))
    }
  }
// funcao de protecao dos dados na tela - fim

function hidden()
{
  document.body.style.overflow='hidden';
}

function dimensiona(w, h) {

  //w e h sao as dimensoes minimas
  if (window.innerWidth) //if browser supports window.innerWidth
  {
    default_w = 915;
    default_h = 501;
    current_w = window.innerWidth;
    current_h = window.innerHeight;
    nav = 1;
  }
  else if (document.all) //else if browser supports document.all (IE 4+)
  {
    default_w = 894;
    default_h = 545; //550 no explorer antigo
    current_w = document.body.clientWidth;
    current_h = document.body.clientHeight;
    nav = 2;
  }
  else
  {
    default_w = w;
    default_h = h;
    current_w = 0;
    current_h = 0;
    nav = 3;
  }

  dimensiona = false;
  if (current_w < default_w)
  {
    dimensiona = true;
  }
  if (current_h < default_h)
  {
    dimensiona = true;
  }

  if (dimensiona == true)
  {
    //alert("VAI DIMENSIONAR. As dimensões atuais do ser navegador são: " + current_w + " x " + current_h);
    window.moveTo(0, 0);
    window.resizeBy(-screen.width, -screen.height);
    window.resizeBy(w, h);
    window.moveTo(0, 0);
  }

}

function putFocus(formInst, elementInst) {
// The second number in the "onLoad" command in the body
// tag determines the form's focus. Counting starts with '0'
    if (document.forms.length > 0) {
     document.forms[formInst].elements[elementInst].focus();
    }
}

function BoxFormat(objForm, strField, strfull, sMask) {
  if (document.all) //else if browser supports document.all (IE 4+)
  {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
    sValue = strfull;
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;
    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;
    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }
    objForm[strField].value = sCod;
    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
      else { // qualquer caracter...
        return true;
      } }
    else {
      return true;
    }
  }
}

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
  if (document.all) //else if browser supports document.all (IE 4+)
  {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
    if(document.all) {
      nTecla = evtKeyPress.keyCode; }
    else if(document.layers) {
      nTecla = evtKeyPress.which;
    }
    sValue = objForm[strField].value;
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;
    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;
    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }
    objForm[strField].value = sCod;
    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
      else { // qualquer caracter...
        return true;
      } }
    else {
      return true;
    }
  }
}

function string_moeda (val, moeda, exibe_moeda, str_moeda)
{
  //
  if (moeda) {moeda = moeda;} else {moeda = 'REAL';}
  if (exibe_moeda) {exibe_moeda = exibe_moeda;} else {exibe_moeda = true;}
  if (moeda.toUpperCase() == 'REAL')
  {
    if (str_moeda) {str_moeda = str_moeda;} else {str_moeda = 'R$ ';}
  }
  if (moeda.toUpperCase() == 'EURO')
  {
    if (str_moeda) {str_moeda = str_moeda;} else {str_moeda = '€ ';}
  }
  if (moeda.toUpperCase() == 'DOLAR')
  {
    if (str_moeda) {str_moeda = str_moeda;} else {str_moeda = '$ ';}
  }
  //
  if (isNaN(val))
  {
    var str_val = val;
  }
  else
  {
    //define "val" para 2 casas decimais
    var str_result = Math.round (val * 100) / 100;
    var str_val = str_result;
  }
  //
  if (exibe_moeda)
  {
    str_moeda = str_moeda;
  }
  else
  {
    str_moeda = '';
  }
  str_val = str_moeda + str_val;
  str_val = str_val.replace('.', ';');
  str_val = str_val.replace(',', '.');
  str_val = str_val.replace(';', ',');
  len = str_val.length;
  if (str_val.charAt(len - 1) == ',') {str_val = str_val + '00'}
  else if (str_val.charAt(len - 2) == ',') {str_val = str_val + '0'}
  else if (str_val.charAt(len - 3) == ',') {str_val = str_val + ''}
  else {str_val = str_val + ',00'}
  return str_val;
}

function msg_dialog(msg, title, statusbar)
{
  //
  win = new Window
  (
    {
    id: "dialog_msg",
    className: "dialog",
    title: title,
    width:350,
    height:100,
    resizable: false,
    maximizable: false,
    draggable: false,
    showEffectOptions: {duration:1.5},
    destroyOnClose: true,
    recenterAuto:true
    }
  )
  ;
  //
  win.getContent().innerHTML = msg;
  win.setStatusBar(statusbar);
  win.showCenter(true);

}

function como_desbloquear_popup(str_title_img, group_name, str_coment_img1, str_coment_img2, str_coment_img3)
{
  //verifica o navegador e versao e define a classe da janela
  if (navigator.appVersion.indexOf('MSIE')!= -1)
  {
    var temp = navigator.appVersion.split('MSIE');
    var versao = parseFloat(temp[1]);
    //alert ('Você está usando a versão ' + versao + ' do IE.');
    if (versao >= 7)
    {
      var file_img = 'desativa_popup_ie.jpg';
      var img_ped_w = 376;
      var img_ped_h = 336;
    }
    else
    {
      var file_img = 'desativa_popup_ie.jpg';
      var img_ped_w = 376;
      var img_ped_h = 336;
    }
  }
  else
  {
    //alert ('Você não está usando IE');
    if(navigator.userAgent.indexOf('Firefox')!= -1)
    {
      var temp = navigator.userAgent.indexOf('Firefox') + 8;
      var versao = navigator.userAgent.substring(temp, temp + 6);
      //alert('Você está usando a versão ' + versao + ' do Firefox');
      var file_img = 'desativa_popup_ff.jpg';
      var img_ped_w = 430;
      var img_ped_h = 336;
    }
    else
    {
      //alert ('Você não está usando IE nem Firefox');
      var file_img = 'desativa_popup_ie.jpg';
      var img_ped_w = 376;
      var img_ped_h = 336;
    }
  }
  file_img = path_img + file_img;
  //
  trailOn(file_img, str_title_img, group_name, str_coment_img1, str_coment_img2, str_coment_img3, img_ped_w, img_ped_h);
}

function Livezilla_loader(time_space, div_id, page, img_wait, msg_wait)
{


  carrega_pagina_div(div_id, page, img_wait, msg_wait)
//alert('Em breve chat online ao vivo!');

}

