﻿/// <reference path="jquery.js" />
var ie6Popup = eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('\'<J 1h="K/L">M.1i = N(){$("#C").D("i",$(M).1j())};N O(){$(".P-Q").1k();$("#C").R();$("S").D({q: "", T: ""})}$("S").D({q: "f%", T: "f%"});$(".P-Q").R();</J><1 1l="C" 2="r-1m:1n, 1o, 1p-1q; r-U: 1r; s: V; j: f%; q: f%; i: k; t: k;"><1 2="1s: 1t(1u=1v); -1w-W:0.8; W: 0.8; j: f%; q: f%; E-l: #1x; s: X; z-F: 1y; i: k; t: k;"></1><1 2="s: V; j: Y; t: Z%; i: Z%; z-F: 1z;"><1 2="E-l: #1A; m: 1B 10 1C; s: X; i: -1D; t: -1E; z-F: 1F; j: Y; G: k;"><1 2="j: 1G; E-l: #1H; G: 10; l: #1I; K-H: 11; r-1J: 1K; r-U:1L">1M&12;&13;o!</1><1 2="G: 1N;"><p>1O&14; 1P&15; 1Q 16 I 17!</p><7 /><p><9>1R 18 1S 1T&14; n&13;o 1U&15; 18 1V 1W.</9></p><7 /><p>1X 1Y 1Z&12;&20;21 22 23 24 25 26 27 28 29 16 I 17 <a d="3://5.2a.4.7/19/2b-2c-2d-6-2e-o-2f-a-2g-2h-2i-2j-.2k" g="h"><9>1a 1b[2l]</9></a> 2m <a d="3://19.2n.4.7/2o/2p-2q/1c-2r-2s-a-2t-2u-2v-2w.2x" g="h"><9>1b[2y 2z]</9></a>. 2A 1a 2B 2C 2D 2E 2F o 1d 2G 2H I 2I 2J.</p><1 H="2K"><a d="3://u-7.5.2L.4/u-1e/" g="h" 2="v: 0 b; 0 b;"><w x="3://5.c.4/y/A/c-2M.B" m="0" /></a><a d="3://5.1c.4/2N/2O.2P?2Q=2R-2S-2T-2U-2V&2W=u-7" g="h" 2="v: 0 b; 0 b;"><w x="3://5.c.4/y/A/c-2X.B" m="0" /></a><a d="3://5.2Y.4/7/1f/1d/" g="h" 2="v: 0 b; 0 b;"><w x="3://5.c.4/y/A/c-1f.B" m="0" /></a><a d="3://5.2Z.4/1g?30=u-1e" g="h" 2="v: 0 b; 0 b;"><w x="3://5.c.4/y/A/c-1g.B" m="0" /></a></1><7 /><p H="11"><a 2="l: #31;" d="L:O();"><9>32 33 e 34 a 35 a pá36</9></a></p></1></1></1></1>\'', 62, 193, '|div|style|http|com|www||br||strong||20px|ie6nomore|href||100|target|_blank|top|width|0px|color|border||||height|font|position|left|pt|margin|img|src|files||theme|jpg|ie6Popup|css|background|index|padding|align|navegador|script|text|javascript|window|function|hideAlert|flash|replaced|hide|body|minHeight|size|absolute|opacity|relative|500px|50|4px|right|ccedil|atilde|ecirc|aacute|um|desatualizado|este|info|clique|aqui|microsoft|download|BR|safari|chrome|type|onscroll|scrollTop|show|id|family|Verdana|Geneva|sans|serif|11px|filter|Alpha|Opacity|80|moz|000000|500|750|FEEFDA|solid|black|350px|250px|1000|492px|990000|FFFFFF|weight|bold|15px|Aten|10px|Voc|est|utilizando|Por|motivo|voc|visualizar|site|corretamente|Para|maiores|informa|otilde|es|sobre|os|problemas|que|podem|ocorrer|ao|utilizar|baixaki|2604|internet|explorer|ajude|mundo|ser|livre|desta|praga|htm|Baixaki|ou|abril|noticias|tecnologia|pessoal|encoraja|usuarios|abandonar|ie6|13082009|47|shl|Revista|Info|Ou|nas|imagens|abaixo|para|fazer|de|outro|mais|atual|center|mozilla|firefox|downloads|details|aspx|FamilyID|341c2ad5|8c3d|4347|8c03|08cdecd8852b|DisplayLang|ie8|apple|google|hl|CC0000|Fechar|aviso|continuar|vizualizar|gina'.split('|'), 0, {}))

