var blurImageIndex = 0;
var blurImageOpacity = 0;
function blurHotelImage(fotoCount) {
    var d = document.getElementById("fotob");
    var g = document.getElementById("fotoa");
    if (d && g) {
        blurImageOpacity -= 5
        if (blurImageOpacity <= 0) {
            blurImageOpacity = 300;
            blurImageIndex = (blurImageIndex + 1) % fotoCount;
            d.className = g.className;
            g.className = "fx" + blurImageIndex;
        }
        d.style.opacity = Math.min(1, blurImageOpacity / 100);
        d.style.filter = "alpha(opacity=" + blurImageOpacity + ")";
    }
}
var gdir = null, travelMode = null, gdirquery = "";
function initMappa(lat, lng, html) {
    if (GBrowserIsCompatible()) {
        var center = new GLatLng(lat, lng);
        gmap = new GMap2(document.getElementById("map"));
        gmap.addControl(new GLargeMapControl());
        gmap.addControl(new GMapTypeControl());
        gmap.addMapType(G_PHYSICAL_MAP);
        gmap.removeMapType(G_HYBRID_MAP);
        gdir = new GDirections(gmap, document.getElementById("percorso_map"));
        GEvent.addListener(gdir, "error", handleErrors);
        gmap.setCenter(center, 15);
        var marker = new GMarker(center);
        GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(html);
        });
        gmap.addOverlay(marker);
        GEvent.trigger(marker, "click");
    }
}
function onClickTrovaIndirizzo() {
    var indirizzo = window.document.getElementById("indirizzo");
    if (indirizzo.value) {
        var from = ""
        var dest = "";
        var luogo = window.document.getElementById("luogo_indirizzo");
        if (luogo) {
            if (luogo.value == 'R') {
                from = "41.8736700,14.0697870";
                dest = indirizzo.value + ",Rivisondoli (AQ),Italia";
            }
            else if (luogo.value == 'I') {
                dest = "41.8736700,14.0697870";
                from = indirizzo.value + ",Italia";
            }
        }
        else {
            from = "41.8736700,14.0697870";
            dest = indirizzo.value + ",Rivisondoli (AQ),Italia";
        }
        gdir.clear();
        travelMode = G_TRAVEL_MODE_DRIVING;
        gdirquery = "from: " + from + " to: " + dest;
        gdir.load(gdirquery, {
            locale: myhlang
        });
    }
}
function handleErrors() {
    if (travelMode == G_TRAVEL_MODE_DRIVING) {
        gdir.clear();
        travelMode = G_TRAVEL_MODE_WALKING;
        gdir.load(gdirquery, {
            locale: "it",
            travelMode: G_TRAVEL_MODE_WALKING
        });
    } else {
        alert("Indirizzo non trovato");
    }
}
function onloadmap(lat, lng, html) {
    window.onload = function() {
        initMappa(lat, lng, html);
    }
    window.onunload = GUnload;
}
function loadPacchettiOfferhotel() {
    var ul = document.createElement("ul");
    for (var i=0; i<Math.min(4, ohpacchetti.length); i++) {
        var a = document.createElement("a");
        a.href = "booking23de.html?ohpkg=" + ohpacchetti[i].id;
        a.innerHTML = ohpacchetti[i].nome.substr(0, 60) + "...";
        var li = document.createElement("li");
        li.appendChild(a);
        ul.appendChild(li);
    }
    var d = document.getElementById("pacchetti");
    d.appendChild(ul);
}
