/**************************************************
	RESIZE IFRAME
**************************************************/

function resizeIframe(id) 
{
	try {
	
	 frame = document.getElementById(id);
	 innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
	
	 objToResize = (frame.style) ? frame.style : frame;
	
	if(innerDoc=="[object]")
	{
		tamanho = innerDoc.body.scrollHeight; //IE
		auxilio = 20;
	}
	else
	{
		tamanho = innerDoc.body.offsetHeight; //Mozilla
		auxilio = 50;
	}
		objToResize.height = Number(tamanho+auxilio);
		document.getElementById('topo').focus();
	}
	
	catch (e) 
	{
		window.status = '';
	}
}


/**************************************************
	ENCONTRA OBJETOS E
	ELEMENTOS
**************************************************/

function localizaObj(objNome, objDocumento) 
{
	var intContador, p, x;
	if (!objDocumento)
	{
		objDocumento = document;
	}
	if ((p = objNome.indexOf("?")) > 0 && parent.frames.length)
	{
		objDocumento = parent.frames[objNome.substring(p + 1)].document;
		objNome = objNome.substring(0, p);
	}
	if (!(x = objDocumento[objNome]) && objDocumento.all)
	{
		x = objDocumento.all[objNome];
	}
	for (intContador = 0; !x && intContador < objDocumento.forms.length; intContador++) x = objDocumento.forms[intContador][objNome];
	for (intContador = 0; !x && objDocumento.layers && intContador < objDocumento.layers.length; intContador++) x = localizaObj(objNome,objDocumento.layers[intContador].document);
	if (!x && objDocumento.getElementById)
	{
		x = objDocumento.getElementById(objNome);
	}
	return x;
}


/**************************************************
	MOSTRA/ESCONDE CAMADAS
**************************************************/

function manipulaDiv()
{
	var intContador, strDisplay, objNome, arrArgs = manipulaDiv.arguments;
	for (intContador = 0; intContador < (arrArgs.length - 1); intContador += 2)
	{
		if ((objNome = localizaObj(arrArgs[intContador])) != null)
		{
			strDisplay = arrArgs[intContador + 1];
			if (objNome.style)
			{
				objNome = objNome.style;
				strDisplay = (strDisplay == 'show')?'block':(strDisplay == 'hide')?'none':strDisplay;
			}
			objNome.display = strDisplay;
		}
	}
}


/**************************************************
	TROCA IMAGEM
**************************************************/

function trocaImg(img,id)
{
	campo = document.getElementById(id);
	campo.src = img;
}


/**************************************************
	BUSCA VIDEOS
**************************************************/

function buscaVideo()
{
	palavra = document.getElementById("chave").value;
	
	if (palavra == ""){
		alert("Preencha uma palavra chave para realizar a busca.");
	} else {
		location.href = "qixtv.php?chave="+palavra;
	}
}

/**************************************************
	BUSCA NEWS
**************************************************/

function buscaNews()
{
	chave = document.busca_news.palavra.value;
	
	if (chave != "")
	{
		location.href = "news.php?tipo=busca&palavra="+chave;	
	}
}

/**************************************************
	ABRE CONTEÚDO DO MENU PRINCIPAL
**************************************************/

function abreConteudo(url)
{
	location.href = url;	
}

/**************************************************
	ABRE DIV DE ACORDO COM O X E Y DO MOUSE
**************************************************/

wmtt = null;
document.onmousemove = updateWMTT;

function showWMTT(id,arquivo) {
	wmtt = document.getElementById(id);
	wmtt.innerHTML = "<img src='"+arquivo+"' border='0'>";
	wmtt.style.display = "block";
}

function showWMTT_TXT(id,texto) {
	wmtt = document.getElementById(id);
	wmtt.innerHTML = texto;
	wmtt.style.display = "block";
}

function updateWMTT(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x+20) + "px";
		wmtt.style.top 	= (y-5) + "px";
	}
}

function hideWMTT() {
	wmtt.style.display = "none";
}

/**************************************************
	EXCLUIR VALOR
**************************************************/

function execAct(dir,acao,query)
{
	if (confirm("Voce tem certeza que deseja excluir este registro?")){
		location.href = '../'+dir+'/acoes.php?acao='+acao+'&id='+query;	
	}
}

/**************************************************
	PERMITE CARACTERES SETADOS
**************************************************/

function IsNumeric(sText,sDigitos)
{
	var ValidChars = sDigitos;
	var IsNumber   =  true;
	var Char;
	
	for (i=0; i<sText.length && IsNumber == true; i++) 
	{ 
	Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}

/**************************************************
	POPUP CENTRALIZADO
**************************************************/

function abrePopup(pagina,largura,altura,rolagem)
{
	var posX;
	var posY;
	posX = (window.screen.width - largura) / 2;
	posY = (window.screen.height - altura) / 2;
	window.open(pagina,"_blank","width="+largura+",height="+altura+",top="+posY+",left="+posX+",scrollbars="+rolagem+",toolbar=no,location=no,directories=no,menubar=no,resizable=no,menubar=no");
}

/**************************************************
	POPUP POSIÇÃO PADRÃO
**************************************************/

function abrePopupMenor(pagina,largura,altura,rolagem)
{
	window.open(pagina,"_blank","width="+largura+",height="+altura+",top=80,left=80,scrollbars="+rolagem+",toolbar=no,location=no,directories=no,menubar=no");
}

/**************************************************
	LIBERA CAMPOS AO INSERIR DOWNLOAD
**************************************************/

function downCampos()
{
	with(document.formulario)
	{
		if (categoria.value == 1) {
			resolucao.options[0].selected;
			resolucao.disabled = true;
		}
		if (categoria.value == 2) {
			resolucao.disabled = false;
		}
	}
}

/**************************************************
	ESCONDE E MOSTRA DIVs
**************************************************/

function abreMenu(id) 
{
	if (document.getElementById(id).style.display == "none")
	{
		document.getElementById(id).style.display = "block";
	} 
	else 
	{
		document.getElementById(id).style.display = "none";
	}
}

