function ajaxInit() {
var req;
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(ex) {
try {
req = new XMLHttpRequest();
} catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax");
req = null;
}
}
}
return req;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function Mascara(tipo, campo, teclaPress) {
	if (window.event)
	{
		var tecla = teclaPress.keyCode;
	} else {
		tecla = teclaPress.which;
	}

	var s = new String(campo.value);
	// Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
	s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');

	tam = s.length + 1;

	if ( tecla != 9 && tecla != 8 ) {
		switch (tipo)
		{
		case 'CPF' :
			if (tam > 3 && tam < 7)
				campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
			if (tam >= 7 && tam < 10)
				campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
			if (tam >= 10 && tam < 12)
				campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
		break;

		case 'CNPJ' :

			if (tam > 2 && tam < 6)
				campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
			if (tam >= 6 && tam < 9)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
			if (tam >= 9 && tam < 13)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
			if (tam >= 13 && tam < 15)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
		break;

		case 'TEL' :
			if (tam > 2 && tam < 4)
				campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
			if (tam >= 7 && tam < 11)
				campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
		break;

		case 'DATA' :
			if (tam > 2 && tam < 4)
				campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
			if (tam > 4 && tam < 11)
				campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
		break;
		
		case 'CEP' :
			if (tam > 5 && tam < 9)
				campo.value = s.substr(0,5) + '-' + s.substr(5, tam);
   if (tam > 5 && tam < 5)
				campo.value = s.substr(0,5) + '-' + s.substr(5,5) + '-' + s.substr(3,tam-3);
		break;
		}
	}
}

function SelecionarProvaTexto(){
prova_texto = document.frm_file.prova_texto.options[document.frm_file.prova_texto.options.selectedIndex].value;
document.frm_file.action = 'index.php?AccXID=PROVA-TEXTO&UXD='+prova_texto;
document.frm_file.submit();
}

function AprovarProvaCliente(uxd){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/ExecutarProva.php?FNC=APROVAR&UDX='+uxd;
document.frm_file.submit();
}

function AlterarProvaCliente(uxd){
document.getElementById('campo_altera').innerHTML = ''
+'<table border="0" width="100%" cellspacing="4" cellpadding="0">'
+'<tr>'
+'<td colspan="2"><b><font face="Arial" size="2" color="#3366CC">:: Fazer Alteração ::</font></b></td>'
+'</tr>'
+'<tr>'
+'<td width="40%" valign="top">'
+'<p align="right"><b><font face="Arial" size="2" color="#800000">Digite aqui suas alterações:</font></b></td>'
+'<td width="60%"><textarea rows="6" name="alteracao" id="alteracao" cols="40"></textarea></td>'
+'</tr>'
+'<tr>'
+'<td width="40%">&nbsp;</td>'
+'<td width="60%"><input type="button" value="Enviar Alteração" onclick="SendAlteracaoProva();"></td>'
+'</tr>'
+'</table>';
}

function RecusarProvaCliente(uxd){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/ExecutarProva.php?FNC=RECUSAR&UDX='+uxd;
document.frm_file.submit();
}

function SendAlteracaoProva(){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/ExecutarProva.php?FNC=ALTERAR';
document.frm_file.submit();
}

