﻿/// <reference path="../../../../Javascript/jquery-1.3.2.min-vsdoc.js" />
(function(F, C) { var D = function(H) { var G, I = []; for (G in H) { if (/string|number/.test(typeof H[G]) && H[G] !== "") { I.push(G + '="' + H[G] + '"') } } return I[A]("") }, E = function(I) { var G, K, J = [], H; if (typeof I == "object") { for (G in I) { if (typeof I[G] == "object") { H = []; for (K in I[G]) { H.push([K, "=", encodeURIComponent(I[G][K])][A]("")) } I[G] = H[A]("&amp;") } if (I[G]) { J.push(['<param name="', G, '" value="', I[G], '" />'][A]("")) } } I = J[A]("") } return I }, B = false, A = "join"; F[C] = (function() { try { var G = "0,0,0", H = navigator.plugins["Shockwave Flash"] || ActiveXObject; G = H.description || (function() { try { return (new H("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version") } catch (J) { } } ()) } catch (I) { } G = G.match(/^[A-Za-z\s]*?(\d+)[\.|,](\d+)(?:\s+[d|r]|,)(\d+)/); return { available: G[1] > 0, activeX: H && !H.name, version: { major: G[1] * 1, minor: G[2] * 1, release: G[3] * 1 }, hasVersion: function(K) { var N = this.version, L = "major", M = "minor", J = "release"; K = (/string|number/.test(typeof K)) ? K.toString().split(".") : K || [0, 0, 0]; K = [K[L] || K[0] || N[L], K[M] || K[1] || N[M], K[J] || K[2] || N[J]]; return (K[0] < N[L]) || (K[0] == N[L] && K[1] < N[M]) || (K[0] == N[L] && K[1] == N[M] && K[2] <= N[J]) }, expressInstall: "expressInstall.swf", create: function(J) { if (!F[C].available || B || !typeof J == "object" || !J.swf) { return false } if (J.hasVersion && !F[C].hasVersion(J.hasVersion)) { J = { swf: J.expressInstall || F[C].expressInstall, attrs: { id: J.id || "SWFObjectExprInst", name: J.name, height: Math.max(J.height || 137), width: Math.max(J.width || 214) }, params: { flashvars: { MMredirectURL: location.href, MMplayerType: (F[C].activeX) ? "ActiveX" : "PlugIn", MMdoctitle: document.title.slice(0, 47) + " - Flash Player Installation"}} }; B = true } else { J = F.extend(true, { attrs: { id: J.id, name: J.name, height: J.height || 180, width: J.width || 320 }, params: { wmode: J.wmode || "opaque", flashvars: J.flashvars} }, J) } if (F[C].activeX) { J.attrs.classid = J.attrs.classid || "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; J.params.movie = J.params.movie || J.swf } else { J.attrs.type = J.attrs.classid || "application/x-shockwave-flash"; J.attrs.data = J.attrs.data || J.swf } return ["<object ", D(J.attrs), ">", E(J.params), "</object>"][A]("") } } } ()); F.fn[C] = function(G) { if (typeof G == "object") { this.each(function() { var I = document.createElement(C); var H = F[C].create(G); if (H) { I.innerHTML = H; if (I.childNodes[0]) { this.appendChild(I.childNodes[0]) } } }) } else { if (typeof G == "function") { this.find("object").andSelf().filter("object").each(function() { var I = this, H = "jsInteractionTimeoutMs"; I[H] = I[H] || 0; if (I[H] < 660) { if (I.clientWidth || I.clientHeight) { G.call(this) } else { setTimeout(function() { F(I)[C](G) }, I[H] + 66) } } }) } } return this } } (jQuery, "flash"));

$(window).load(ini);
$(email);
$(intro);
$(Plattegrond);

function ini() {

    var CountImages = $("#Gallery li").size() - 1;
    var Counter = 0;

    $("#Gallery li").css({ "float": "left", "opacity": "0.5" });
    $("#Gallery li:first-child").css({ "opacity": "1" });

    var MarginLeft = ($("#GalleryContainer").width() - $("#Gallery > li:first-child").width()) / 2;

    $("#Gallery").css({ "margin-left": MarginLeft + "px" });

    //Add prev and next
    var Previous = $("<img src='/template/raj_restaurant_nl/binaryresource/theme/default/images/arrowLeft.png'>").click(Prev);
    var Next = $("<img src='/template/raj_restaurant_nl/binaryresource/theme/default/images/arrowRight.png'>").click(Nex);
    var NaviContainer = $("<div id='NaviContainer'></div>");
    NaviContainer.append(Previous).append(Next);
    $("#Gallery").after(NaviContainer);




    // functions
    function Prev() {
        if (Counter > 0) {
            var CurrentListItem = $("#Gallery li").eq(Counter);
            Counter -= 1;
            var NextListItem = $("#Gallery li").eq(Counter);

            MarginLeft += (CurrentListItem.width() / 2) + (NextListItem.width() / 2) + 15;

            $("#Gallery").animate({ marginLeft: MarginLeft + "px" }, "normal", "swing");
            CurrentListItem.animate({ "opacity": ".5" }, "normal");
            NextListItem.animate({ "opacity": "1" }, "normal");
        }
    }

    function Nex() {
        if (Counter < CountImages) {
            var CurrentListItem = $("#Gallery li").eq(Counter);
            Counter += 1;
            var NextListItem = $("#Gallery li").eq(Counter);

            MarginLeft -= (CurrentListItem.width() / 2) + (NextListItem.width() / 2) + 15;

            $("#Gallery").animate({ marginLeft: MarginLeft + "px" }, "normal", "swing");
            CurrentListItem.animate({ "opacity": ".5" }, "normal");
            NextListItem.animate({ "opacity": "1" }, "normal");
        }
    }
}


function email() {
    $(".emailSpan").html("<a href='mailto:resto@raj.be'>resto@raj.be</a>");
}

function intro() {
    if ($("#Intro").length) {
        var flashUrl = $("#Intro").text();
        $("#Intro").html("")
                   .flash({
                       swf: flashUrl,
                       width: 568,
                       height: 414
                   });
    }
}

/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
* @author Ariel Flesler
* @version 1.4.2
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
(function(d) { var k = d.scrollTo = function(a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function(a) { return d(window)._scrollable() }; d.fn._scrollable = function() { return this.map(function() { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function(n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function() { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function(a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function() { a.call(this, n, b) }) } }).end() }; k.max = function(a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

function Plattegrond() {
    if ($("#Plattegrond").length) {
        $("#Tafels #BigImage").show();

        $("#Tafels a").click(function() {
            changeBigImage($(this));
            return false;
        });

        function changeBigImage(s) {
            var url = s.attr("href");
            $("#Tafels #BigImage img").attr("src", url);
            reset_o();
            $("#Tafels #BigImage").scrollTo("100%", 10000).scrollTo(0, 10000);
        }

        function reset_o() {//before each animation, reset to (0,0), skip this.
            $("#Tafels #BigImage").stop(true).attr({ scrollLeft: 0, scrollTop: 0 });
        };
    };
};


