﻿
/*************************************/
/***** 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 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)
{{
    if(document.aspnetForm.ctl00$txtRicerca.value=='')
    {{
        alert(alertMsg);
        return false;
    }}
    else
    {{
        document.aspnetForm.action='ricerca.aspx';
        return true;
    }}
}}

/* Inizializzazione widget jquery */

$(function() {

    $('#hlImgCarrello').click(function() {
        EspandiCarrello();
    });

    $('#hlImgWishList').click(function() {
        EspandiWhishList();
    });
});

$(document).ready(function() {
    $("#popupLogin").dialog({ autoOpen: false,
        height: 270,
        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(){
    $("#Clubs").scrollable({
            disabledClass: "FrecciaDisabilitata",
            circular: false,
            onBeforeSeek: function() {
                $("#ctl00_ContentPlaceHolderCenter_clubs .paginaScrl")[0].innerHTML = this.getIndex() + 1;
                $("#ctl00_ContentPlaceHolderCenter_clubs .numPagineScrl")[0].innerHTML = this.getSize();
            },  
            onSeek: function() {
                $("#ctl00_ContentPlaceHolderCenter_clubs .paginaScrl")[0].innerHTML = this.getIndex() + 1;
                $("#ctl00_ContentPlaceHolderCenter_clubs .numPagineScrl")[0].innerHTML = this.getSize();
            }
        })
    });

$(function() {
    $("#Nationals").scrollable({
        disabledClass: "FrecciaDisabilitata",
        circular: false,
        onBeforeSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_nazionali .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_nazionali .numPagineScrl")[0].innerHTML = this.getSize();
        },  
        onSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_nazionali .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_nazionali .numPagineScrl")[0].innerHTML = this.getSize();
        }
    })
});

$(function() {
    $("#Players").scrollable({
        disabledClass: "FrecciaDisabilitata",
        circular: false,
        onBeforeSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_players .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_players .numPagineScrl")[0].innerHTML = this.getSize();
        },        
        onSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_players .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_players .numPagineScrl")[0].innerHTML = this.getSize();
        }
    })
});

$(function() {
    $("#brandsSez").scrollable({
        disabledClass: "FrecciaDisabilitata",
        circular: false,
        onBeforeSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_brands .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_brands .numPagineScrl")[0].innerHTML = this.getSize();
        },  
        onSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_brands .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_brands .numPagineScrl")[0].innerHTML = this.getSize();
        }
    })
});

$(function() {
    $("#MarcheScr").scrollable({
        disabledClass: "FrecciaDisabilitata",
        circular: false,
        onBeforeSeek: function() {
            $("#ctl00_ContentPlaceHolderCenter_marche .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_marche .numPagineScrl")[0].innerHTML = this.getSize();
        },
        onSeek: function() {

            $("#ctl00_ContentPlaceHolderCenter_marche .paginaScrl")[0].innerHTML = this.getIndex() + 1;
            $("#ctl00_ContentPlaceHolderCenter_marche .numPagineScrl")[0].innerHTML = this.getSize();
        }
    });
});

$(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
                }
            }
    });
});


function LoadThisImage(loader) {
    var img = new Image();
    $(img).load(function() {
        $(this).css('display', 'none'); 
        // .hide() doesn't work in Safari when the element isn't on the DOM already
        //$(this).hide();
        $(this).attr('height', 75);
        $(this).attr('width', 75);

        loader.removeClass('loading').append(this);
        $(this).fadeIn();
    }).error(function() {
        // notify the user that the image could not be loaded
    }).attr('src', loader.attr('src')
    ).attr('alt', loader.attr('alt'));
};


$(function() {
    $('.loadable-image').each(function() {
        var loader = $(this);
        setTimeout(function(){LoadThisImage(loader)},20);
    });
});




