function valida_numeros(e) {
	if(document.all) var tecla=event.keyCode;
	else if(document.layers) var tecla=e.which;
	if(tecla>47 && tecla<58) // numeros de 0 a 9
		return true;
	else {
		if (tecla!=8) // backspace
			event.keyCode=0;
		else
			return true;
	}
}
//--------------------------------------------------------------------------------------------------//
function abrefoto (foto,w,h)
{
	// Centralizar a janela
	var winl = (window.screen.width-w)/2;
	var wint = (window.screen.height-h)/2;

	var propriedades =  'width='+w+
						',height='+h+
						',top='+wint+
						',left='+winl+
						',scrollbars=NO';

	window.open('../../paginas/foto_produto.php?'+foto,'fotos',propriedades);
}

/****************************************************/
/*					Acha o posicionamento do objeto					*/
/****************************************************/
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

/****************************************************/
/*	Funções para mostrar/ocular o box dos produtos	*/
/****************************************************/
	var tempoProduto;
	var box = document.getElementById('produtos_categorias');
	var produtos;

	function ocultarProduto()
	{
		box.style.display = "none";
	}

	function mostrar(obj, categoria)
	{
		clearTimeout(tempoProduto);
		box = document.getElementById('produtos_categorias');
		var obj = document.getElementById(obj);
		var posicao_x = findPosX(obj);
		var posicao_y = findPosY(obj);

		produtos = document.getElementById('produtos1');
		if(produtos.style.display != "none")
			produtos.style.display = "none";

		produtos = document.getElementById('produtos2');
		if(produtos.style.display != "none")
			produtos.style.display = "none";

		produtos = document.getElementById('produtos3');
		if(produtos.style.display != "none")
			produtos.style.display = "none";

		produtos = document.getElementById('produtos4');
		if(produtos.style.display != "none")
			produtos.style.display = "none";

		document.getElementById('produtos'+categoria).style.display = "block";

		box.style.top = posicao_y + "px";
		box.style.left = posicao_x + 120 + "px";
		box.style.display = "block";

		tempoProduto = setTimeout("ocultarProduto()",3500);
	}


	function abre_news(obj)
	{
		var posicao_x = findPosX(obj);
		var posicao_y = findPosY(obj);

		var div = document.getElementById('newsletter');
		div.style.top = posicao_y - 50 + "px";
		div.style.left = posicao_x - 20 + "px";
		div.style.display = "block";
}


//---enquete---//
function enquete_home() {
	var div = document.getElementById('parciais');
	div.style.marginLeft = "0px";
	div.style.width = "auto";
}
function enquete_vis_parciais(acao) {
	if(acao==1) {
		var obj = document.getElementById('parciais');
		obj.style.visibility = 'visible';
	}
	else {
		var obj = document.getElementById('parciais');
		obj.style.visibility = 'hidden';
		obj.innerHTML = '';
	}
}
function enquete_posiciona(posY,posX) {
	var div = document.getElementById('parciais');
//	var pos = parseInt(posY)-parseInt(divX)-10;
	if (screen.width == "800" && screen.height == "600")
	{
		posX -= 100;
	}
	if (screen.width == "1024" && screen.height == "768"){
		posX -= 215;
	}
	if (screen.width == "1280" && screen.height == "1024"){
		posX -= 340;
	}

	div.style.top = posY-80+"px";
	div.style.left = posX+"px";
	div.style.display = "block";
}
function enquete_validar() {
	var form = document.form_enquete;
	var i; var x;
	for (i=0;i<form.enquete.length;i++) {
		if(form.enquete[i].checked) x=form.enquete[i].value;
	}
	if(x) return x; else return false;
}

function abrejanela (end) { window.open(end,'fotos','width=750,height=385,scrollbars=yes'); }