$(function() {
   //IE6 Alert
   if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
      $('body').css('height', '100%');
      $('#content').before('<div id="outer"></div>');
      setTimeout(function() { $(ie6Popup).appendTo('#outer'); }, 100);
   }

   $('a[rel*="external"]').attr('target', '_blank');
	
	$("a.cHtml5").click(function() {
		if (confirm("O site somente será visualizado corretamente nos seguintes navegadores:\n\- Internet Explorer 9.0+\n\- Firefox 3.5+\n\- Chrome 5.0+\n\- Opera 11.0+\n\- Safari 5.0+\n\Deseja continuar?")) {
			window.location = $(this).attr("href");
		}
		return false;
	});
	
});

//Função para log usando o Firebug *quando ativado
function log(t) {
   if (!(typeof console === 'undefined')) console.log(t);
}

//----------------------------------------------------------------------------------------------//

function doMask(option, value) {
   value = value.replace(/\D/g, "");

   switch (option) {
      case "phone": // (11) 1111-1111
         value = value.replace(/^(\d{2})(\d)/g, "($1) $2");
         value = value.replace(/(\d{4})(\d)/, "$1-$2");
         break;
      case "vox": // 1111-11
         value = value.replace(/^(\d{4})(\d)/g, "$1-$2");
         break;
      case "zipcode": // CEP: 11111-11
         value = value.replace(/^(\d{5})(\d)/g, "$1-$2");
         break;
      case "date": // 11/11/1111
         value = value.replace(/^(\d{2})(\d)/g, "$1/$2");
         value = value.replace(/(\d{2})(\d)/, "$1/$2");
         break;
      case "decimal": // ...111.111.111,11
         value = value.replace(/(\d)(\d{2})$/g, "$1,$2");
         value = value.replace(/(\d)(\d{3},\d{2})/g, "$1.$2");
         value = value.replace(/(\d)(\d{3}\.\d{3},\d{2})/g, "$1.$2");
         break;
      case "number": // ...111
         value = value.replace(/(\d)$/g, "$1");
         break;
      case "kilo": // ...1111,111
         value = value.replace(/(\d)(\d{3})$/g, "$1,$2");
         break;
      case "cpf": // 111.111.111-11
         value = value.replace(/^(\d{3})(\d)/g, "$1.$2");
         value = value.replace(/(\d{3})(\d)/, "$1.$2");
         value = value.replace(/(\d{3})(\d)/, "$1-$2");
         break;
      case "id": // RG: 11.111.111-1 || 11.111.111-x
         value = value.replace(/^(\d{2})(\d)/g, "$1.$2");
         value = value.replace(/(\d{3})(\d)/, "$1.$2");
         value = value.replace(/(\d{3})(\d|x)/, "$1-$2");
         break;
      case "cnpj": // CNPJ: 00.000.000/0000-00
         value = value.replace(/(\d)(\d{2})$/g, "$1-$2");
         value = value.replace(/(\d)(\d{4}-\d{2})/g, "$1/$2");
         value = value.replace(/(\d)(\d{3}\/\d{4}-\d{2})/g, "$1.$2");
         value = value.replace(/(\d)(\d{3}\.\d{3}\/\d{4}-\d{2})/g, "$1.$2");
         break;
   }
   return value;
}

//////////////////////////////////////////////////////////////////////////////////////
//Funcao mask utilizada para criar mascaras para campos

function mask(o, opt) {
   v_obj = o
   v_opt = opt
   setTimeout("execMask()", 1)
}

function execMask() {
   v_obj.value = doMask(v_opt, v_obj.value)
}

function randomString(string_length) {
   var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
   var randomstring = '';
   for (var i = 0; i < string_length; i++) {
      var rnum = Math.floor(Math.random() * chars.length);
      randomstring += chars.substring(rnum, rnum + 1);
   }
   return randomstring
}

