
/* Copyright © Website Engineers Limited */

// Content
var content = {
    clear:
    function () {
        $(".ContentLoading").show();
        $(".ContentData").hide();
        $(".ContentData").html("");
        $(".Links p").each(
            function () {
                $(this).removeClass("True");
            }
        );
    },
    show:
    function (id, html) {
        $("#link_" + id).addClass("True");
        $(".ContentData").html(html);
        $(".ContentLoading").fadeOut("slow",
            function () {
                $(".ContentData").fadeIn("slow");
                switch (id) {
                    case "content_default":
                        $("#content_default").jcarousel({ scroll: 1, wrap: "circular", itemFallbackDimension: 267 });
                        $("#content_default a").lightBox({ fixedNavigation: true });
                        break;
                    case "content_restaurant":
                        $("#content_restaurant").jcarousel({ scroll: 1, wrap: "circular", itemFallbackDimension: 267 });
                        break;
                    case "content_menu":
                        $("#content_menu a").lightBox({ fixedNavigation: true });
                        break;
                    case "content_findus":
                        $("#content_findus a").lightBox({ fixedNavigation: true });
                        break;
                }
            }
        );
    },
    load:
    function (id) {
        var contentUrl = "/" + id + ".aspx";
        content.clear();
        $.ajax(
            {
                type: "POST",
                url: contentUrl,
                dataType: "text",
                success: function (text) { content.show(id, text) },
                error: function () { alert("Ajax error") }
            }
        );
    }
}

// Flash
var flash = {
    embed:
    function (id, movie, width, height) {
        var flashHtml = '';
        flashHtml += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" id="Flash' + id + '">';
        flashHtml += '<param name="movie" value="' + movie + '" />';
        flashHtml += '<param name="menu" value="false" />';
        flashHtml += '<param name="quality" value="high" />';
        flashHtml += '<param name="bgcolor" value="#000000" />';
        flashHtml += '<param name="wmode" value="transparent" />';
        flashHtml += '<embed src="' + movie + '" quality="high" menu="false" wmode="transparent" bgcolor="#000000" width="' + width + '" height="' + height + '" name="Flash' + id + '" type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed>';
        flashHtml += '</object>';
        $("#" + id).html(flashHtml);
        $("#Soundwave").removeClass(id);
    }
}


// Sound
var sound = {
    agra3Sound: null, 
    loadFlash:
    function () {
        flash.embed("Soundwave", "/flash/soundwaves.swf", 200, 200);
    },
    killFlash:
    function () {
        $("#Soundwave").html("");
        $("#Soundwave").addClass("Soundwave");
    },
    startSoundManager:
    function () {
        soundManager.url = "/sound/";
        soundManager.useFlashBlock = false;
        soundManager.debugMode = false;
        soundManager.onready(
            function (oStatus) {
                if (oStatus.success) {
                    sound.agra3Sound = soundManager.createSound(
                        {
                            id: "agra3Sound",
                            url: "sound/agra3.mp3"
                        }
                    );
                    sound.agra3Sound.play();
                    sound.loadFlash();
                }
                else {
                    alert("To hear sound, please install the latest Flash player.");
                }
            }
        );
    },
    on:
    function () {
        sound.agra3Sound.play();
        sound.loadFlash();
    },
    off:
    function () {
        sound.agra3Sound.pause();
        sound.killFlash();
    }
}

// Page Load
$(document).ready(
    function () {
        // Content
        $(".Links p").click(
            function () {
                //if (this.id == "link_content_menu") {
                //    window.open("/pdf/menu.pdf", "Agra3");
                //}
                //else {
                    content.load(this.id.replace("link_", ""));
                //}
            }
        );
        content.load("content_default");
        // Sound 
        $("#SoundOn").change(
            function () {
                sound.on();
            }
        );
        $("#SoundOff").change(
            function () {
                sound.off();
            }
        );
        sound.startSoundManager();
    }
);

/* End */

