$(document).ready(function() { //import scripts only when required

    switch (siteCode) { //specific site script initializations only
        case "CA":
            try {
                var siteDownload = "/directdownload-it.asp";

                //TABS
                try {
                    if ($("#tab-container").length > 0) {
                        $(".tabs").tabs(".panes > div", { initialIndex: 0, effect: "fade", fadeInSpeed: 800, fadeOutSpeed: 800 });
                    }
                } catch (h) { }

                //LOGO
                try {
                    flashembed("calogoflash",
                    { src: "/images/flash/ca/ca_logoflash.swf", wmode: "transparent", version: [9, 0] },
                    { homelink: "/" });
                } catch (err) { alert(err.description); }

                //BUTTON       
                if ($("#free500").length > 0) {

                    switch (currency) {
                        case "GBP":
                            curValue = "gbp";
                            break;
                        case "EURO":
                            curValue = "eur";
                            break;
                        default:
                            curValue = "usd";
                            break;
                    }
                    flashembed("free500",
                    { src: "/images/flash/ca/downloadbutton_it.swf", wmode: "transparent", version: [9, 0] },
                    { downlink: siteDownload, siteCurr: curValue });
                }

                //MOVIE
                if ($("#camovie").length > 0) {
                    flashembed("camovie",
                    { src: "/images/flash/ca/ca_movie_it.swf", wmode: "transparent", version: [9, 0] },
                    { downlink: siteDownload });
                }
            } catch (err) { }
            break;

        case "ZC":
            try {
                if ($("#midground").length > 0) {
                    $('#midground').css({ backgroundPosition: '0px 0px' });
                    $('#foreground').css({ backgroundPosition: '0px 0px' });
                    $('#midground').animate({
                        backgroundPosition: "(-10000px -2000px)"
                    }, 240000, 'linear');
                    $('#foreground').animate({
                        backgroundPosition: "(-10000px -2000px)"
                    }, 120000, 'linear');
                }
            } catch (err) { }

            /* FLASH MOVIE EMBED */
            try {
                var siteDownload = "/directdownload-it.asp";
                if ($("#zcmovieA").length > 0) {
                    switch (currency) {
                        case "GBP":
                            curValue = "gbp";
                            break;
                        case "EURO":
                            curValue = "eur"
                            break;
                        default:
                            curValue = "usd";
                            break;
                    }
                    flashembed("zcmovieA",
                        { src: "/images/flash/zc/zc_bonus-v3c_it.swf", wmode: "opaque", version: [9, 0] },
                        { downlink: siteDownload, siteCurr: curValue });
                }
                if ($("#zcmovieB").length > 0) {
                    switch (currency) {
                        case "GBP":
                            curValue = "gbp";
                            break;
                        case "EURO":
                            curValue = "eur"
                            break;
                        default:
                            curValue = "usd";
                            break;
                    }
                    flashembed("zcmovieB",
                        { src: "/images/flash/zc/zc_bonus-v3d_it.swf", wmode: "opaque", version: [9, 0] },
                        { downlink: siteDownload, siteCurr: curValue });
                }

            } catch (err) { }

            break;
            
    }

    //FOR ALL SITES

    //TOOLTIPS
    try {
        if ($("#Table_DL > a").length > 0) {
            $("#Table_DL a").tooltip({ tip: ".tooltip", position: "bottom right", relative: true });
        }
    } catch (h) { }

    //RSS
    try {
        if ($(".rssarea").length > 0) {
            setTimeout(function() {
                rssTicker(".rssarea .headline");
            },
            666);
        }
    } catch (err) { }

    //VIDEO
    try {
        if ($("#videoLayer").length > 0) {
            setTimeout(function() {
                createplayer();
            },
            666);
        }
    } catch (err) { }

    //PROGRESSIVES
    try {
        if (($("input[name=progressive55]").length > 0) || ($("input[name^=progressive]").length > 0)) { //We Need Tickers
            $.ajax({
                type: "GET",
                url: "http://www.tickerassist.co.uk/ProgressiveTickers/WebServiceProgressiveTickerScript.asmx/renderScript?form=json",
                success: function() {
                    setTimeout(function() {
                        if ($("input[name^=progressive]").length > 0) {
                            counter = $("input[name^=progressive]").length;
                            switch (counter) {
                                case 16:
                                    try {
                                        ScrollTotals(currency);
                                        ShowCounters(currency);
                                    } catch (err) { }
                                    break;
                                default:
                                    if ($("input[name=progressive55]").length > 0) {
                                        try {
                                            ScrollTotals(currency);
                                        } catch (err) { }
                                    } else {
                                        try {
                                            thisCounter = $("input[name^=progressive]").attr("name").replace("progressive", "");
                                            ScrollCounters(thisCounter, currency);
                                        } catch (err) { }
                                    }
                                    break;
                            }
                        }
                    },
                    2000);
                },
                dataType: "script",
                cache: false
            });
        }
    } catch (err) { }

    //SCROLLING MARQUEE
    try {
        /*if ($("div#contact").length > 0) { //Check The Contact Numbers Marquee Exists
        setTimeout(function () {
        $("div#contact").show();
        $("div#contact marquee").marquee();
        },
        666);
        }*/

        if ($("#marqueeScroller").length > 0) {
            setTimeout(function() {
                // initialize scrollable together with the autoscroll plugin
                window.api = $("#marqueeScroller").scrollable({
                    //Scrollable configuration
                    size: 1,
                    loop: true,
                    speed: 2000,
                    keyboard: false,
                    clickable: false,
                    vertical: false
                }).circular().autoscroll({
                    //Autoscroll configuration
                    autoplay: true,
                    api: true,
                    autopause: false,
                    interval: 3000
                });
            }, 666)
        }
    } catch (err) { }

    //SCROLLER 1
    try {
        /*if ($("div#s2").length > 0) { //Check The Game Scroller S2 Exists
        setTimeout(function () {
        $("div#s2").show();
        $('#s2').cycle({
        fx: 'scrollDown',
        easing: 'backinout',
        timeout: 1000,
        delay: -500
        });
        },
        666);
        }*/
        if ($("div#s2").length > 0) {
            setTimeout(function() {
                //Custom scroll effect
                $.easing.custom = function(e, f, a, i, h) { var g = 1.70158; if ((f /= h / 2) < 1) { return i / 2 * (f * f * (((g *= (1.525)) + 1) * f - g)) + a } return i / 2 * ((f -= 2) * f * (((g *= (1.525)) + 1) * f + g) + 2) + a }

                // initialize scrollable together with the autoscroll plugin
                window.api = $("#s2").scrollable({
                    //Scrollable configuration
                    size: 1,
                    vertical: true,
                    loop: true,
                    keyboard: false,
                    clickable: false,
                    easing: "custom",
                    speed: 1500
                }).circular().autoscroll({
                    //Autoscroll configuration
                    autoplay: true,
                    api: true,
                    autopause: false
                });
            }, 666)
        }
    } catch (err) { }

    //SCROLLER 2
    try {
        /*if ($("div#s3").length > 0) { //Check The Game Scroller S3 Exists
        setTimeout(function () {
        $("div#s3").show();
        $('#s3').cycle({
        fx: 'scrollDown',
        timeout: 250,
        delay: -250
        });
        },
        666);
        }*/
        if ($("div#s3").length > 0) {
            setTimeout(function() {
                //Custom scroll effect
                $.easing.custom = function(e, f, a, i, h) { var g = 1.70158; if ((f /= h / 2) < 1) { return i / 2 * (f * f * (((g *= (1.525)) + 1) * f - g)) + a } return i / 2 * ((f -= 2) * f * (((g *= (1.525)) + 1) * f + g) + 2) + a }

                // initialize scrollable together with the autoscroll plugin
                window.api = $("#s3").scrollable({
                    //Scrollable configuration
                    size: 1,
                    vertical: true,
                    loop: true,
                    keyboard: false,
                    clickable: false,
                    easing: "custom",
                    speed: 1500
                }).circular().autoscroll({
                    //Autoscroll configuration
                    autoplay: true,
                    api: true,
                    autopause: false
                });
            }, 666)
        }
    } catch (err) { }

    try {
        if ($("a.download").length > 0) {
            setTimeout(function() {
                tb_download_init('a.download')
            },
            666);
        }
    } catch (err) { }
});

function tb_download_init(domChunk) {
    $(domChunk).click(function() {
        var t = "Scarica il nostro software del casin&#x00F2;, sicuro al 100%"; //this.title || this.name || null;
        var a = this.rev + "?TB_iframe=true&height=160&width=440&modal=false" || null;
        var g = this.rel || false;
        tb_show(t, a, g);
        this.blur();
        return true;
    });
}