function objXMLHttp() {
if (window.XMLHttpRequest) {
var objetoXMLHttp = new XMLHttpRequest();
return objetoXMLHttp;
}else if (window.ActiveXObject) {
var versoes = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp"];
for (var i = 0; i < versoes.length; i++) {
try {
var objetoXMLHttp = new ActiveXObject(versoes[i]);
return objetoXMLHttp;
}catch (ex) {
// nada
}
}
}
return false;
};
var urlpag = 'my_controle.php';
var xida = 0;
var xidt2 = 0;
var xconta = 0;
var xtabela = '';
var xidr = 0;
var xtipo = 0;
var xidt = 0;
var bytesUploaded = 0;
var slocal = 'atualiza_arquivo';
function isEmailValid(email) {
var regex = /^[a-z0-9!$'*+\-_]+(\.[a-z0-9!$'*+\-_]+)*@([a-z0-9]+(-+[a-z0-9]+)*\.)+([a-z]{2}|aero|arpa|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|msp|name|net|org|pro|travel|br)$/;
return regex.test(email.toLowerCase());
};
function Trim(str) {
return str.replace(/^\s+|\s+$/g,"");
}
function er_replace( pattern, replacement, subject ){
return subject.replace( pattern, replacement );
}
function login(pag, item, conta, nump, dados, local) {
processando(1,'');
if (pag == 1) {
if (dados.email.value.length > 1) {
if (!isEmailValid(dados.email.value)) {
alerta('ERRO', 'O campo [ E-mail ] parece inválido.');
processando(2,'');
return false;
}else if (dados.senha.value.length < 1) {
alerta('ERRO', 'O campo [ Senha ] deve ser preenchido.');
processando(2,'');
return false;
}
}else if (dados.senha.value.length < 1) {
alerta('ERRO', 'O campo [ Senha ] deve ser preenchido.');
processando(2,'');
return false;
}
var dados = 'opx=1&pag=' + pag + '&item=' + item + '&conta=' + conta + '&nump=' + nump + '&' + getFormValues(dados,'');
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
if (Trim(oXMLHttp.responseText) == 'OK') {
window.location = 'index.php';
}else if (Trim(oXMLHttp.responseText) == '1') {
alerta('ERRO DE ACESSO', 'Senha inválida, favor verificar.');
}else {
alerta('ERRO DE ACESSO', 'E-mail ou Senha inválidos, favor verificar.');
document.getElementById('rsenha').style.display = 'block';
}
//alert(oXMLHttp.responseText);
processando(2,'');
}else {
alerta('ERRO', oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}else if (pag == 2) {
var dados = 'opx=1&pag=' + pag + '&item=' + item + '&conta=' + conta + '&nump=' + nump;
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
window.location = 'index.php';
processando(2,'');
}else {
alerta('ERRO', oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}else if (pag == 3) {
if (!isEmailValid(dados.email.value)) {
alerta('ERRO', 'O campo [ E-mail ] parece inválido.');
dados.email.focus();
processando(2,'');
return false;
}
var dados = 'opx=1&pag=' + pag + '&item=' + item + '&conta=' + conta + '&nump=' + nump + '&' + getFormValues(dados,'');
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
if (Trim(oXMLHttp.responseText) == 'OK') {
alerta('OK', 'Senha enviada com Sucesso. Verifique sua caixa de SPAM caso o email com sua senha de acesso demore a chegar.');
window.location = 'index.php';
}else if (Trim(oXMLHttp.responseText) == 'ERRO') {
alerta('ERRO DE ACESSO', 'Email informado nao localizado em nosso sistema, favor verificar.');
}else {
alert(oXMLHttp.responseText);
}
processando(2,'');
}else {
alerta('ERRO', oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
}
function tabela(t, tabela, chave, tipo, menu, idtabela, local) {
processando(1, local);
if (idtabela == 24) {
var dados = 'opx=5&t=' + t + '&tabela=' + tabela + '&chave=' + chave + '&tipo=' + tipo + '&menu=' + (menu) + '&idtabela=' + idtabela + '&local=' + local;
tipo = 2;
}else {
var dados = 'opx=2&t=' + t + '&tabela=' + tabela + '&chave=' + chave + '&tipo=' + tipo + '&menu=' + (menu) + '&idtabela=' + idtabela + '&local=' + local;
}
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#botao1').button();
$('#navbar1').navbar();
$("#fone" + t).mask("(99)9999-9999");
$("#celular" + t).mask("(99)99999-9999");
$("#validade" + t).mask("99/99/9999");
$("#cep" + t).mask("99999-999");
$("#data" + t).mask("99/99/9999");
$("#dataa" + t).mask("99/99/9999");
$("#datab" + t).mask("99/99/9999");
$("#datac" + t).mask("99/99/9999");
$("#cpf" + t).mask("999.999.999-99");
$("#cnpj" + t).mask("99.999.999/9999-99");
$("#pontos" + t).maskMoney({symbol:'R$ ', showSymbol:false, thousands:',', decimal:'.', symbolStay: false});
$("#valor" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#valora" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#valorb" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#valorc" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#proporcionalidade" + t).mask("0.99");
$("#proporcionalidadeb" + t).mask("0.99");
$("#proporcionalidadec" + t).mask("0.99");
//$("a[rel^='prettyPhoto']").prettyPhoto();
if (tipo == 0) {
var f = document.getElementById('fcadastra');
for(var i = 0; i < f.length; i++) {
if (f[i].type != 'hidden') {
if ((f[i].type == 'text') || (f[i].type == 'email')){
$('#' + f[i].name).textinput();
}else if (f[i].type == 'select-one') {
$('#' + f[i].name).selectmenu();
}else if (f[i].type == 'textarea') {
$('#' + f[i].name).textinput();
}else if (f[i].type == 'checkbox') {
//$('#' + f[i].id).checkboxradio();
}
}
}
carrega_editor(t);
carrega_data(t);
$('#bcadastrar').button();
$('#mlistagem').listview();
if (document.getElementById('mnav0') != null) {
$('#mnav0').navbar();
}
if (document.getElementById('mnav1') != null) {
$('#mnav1').navbar();
}
if (document.getElementById('mnav2') != null) {
$('#mnav2').navbar();
}
if (document.getElementById('mnav3') != null) {
$('#mnav3').navbar();
}
if (document.getElementById('mnav4') != null) {
$('#mnav4').navbar();
}
if (document.getElementById('mnav5') != null) {
$('#mnav5').navbar();
}
if (document.getElementById('mnav6') != null) {
$('#mnav6').navbar();
}
if (document.getElementById('mnav7') != null) {
$('#mnav7').navbar();
}
if (document.getElementById('mnav8') != null) {
$('#mnav8').navbar();
}
if (document.getElementById('mnav9') != null) {
$('#mnav9').navbar();
}
if (document.getElementById('mnav10') != null) {
$('#mnav10').navbar();
}
if (document.getElementById('mnavl') != null) {
$('#mnavl').navbar();
}
}else if (tipo == 1) {
var f = document.getElementById('fatualiza');
for(var i = 0; i < f.length; i++) {
if (f[i].type != 'hidden') {
if ((f[i].type == 'text') || (f[i].type == 'email')){
$('#' + f[i].name).textinput();
}else if (f[i].type == 'select-one') {
$('#' + f[i].name).selectmenu();
}
}
}
if (tabela == 'cor') {
$('.cores').each( function() {
$(this).minicolors({
control: $(this).attr('data-control') || 'hue',
defaultValue: $(this).attr('data-defaultValue') || '',
inline: $(this).attr('data-inline') === 'true',
letterCase: $(this).attr('data-letterCase') || 'lowercase',
opacity: $(this).attr('data-opacity'),
position: 'bottom right',
change: function(hex, opacity) {
if( !hex ) return;
if( opacity ) hex += ', ' + opacity;
try {
//console.log(hex);
} catch(e) {}
},
theme: 'bootstrap'
});
});
}
for(var i = 0; i < 40; i++) {
if (document.getElementById('b' + i) != null) {
$('#b' + i).button();
}
if (document.getElementById('fileToUpload' + i) != null) {
$('#fileToUpload' + i).textinput();
}
if (document.getElementById('bapaga' + i) != null) {
$('#bapaga' + i).button();
}
}
if (tabela != 'cliente') {
carrega_editor(t);
}
carrega_data(t);
carrega_editor(t);
$('#batualiza').button();
}else if (tipo == 2) {
for(var i = 0; i < 40; i++) {
if (document.getElementById('b' + i) != null) {
$('#b' + i).button();
}
if (document.getElementById('fileToUpload' + i) != null) {
$('#fileToUpload' + i).textinput();
}
if (document.getElementById('titulo') != null) {
$('#titulo').textinput();
}
if (document.getElementById('bapaga' + i) != null) {
$('#bapaga' + i).button();
}
$('#mlistagem').listview();
if (document.getElementById('mnav0') != null) {
$('#mnav0').navbar();
}
if (document.getElementById('mnav1') != null) {
$('#mnav1').navbar();
}
if (document.getElementById('mnav2') != null) {
$('#mnav2').navbar();
}
if (document.getElementById('mnav3') != null) {
$('#mnav3').navbar();
}
if (document.getElementById('mnav4') != null) {
$('#mnav4').navbar();
}
if (document.getElementById('mnav5') != null) {
$('#mnav5').navbar();
}
if (document.getElementById('mnav6') != null) {
$('#mnav6').navbar();
}
if (document.getElementById('mnav7') != null) {
$('#mnav7').navbar();
}
if (document.getElementById('mnav8') != null) {
$('#mnav8').navbar();
}
if (document.getElementById('mnav9') != null) {
$('#mnav9').navbar();
}
if (document.getElementById('mnav10') != null) {
$('#mnav10').navbar();
}
if (document.getElementById('mnavl') != null) {
$('#mnavl').navbar();
}
}
}else if (tipo == 3) {
$('#mlistagem').listview();
if (document.getElementById('mnav0') != null) {
$('#mnav0').navbar();
}
if (document.getElementById('mnav1') != null) {
$('#mnav1').navbar();
}
if (document.getElementById('mnav2') != null) {
$('#mnav2').navbar();
}
if (document.getElementById('mnav3') != null) {
$('#mnav3').navbar();
}
if (document.getElementById('mnav4') != null) {
$('#mnav4').navbar();
}
if (document.getElementById('mnav5') != null) {
$('#mnav5').navbar();
}
if (document.getElementById('mnav6') != null) {
$('#mnav6').navbar();
}
if (document.getElementById('mnav7') != null) {
$('#mnav7').navbar();
}
if (document.getElementById('mnav8') != null) {
$('#mnav8').navbar();
}
if (document.getElementById('mnav9') != null) {
$('#mnav9').navbar();
}
if (document.getElementById('mnav10') != null) {
$('#mnav10').navbar();
}
if (document.getElementById('mnavl') != null) {
$('#mnavl').navbar();
}
}
$('#menulist').listview();
if (tabela == 'catalogo') {
if (document.getElementById('va' + xida) != null) {
$('html,body').animate({scrollTop: $('#va' + xida).offset().top}, 1000);
}else {
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}
}else if (tabela == 'cliente') {
if (xida > 0) {
$('html,body').animate({scrollTop: $('#mf' + xida).offset().top}, 1000);
xida = 0;
}else {
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}
}else {
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}
processando(2, local);
}else {
alert("Ocorreu um Erro" + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
function pagina(pag, idr, qtd, pes, local) {
processando(1, local);
var dados = 'opx=14&pag=' + pag + '&idr=' + idr + '&qtd=' + qtd + '&pes=' + pes + '&local=' + local;
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#botao1').button();
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
processando(2, local);
}else {
alerta('ERRO', 'Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
function listau(pag, local) {
processando(1, local);
var dados = 'opx=10&pag=' + pag;
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#botao1').button();
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
processando(2, local);
}else {
alerta('ERRO', 'Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
function tabela_dados(pag, t, dados, local) {
var oppreferencia = '';
var oppiscina = '';
var oplazer = '';
var opestrutura = '';
if (dados.tabela.value == 'imovel') {
if (pag == 1) {
for (var x = 0; x < dados.op_preferencia.length; x++) {
if (dados.op_preferencia[x].checked) {
oppreferencia += '-' + dados.op_preferencia[x].value;
}
}
if (oppreferencia != '') {
oppreferencia+= '-';
}
for (var x = 0; x < dados.op_piscina.length; x++) {
if (dados.op_piscina[x].checked) {
oppiscina+= '-' + dados.op_piscina[x].value;
}
}
if (oppiscina != '') {
oppiscina+= '-';
}
for (var x = 0; x < dados.op_lazer.length; x++) {
if (dados.op_lazer[x].checked) {
oplazer+= '-' + dados.op_lazer[x].value;
}
}
if (oplazer != '') {
oplazer+= '-';
}
for (var x = 0; x < dados.op_estrutura.length; x++) {
if (dados.op_estrutura[x].checked) {
opestrutura+= '-' + dados.op_estrutura[x].value;
}
}
if (opestrutura != '') {
opestrutura+= '-';
}
}else if (pag == 2) {
for (var x = 0; x < dados.op_preferenciaX.length; x++) {
if (dados.op_preferenciaX[x].checked) {
oppreferencia+= '-' + dados.op_preferenciaX[x].value;
}
}
if (oppreferencia != '') {
oppreferencia+= '-';
}
for (var x = 0; x < dados.op_piscinaX.length; x++) {
if (dados.op_piscinaX[x].checked) {
oppiscina+= '-' + dados.op_piscinaX[x].value;
}
}
if (oppiscina != '') {
oppiscina+= '-';
}
for (var x = 0; x < dados.op_lazerX.length; x++) {
if (dados.op_lazerX[x].checked) {
oplazer+= '-' + dados.op_lazerX[x].value;
}
}
if (oplazer != '') {
oplazer+= '-';
}
for (var x = 0; x < dados.op_estruturaX.length; x++) {
if (dados.op_estruturaX[x].checked) {
opestrutura+= '-' + dados.op_estruturaX[x].value;
}
}
if (opestrutura != '') {
opestrutura+= '-';
}
}
}
processando(1, local);
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
if (dados.tabela.value == 'imovel') {
var dados1 = 'opx=4&pag=' + pag + '&oppreferencia=' + oppreferencia + '&oppiscina=' + oppiscina + '&oplazer=' + oplazer + '&opestrutura=' + opestrutura + '&' + getFormValues(dados, t);
}else {
var dados1 = 'opx=4&pag=' + pag + '&' + getFormValues(dados, t);
}
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
if (pag == 1) {
if (Trim(oXMLHttp.responseText) == '1') {
alerta('ATENÇÃO', 'Parece que já existe um registro com estas informações, favor verificar');
processando(2, local);
}else if (Trim(oXMLHttp.responseText) == '2') {
alerta('ATENÇÃO', 'Email ou Token inválido. Favor checar sua conta e token gerado pelo pagseguro. Vendas Online Bloqueada.');
processando(2, local);
}else if (Trim(oXMLHttp.responseText) == '3') {
alerta('ATENÇÃO', 'Você chegou ao limite de cadastro permitido para este item.');
processando(2, local);
}else if (Trim(oXMLHttp.responseText) == '4') {
alerta('ATENÇÃO', 'O acesso individual informado ja esta em uso, favor escolher outro nome');
processando(2, local);
}else {
alerta('OK', oXMLHttp.responseText);
document.getElementById(local).innerHTML = '

Carregando...
';
if ((dados.tabela.value == 'cliente') || (dados.tabela.value == 'imovel') || (dados.tabela.value == 'car_veiculos') || (dados.tabela.value == 'imo_imoveis') || (dados.tabela.value == 'pro_produtos') || (dados.tabela.value == 'gas_dados') || (dados.tabela.value == 'gas_produtos') || (dados.tabela.value == 'ser_servicos') || (dados.tabela.value == 'midia')) {
tabela(dados.t.value, dados.tabela.value, '', dados.tipox.value, dados.menu.value, dados.idtabela.value, 'conteudomenu2');
}else {
tabela(dados.t.value, dados.tabela.value, '', dados.tipox.value, dados.menu.value, dados.idtabela.value, 'conteudomenu');
}
processando(2, local);
}
}else if (pag == 2) {
if (Trim(oXMLHttp.responseText) == '1') {
alerta('ATENÇÃO', 'Parece que já existe um registro com estas informações, favor verificar');
processando(2, local);
}else if (Trim(oXMLHttp.responseText) == '2') {
alerta('ATENÇÃO', 'Email ou Token inválido. Favor checar sua conta e token gerado pelo pagseguro. Vendas Online Bloqueada.');
processando(2, local);
}else if (Trim(oXMLHttp.responseText) == '3') {
alerta('ATENÇÃO', 'Existem compras de cupons para este produto, voce nao pode atualizar as informacoes');
processando(2, local);
}else if (Trim(oXMLHttp.responseText) == '4') {
alerta('ATENÇÃO', 'O acesso individual informado ja esta em uso, favor escolher outro nome');
processando(2, local);
}else {
alerta('OK', oXMLHttp.responseText);
document.getElementById('atualiza_registro').innerHTML = '';
listagem(dados.tabela.value, dados.conta.value, 'listagem');
processando(2, local);
}
}else if (pag == 3) {
if (Trim(oXMLHttp.responseText) == '2') {
alerta('ATENÇÃO', 'Email ou Token inválido. Favor checar sua conta e token gerado pelo pagseguro. Vendas Online Bloqueada.');
}else {
alerta('OK', oXMLHttp.responseText);
if ((dados.tabela.value == 'cliente') || (dados.tabela.value == 'ofertas') || (dados.tabela.value == 'car_veiculos') || (dados.tabela.value == 'imo_imoveis') || (dados.tabela.value == 'pro_produtos') || (dados.tabela.value == 'gas_dados') || (dados.tabela.value == 'gas_produtos') || (dados.tabela.value == 'ser_servicos') || (dados.tabela.value == 'catalogo') || (dados.tabela.value == 'midia')) {
tabela(dados.t.value, dados.tabela.value, '', dados.tipox.value, dados.menu.value, dados.idtabela.value, 'conteudomenu2');
}else {
tabela(dados.t.value, dados.tabela.value, '', dados.tipox.value, dados.menu.value, dados.idtabela.value, 'conteudomenu');
}
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}
processando(2, local);
}
}else {
alerta('ERRO', 'Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados1);
return false;
}
function dateDiferencaEmDias(a, b) {
var utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
var utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
return Math.floor((utc2 - utc1) / ( 1000 * 60 * 60 * 24) );
}
function mensagens(pag, conta, pes, local) {
processando(1, local);
var dados = 'opx=18&pag=' + pag + '&conta=' + conta + '&pes=' + pes + '&local=' + local;
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
if ((pag == 1) || (pag == 3) || (pag == 5)) {
$('#botao1').button();
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
if (document.getElementById('mnav0') != null) {
$('#mnav0').navbar();
}
if (document.getElementById('mnav1') != null) {
$('#mnav1').navbar();
}
if (document.getElementById('mnav2') != null) {
$('#mnav2').navbar();
}
if (document.getElementById('mnav3') != null) {
$('#mnav3').navbar();
}
if (document.getElementById('mnav4') != null) {
$('#mnav4').navbar();
}
if (document.getElementById('mnav5') != null) {
$('#mnav5').navbar();
}
if (document.getElementById('mnav6') != null) {
$('#mnav6').navbar();
}
if (document.getElementById('mnav7') != null) {
$('#mnav7').navbar();
}
if (document.getElementById('mnav8') != null) {
$('#mnav8').navbar();
}
if (document.getElementById('mnav9') != null) {
$('#mnav9').navbar();
}
if (document.getElementById('mnav10') != null) {
$('#mnav10').navbar();
}
if (document.getElementById('mnavl') != null) {
$('#mnavl').navbar();
}
}
processando(2, local);
}else {
alerta('ERRO', 'Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
function listagem(t, conta, local) {
if (document.getElementById("atualiza_arquivo") != null){
document.getElementById("atualiza_arquivo").innerHTML = '';
}
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
processando(1, local);
if (document.getElementById("pesquisa") != null){
if (document.fpesquisa.pesquisa.value != '') {
var dados = "opx=8&tabela=" + t + "&conta=" + conta + "&pesquisa=" + document.fpesquisa.pesquisa.value + "&campo=" + document.fpesquisa.campo.value;
document.fpesquisa.pesquisa.value = '';
}else {
var dados = "opx=8&tabela=" + t + "&conta=" + conta + "&pesquisa=" + "&campo=";
}
}else {
var dados = "opx=8&tabela=" + t + "&conta=" + conta + "&pesquisa=" + "&campo=";
}
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
processando(2, local);
$('#mlistagem').listview();
if (document.getElementById('mnav0') != null) {
$('#mnav0').navbar();
}
if (document.getElementById('mnav1') != null) {
$('#mnav1').navbar();
}
if (document.getElementById('mnav2') != null) {
$('#mnav2').navbar();
}
if (document.getElementById('mnav3') != null) {
$('#mnav3').navbar();
}
if (document.getElementById('mnav4') != null) {
$('#mnav4').navbar();
}
if (document.getElementById('mnav5') != null) {
$('#mnav5').navbar();
}
if (document.getElementById('mnav6') != null) {
$('#mnav6').navbar();
}
if (document.getElementById('mnav7') != null) {
$('#mnav7').navbar();
}
if (document.getElementById('mnav8') != null) {
$('#mnav8').navbar();
}
if (document.getElementById('mnav9') != null) {
$('#mnav9').navbar();
}
if (document.getElementById('mnav10') != null) {
$('#mnav10').navbar();
}
if (document.getElementById('mnavl') != null) {
$('#mnavl').navbar();
}
$('html,body').animate({scrollTop: $('#' + local).offset().top}, 1000);
//$("a[rel^='prettyPhoto']").prettyPhoto();
}else {
alert('Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
function atualiza_registro(t, tabela, idc, titulo, conta, controle, local) {
var dados = 'opx=9&t=' + t + '&tabela=' + tabela + '&idc=' + idc + '&conta=' + conta + '&titulo=' + escape(titulo);
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
processando(1, local);
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#botao1').button();
$('#navbar1').navbar();
$("#fone" + t).mask("(99)9999-9999");
$("#celular" + t).mask("(99)99999-9999");
$("#validade" + t).mask("99/99/9999");
$("#cep" + t).mask("99999-999");
$("#data" + t).mask("99/99/9999");
$("#dataa" + t).mask("99/99/9999");
$("#datab" + t).mask("99/99/9999");
$("#datac" + t).mask("99/99/9999");
$("#cpf" + t).mask("999.999.999-99");
$("#cnpj" + t).mask("99.999.999/9999-99");
$("#pontos" + t).maskMoney({symbol:'R$ ', showSymbol:false, thousands:',', decimal:'.', symbolStay: false});
$("#valor" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#valora" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#valorb" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#valorc" + t).maskMoney({symbol:'R$ ', showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
$("#proporcionalidade" + t).mask("0.99");
$("#proporcionalidadeb" + t).mask("0.99");
$("#proporcionalidadec" + t).mask("0.99");
//$("a[rel^='prettyPhoto']").prettyPhoto();
var f = document.getElementById('fatualiza');
for(var i = 0; i < f.length; i++) {
if (f[i].type != 'hidden') {
if ((f[i].type == 'text') || (f[i].type == 'email')){
$('#' + f[i].name).textinput();
}else if (f[i].type == 'select-one') {
$('#' + f[i].name).selectmenu();
}else if (f[i].type == 'textarea') {
$('#' + f[i].name).textinput();
}else if (f[i].type == 'checkbox') {
//$('#' + f[i].id).checkboxradio();
}
}
}
carrega_editor(t);
carrega_data(t);
$('#batualiza').button();
$('#botaof').button();
$('html,body').animate({scrollTop: $('#' + local).offset().top}, 1000);
processando(2, local);
$('#alternativa' + t).keyup(function(){
var $this = $( this );
$this.val( er_replace( /[^a-z0-9]+/g,'', $this.val() ) );
});
}else {
alert('Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
};
function excluir(t, idp, local) {
if (confirm ("Deseja Realmente Remover este Registro?")) {
var dados = "opx=7&tabela=" + t + "&idp=" + idp;
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
processando(1, local);
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
if (Trim(oXMLHttp.responseText) == 'ERRO') {
alerta('ATENÇÃO', 'Este Registro não pode ser Excluído devido as ligações com outras tabelas do sistema \nFavor Verificar.');
$('html,body').animate({scrollTop: $('#' + local).offset().top}, 1000);
processando(2, local);
}else {
alerta('OK', 'Registro Excluido com Sucesso...');
if (t == 'selfie') {
tabela('', 'selfie', '', '2', '', '24', 'conteudomenu');
return false;
}
if (document.getElementById('atualiza_registro') != null) {
document.getElementById('atualiza_registro').innerHTML = '';
}
if (document.getElementById('atualiza_arquivo') != null) {
document.getElementById('atualiza_arquivo').innerHTML = '';
}
listagem(t, 0, local);
$('html,body').animate({scrollTop: $('#' + local).offset().top}, 1000);
processando(2, local);
return true;
}
}else {
alert('Ocorreu um Erro' + oXMLHttp.statusText);
}
}
};
oXMLHttp.send(dados);
return dados;
}
}
function troca_cidade(valor, nome, local) {
var v = valor.value;
if((parseFloat(v) == parseInt(v)) && !isNaN(v)) {
//
}else {
v = valor;
if (v == '') {
if (nome == '') {
v = document.getElementById('id_estado').value;
}else {
v = document.getElementById('id_estadoX').value;
}
}
}
if ((document.getElementById(local) != null)) {
var dados = "opx=13&valor=" + v + "&nome=" + nome;
document.getElementById(local).innerHTML = '
Carregando...';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#id_cidade' + nome).selectmenu();
}else {
alerta('ERRO', 'Ocorreu um Erro ' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
};
function troca_bairro(valor, nome, local) {
var v = valor.value;
if((parseFloat(v) == parseInt(v)) && !isNaN(v)) {
//
}else {
v = valor;
if (v == '') {
if (nome == '') {
v = document.getElementById('id_bairro').value;
}else {
v = document.getElementById('id_bairroX').value;
}
}
}
if ((document.getElementById(local) != null)) {
var dados = 'opx=15&valor=' + v + '&nome=' + nome;
document.getElementById(local).innerHTML = '
Carregando...';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#id_endereco' + nome).selectmenu();
}else {
alert("Ocorreu um Erro " + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
};
function troca_categoria(letra, valor, nome, local) {
var v = valor.value;
if((parseFloat(v) == parseInt(v)) && !isNaN(v)) {
//
}else {
v = valor;
if (v == '') {
if (nome == '') {
v = document.getElementById('id_categoria' + letra).value;
}else {
v = document.getElementById('id_categoria' + letra + 'X').value;
}
}
}
if ((document.getElementById(local) != null)) {
var dados = 'opx=16&valor=' + v + '&letra=' + letra + '&nome=' + nome;
document.getElementById(local).innerHTML = '
Carregando...';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#id_categoriasub' + letra + nome).selectmenu();
}else {
alert("Ocorreu um Erro " + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
};
function processando(pag, local) {
if (pag == 1) {
$.mobile.loading( 'show', {
text: 'PROCESSANDO, AGUARDE...',
textVisible: true,
theme: 'b',
html: ''
});
}else if (pag == 2) {
$.mobile.loading('hide');
}
}
function getFormValues(fobj, t){
var str='';
var str1 = '';
for (var i=0;i< fobj.elements.length;i++){
//alert(fobj.elements[i].type + '-' + fobj.elements[i].name);
if ((fobj.elements[i].type == 'hidden')) {
//alert(fobj.elements[i].name);
if ((fobj.elements[i].name == 'texto' + t) || (fobj.elements[i].name == 'textoa' + t) || (fobj.elements[i].name == 'textob' + t) || (fobj.elements[i].name == 'textoc' + t)) {
var editor = $('#' + fobj.elements[i].name).html();
str1 = escape(editor.getData());
}else {
str1 = escape(fobj.elements[i].value);
}
str+=fobj.elements[i].name+'='+ str1 +'&';
}else if (fobj.elements[i].type != 'submit') {
if (fobj.elements[i].name != '') {
if (fobj.elements[i].type == 'checkbox') {
/*if (fobj.elements[i].checked == true) {
str+=fobj.elements[i].name+'='+fobj.elements[i].value+'&';
}else {
str+=fobj.elements[i].name+'=&';
}
*/
}else {
if ((fobj.elements[i].name == 'texto' + t) || (fobj.elements[i].name == 'textoa' + t) || (fobj.elements[i].name == 'textob' + t) || (fobj.elements[i].name == 'textoc' + t)) {
//var editor = $('#' + fobj.elements[i].name).html();
//str1 = escape(editor.getData());
}else {
str1 = escape(fobj.elements[i].value);
}
str+=fobj.elements[i].name+'='+ str1 +'&';
}
}
}
}
str = str.substr(0,(str.length-1));
if (document.getElementById('texto' + t) != null) {
var editor = $('#texto' + t).editable("getHTML");
str1 = escape(editor);
str1 = str1.replace(/\%u201C/g, '"');
str1 = str1.replace(/\%u201D/g, '"');
str+='&texto' + t + '=' + str1 + '&';
}
if (document.getElementById('textoa' + t) != null) {
var editor = $('#textoa' + t).editable("getHTML");
str1 = escape(editor);
str1 = str1.replace(/\%u201C/g, '"');
str1 = str1.replace(/\%u201D/g, '"');
str+='&textoa' + t + '=' + str1 + '&';
}
if (document.getElementById('textob' + t) != null) {
var editor = $('#textob' + t).editable("getHTML");
str1 = escape(editor);
str1 = str1.replace(/\%u201C/g, '"');
str1 = str1.replace(/\%u201D/g, '"');
str+='&textob' + t + '=' + str1 + '&';
}
if (document.getElementById('textoc' + t) != null) {
var editor = $('#textoc' + t).editable("getHTML");
str1 = escape(editor);
str1 = str1.replace(/\%u201C/g, '"');
str1 = str1.replace(/\%u201D/g, '"');
str+='&textoc' + t + '=' + str1 + '&';
}
if (document.getElementById('textod' + t) != null) {
var editor = $('#textod' + t).editable("getHTML");
str1 = escape(editor);
str1 = str1.replace(/\%u201C/g, '"');
str1 = str1.replace(/\%u201D/g, '"');
str+='&textod' + t + '=' + str1 + '&';
}
return str;
}
function fileSelected(ida) {
var file = document.getElementById('fileToUpload' + ida).files[0];
var ext = file.name;
ext = ext.substr(ext.length - 3,3);
var fileSize = 0;
var tamanho = 0;
if (file.size > 1024 * 1024) {
fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
tamanho = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString();
}else {
fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
tamanho = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString();
}
document.getElementById('fileInfo' + ida).style.display = 'block';
document.getElementById('fileName' + ida).innerHTML = 'Nome: ' + file.name;
document.getElementById('fileSize' + ida).innerHTML = 'Tamanho: ' + fileSize;
document.getElementById('fileType' + ida).innerHTML = 'Tipo: ' + file.type;
if ((ext == 'jpg') || (ext == 'JPG')) {
if (tamanho > 1.9) {
alerta('ATENÇÃO', 'Atenção você está enviando uma imagem superior a 2Mb. Necessário reduzir o tamanho da imagem.');
return false;
}
}
if (tamanho > 51) {
alerta('ATENÇÃO', 'Atenção você está enviando um arquivo superior a 50Mb');
}
}
function carrega_editor(t) {
if (document.getElementById('texto' + t) != null) {
$('#texto' + t).editable({
inlineMode: false,
imageUploadURL: 'upload.php',
imageUploadParams: {id: 'texto' + t},
height: 220,
language: 'pt_br'
});
}
if (document.getElementById('textoa' + t) != null) {
$('#textoa' + t).editable({
inlineMode: false,
imageUploadURL: 'upload.php',
imageUploadParams: {id: 'textoa' + t},
height: 220,
language: 'pt_br'
});
}
if (document.getElementById('textob' + t) != null) {
$('#textob' + t).editable({
inlineMode: false,
imageUploadURL: 'upload.php',
imageUploadParams: {id: 'textob' + t},
height: 220,
language: 'pt_br'
});
}
if (document.getElementById('textoc' + t) != null) {
$('#textoc' + t).editable({
inlineMode: false,
imageUploadURL: 'upload.php',
imageUploadParams: {id: 'textoc' + t},
height: 220,
language: 'pt_br'
});
}
if (document.getElementById('textod' + t) != null) {
$('#textod' + t).editable({
inlineMode: false,
imageUploadURL: 'upload.php',
imageUploadParams: {id: 'textod' + t},
height: 250,
language: 'pt_br'
});
}
}
function carrega_data(t) {
if (document.getElementById('ddata' + t) != null){
$('#ddata' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['data' + t].value = $('#ddata' + t).val();
}else {
document.fatualiza['data' + t].value = $('#ddata' + t).val();
}
}
});
$('#ddata' + t).datepicker();
$('#ddata' + t).bind('click', function() {
if (t == '') {
document.fcadastra['data' + t].value = $('#ddata' + t).val();
}else {
document.fatualiza['data' + t].value = $('#ddata' + t).val();
}
});
}
if (document.getElementById('ddataa' + t) != null){
$('#ddataa' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['dataa' + t].value = $('#ddataa' + t).val();
}else {
document.fatualiza['dataa' + t].value = $('#ddataa' + t).val();
}
}
});
$('#ddataa' + t).datepicker();
$('#ddataa' + t).bind('click', function() {
if (t == '') {
document.fcadastra['dataa' + t].value = $('#ddataa' + t).val();
}else {
document.fatualiza['dataa' + t].value = $('#ddataa' + t).val();
}
});
}
if (document.getElementById('ddatab' + t) != null){
$('#ddatab' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['datab' + t].value = $('#ddatab' + t).val();
}else {
document.fatualiza['datab' + t].value = $('#ddatab' + t).val();
}
}
});
$('#ddatab' + t).datepicker();
$('#ddatab' + t).bind('click', function() {
if (t == '') {
document.fcadastra['datab' + t].value = $('#ddatab' + t).val();
}else {
document.fatualiza['datab' + t].value = $('#ddatab' + t).val();
}
});
}
if (document.getElementById('ddatac' + t) != null){
$('#ddatac' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['datac' + t].value = $('#ddatac' + t).val();
}else {
document.fatualiza['datac' + t].value = $('#ddatac' + t).val();
}
}
});
$('#ddatac' + t).datepicker();
$('#ddatac' + t).bind('click', function() {
if (t == '') {
document.fcadastra['datac' + t].value = $('#ddatac' + t).val();
}else {
document.fatualiza['datac' + t].value = $('#ddatac' + t).val();
}
});
}
if (document.getElementById('dvalidade' + t) != null){
$('#dvalidade' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['validade' + t].value = $('#dvalidade' + t).val();
}else {
document.fatualiza['validade' + t].value = $('#dvalidade' + t).val();
}
}
});
$('#dvalidade' + t).datepicker();
$('#dvalidade' + t).bind('click', function() {
if (t == '') {
document.fcadastra['validade' + t].value = $('#dvalidade' + t).val();
}else {
document.fatualiza['validade' + t].value = $('#dvalidade' + t).val();
}
});
}
if (document.getElementById('dde' + t) != null){
$('#dde' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['de' + t].value = $('#dde' + t).val();
}else {
document.fatualiza['de' + t].value = $('#dde' + t).val();
}
}
});
$('#dde' + t).datepicker();
$('#dde' + t).bind('click', function() {
if (t == '') {
document.fcadastra['de' + t].value = $('#dde' + t).val();
}else {
document.fatualiza['de' + t].value = $('#dde' + t).val();
}
});
}
if (document.getElementById('date' + t) != null){
$('#date' + t).datepicker({
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'],
dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
nextText: 'Próximo',
prevText: 'Anterior',
onSelect: function(dateText, inst) {
if (t == '') {
document.fcadastra['ate' + t].value = $('#date' + t).val();
}else {
document.fatualiza['ate' + t].value = $('#date' + t).val();
}
}
});
$('#date' + t).datepicker();
$('#date' + t).bind('click', function() {
if (t == '') {
document.fcadastra['ate' + t].value = $('#date' + t).val();
}else {
document.fatualiza['ate' + t].value = $('#date' + t).val();
}
});
}
}
function troca_campo(pag, valor, nome, t, local) {
var v = valor.value;
if((parseFloat(v) == parseInt(v)) && !isNaN(v)) {
//
}else {
v = valor;
if (v == '') {
if (pag == 3) {
v = document.getElementById('id_bairro' + t).value;
}else if (pag == 4) {
v = document.getElementById('id_pro_departamento' + t).value;
}else if (pag == 5) {
v = document.getElementById('id_ser_departamento' + t).value;
}else {
v = document.getElementById(nome).value;
}
}
}
if ((document.getElementById(local) != null)) {
var dados = 'opx=19&pag=' + pag + '&t=' + t + '&valor=' + v + '&nome=' + nome + '&idbr=' + document.getElementById('idbr').value;
document.getElementById(local).innerHTML = '
Carregando...';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#id_enderecoX').selectmenu();
$('#id_endereco').selectmenu();
$('#id_pro_subX').selectmenu();
$('#id_pro_sub').selectmenu();
$('#id_ser_subX').selectmenu();
$('#id_ser_sub').selectmenu();
if (pag == 2) {
v = document.getElementById('id_bairro' + t).value;
troca_campo(3, v, 'id_endereco' + t, t, 'lista_endereco' + t);
}
}else {
alert("Ocorreu um Erro " + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
};
function grava_cor(local) {
if (document.getElementById('cora').value.length < 7) {
alert('Informe a cor corretamente.');
return false;
}else if (document.getElementById('corb').value.length < 7) {
alert('Informe a cor corretamente.');
return false;
}else if (document.getElementById('corc').value.length < 7) {
alert('Informe a cor corretamente.');
return false;
}else if (document.getElementById('cord').value.length < 7) {
alert('Informe a cor corretamente.');
return false;
}else if (document.getElementById('core').value.length < 7) {
alert('Informe a cor corretamente.');
return false;
}
if (confirm('Confirma a mudança de cores da sua Página')) {
var dados = 'opx=3&cora=' + document.getElementById('cora').value + '&corb=' + document.getElementById('corb').value + '&corc=' + document.getElementById('corc').value + '&cord=' + document.getElementById('cord').value + '&core=' + document.getElementById('core').value;
document.getElementById(local).innerHTML = '
Processando, aguarde...';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
alert('Cores Atualizada com Sucesso...');
document.getElementById(local).innerHTML = '';
}else {
alert("Ocorreu um Erro " + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
}
function uploadFile(idt, idr, ida, opx, ex, t, i, x1, tip, idt2) {
var ext = ex.split('-');
var total = ext.length;
var passa = 0;
var s = '';
if (idt2 == 24) {
if (document.getElementById('titulo') != null) {
if (document.getElementById('titulo').value == '') {
alerta('', 'Informe o Título para este Selfie.');
document.getElementById('titulo').focus();
return false;
}else {
s = escape(document.getElementById('titulo').value);
}
}
}
if (document.getElementById('fileToUpload' + ida).files[0] == null) {
alerta('', 'Favor selecionar o arquivo desejado.');
return false;
}
var ext1 = document.getElementById('fileToUpload' + ida).files[0].name;
var ext2 = ext1.substr(ext1.length - 3,3);
if (ext2 == 'ocx') {
ext1 = 'docx';
}else {
ext1 = ext2;
}
for (var x = 0; x < total; x++) {
if (ext[x] == ext1) {
passa = 1;
}
}
if ((ext1 == 'jpg') || (ext1 == 'JPG')) {
var file = document.getElementById('fileToUpload' + ida).files[0];
if (file.size > 1024 * 1024) {
tamanho = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString();
}else {
tamanho = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString();
}
if (tamanho > 1.9) {
alerta('ATENÇÃO', 'Atenção você está enviando uma imagem superior a 2Mb. Necessário reduzir o tamanho da imagem.');
return false;
}
}
if (passa == 0) {
alerta('ATENÇÃO', 'O Arquivo deve estar no(s) formato(s): ' + ex);
return false;
}
xidt = idr;
xtipo = tip;
xtabela = t;
xidr = i;
xida = ida;
xidt2 = idt2;
previousBytesLoaded = 0;
document.getElementById('uploadResponse' + xida).style.display = 'none';
document.getElementById('progressNumber' + xida).innerHTML = '';
processando(1,'');
var progressBar = document.getElementById('progressBar' + xida);
progressBar.style.display = 'block';
progressBar.style.width = '0px';
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("post", "arquivo.php?upload=true&opx=" + opx + "&idt=" + idt + "&idr=" + idr + "&ida=" + x1 + "&ext=" + ex + "&s=" + s , true);
xhr.setRequestHeader("If-Modified-Since", "Mon, 26 Jul 1997 05:00:00 GMT");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", document.getElementById('fileToUpload' + xida).files[0].name);
xhr.setRequestHeader("X-File-Size", document.getElementById('fileToUpload' + xida).files[0].size);
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.send(document.getElementById('fileToUpload' + xida).files[0]);
intervalTimer = setInterval(updateTransferSpeed, 500);
//alert(document.getElementById('fileToUpload' + xida).files[0].size);
}
function updateTransferSpeed() {
var currentBytes = bytesUploaded;
var bytesDiff = currentBytes - previousBytesLoaded;
if (bytesDiff == 0) return;
previousBytesLoaded = currentBytes;
bytesDiff = bytesDiff * 2;
var bytesRemaining = bytesTotal - previousBytesLoaded;
var secondsRemaining = bytesRemaining / bytesDiff;
var speed = "";
if (bytesDiff > 1024 * 1024)
speed = (Math.round(bytesDiff * 100/(1024*1024))/100).toString() + 'MBps';
else if (bytesDiff > 1024)
speed = (Math.round(bytesDiff * 100/1024)/100).toString() + 'KBps';
else
speed = bytesDiff.toString() + 'Bps';
document.getElementById('transferSpeedInfo' + xida).innerHTML = speed;
document.getElementById('timeRemainingInfo' + xida).innerHTML = '| ' + secondsToString(secondsRemaining);
}
function secondsToString(seconds) {
var h = Math.floor(seconds / 3600);
var m = Math.floor(seconds % 3600 / 60);
var s = Math.floor(seconds % 3600 % 60);
return ((h > 0 ? h + ":" : "") + (m > 0 ? (h > 0 && m < 10 ? "0" : "") + m + ":" : "0:") + (s < 10 ? "0" : "") + s);
}
function uploadProgress(evt) {
if (evt.lengthComputable) {
bytesUploaded = evt.loaded;
bytesTotal = evt.total;
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
var bytesTransfered = '';
if (bytesUploaded > 1024*1024)
bytesTransfered = (Math.round(bytesUploaded * 100/(1024*1024))/100).toString() + 'MB';
else if (bytesUploaded > 1024)
bytesTransfered = (Math.round(bytesUploaded * 100/1024)/100).toString() + 'KB';
else
bytesTransfered = (Math.round(bytesUploaded * 100)/100).toString() + 'Bytes';
document.getElementById('progressNumber' + xida).innerHTML = percentComplete.toString() + '%';
document.getElementById('progressBar' + xida).style.width = (percentComplete).toString() + '%';
document.getElementById('transferBytesInfo' + xida).innerHTML = bytesTransfered;
if (percentComplete == 100) {
if (document.getElementById('progressInfo' + xida) != null) {
document.getElementById('progressInfo' + xida).style.display = 'none';
}
var uploadResponse = document.getElementById('uploadResponse' + xida);
uploadResponse.innerHTML = 'Aguarde...';
uploadResponse.style.display = 'block';
}
}
else {
document.getElementById('progressBar' + xida).innerHTML = 'unable to compute';
}
}
function uploadComplete(evt) {
processando(2,'');
clearInterval(intervalTimer);
var uploadResponse = document.getElementById('uploadResponse' + xida);
uploadResponse.innerHTML = evt.target.responseText;
alert(evt.target.responseText);
uploadResponse.style.display = 'block';
if (xtipo == 2) {
tabela('', xtabela, '', xtipo, 'IMAGENS E ARQUIVOS', xidt2, 'conteudomenu');
}else if (xtipo == 1) {
if (xtabela == 'cliente') {
tabela('X', xtabela, '', xtipo, 'ATUALIZAR CADASTRO', xidt2, 'conteudomenu2');
}else if (xtabela == 'catalogo') {
tabela('X', xtabela, '', xtipo, 'CATALOGO VIRTUAL', xidt2, 'conteudomenu2');
}else {
tabela('X', xtabela, '', xtipo, 'IMAGENS E ARQUIVOS', xidt2, 'conteudomenu');
}
}else {
if (document.getElementById(slocal) != null) {
//document.getElementById(slocal).innerHTML = '';
}
arquivo(xtabela, xidt, xconta, xtipo, 'atualiza_arquivo');
// listagem(xtabela, xconta, 'listagem');
}
}
function arquivo(tabela, conta, conta2, tipo, local) {
slocal = local;
xconta = conta2;
xtipo = tipo;
//$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
processando(1, local);
var dados = 'opx=11&tabela=' + tabela + '&conta=' + conta + '&tipo=' + tipo;
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
processando(2, local);
for(var i = 0; i < 30; i++) {
if (document.getElementById('b' + i) != null) {
$('#b' + i).button();
}
if (document.getElementById('fileToUpload' + i) != null) {
$('#fileToUpload' + i).textinput();
}
if (document.getElementById('bapaga' + i) != null) {
$('#bapaga' + i).button();
}
}
//$("a[rel^='prettyPhoto']").prettyPhoto();
$('#botaof').button();
if ((document.getElementById('x' + (xida + 1)) != null) && (xida > 0)) {
$('html,body').animate({scrollTop: $('#x' + (xida + 1)).offset().top - 100}, 1000);
}else {
$('html,body').animate({scrollTop: $('#ar').offset().top}, 1000);
}
}else {
alert('Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
};
function excluir_foto(idr, ida, ext, pasta, x) {
if (confirm ("Deseja Realmente Remover este Arquivo?")) {
var dados = "opx=12&idr=" + idr + "&ida=" + x + "&ext=" + ext + "&pasta=" + pasta;
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
//alert('Arquivo Removido com Sucesso');
document.getElementById('mf' + ida).innerHTML = '
';
document.getElementById('va' + ida).innerHTML = '';
if (x == 1) {
if (document.getElementById('img' + idr) != null) {
document.getElementById('img' + idr).innerHTML = '';
}
}
return true;
}else {
alert("Ocorreu um Erro" + oXMLHttp.statusText);
}
}
};
oXMLHttp.send(dados);
return dados;
} else {
return false;
}
}
function comprar(pag, idc, nump, local) {
if (pag == 1) {
var dados1 = 'opx=6&pag=' + pag + '&idc=' + idc + '&nump=' + nump;
document.getElementById(local).innerHTML = 'Gerando Pagamento, aguarde...

';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", 'my_controle.php', true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
if (Trim(oXMLHttp.responseText) == 'ERRO') {
alert(acentuacao('Ocorreu um erro durante o processo de compra, tente novamente.'));
}else {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
}
}else {
alert('Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados1);
return false;
}
}
function rede(pag, idc, local) {
if (pag == 1) {
var dados1 = 'opx=17&pag=' + pag + '&idc=' + idc + '&local=' + local;
document.getElementById(local).innerHTML = 'Carregando, aguarde...

';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", 'my_controle.php', true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#botao1').button();
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}else {
alert('Ocorreu um Erro' + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados1);
return false;
}
}
function uploadFailed(evt) {
clearInterval(intervalTimer);
alert("An error occurred while uploading the file.");
}
function uploadCanceled(evt) {
clearInterval(intervalTimer);
alert("The upload has been canceled by the user or the browser dropped the connection.");
}
function alerta(titulo, msg) {
//$.mobile.changePage('dialogo.php?titulo=' + titulo + '&msg=' + msg, { role: 'dialog', transition: 'fade'});
alert(msg);
}
function video(pag, local) {
var dados = 'opx=20&pag=' + pag;
document.getElementById(local).innerHTML = '
Carregando...
';
var oXMLHttp = objXMLHttp();
oXMLHttp.open("POST", urlpag, true);
oXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oXMLHttp.onreadystatechange = function() {
if (oXMLHttp.readyState == 4) {
if (oXMLHttp.status == 200) {
document.getElementById(local).innerHTML = oXMLHttp.responseText;
$('#bvideo').button();
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}else {
alert("Ocorreu um Erro " + oXMLHttp.statusText);
}
}
}
oXMLHttp.send(dados);
return false;
}
function fechar(pag, local) {
if (pag == 1) {
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
document.getElementById(local).innerHTML = '';
}
}
function SomenteNumero(e){
var tecla=(window.event)?event.keyCode:e.which;
if((tecla > 47 && tecla < 58) || (tecla == 0)) return true;
else{
if (tecla != 8) return false;
else return true;
}
}
function SomenteLetras(e){
var tecla=(window.event)?event.keyCode:e.which;
if((tecla > 65 && tecla < 90)||(tecla > 97 && tecla < 122)) return true;
else{
if (tecla != 8) return false;
else return true;
}
}
function SomenteLetrasNumeros(e){
var tecla=(window.event)?event.keyCode:e.which;
if((tecla >= 97 && tecla <= 122) || (tecla > 47 && tecla < 58)) return true;
else{
if (tecla != 8) return false;
else return true;
}
}
function ampliaf(ida, arq) {
document.getElementById('ampf' + ida).innerHTML = '
';
}
function teste(text1, text2, botao, callback) {
document.getElementById('mdialogo').innerHTML = '1';
$.mobile.changePage('#myDialog', {transition: 'pop', role: 'dialog'});
}
function abre(op, local) {
if (op == 1) {
document.getElementById(local).innerHTML = '
';
$('html,body').animate({scrollTop: $('#' + local).offset().top}, 1000);
}else if (op == 2) {
document.getElementById(local).innerHTML = 'CLIQUE AQUI PARA VISUALIZAR O MAPA DE CORES DO SITE';
$('html,body').animate({scrollTop: $('#top').offset().top}, 1000);
}
}
function alertam(op) {
if (op == 1) {
alert('Para utilizar este recurso você deve adquirir nosso plano Anual');
}
}