
var OLD = 0;
function chgFoto(NUM)
{
	window.location ='#'+NUM+' - '+OLD;
	if(NUM == OLD)	{	return false; }
	
	$("li#FOTO"+OLD).stop().animate({
		opacity: 'hide'
	}, 'slow', function() {
		$("li#FOTO"+NUM).stop().animate({
			opacity: 'show'
		}, 'slow');
	});
	OLD = NUM;
}
/********************************************************************************************************************************************************************************
	ANIMAÇÃO DE ESTRELAS DE VOTAÇÃO
********************************************************************************************************************************************************************************/
var intervalID = false;
function setStar(NUM)
{
	if(intervalID) {	clearInterval(intervalID); }

	for (var i=1; i <= 5; i++)
	{
		document.getElementById('star_'+ i).src = (i > NUM) ? 'images/botoes_estrela_apagada.gif' : 'images/botoes_estrela.gif';
	}
}

function clearStar(NUM)
{
	intervalID = setInterval(function() {
		document.getElementById('star_'+ NUM).src = 'images/botoes_estrela_apagada.gif';
		NUM--;
		
		if(NUM === 0) {	clearInterval(intervalID); }
	}, 50);
}
/********************************************************************************************************************************************************************************
	GOOGLE MAPS
*******************************************************************************************************************************************************************************/
var geocoder, map, latlng, myOptions, address, marker, LAT, LNG;

//	POG PRA CARREGAR O CALLBACK DO LOAD API VIA AJAX DO GOOGLE
function mapsLoaded()
{
	iniMapa (LAT, LNG, ADDRESS);
}

function iniMapa (LAT, LNG, ADDRESS, ZOOM)
{
	//	VALOR DEFAUL
	ZOOM = ZOOM || 12;
	
	//ABRE O MAPA COM LOADER
	$('div#GMAPA').show();

	if (LAT!=null && LNG!=null)
	{
		latlng		= new google.maps.LatLng(LAT, LNG);
		setMapa(latlng, ZOOM);
	}
	else
	{
		geocoder	= new google.maps.Geocoder();
		geocoder.geocode( { 'address': ADDRESS}, function(results, status)
		{
			if (status == google.maps.GeocoderStatus.OK)
			{
				latlng = results[0].geometry.location;
				setMapa(latlng, ZOOM);
//				map.setCenter(results[0].geometry.location);
			}
			else
			{
				$('div#GMAPA').html('Serviço de mapas do Google não esta disponível:' + status)
			}
		});
	}
}

function setMapa(CORD, ZOOM)
{
	myOptions 	= {
		zoom			: ZOOM,
		center			: CORD,
		scrollwheel		: false,
		mapTypeControl	: false,
		mapTypeId		: google.maps.MapTypeId.ROADMAP
	};
	
	map		= new google.maps.Map(document.getElementById('GMAPA'), myOptions);
	marker	= new google.maps.Marker(
	{
		map			: map, 
		icon		: 'http://www.guiadepraias.com.br/images/icone_mapa.png',
		position	: CORD
	});
}