//-- Validations
//-*-* Date
function isDate(date) {
   var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
   if ((date.match(RegExPattern)) && (date != '')) {
      return true;
   } else {
      return false
   }
}
//-*-* Email
function isEmail(email) {
   var valida = /^[a-z0-9_.-]+@[a-z0-9_-]+\.[a-z0-9.-]+$/i.test(email); //Validacao de e-mail com Regex
   return valida;
}
//-*-* Url
function isUrl(url) {
   var valida = /^(http\:\/\/[a-zA-Z0-9_\-]+(?:\.[a-zA-Z0-9_\-]+)*\.[a-zA-Z]{2,4}(?:\/[a-zA-Z0-9_]+)*(?:\/[a-zA-Z0-9_]+\.[a-zA-Z]{2,4}(?:\?[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)?)?(?:\&[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)*)$/i.test(url);
   return valida;
}
//-*-* CEP
function isCep(cep) {
   var valida = /^\d{5}-\d{3}$/i.test(cep);
   return valida;
}
//-*-* Telefone
function isTel(tel) {
   var valida = /^\(\d{2}\) \d{4}-\d{4}$/i.test(tel);
   return valida;
}
//-*-* CPF
function isCPF(cpf) {
   var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;
   if (!filtro.test(cpf)) {
      return false;
   }

   cpf = cpf.replace(/[.-]/g, "");

   if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
		cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
		cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
		cpf == "88888888888" || cpf == "99999999999") {
      return false;
   }

   soma = 0;
   for (i = 0; i < 9; i++) soma += parseInt(cpf.charAt(i)) * (10 - i);
   resto = 11 - (soma % 11);
   if (resto == 10 || resto == 11) resto = 0;
   if (resto != parseInt(cpf.charAt(9))) {
      return false;
   }

   soma = 0;
   for (i = 0; i < 10; i++) soma += parseInt(cpf.charAt(i)) * (11 - i);
   resto = 11 - (soma % 11);
   if (resto == 10 || resto == 11) resto = 0;
   if (resto != parseInt(cpf.charAt(10))) {
      return false;
   }
   return true;
}
//-*-* CNPJ
function isCNPJ(cnpj) {
   var filtro = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/i;

   if (!filtro.test(cnpj)) {
      return false;
   }

   cnpj = cnpj.replace(/[.\/-]/g, "");

   var a = [];
   var b = new Number;
   var c = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
   for (i = 0; i < 12; i++) {
      a[i] = cnpj.charAt(i);
      b += a[i] * c[i + 1];
   }
   if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11 - x }
   b = 0;
   for (y = 0; y < 13; y++) {
      b += (a[y] * c[y]);
   }
   if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11 - x; }
   if ((cnpj.charAt(12) != a[12]) || (cnpj.charAt(13) != a[13])) {
      return false;
   }
   return true;

}
// Funo utilizada para bloquear a digitao de caracteres que no sejam nmeros
function noDigit(o) {
    var objVal = o.value;
    var objId = o.id;

    objVal = objVal.replace(/\D/g, "");
    document.getElementById(objId).value = objVal;
}

//-- End Validations

jQuery.fn.ForceNumericOnly = function() {
   return this.each(function() {
      $(this).keydown(function(e) {
         var key = e.charCode || e.keyCode || 0;
         // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
         return (key == 8 ||
                 key == 9 ||
                 key == 46 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
      })
   })
};

///CONVERT VALORES PARA COMPARACAO NO JQUERY
function parse_monetary(vl)
{
	 var valor = vl;
	 var n = 0;
	 if(valor == null || valor == '')
	 {
		  return n;
	 }
	 else
	 {
		  // 23.456,50 --> 23456.50
		  valor = valor.replace(/\,/g, '|');
		  valor = valor.replace(/\./g, '');
		  valor = valor.replace(/\|/g, '.');
		  
		  return parseFloat(valor);
	 }
};
///CONVERT VALORES PARA COMPARACAO NO JQUERY

///FORMATA VALORES COM 2 CASAS DECIMAIS
function formatNumber2(strValue) {
	//alert('strValue: '+strValue);
   strValue = strValue.toString().replace(/\R$|\,/g, '');
   dblValue = parseFloat(strValue);

   blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
   //dblValue = Math.floor(dblValue * 100 + 0.500000000001); ///ARREDONDA PARA CIMA
	dblValue = Math.floor(dblValue * 100); ///ARREDONDA PARA BAIXO
   intCents = dblValue % 100;
   strCents = intCents.toString();
   dblValue = Math.floor(dblValue / 100).toString();
	if (intCents < 10)
      strCents = "0" + strCents;
   for (var i = 0; i < Math.floor((dblValue.length - (1 + i)) / 3); i++)
      dblValue = dblValue.substring(0, dblValue.length - (4 * i + 3)) + '.' +
		dblValue.substring(dblValue.length - (4 * i + 3));
   return (((blnSign) ? '' : '-') + dblValue + ',' + strCents);
}
///FORMATA VALORES COM 2 CASAS DECIMAIS
