﻿//============================================================================================//
//============================================================================================//
//============================================================================================//
var
  gUrlHttp  = 'http://www.lojasvolpato.com';
  gUrlHttps = 'https://www.lojasvolpato.com';

//============================================================================================//
function IrPara(pProtocolo, pArquivo) {
  if (pProtocolo == 'http')
    document.location.href = gUrlHttp  + '/' + pArquivo;
  else
    document.location.href = gUrlHttps + '/' + pArquivo;
}
//============================================================================================//
//AWFCatXXX_DivRepeaterBanSobreposto
function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
  obj.visibility=v; }
}
function xolayer(){
  MM_showHideLayers('AWFCatXXX_DivRepeaterBanSobreposto','','hide')
}
function Trim(str) { return str.replace(/^\s+|\s+$/g, ""); }
function VerificaDiv() {
  if (Trim(document.getElementById('AWFCatXXX_DivRepeaterBanSobreposto').innerHTML) == "") {
    MM_showHideLayers('AWFCatXXX_DivRepeaterBanSobreposto', '', 'hide')
  } else {
    MM_showHideLayers('AWFCatXXX_DivRepeaterBanSobreposto', '', 'show')
  }
}
//============================================================================================//
function AbrirJanela(pProtocolo, pUrl, pWidth, pHeight, pCaracteristicas) {
  var top = (screen.height - pHeight) / 2;
  var left = (screen.width - pWidth) / 2;
  if (pProtocolo == 'http')
    window.open(
      gUrlHttp + '/' + pUrl,
      'jPlusnetWebStore',
      'width=' + pWidth + ', height=' + pHeight + ', top=' + top + ', left=' + left + pCaracteristicas
    );
  else
    window.open(
      gUrlHttps + '/' + pUrl,
      'jPlusnetWebStore',
      'width=' + pWidth + ', height=' + pHeight + ', top=' + top + ', left=' + left + pCaracteristicas
    );
}
//============================================================================================//
function AbrirJanela_AWFCatAvi(pUrl) {
  var width = 268;
  var height = 250;
  var top = (screen.height - height) / 2;
  var left = (screen.width - width) / 2;
  window.open(
    gUrlHttp + '/' + pUrl,
    'jPlusnetWebStore',
    'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left
  );
}
//============================================================================================//
function ControlarQuantidade(p_Campo, p_PerFracao, p_FatQuantidade, p_LimMaximo) {
  var ExpRegInteiro = /^\d+$/;
  var ExpRegReal = /^((\d+|\d{1,3})(\,\d*)?|\,\d+)$/;
  p_Campo.value = StrLRTrim(p_Campo.value);
  if (p_Campo.value != '') {
    //p_PerFracao
    if (p_PerFracao) {
      if (!ExpRegReal.test(p_Campo.value)) {
        alert('ATENÇÃO!\n\n' +
              'Este produto aceita apenas quantidades com valores numéricos inteiros ou fracionários.');
        p_Campo.focus();
        p_Campo.select();
        return false;
      }
    } else {
      if (!ExpRegInteiro.test(p_Campo.value)) {
        alert('ATENÇÃO!\n\n' +
              'Este produto aceita apenas quantidades com valores numéricos inteiros.');
        p_Campo.focus();
        p_Campo.select();
        return false;
      }
    }
    //p_FatQuantidade
    if ((p_FatQuantidade > 0)) {
      aux = p_Campo.value.replace(",", ".") / p_FatQuantidade;
      aux = aux.toFixed(2);
      if (aux != parseInt(aux)) {
        aux = (p_FatQuantidade * (parseInt(aux) + 1)).toFixed(2);
        aux = aux.replace(".", ",")
        p_Campo.value = aux;
        alert("A quantidade será ajustada para " + p_Campo.value + "\nconforme a embalagem.");
        p_Campo.focus();
        p_Campo.select();
        return false;
      }
    };
    //p_LimMaximo
    if ((parseFloat(p_Campo.value) > p_LimMaximo) && (p_LimMaximo > 0)) {
      alert('ATENÇÃO!\n\n' +
          'Este produto possui um limite máximo por pedido de: ' + p_LimMaximo + '\n');
      p_Campo.focus();
      p_Campo.select();
      return false;
    };
  };
};
//============================================================================================//
function StrLRTrim(p_Str) {
  var strTrim = new String(p_Str);

  while (strTrim.substr(0, 1) == ' ') strTrim = strTrim.substr(1, strTrim.length - 1);
  while (strTrim.substr(strTrim.length - 1, 1) == ' ') strTrim = strTrim.substr(0, strTrim.length - 1);
  return strTrim
};
//============================================================================================//
function correios() {
  var newWin = window.open("AWFXXXCep.aspx", "newWin", "toolbar=no,status=no,menubar=no,scrollbars=no,width=360,height=390,hotkeys=no,location=no,resizable=no,screenX=10,screenY=30,status=no,top=30,left=10");
}
