﻿$(document).ready(function () {
    $(document).pngFix();
    $('#tab_content').tabs();
    $('.popupme').fancybox();
    $('#company_info').fancybox();
    $('#credits_info').fancybox();
    $("#privacy_info").fancybox({
        'width': '75%',
        'height': '75%',
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe'
    });
    $("#privacy_form").fancybox({
        'width': '75%',
        'height': '75%',
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe'
    });


    $("a[rel=foto_gallery]").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'titlePosition': 'over',
        'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });

    /* gestione cambio lingua */
    //$('#LangNav a').eq(0).click(function () { if (window.location.pathname != "/default.aspx") { $(this).attr('href', window.location.pathname.replace("/en/", "/it/")); } });
    //$('#LangNav a').eq(1).click(function () { if (window.location.pathname != "/default.aspx") { $(this).attr('href', window.location.pathname.replace("/it/", "/en/")); } });
    if (window.location.pathname != "/default.aspx" && window.location.pathname != "/") {
        $('#LangNav a').eq(0).click(function () { $(this).attr('href', window.location.pathname.replace("/en/", "/it/")); });
        $('#LangNav a').eq(1).click(function () { $(this).attr('href', window.location.pathname.replace("/it/", "/en/")); });
    }

    /* gestione provvisoria pop-up controllo età */
    var doFadeIn = function () {
        $('.fadein').css({ opacity: 0, visibility: 'visible' }).fadeTo(250, 1);
    };
    $('body').one('mousemove', doFadeIn);

    $("a.yes").click(function () {
        $(".over").fadeOut("slow");
    });

    /* galleria home page */
    $('#HomeSlideShow').cycle({
        fx: 'fade'
    });

});

function confirm_age(l) {
    var dataString = 'f=wok';
    var xhr = $.ajax({
        type: "POST",
        url: "/act.aspx",
        data: dataString,
        success: function (data, status) {
            document.location.href = '/'+l+'/';
        }
    });
    return false;
}
