function popupFotoProduto(Produto_Codigo, Produto_Foto_Codigo, Origem){
	var winEmail = AbreJanela("../site/produto_fotos.asp?produto_codigo=" + Produto_Codigo + "&produto_foto_codigo=" + Produto_Foto_Codigo + "&origem=" + Origem + "","popProdutoFoto","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=550");
	winEmail.focus();
	return false;
}

function showPop(){
	document.getElementById("pop").style.display = "block";
}
function hidePop(){
	document.getElementById("pop").style.display = "none";
}

function setLocation(Url){
	window.location.href = Url;
}

function setStatusBar(texto){
	window.status=texto;
}

function statusBarIn(obj){
	var texto = "";
	if (obj.title!=""){
		texto = obj.title;
	}
	setStatusBar(texto);
	return true;
}

function statusBarOut(){
	setStatusBar("");
	return true;
}

function LembreteSenha(objForm){
	objForm.acao.value = "LEMBRETE_SENHA";
	objForm.submit();
}

function AbreJanela(Url, Nome, Opcoes){
	var Janela = window.open(Url,Nome,Opcoes);
	return Janela;
}

function openWebTrendsWindow(url){
	var winWebTrends = AbreJanela(url,"popWebTrends","toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=575,height=405");
	winWebTrends.focus();
	return false;
}

function setLojaFoto(objForm, Sequencia){
	objForm.loja_foto_sequencia.value = Sequencia;
	objForm.submit();
}
function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}
function Confirma(strTexto, strURL){
	if (confirm(strTexto)){
		setLocation (strURL);
		return true;
	}
	else{
		return false;
	}
}

function FiltroProdutos(objForm){
	try{
		objForm.categoria_codigo.options.selectedIndex = 0;
	}
	catch(e){}
	objForm.submit();
}

function AdmImagens(caminho, retorno){
	var winEmail = AbreJanela("arquivo_upload.asp?caminho=" + caminho + "&retorno=" + retorno + "","popArquivoUpload","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=520");
	winEmail.focus();
	return false;
}

function AdmImagensEmail(caminho, retorno){
	var winEmail = AbreJanela("arquivo_upload_email.asp?caminho=" + caminho + "&retorno=" + retorno + "","popArquivoUpload","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=540");
	winEmail.focus();
	return false;
}

function setImagem(src, objImg, hidden){
	objImg		= document.getElementById(objImg);
	objHidden	= document.getElementById(hidden);
	objImg.src	= src;
	objHidden.value = src;
}

function AbrirFiltroClientes(CampoRetorno){
	AbreJanela("clientes_emails_send_filtro.asp?camporetorno=" + CampoRetorno, "popFiltroClientes", "menubar=0,scrollbars=yes,width=460,height=400,top=5,left=5");
}

function CheckAll(objForm, acao){
	var cont = 0;
	for (cont = 0; cont < objForm.elements.length; cont++){
		var obj = objForm.elements(cont);
		if (obj.type == "checkbox"){
			obj.checked = acao;
		}
	}
}

function Selecionar(objForm, objRetorno){
	var cont = 0;
	var aux = "";
	objRetorno.value = "";
	for (cont = 0; cont < objForm.elements.length; cont++){
		var obj = objForm.elements(cont);
		if (obj.type == "checkbox"){
			if (obj.checked && obj.name!="all"){
				objRetorno.value += aux + obj.email;
				aux = ";";
			}
		}
	}
}

function changePagina(e, objForm){
	if(document.all) // Internet Explorer
		var tecla = event.keyCode;
	else
		if(document.layers) // Nestcape
			var tecla = e.which;
	objForm.submit();
}

function doAddCarrinho(obj, wait, prod, tamanho, cor, tipo, quant){
	var objDiv	= document.getElementById(obj);
	var varArquivo	= "ajax.asp?acao=CHECK_ESTOQUE&prod=" + prod + "&tamanho=" + tamanho + "&cor=" + cor + "&tipo=" + tipo + "&quant=" + quant;
	objDiv.innerHTML = wait;
	var oAjax = new Ajax(objDiv, "get", varArquivo);	
}
function doShowCores(obj, wait, prod, tamanho){
	var objDiv	= document.getElementById(obj);
	var varArquivo	= "ajax.asp?acao=SHOW_CORES&prod=" + prod + "&tamanho=" + tamanho;
	objDiv.innerHTML = wait;
	var oAjax = new Ajax(objDiv, "get", varArquivo);	
}
function doShowTipos(obj, wait, prod, tamanho, cor){
	var objDiv	= document.getElementById(obj);
	var varArquivo	= "ajax.asp?acao=SHOW_TIPOS&prod=" + prod + "&tamanho=" + tamanho + "&cor=" + cor;
	objDiv.innerHTML = wait;
	var oAjax = new Ajax(objDiv, "get", varArquivo);	
}
function sendAvisoProduto(p){
	var wait = "<img src='../imagens/diversos/wait.gif' height='16' width='16' border='0' align='absmiddle' />";
	var objDiv	= document.getElementById("aviso");
	var varArquivo	= "ajax.asp?acao=AVISO_DISPONIBILIDADE&prod=" + p + "";
	objDiv.innerHTML = wait;
	var oAjax = new Ajax(objDiv, "get", varArquivo);	
}
function sendAvisoProduto2(p){
	var m = document.getElementById('email_solicitacao').value;
	//Validacao
	if (IsEmail(m)){
		var wait = "<img src='../imagens/diversos/wait.gif' height='16' width='16' border='0' align='absmiddle' />";
		var objDiv	= document.getElementById("aviso");
		var varArquivo	= "ajax.asp?acao=AVISO_DISPONIBILIDADE&prod=" + p + "&id=" + m;
		objDiv.innerHTML = wait;
		var oAjax = new Ajax(objDiv, "get", varArquivo);	
	}
	else{
		alert("É necessário preencher o email,\nverifique se ele está correto.");
	}
}
function IsEmail(email){
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;
    if(((email.search(exclude) != -1)||(email.search(check)) == -1)||(email.search(checkend) == -1)){return false;}
    else {return true;}
}