	function obterPosicao(eixo){
		//alert('Aktuell:' + getCookie('popup'+eixo));
		if(getCookie('popup'+eixo) == null){
			setCookie('popup'+eixo, 200, 365);
		}
		//alert('Ende:' + getCookie('popup'+eixo));
		return(getCookie('popup'+eixo));
	}

	function codigo(codigo){
		var popup = window.open('/popups-mostra-codigo.aspx?c='+codigo,'none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		//colocar "../mostracodigo.aspx"
		popup.window.focus();
	    return false;
	}

	function deletar(codigo){
		var popup = window.open('/popups-deletar.aspx?c='+codigo,'none','width=420,height=350,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	    return false;
	}


	function ouvir(arquivo){
		var popup = window.open('/popups-ouvir.aspx?c='+arquivo,'none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	    return false;
	}

	function zoom(codigo){
		var popup = window.open('/popups-zoom.aspx?c='+codigo,'none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	    return false;
	}

	function editar(codigo){
		var popup = window.open('/popups-admin-editar.aspx?c='+codigo,'none','width=420,height=195,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		//colocar "../ouvir.aspx.aspx"
		popup.window.focus();
	    //return false;
	}

	function cesta(codigo){
		var popup = window.open('/popups-cesta.aspx?action=add&c='+codigo,'none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	}

	function enquete(enquete){
		var popup = window.open('/popups-enquete.aspx?enquete='+enquete,'none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	}

	function abrirCesta(){
		var popup = window.open('/popups-cesta.aspx','none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	}

	function recomende(){
		var popup = window.open('/recomende.aspx','none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=' + obterPosicao('y') + ',left=' + obterPosicao('x'));
		popup.window.focus();
	}

	function imprimirMateria(codigo){
		var popup = window.open('/materias/impressao.aspx?c='+codigo,'none','width=420,height=400,toolbar=no,copyhistory=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
		popup.window.focus();
	}

	function FecharPopup() {
		if (popup!=null && !popup.closed) {
			popup.close();
		}
	}

	function tamanho2(altura,largura){
		document.getElementById('_ctl0__ctl0_direita_txtAltura').value = altura;
		document.getElementById('_ctl0__ctl0_direita_txtLargura').value = largura;
	}

	function tamanho(valor){
		if(valor==1){largura=96;altura=65;}
		if(valor==2){largura=101;altura=128;}
		if(valor==3){largura=128;altura=128;}
		if(valor==4){largura=128;altura=160;}
		if(valor==5){largura=132;altura=176;}
		if(valor==6){largura=176;altura=128;}
		if(valor==7){largura=176;altura=208;}
		document.getElementById('_ctl0__ctl0_direita_txtAltura').value = altura;
		document.getElementById('_ctl0__ctl0_direita_txtLargura').value = largura;
	}

	function soNumeros(fld, e) 
	{
		//  Usar no onKeyPress="return(soNumeros(this,event))" do input(text)
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		key = String.fromCharCode(whichCode);  // Get key value from key code
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	}
	function soNumerossenha(fld, e) 
	{
		if(e.keyCode==13){
			var followingInput = document.getElementById("_ctl0__ctl0_btnLogar");
			followingInput.focus();
		}
		//  Usar no onKeyPress="return(soNumeros(this,event))" do input(text)
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		key = String.fromCharCode(whichCode);  // Get key value from key code
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
		
	}
	function buscaEnter(fld, e){
		if(e.keyCode==13){
			var followingInput = document.getElementById("_ctl0:_ctl0:btnBusca");
			followingInput.focus();
		}
	}

	function capitalizeWords(string) { var tmpStr, tmpChar, preString, postString, strlen; tmpStr = string.toLowerCase(); stringLen = tmpStr.length; if (stringLen > 0) { for (i = 0; i < stringLen; i++) { if (i == 0) { tmpChar = tmpStr.substring(0,1).toUpperCase(); postString = tmpStr.substring(1,stringLen); tmpStr = tmpChar + postString; } else { tmpChar = tmpStr.substring(i,i+1); if (tmpChar == " " && i < (stringLen-1)) { tmpChar = tmpStr.substring(i+1,i+2).toUpperCase(); preString = tmpStr.substring(0,i+1); postString = tmpStr.substring(i+2,stringLen); tmpStr = preString + tmpChar + postString; } } } } return tmpStr; }

	function salvaPosicao(manual){
		if (navigator.appVersion.indexOf("MSIE") != -1){
			//setCookie('popupx', 200, 365);
			//setCookie('popupy', 200, 365);
			//alert('Merda detectada!');
			//O MSIE é burro, ele salva a posição da janela fechada
		}else{
			if(!window.screenX)screenX=window.screenLeft;
			if(!window.screenY)screenY=window.screenTop;
			setCookie('popupx', screenX, 365);
			setCookie('popupy', screenY, 365);
		}
		if(manual == true){
			if(!window.screenX)screenX=window.screenLeft;
			if(!window.screenY)screenY=window.screenTop;
			setCookie('popupx', screenX, 365);
			setCookie('popupy', screenY, 365);
		}
		//alert('Ende:' + getCookie('popupx') + ', ' + getCookie('popupy'));
	}

	function setCookie(nome_do_cookie, value, expiredays) 
		{ var ExpireDate = new Date ();
		ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
		document.cookie = nome_do_cookie + "=" + escape(value) + 
		((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
	}

	function getCookie(nome_do_cookie)
		{ if (document.cookie.length > 0) 
		{ begin = document.cookie.indexOf(nome_do_cookie +"="); 
		if (begin != -1) 
		{
		begin += nome_do_cookie.length+1; 
		end = document.cookie.indexOf(";", begin);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(begin, end)); } 
		}
		return null; 
	} 

	function irPara(url){
		if (parent.opener.closed == false){
			opener.document.location.href = url;
			opener.window.focus();
			window.close();
		}
	}

	function aguarde(item){
		if(item=="lista"){
			document.getElementById("carregadorLista").innerHTML = "<style type='text/css'>#itens{filter:alpha(opacity=25);-moz-opacity:.25;opacity:.25;}</style>";
			document.getElementById("carregadorLista").innerHTML += "<div style='position:absolute;top:150px;left:120px;text-align:center;font-weight:bold;width:300px;background:#f5f5f5;padding:10px;border:1px solid black;margin:0px 0px 0px 0px;'><img src='img/carregando.gif' border='0' /><p>Carregando...</p></div>";
		}else{
			document.getElementById(item).innerHTML += "<div style='position:absolute;top:0px;left:0px;text-align:center;font-weight:bold;width:100%;background:#f5f5f5;padding:3px;border:1px solid black;margin:0px 0px 0px 0px;'><img src='/img/waiting.gif' border='0' /><p>Carregando...</p></div>";
		}
	}