function ImprimirProvaTexto(uxd){
var URL = 'http://www.shopnoivas.com.br/admin/modulos/module_loja_virtual_01/pag/VISUALIZAR-PROVA-TEXTO.php?UXD='+uxd;
var width = 800;
var height = 600;
var left = 0;
var top = 0;
window.open(URL,'Print', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=yes, location=no, directories=no, menubar=yes, resizable=yes, fullscreen=no');
}

//###@@@@@@@@@@ WEB CHAT 9.0 @@@@@@@@@@###//
function OpenWebChat(IP){
var URL = 'admin/modulos/module_webchat/pag/chat.php?IP='+IP;
var width = 500;
var height = 400;
var left = 0;
var top = 0;
window.open(URL,'Print', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
//###@@@@@@@@@@ WEB CHAT 9.0 @@@@@@@@@@###//
function SendAmostraAleatoria(){
nome=document.getElementById('nome').value;
endereco=document.getElementById('endereco').value;
numero=document.getElementById('numero').value;
//complemento=document.getElementById('complemento').value;
cep=document.getElementById('cep').value;
cidade=document.getElementById('cidade').value;
estado=document.getElementById('estado').value;
email=document.getElementById('email').value;
//data=document.getElementById('data').value;
var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(nome!=''){
if(endereco!=''){
if(numero!=''){
//if(complemento!=''){
if(cep!=''){
if(cidade!=''){
if(estado!=''){
if(email!=''){
//if(data!=''){
if(filter.test(email)){
document.frm_file.action = 'admin/executar.php?fnc=SendAmostraAleatoria';
document.frm_file.submit();
}else{alert('Porfavor Digite seu E-mail Corretamente!');}
//}else{alert('Porfavor Digite a Data do Evento!');}
}else{alert('Porfavor Digite seu E-mail!');}
}else{alert('Porfavor Digite seu Estado/UF!');}
}else{alert('Porfavor Digite sua Cidade!');}
}else{alert('Porfavor Digite seu CEP!');}
//}else{alert('Porfavor Digite o Complemento!');}
}else{alert('Porfavor Digite o Número de sua Residência!');}
}else{alert('Porfavor Digite seu Endereço/Rua!');}
}else{alert('Porfavor Digite seu Nome Completo!');}
}

function imprime_frete(){
document.frm_file.action = 'index.php?uid=VirtualCart#correio';
document.frm_file.submit();
}

function AtualizeCadastro(){
document.frm_file.action = 'index.php?AccXID=ATUALIZA-DADOS&Int=Atualize';
document.frm_file.submit();
}

function AtualizeCadastroPassword(){
password_atual=document.getElementById('password_atual').value;
password_new=document.getElementById('password_new').value;
password_new2=document.getElementById('password_new2').value;
if(password_atual!=''){
if(password_new!=''){
if(password_new2!=''){
document.frm_file.action = 'index.php?AccXID=ATUALIZA-DADOS&PasswordAt=Atualize';
document.frm_file.submit();
}else{alert('Todos os Campos são Necessários!');}
}else{alert('Todos os Campos são Necessários!');}
}else{alert('Todos os Campos são Necessários!');}
}

//FALE CONOSCO FORMULARIO//
function SendMessageContato(){
nome_user=document.getElementById('nome').value;
email_user=document.getElementById('email').value;
mensagem_user=document.getElementById('mensagem').value;
var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(nome_user!=''){
if(email_user!=''){
if(mensagem_user!=''){
if(filter.test(email_user)){
document.frm_file.action = 'admin/executar.php?fnc=SendMessageContato';
document.frm_file.submit();
}else{alert('O E-mail que você digitou está incorreto!');}
}else{alert('Digite sua Mensagem!');}
}else{alert('Digite seu E-mail!');}
}else{alert('Digite seu Nome Completo!');}
}
//FALE CONOSCO FORMULARIO//

//RECUPERAR SENHA//
function RecPasswordAccount(){
cpf=document.getElementById('cpf').value;
if(cpf!=''){
document.frm_file.action = 'admin/executar.php?fnc=RecPasswordAccount';
document.frm_file.submit();
}else{alert('Digite Corretamente seu CPF!');}
}
//RECUPERAR SENHA//
//*****************************************Realiza Pagamento pelo Pag Digital*************************************//
function FazerPgtoPagDigital(){
document.frm_file.action = 'https://www.pagamentodigital.com.br/checkout/pay/';
document.frm_file.submit();
}
//*****************************************Realiza Pagamento pelo Pag Digital*************************************//

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getEndereco() {
if($.trim($("#cep").val()) != ""){
$.getScript("http://cep.republicavirtual.com.br/web_cep.php?formato=javascript&cep="+$("#cep").val(), function(){
if(resultadoCEP["resultado"]){
$("#rua").val(unescape(resultadoCEP["tipo_logradouro"])+": "+unescape(resultadoCEP["logradouro"]));
$("#bairro").val(unescape(resultadoCEP["bairro"]));
$("#cidade").val(unescape(resultadoCEP["cidade"]));
$("#estado").val(unescape(resultadoCEP["uf"]));
}else{
alert("Endereço não encontrado");
}
});
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function VisualizeAcessorioModalLoja(id){
previewace=dhtmlmodal.open('previewace', 'ajax', 'admin/modulos/module_loja_virtual_01/pag/preview_ace.php?cod='+id, 'Ampliar:', 'width=500px,height=450px,center=1,resize=0,scrolling=1');
}
function VisualizeProdutoModalLoja(id){
previewpdt=dhtmlmodal.open('previewpdt', 'ajax', 'admin/modulos/module_loja_virtual_01/pag/preview_pdt.php?cod='+id, 'Ampliar:', 'width=500px,height=450px,center=1,resize=0,scrolling=1');
}
function Close_Previewace(){
document.getElementById('previewace').hide();
}
function Close_Previewpdt(){
document.getElementById('previewpdt').hide();
}
function ComprarCartCarrinho(PAGAMENTO){
frete = document.getElementById('frete').value;
if(frete!='ZERO'){
document.frm_file.action = 'index.php?uid=Final_de_Compra&pgto='+PAGAMENTO;
document.frm_file.submit();
}else{
alert('Ajuda:\n\nPrimeiro você deve informar o CEP do local de entrega e logo clique em Consultar Frete, depois escolha o tipo de Frete desejado para prosseguir com sua Compra!');
}
}
function GerarBoletoBancario(tipo,pedido){
var URL = 'admin/modulos/boleto_bancario/pag/boleto_'+tipo+'.php?pedido='+pedido;
var width = 800;
var height = 600;
var left = 0;
var top = 0;
window.open(URL,'Print', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=no');
}
function Ampliar_IMG(photo){
ampliar=dhtmlmodal.open('ampliar', 'ajax', 'ADD_THEMES/loja_virtual_template_dinamico/theme/ampliar_img.php?photo='+photo, 'Ampliar:', 'width=500px,height=500px,center=1,resize=0,scrolling=1');
}
function Close_Ampliar(){
document.getElementById('ampliar').hide();
}
function AddToCart(){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/executa.php';
document.frm_file.submit();
}
function HabilitaCampoFinaliza(){
frete2 = document.getElementById('frete2').value;
frete3 = document.getElementById('frete3').value;
alert(frete2);
alert(frete3);
}
function Close_Add(){
document.getElementById('add').hide();
}
function AtualizeCart(){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/atualize_cart.php';
document.frm_file.submit();
}
function DeleteItemCart(item,xid){
var mensagem='Tem certeza? Deseja remover esse item de seu carrinho?!';
if(confirm(mensagem)){confirmar();}else{cancelar()}
function confirmar(){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/delete_item_cart.php?item='+item+'&xid='+xid;
document.frm_file.submit();
}
function cancelar(){}
}
function ContinuaAdd(){
location='index.php';
}
function FinalizeAdd(){
document.frm_file.action = 'index.php?uid=AccountCart';
document.frm_file.submit();
}
function WizardNewAccount(){
document.getElementById('box_Indice').style.display='none';
document.getElementById('box_WizardNewAccount').style.display='inline';
}
function CriarAccountCart(){
var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
email1 = document.getElementById('email1').value;
email2 = document.getElementById('email2').value;
senha1 = document.getElementById('senha1').value;
senha2 = document.getElementById('senha2').value;
nome = document.getElementById('nome').value;
cpf = document.getElementById('cpf').value;
telefone = document.getElementById('telefone').value;
cep = document.getElementById('cep').value;
rua = document.getElementById('rua').value;
numero = document.getElementById('numero').value;
cidade = document.getElementById('cidade').value;
estado = document.getElementById('estado').value;
if(filter.test(email1)){
if(email1 != ''){
if(email2 != ''){
if(senha1 != ''){
if(senha2 != ''){
if(nome != ''){
if(cpf != ''){
if(telefone != ''){
if(cep != ''){
if(rua != ''){
if(numero != ''){
if(cidade != ''){
if(estado != ''){
if(email1 == email2){
if(senha1 == senha2){
document.frm_file.action = 'admin/modulos/module_loja_virtual_01/pag/criar_account.php';
document.frm_file.submit();
}else{alert('A senha digitada não é igual nos dois campos!');}
}else{alert('E-mail digitado não é igual nos dois campos!');}
}else{alert('Digite seu Estado!');}
}else{alert('Digite sua Cidade!');}
}else{alert('Digite o Número do seu Endereço!');}
}else{alert('Digite seu Endereço corretamente!');}
}else{alert('Digite seu CEP corretamente!');}
}else{alert('Digite seu Telefone com o códido de área!');}
}else{alert('Digite seu CPF corretamente!');}
}else{alert('Digite seu Nome Completo!');}
}else{alert('Digite novamente sua Senha!');}
}else{alert('Digite uma Senha!');}
}else{alert('Digite novamente seu E-mail!');}
}else{alert('Digite seu E-mail!');}
}else{alert('O endereço de E-mail não é válido!');}
}
function FazerLogin(uid){
loginf = document.getElementById('loginf').value;
senhaf = document.getElementById('senhaf').value;
if(loginf != ''){
if(senhaf != ''){
document.frm_file.action = 'index.php?WZ=OK&uid='+uid;
document.frm_file.submit();
}else{alert('Digite sua Senha por favor!');}
}else{alert('Digite seu Login por favor!');}
}
function FazerLoginGeral(uid){
loginf = document.getElementById('loginf02').value;
senhaf = document.getElementById('senhaf02').value;
if(loginf != ''){
if(senhaf != ''){
document.frm_file.action = 'index.php?WZ=OK&uid='+uid;
document.frm_file.submit();
}else{alert('Digite sua Senha por favor!');}
}else{alert('Digite seu Login por favor!');}
}

function ConsultaFrete(){
document.frm_file.action = 'http://euaqui.kamotini.kinghost.net/APLICATION/angelnobre/apl_frete.php';
document.frm_file.submit();
}
function ConsultaFreteALTERNATIVO(){
document.frm_file.action = 'http://euaqui.kamotini.kinghost.net/correios/frete.php';
document.frm_file.submit();
}
//////////////////////////////////////////// MENU EXPANDE ///////////////////////////////
var toggleMenu = {
	init : function(sContainerClass, sHiddenClass) {
		if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
		var arrMenus = this.getElementsByClassName(document, 'ul', sContainerClass);
		var arrSubMenus, oSubMenu, oLink;
		for (var i = 0; i < arrMenus.length; i++) {
			arrSubMenus = arrMenus[i].getElementsByTagName('ul');
			for (var j = 0; j < arrSubMenus.length; j++) {
				oSubMenu = arrSubMenus[j];
				oLink = oSubMenu.parentNode.getElementsByTagName('a')[0];
				oLink.onclick = function(){toggleMenu.toggle(this.parentNode.getElementsByTagName('ul')[0], sHiddenClass); return false;}
				this.toggle(oSubMenu, sHiddenClass);
			}
		}
	},
	toggle : function(el, sHiddenClass) {
		var oRegExp = new RegExp("(^|\\s)" + sHiddenClass + "(\\s|$)");
		el.className = (oRegExp.test(el.className)) ? el.className.replace(oRegExp, '') : el.className + ' ' + sHiddenClass; // Add or remove the class name that hides the element
	},
/* addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */
	addEvent : function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	},
/*
Written by Jonathan Snook, http://www.snook.ca/jonathan
Add-ons by Robert Nyman, http://www.robertnyman.com
*/
	getElementsByClassName : function(oElm, strTagName, strClassName){
	    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	    var arrReturnElements = new Array();
	    strClassName = strClassName.replace(/\-/g, "\\-");
	    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	    var oElement;
	    for(var i=0; i<arrElements.length; i++){
	        oElement = arrElements[i];
	        if(oRegExp.test(oElement.className)){
	            arrReturnElements.push(oElement);
	        }
	    }
	    return (arrReturnElements)
	}
};
toggleMenu.addEvent(window, 'load', function(){toggleMenu.init('menu','hidden');});
//////////////////////////////////////////// MENU EXPANDE ///////////////////////////////
function SearchLoja(){
document.frm_file.action = 'index.php?uid=SearchBuscaLoja';
document.frm_file.submit();
}

////////////////////////////////////////////////////////////////////////////////////////
//                            SISTEMA DE PROVA DE TEXTO                               //
//                                  LOJA VIRTUAL                                      //
////////////////////////////////////////////////////////////////////////////////////////
function Open_PreviewSugesLetras(){
var URL = 'admin/modulos/module_loja_virtual_01/pag/sugestoes_letras.php';
var width = 800;
var height = 600;
var left = 0;
var top = 0;
window.open(URL,'Print', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=no');
}
function OpenSugestoesTexto(){
var URL = 'admin/modulos/module_loja_virtual_01/pag/sugestoes_textos_popup.php';
var width = 800;
var height = 600;
var left = 0;
var top = 0;
window.open(URL,'Print', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=yes, fullscreen=no');
}
function SendProvaTexto(){
number_pedido = document.getElementById('number_pedido').value;
texto01 = document.getElementById('texto01').value;
texto02 = document.getElementById('texto02').value;
letra = document.getElementById('letra').value;
email_prova = document.getElementById('email_prova').value;
comentario = document.getElementById('comentario').value;
if(email_prova!=''){
var url = 'admin/modulos/module_loja_virtual_01/pag/send_prova_texto.php?number_pedido='+number_pedido+'&texto01='+texto01+'&texto02='+texto02+'&letra='+letra+'&email_prova='+email_prova+'&comentario='+comentario;
ajax = ajaxInit();
if(ajax) {
ajax.open("GET", url, true);
ajax.onreadystatechange = function() {
if (ajax.readyState==1){
document.getElementById('formulario').style.display='none';
document.getElementById('prosseguir').style.display='inline';
document.getElementById('aguarde').style.display='inline';
}
if(ajax.readyState == 4) {
var resposta = ajax.responseText;
alert(resposta);
document.getElementById('aguarde').style.display='none';
document.getElementById('pagamento').style.display='inline';
}
}
ajax.send(null);
}
}else{alert('Digite um E-mail para Receber a Prova de Texto!');}
}
////////////////////////////////////////////////////////////////////////////////////////
//                            SISTEMA DE PROVA DE TEXTO                               //
//                                  LOJA VIRTUAL                                      //
////////////////////////////////////////////////////////////////////////////////////////
