﻿
$().ready(function() {
    $('.maph').maphilight({ fade: true });

    $('.elenco_regioni a').bind('mouseover', function() {
        html = $(this).html();
        $('area').each(function() {
            if ($(this).attr('title') == html) {
                $('area').trigger('mouseout');
                $(this).trigger('mouseover');
            }
        });
    });
    $('.elenco_regioni').bind('mouseout', function() { $('area').trigger('mouseout'); });

    function findValueCallback(event, data, formatted) {
        $("<li>").html(!data ? "No match!" : "Selected: " + formatted).appendTo("#result");
    }

    function formatItem(row) {
        return row[0] + " (<strong>id: " + row[1] + "</strong>)";
    }
    function formatResult(row) {
        return row[0].replace(/(<.+?>)/gi, '');
    }

    $("#txtAutocomplete").autocomplete("searchComuni.aspx", {
        selectFirst: true,
        width: 255,
        max: 50
    });

    $("#txtAutocomplete").result(function(event, data, formatted) {
        if (data) {
            $("#txtAutocomplete").val(data[1]);
            document.forms[0].submit();
        }
    });


});


function mail_no_spam(user, dominio, user1) {
    document.location.href = "mailto:" + user + "@" + dominio + ";" + user1 + "@" + dominio + "?subject=Richiesta Informazioni - Home Page";
}

function randomHref() {
    link = new Array(3);
    link[0] = "<a href='http://www.cercaturismo.it/ricerca_bed_and_breakfast/bb_Trentino_Alto_Adige/Trentino%20Alto%20Adige/bed_and_breakfast_trentino_alto_adige.html' rel='nofollow' >";
    link[1] = "<a href='http://www.cercaturismo.it/ricerca_bed_and_breakfast/bb_Valle_DAosta/Valle%20DAosta/bed_and_breakfast_Valle_DAosta.html' rel='nofollow' >";
    link[2] = "<a href='http://www.cercaturismo.it/ricerca_bed_and_breakfast/bb_Abruzzo/Abruzzo/bed_and_breakfast_abruzzo.html' rel='nofollow' >";

    index = Math.floor(Math.random() * link.length);

    document.write(link[index]);
}
