//////////////////////////////////////////////////////	BOX
// Função que fecha o pop-up ao clicar no link fechar
function fecharbox(){
	document.getElementById('mLboxFundo').style.display = 'none';
	document.getElementById('mLboxbox').style.display = 'none';
	document.getElementById('boxAtual').value = '';
}
// Aqui abre a box

function abrirbox(popurl, tipo, identb){
document.getElementById('mLboxFundo').style.display = 'block';
document.getElementById('mLboxbox').style.display = 'block';

carregaconteudo(popurl, tipo, identb);
}

document.write('<div id="mLboxbox"><input type="hidden" id="boxAtual" value=""><div id="mLboxcontboxAling"><div id="mLboxcontboxMarding"> <div id="mLboxcontbox"></div></div> <div id="mLboxbuttombox"><a href="javascript: void(0)" onclick="fecharbox()"><img src="img/layout/box_close.png" alt="X" /></a></div></div></div>');

document.write("<div id=\"mLboxFundo\" onclick=\"fecharbox()\"></div>")

////////////////////////////////////////////	CARREGA O  CONTEUDO
var abrepop = new ajax();
function carregaconteudo(pagina, tipo, ident){
	if(tipo == 'iframe'){
		
		if(isset(ident)){
			document.getElementById('boxAtual').value = ident;
		} 
		document.getElementById('mLboxcontbox').innerHTML = "<iframe src="+pagina+" width='100%' height='400px' scrollling='none' frameborder='0'></iframe>"; 
		
	} else {
		document.getElementById('mLboxcontbox').innerHTML = "<center class='c30'><img src='img/layout/loading.gif' alt='carregando'></center>"; 

		abrepop.open("post",pagina,true);
		abrepop.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		abrepop.onreadystatechange=function() {
			if(abrepop.readyState==4) {
				document.getElementById('mLboxcontbox').innerHTML = abrepop.responseText; 
			}
		}
		abrepop.send(null);
	}
}

function fadeOut(id, time, opac) {
	target = document.getElementById(id);
	alpha = opac;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0)	{
					clearInterval(i);
					target.style.display = 'none';
				} 
				
				setAlpha(target, alpha);
				alpha -= 2;
				
			}, timer);
}

function fadeIn(id, time, opac) {
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= opac)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, time);
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}