﻿
/*************************************/
/***** Script MerchandisingPlaza *****
/*************************************/

/* Variabili globali */

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var expanding = false;
var expandingWhishlist = false;
var attivo = false;
var attivoWhishlist = false;


/* Funzioni */
function monkeyPatchAutocomplete() {

    // Don't really need to save the old fn, 
    // but I could chain if I wanted to
    var oldFn = $.ui.autocomplete.prototype._renderItem;

    $.ui.autocomplete.prototype._renderItem = function(ul, item) {
        var re = new RegExp(this.term, "i");
        var t = item.label.replace(re, "<span style='font-weight:bold'><span style='text-decoration:underline'>" + this.term + "</span></span>");
        return $("<li></li>")
                  .data("item.autocomplete", item)
                  .append("<a>" + t + "</a>")
                  .appendTo(ul);
    };
}

function InizializzaEmailTextBox(id, txtNoEmail) {
    var ctl = document.getElementById(id);
    if (ctl.value == txtNoEmail) ctl.value = "";
}

function CheckEmailTextBox(id, text) {
    var ctl = document.getElementById(id);
    if (ctl.value == "") {
        ctl.value = text;
    }
}

function Ricerca(alertMsg) 
{
    var txtQuery = $('#ctl00_txtRicerca').val();
    if (txtQuery == '')
    {
        alert(alertMsg);
        return false;
    }
    else 
    {     
        return true;
    }
}

/* Inizializzazione widget jquery */

$(function() {

    $('#hlImgCarrello').click(function() {
        EspandiCarrello();
    });

    $('#hlImgWishList').click(function() {
        EspandiWhishList();
    });
});

$(document).ready(function() {
    $("#popupLogin").dialog({ autoOpen: false,
        width: 590,
        title: 'Login',
        open: function() { $(this).parent().appendTo("form"); },
        modal: true,
        resizable: false
    });
});

$(document).ready(function() {
    $("#ctl00_MenuMplaza").supersubs({
        minWidth: 3,
        maxWidth: 20,
        extraWidth: 1
    }).superfish({
        animation: { opacity: 'show' },   // slide-down effect without fade-in */
        delay: 0,              // 1.2 second delay on mouseout 
        speed: 0.5,
        autoArrows: false,
        dropShadows: false
    });
});

$(document).ready(function() {
    $("#listaPulsanti").superfish({
        animation: { opacity: 'show' },   // slide-down effect without fade-in */
        delay: 0,
        speed: 200,
        autoArrows: false,
        dropShadows: false
        
    });
});

/* Scrollable Widgets */

$(document).ready(function() {
    $("#ctl00_Menu").superfish({
        animation: { opacity: 'show' },   // slide-down effect without fade-in */
        delay: 0,
        speed: 0.1,
        autoArrows: false,
        dropShadows: false,
        onShow: function() { if ($("#ctl00_imgEspandiMenu") != null) $("#ctl00_imgEspandiMenu").attr('src', 'img/MasterPage/btnEspandiMenuHover.png') },
        onHide: function() { if ($("#ctl00_imgEspandiMenu") != null) $("#ctl00_imgEspandiMenu").attr('src', 'img/MasterPage/btnEspandiMenu.png') }

    });
});

$(function() {
    $("#RotatorProdotti").scrollable({
        vertical: true,
        loop: true,
        size: 3,
        circular: true
    }).autoscroll({ autoplay: true, steps: 1, interval: 4000 });
});


/*** Tooltip JQuery ***/
/*$(document).ready(function() {
    $(".TooltipJQuery").qtip({
        content: { text: false },
        hide:
            {
                effect:
                {
                    type: 'grow',
                    length: 300
                }
            },
        show:
            {
                effect:
                {
                    type: 'grow',
                    length: 300
                }
            }
    });
});*/
