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 goComboCategorias(objCombo){
		Categoria_Codigo = objCombo.options[objCombo.options.selectedIndex].value;
		if (Categoria_Codigo != "")
			setLocation("produtos_lista.asp?categoria_codigo=" + Categoria_Codigo);
}

function voltar(){
	window.history.back();
}

function AbreJanela(Url, Nome, Opcoes){
	var Janela = window.open(Url,Nome,Opcoes);
	return Janela;
}

function LembreteSenha(objForm){
	objForm.acao.value = "LEMBRETE_SENHA";
	objForm.submit();
}

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){
	if(document.all) // Internet Explorer
		var tecla = event.keyCode;
	else 
		if(document.layers) // Nestcape
			var tecla = e.which;
		if(tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else{
			if (tecla != 8) // backspace
				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?tipo=IMGS&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 setImagem(src, img, hidden){
	objImg		= document.getElementById(img);
	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 changeFoto(src, txt){
	obj = document.getElementById("foto_produto");
	obj2 = document.getElementById("foto_produto_texto");
	obj.src = src;
	obj2.innerText = txt;
}

function AbrirLojaFoto(Loja_Foto_Codigo){
	AbreJanela("loja_foto.asp?loja_foto_codigo=" + Loja_Foto_Codigo, "popLojaFoto", "menubar=0,scrollbars=no,width=460,height=360,top=0,left=0");
}

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 getElementPosition(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}