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

function ShowChangeLocation()
{
	$('#chancheLocationDiv').animate({
		 opacity: 'show', 
		 height: 'show'
		 }, 
		 'slow');
}

function HideChangeLocation()
{
	$('#chancheLocationDiv').animate({
		 opacity: 'hide', 
		 height: 'hide'
		 }, 
		 'slow');
	
}

function showMap()
{
	$("#box_mappa_testata_estesa_closed").css("margin-bottom", "0px");
	$("#box_mappa_testata_estesa").slideDown("normal", function(){
		$(".controllo_mappa").html("");
		$(".controllo_mappa").html("<span onclick=\"javascript:hideMap()\">Nascondi mappa</span>");
		loadMapOnClick();});
	$.post("/", { openMap: "true"});
}

function hideMap()
{
	$(".controllo_mappa").html = "";
	$("#box_mappa_testata_estesa").slideUp("normal", function(){$("#box_mappa_testata_estesa_closed").css("margin-bottom", "15px");
	$(".controllo_mappa").html("<span onclick=\"javascript:showMap()\">Visualizza mappa</span>");
	});
	$.post("/", { openMap: "false"});
}

function goCustom(form, idInputBox, idCityBox)
{
	var text = document.getElementById(idInputBox).value;
	var city = document.getElementById(idCityBox).value;
	if(text == '' || text == 'Ristorante, cronaca, concerto, ...')
	{
		document.getElementById('alert_message_testo').innerHTML = "<p>E' necessario specificare il campo \"Cosa\".<br />Inserisci l'oggetto sul quale effettuare la ricerca.</p>";
		tb_show("", "#TB_inline?height=128&width=330&inlineId=alert_message");
		return false;
	}
	if(city == "")
	{
		document.getElementById('alert_message_testo').innerHTML = "<p>E' necessario specificare il campo \"Dove\".<br />Inserisci la località in cui effettuare la ricerca.</p>"; 
		tb_show("", "#TB_inline?height=128&width=330&inlineId=alert_message");
		return false;
	}
	
	return true;
}

function activateAndChangeStyle(style) {
	if (style == VEMapStyle.Aerial) {
		if (changeMapStyle(VEMapStyle.Aerial)) {
			activateTab(style);
		}
	}

	if (style == VEMapStyle.Birdseye) {
		if (changeMapStyle(VEMapStyle.Birdseye)) {
			activateTab(style);
		}
	}

	if (style == VEMapStyle.Hybrid) {
		if (changeMapStyle(VEMapStyle.Hybrid)) {
			activateTab(style);
		}
	}

	if (style == VEMapStyle.Road) {
		if (changeMapStyle(VEMapStyle.Road)) {
			activateTab(style);
		}
	}
}

function changeMapStyle(style) {
	if (style == VEMapStyle.Road) {
		map.SetMapStyle(style);
		return true;
	}
	if (style == VEMapStyle.Aerial) {
		map.SetMapStyle(style);
		return true;
	}
	if (style == VEMapStyle.Hybrid) {
		map.SetMapStyle(style);
		return true;
	}
	if (style == VEMapStyle.Birdseye) {
		if (map.IsBirdseyeAvailable()) {
			map.SetMapStyle(style);
			return true;
		} else {
			return false;
		}
	}
	return false;
}

function activateTab(style) {
	id_last_active.className = '';
	if (style == VEMapStyle.Aerial) {
		id_last_active = id_aerial;
		label_last_active = label_aerial;
	}
	if (style == VEMapStyle.Birdseye) {
		id_last_active = id_birdseye2;
		label_last_active = label_birdseye2;
	}
	if (style == VEMapStyle.Hybrid) {
		id_last_active = id_hybrid;
		label_last_active = label_hybrid;
	}
	if (style == VEMapStyle.Road) {
		id_last_active = id_road;
		label_last_active = label_road;
	}
	id_last_active.className = nomeClasseAttiva;
}

function zoomIn(zoomLevel) {
	map.ZoomIn();
	checkBird();
}

function zoomOut(zoomLevel) {
	map.ZoomOut();
	checkBird();
}

/** *********************** x Birdseye *********************** */

function preventPanAndZoom() {
	map.AttachEvent("onmouseup", checkBird);
	map.AttachEvent("onmousewheel", checkBird);
	map.AttachEvent("onkeyup", checkBird);
}

function checkBird() {
	if (label_last_active != label_birdseye2) {
		setTimeout("checkBirdDelayed()", 1000);
		id_birdseye2.className = "disabilitato";
	}
}
function checkBirdDelayed() {
	// override funzione generica in utils.js
	if (map.IsBirdseyeAvailable()) {
		id_birdseye2.className = "";
	} else {
		id_birdseye2.className = "disabilitato";
	}
}

function biLog(dataValues)
{
	$.ajax({
		   url: "http://adimg.virgilio.it/tracks/bi/images/bi_clk.gif",
		   data: dataValues
		 });

}
