// JavaScript Document
/*CAIXA DE DETALHES CLIENTES*/
var vetCliente = new Array
var vetClienteLat = new Array
function cliente(nome,atividade,cidade,url) {
   this.nome = nome;
   this.atividade = atividade;
   this.cidade = cidade;
   this.url = url;   
}

var w=1
var h=1

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;z-index:2;"></div>')

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail()
{
	document.onmousemove=""
	document.getElementById('trailimageid').innerHTML = ""
	gettrailobj().visibility="hidden"
	gettrailobj().left=-500
	gettrailobj().top=0
}


function showtrail(posVet)
{
	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		//w=width
		//h=height
		
		followmouse()
		str = "<div class='caixaDetCliente'>"
		str += "<h3>" + vetCliente[posVet].nome +  "</h3>"
        str += "<p>"
		str += "<strong>Atividade:</strong> " + vetCliente[posVet].atividade + "<br>"
		str += "<strong>Cidade:</strong> " + vetCliente[posVet].cidade
        str += "</p>"
		if(vetCliente[posVet].url != "")
		{
			str += "<p><strong>Site:</strong> <a href='"+ vetCliente[posVet].url +"'>" + vetCliente[posVet].url + "</a></p>"
		}
        str += "</div>"
		
		document.getElementById('trailimageid').innerHTML = str;
		document.onmousemove=followmouse
		gettrailobj().visibility="visible"
		//gettrailobj().width=w+"px"
		//gettrailobj().height=h+"px"


	}
}


function followmouse(e)
{

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{

		var xcoord=20
		var ycoord=-80

		if (typeof e != "undefined")
		{
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined")
		{
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

		if (xcoord+w+3>docwidth)
		xcoord=xcoord-w-(20*2)

		if (ycoord-truebody().scrollTop+h>truebody().clientHeight)
		ycoord=ycoord-h-20;

		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"

	}

}
/*fim*/



function carregaDetalhesCli()
{	
	$(".clientes").hover(function(e){
		
		$("#trailimageid").remove()
		var idDiv = $(this).attr('id')	
		vetDiv = idDiv.split("_")
		posVet = vetDiv[1] 
		
		str = "<div id='trailimageid'>"
		str += "<div class='caixaDetCliente'>"
		str += "<h3>" + vetCliente[posVet].nome +  "</h3>"
		str += "<p>"
		str += "<strong>Atividade:</strong> " + vetCliente[posVet].atividade + "<br>"
		str += "<strong>Cidade:</strong> " + vetCliente[posVet].cidade
		str += "</p>"
		if(vetCliente[posVet].url != "")
		{
			str += "<p><strong>Site:</strong> <a href='"+ vetCliente[posVet].url +"'>" + vetCliente[posVet].url + "</a></p>"
		}
		str += "</div></div>"
		
		$(str).css('top',e.pageY)		
		$(str).css('left',e.pageX-15)
		.appendTo("body")
		setTimeout("showDetCli()",200)
								 
	 
	},function(){
		$("#trailimageid").remove()
	});							
	
	$(".clientes").mousemove(function(e){
		$("#trailimageid").css('left',e.pageX+10)
		$("#trailimageid").css('top',e.pageY - 15)
		
	})
	
}
function showDetCli()
{
	$("#trailimageid").show()	
}


var foto_atual,proxima_foto,id_foto_atual,id_label_atual;
var num_fotos = 3;
intervalo = new Object()

var arrayLink = new Array();

function mudar_foto(foto){
	
	
	id_proxima_foto = "#foto_"+foto;
	id_proximo_label = "#label_"+foto
	
	$(id_foto_atual).animate( {'opacity':'hide'},'slow');

	$(id_proxima_foto).animate( {'opacity':'show'},'slow',function(){
		foto_atual = foto
		id_foto_atual = id_proxima_foto;
		
		
	})
	
	$(id_label_atual).animate( {'opacity':'hide'},'slow');
	$(id_proximo_label).animate( {'opacity':'show'},'slow',function(){		
		id_label_atual = id_proximo_label;
		
		
	})
	
			
}
function setarFoto(foto)
{
	foto = foto.replace("n","")	
	if(foto != foto_atual)
	{
		mudarClassNum(foto)		
		clearInterval(intervalo)		
		mudar_foto(foto)
		intervalo = setInterval("fotoAuto()",3000)
	}
}
function fotoAuto()
{
	if(foto_atual == num_fotos)
	{
		proxima_foto = 0;
	}
	else
	{
		proxima_foto = parseInt(foto_atual) + 1	
	}	
	
	mudar_foto(proxima_foto)
	mudarClassNum(proxima_foto)
}
function mudarClassNum(proxima_foto)
{
	for(i=0;i<=num_fotos;i++)
	{
		idNum = "#n"+i
		if(i == proxima_foto )
		{
			$(idNum).addClass("numFundo")
			$(idNum).removeClass("semFundo")
		}
		else
		{
			$(idNum).addClass("semFundo")	
			$(idNum).removeClass("numFundo")
		}
	}	
}



function iniciarGaleria()
{
	foto_atual = 0;
	id_foto_atual = "#foto_0";
	id_label_atual = "#label_0"
	
	if(num_fotos > 1)
	{
		for(i=0;i<=num_fotos;i++)
		{
			idNum = "#n"+i
			$(idNum).click(function () { 
			setarFoto(this.id)
			});
			if( i > 0 )
			{
				idAux = "#foto_"+i
				$(idAux).hide()		
			}
		}
		
		intervalo = setInterval("fotoAuto()",3000)
	}
	
}
