// JavaScript Document

ns = document.layers;
ie = document.all;
ns6 = (document.getElementById && !document.all);

function moveMouse(e){
      if(ie){
           	posx = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
           	posy = event.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;
      } else if (ns){
           	posx = e.x;
           	posy = e.y;
      } else if (ns6){
           	posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
         	posy = e.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;
     }
}

window.onload = function(){
	document.onmousemove = moveMouse; 
}

function abre_janela(img,title,w,h){
	var url = 'imagem.php?img='+img+'&title='+title;
	//var name = title+' - MorroAlto - Pirenópolis';
	var features = 'height='+h+', width='+w+', scrollbars=no';
	win = window.open(url,'',features)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function mostraProduto(idproduto,tipoproduto){
	//nomeAtrativo=atrativo;
	quadro = document.createElement("div");	
	quadro.setAttribute("id","mostraProduto"+idproduto);
	quadro.className = "quadroproduto";
	quadro.style.top = posy-120+'px';
	quadro.style.left = posx-55+'px';
	var cabec =  '<div style="float:right;"><a href="javascript:void 0" onclick="escondeProduto(\''+idproduto+'\')"><img src="imagens/fechar.gif" height="13" title="fechar" alt="fechar" border="0"/></a></div><h1>Carregando . . .</h1>';
	var info = '<div style="display: block;text-align: center; padding-top: 30px; margin-bottom: 30px"><img src="imagens/ajax1.gif" alt=""/></div>';
	document.body.appendChild(quadro);
	var url = 'funcoesphp/mostraproduto.php?tipoproduto='+tipoproduto+'&idproduto='+idproduto;
	requestHTTP("POST",url,true);
	quadro.innerHTML = cabec + info;
}
//////////////
function escondeProduto(idproduto){
	var quadro = document.getElementById("mostraProduto"+idproduto);
	var conteudo = document.getElementById("conteudo");
	if(quadro) document.body.removeChild(quadro);
}
/*
///////////////
function trataDados(){
	var meuXML = ajax.responseXML;
	var raiz = meuXML.documentElement;
	var nodos;
	if(raiz.hasChildNodes()){ 
		nodos = raiz.childNodes;
		if(raiz.getAttribute('title')=="mostraProdutos"){
			var idproduto = nodos[0].firstChild.nodeValue;
			var idatrativo = nodos[1].firstChild.nodeValue;
			var nome = nodos[2].firstChild.nodeValue;
			var estrutura = nodos[3].firstChild.nodeValue;
			if(nodos[4].firstChild) var imagemreduzida = nodos[4].firstChild.nodeValue;
			if(nodos[5].firstChild) var imagem = nodos[5].firstChild.nodeValue;
			
			var quadro = document.getElementById('mostraProduto'+idproduto);
			quadro.childNodes[1].firstChild.nodeValue = nome;
			quadro.lastChild.style.textAlign = 'justify';
			quadro.lastChild.style.padding = '0px';
			quadro.lastChild.style.margin = '0';
			quadro.lastChild.style.textIndent = '20px';
			quadro.lastChild.style.fontSize = '.9em';
			var info = '<p>'+estrutura+'</p>';
			if(imagem) info += '<a href="javascript: void 0" onclick="abre_janela(\''+imagem+'\',\'\',720,540)"><img style="text-indent:0;text-align:center; margin:0 0 5px 5px;" src="'+imagemreduzida+'" alt="Imagem '+nome+'" title="Clique para ampliá-la" width="250" height="188" border="0"></a>';
			info += '<p style="text-align:center; text-indent: 0;"><a href="javascript:void 0" onclick="escondeProduto(\''+idproduto+'\')" style="font-size: .9em">Fechar janela</a></p>';
			quadro.lastChild.innerHTML = info;
		}
		///////////////////////////// recalculo
		if(raiz.getAttribute('title')=="recalculo"){		
			var recalculo = document.getElementById('recalculo');
			if(nodos[4].firstChild) var ncriancas = nodos[4].firstChild.nodeValue;
			if(nodos[5].firstChild) var njovens = nodos[5].firstChild.nodeValue;
			if(nodos[6].firstChild) var nadultos = nodos[6].firstChild.nodeValue;
			if(nodos[7].firstChild) var paxmax = nodos[7].firstChild.nodeValue;
			if(nodos[8].firstChild) var valortransporte = nodos[8].firstChild.nodeValue;
			if(nodos[13].firstChild) var preco = nodos[13].firstChild.nodeValue;
			recalculo.lastChild.innerHTML = '<h4>Total</h4><p><b>R$ '+preco+'</b> para um grupo de '+paxmax+' pessoas</p>';
			
		}
	}
}
*/
//var cabec;
//var nomeAtrativo;

/*

function calculaPreco(valormin,valormax,pax){
	var form = document.getElementById("quantPax");
	var quant = form.pax.value;
	var valorUnit = document.getElementById('valorUnit');
	var valorTotal = document.getElementById('valorTotal');
	//if(quant > meio){ 
		var r = (valormax-valormin)/pax;
		var valortot = valormin+(r*(quant-1));
	/*}
	else
		var valortot = valormin;*/
	/*var valortot = Math.ceil(valortot);
	var unitario = valortot/quant;
	valorUnit.innerHTML = 'Unitário: R$ <b>'+formataMoeda(unitario)+'</b> por pessoa';
	valorTotal.innerHTML = 'Total: <b style="color: red;">R$ '+formataMoeda(valortot)+'</b> para um grupo de <b>'+quant+' pessoas</b>';
}

function formataMoeda(num) {
	/*x = 0;
	if(num<0) {
      	num = Math.abs(num);
    	x = 1;
   	}

   	if(isNaN(num)) num = "0";*/

	/*cents = Math.floor((num*100+0.5)%100);
   	num = Math.floor((num*100+0.5)/100).toString();

	if(cents < 10) cents = "0" + cents;
   
   	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++){
	   num = num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
   	}
   	ret = num + ',' + cents;
   //if (x == 1) ret = ' - ' + ret;
   	return ret;

}
function roundCents(num){
	cents = ((num*100+0.05)%100)/100;
	decs = Math.ceil(cents*10)/10;
	int = num-cents;		
	number = int+decs;	
	return number;
}*/