﻿var months = new Array(12);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var currentJSmonthInt = (new Date().getMonth());

var page = {
    tr: null,
    init: function () {
        page.tr = $("#gallery").fadeTransition({ pauseTime: 6000, transitionTime: 2000, ignore: "", delayStart: 100 });
        $("#gallery .navigation").each(function () {
            $(this).children().each(function (idx) {
                if ($(this).is("a"))
                    $(this).click(function () { page.tr.showItem(idx); return false; })
            });
        });
        $("#gallery .navigation a").first().addClass("galleryNavActive");
    },

    show: function (idx) {
        if (page.tr.timer) clearTimeout(page.tr.timer);
        page.tr.showItem(idx);
    }
};

function populateCalendar(month) {
    $('#selectcalendarmonth').html('Loading...');
    if (month < 0) { month = 11; }
    if (month > 11) { month = 0; }
    var caldiv = $('#calendarcontent');
    $(caldiv).fadeOut(function() {
        $.ajax({
            url: '/Calendar/' + (month + 1),
            context: $('#calendarcontent'),
            success: function(response) {
                $(this).html(response).fadeIn();
                currentJSmonthInt = month;
                $('#selectcalendarmonth').html(months[currentJSmonthInt]);
            }
        });
    });
    
}

/* Document is ready code */
//$(document).ready(page.init);
$(document).ready(function() {
    if ($("#gallery .rotator").size() > 1) page.init();

    $('.contactusheader').click(function() { _gaq.push(['_trackEvent', 'Enquiry', 'Contact Us - Header', $(this).attr('href')]); });

    $('.ctaenquirenow').click(function() { _gaq.push(['_trackEvent', 'Enquiry', 'Enquire Now - RHS', $(this).attr('href')]); }); ;

    $(".wpcontent a:has(img)").fancybox({
        'scrolling': 'no',
        'titleShow': false,
        'width': 720,
        'autoDimensions': false,
        'onClosed': function () { },
        'overlayOpacity': 0.8,
        'overlayColor': '#000'
    });

    //$("a:has(img)").attr("title", "Click to enlarge").fancybox();

    //$("a[href$='.jpg'],a[href$='.png'],a[href$='.gif']").attr("title", "Click to enlarge").fancybox();

    $("#showMap").fancybox({
        'scrolling': 'no',
        'titleShow': false,
        'autoScale': false,
        'onClosed': function() { },
        'overlayOpacity': 0.8,
        'overlayColor': '#000',
        'onComplete': function() { $('.map').maphilight(); }
    });

    $(".exploreGallery").fancybox({
        'scrolling': 'no',
        'titleShow': false,
        'cyclic': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#000'
    });

    $('#exploreInPicturesLink').click(function() { $(".exploreGallery").trigger('click'); });

    $('.clientstory-scroll-pane').jScrollPane(
		{
		    showArrows: true,
		    horizontalGutter: 10,
		    verticalArrowPositions: 'os',
		    horizontalArrowPositions: 'os'
		}
	);

    $('.hijax').fancybox({
        'scrolling': 'no',
        'titleShow': false,
        'width': 720,
        'autoDimensions': false,
        'onClosed': function() { },
        'overlayOpacity': 0.8,
        'overlayColor': '#000'
    });

    if ($('#calendarcontent').length > 0) {
        // Calendar exists on page, so populate
        $('#calendarback').click(function() { populateCalendar(currentJSmonthInt - 1); });
        $('#calendarforward').click(function() { populateCalendar(currentJSmonthInt + 1); });
        populateCalendar(currentJSmonthInt);
    }


    $(window).load(
        function() {
            // Only runs once all images have finished loading too
            // So no recheck the scroll areas, incase images were included
            if ($('.clientstory-scroll-pane').size() > 0) $('.clientstory-scroll-pane').jScrollPane().each(function() { var api = $(this).data('jsp'); api.reinitialise(); });
        }
    );


});


var amountToScrollModule = 707;
function moduleScrollLeft(t) {
    var el = $(t).parent().next();
    var fullWidth = el.width();
    var l = el.position().left;
    var leftMod = $(t).parent().find('.scrollModuleLeft');
    if (((l * -1) + amountToScrollModule) < fullWidth) {
        //$('.scrollModuleLeft').fadeIn();
        leftMod.fadeIn();
        el.animate({ 'left': '-=' + amountToScrollModule + 'px' }, 'fast', function() {
            var l = el.position().left;
            var rightMod = $(t).parent().find('.scrollModuleRight');
            if (fullWidth < ((l * -1) + amountToScrollModule)) rightMod.fadeOut();
        });
    }
}

function moduleScrollRight(t) {
    var el = $(t).parent().next();
    var l = el.position().left;
    if ((l * -1) > 0) {
        var leftMod = $(t).parent().find('.scrollModuleLeft');
        var rightMod = $(t).parent().find('.scrollModuleRight');
        rightMod.fadeIn();
        el.animate({ 'left': '+=' + amountToScrollModule + 'px' }, 'fast', function() { l = el.position().left; if ((l * -1) < 1) leftMod.fadeOut(); });
    }
}

/* Fader */
(function($) {
    $.fn.fadeTransition = function(options) {
        var options = $.extend({ pauseTime: 6000, transitionTime: 2000, ignore: null, delayStart: 6000, pauseNavigation: false }, options);
        var transitionObject;

        Trans = function(obj) {
            var timer = null;
            var current = 0;
            var els = (options.ignore) ? $("> *:not(" + options.ignore + ")", obj) : $("> *:not('.navigation)", obj);
            $(obj).css("position", "relative");
            els.css("display", "none").css("left", "0").css("top", "0").css("position", "absolute");

            if (options.delayStart > 0) {
                setTimeout(showFirst, options.delayStart);
            }
            else
                showFirst();

            function showFirst() {
                if (options.ignore) {
                    $(options.ignore, obj).fadeOut(options.transitionTime);
                    $(els[current]).fadeIn(options.transitionTime);
                }
                else {
                    $(els[current]).css("display", "block");
                }
            }

            function transition(next) {
                $('#' + $(els[current]).attr('id') + 'Nav').removeClass('galleryNavActive');
                $(els[current]).fadeOut(options.transitionTime);
                $('#' + $(els[next]).attr('id') + 'Nav').addClass('galleryNavActive');
                $(els[next]).fadeIn(options.transitionTime);
                current = next;
                cue();
            };

            function cue() {
                if ($("> *", obj).length < 2) return false;
                if (timer) clearTimeout(timer);
                if (!options.pauseNavigation) {
                    timer = setTimeout(function() { transition((current + 1) % els.length | 0) }, options.pauseTime);
                }
            };

            this.showItem = function(item) {
                if (timer) clearTimeout(timer);
                transition(item);
            };

            cue();
        }

        this.showItem = function(item) {
            transitionObject.showItem(item);
        };

        return this.each(function() {
            transitionObject = new Trans(this);
        });
    }

})(jQuery);


/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
* 
* Copyright (c) 2008 - 2010 Janis Skarnelis
*
* Version: 1.3.1 (05/03/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/

(function(b) {
    var m, u, x, g, D, i, z, A, B, p = 0, e = {}, q = [], n = 0, c = {}, j = [], E = null, s = new Image, G = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, S = /[^\.]\.(swf)\s*$/i, H, I = 1, k, l, h = false, y = b.extend(b("<div/>")[0], { prop: 0 }), v = 0, O = !b.support.opacity && !window.XMLHttpRequest, J = function() { u.hide(); s.onerror = s.onload = null; E && E.abort(); m.empty() }, P = function() { b.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', { scrolling: "no", padding: 20, transitionIn: "none", transitionOut: "none" }) },
K = function() { return [b(window).width(), b(window).height(), b(document).scrollLeft(), b(document).scrollTop()] }, T = function() {
    var a = K(), d = {}, f = c.margin, o = c.autoScale, t = (20 + f) * 2, w = (20 + f) * 2, r = c.padding * 2; if (c.width.toString().indexOf("%") > -1) { d.width = a[0] * parseFloat(c.width) / 100 - 40; o = false } else d.width = c.width + r; if (c.height.toString().indexOf("%") > -1) { d.height = a[1] * parseFloat(c.height) / 100 - 40; o = false } else d.height = c.height + r; if (o && (d.width > a[0] - t || d.height > a[1] - w)) if (e.type == "image" || e.type == "swf") {
        t += r;
        w += r; o = Math.min(Math.min(a[0] - t, c.width) / c.width, Math.min(a[1] - w, c.height) / c.height); d.width = Math.round(o * (d.width - r)) + r; d.height = Math.round(o * (d.height - r)) + r
    } else { d.width = Math.min(d.width, a[0] - t); d.height = Math.min(d.height, a[1] - w) } d.top = a[3] + (a[1] - (d.height + 40)) * 0.5; d.left = a[2] + (a[0] - (d.width + 40)) * 0.5; if (c.autoScale === false) { d.top = Math.max(a[3] + f, d.top); d.left = Math.max(a[2] + f, d.left) } return d
}, U = function(a) {
    if (a && a.length) switch (c.titlePosition) {
        case "inside": return a; case "over": return '<span id="fancybox-title-over">' +
a + "</span>"; default: return '<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">' + a + '</span><span id="fancybox-title-right"></span></span>'
    } return false
}, V = function() {
    var a = c.title, d = l.width - c.padding * 2, f = "fancybox-title-" + c.titlePosition; b("#fancybox-title").remove(); v = 0; if (c.titleShow !== false) {
        a = b.isFunction(c.titleFormat) ? c.titleFormat(a, j, n, c) : U(a); if (!(!a || a === "")) {
            b('<div id="fancybox-title" class="' + f + '" />').css({ width: d, paddingLeft: c.padding,
                paddingRight: c.padding
            }).html(a).appendTo("body"); switch (c.titlePosition) { case "inside": v = b("#fancybox-title").outerHeight(true) - c.padding; l.height += v; break; case "over": b("#fancybox-title").css("bottom", c.padding); break; default: b("#fancybox-title").css("bottom", b("#fancybox-title").outerHeight(true) * -1); break } b("#fancybox-title").appendTo(D).hide()
        } 
    } 
}, W = function() {
    b(document).unbind("keydown.fb").bind("keydown.fb", function(a) {
        if (a.keyCode == 27 && c.enableEscapeButton) { a.preventDefault(); b.fancybox.close() } else if (a.keyCode ==
37) { a.preventDefault(); b.fancybox.prev() } else if (a.keyCode == 39) { a.preventDefault(); b.fancybox.next() } 
    }); if (b.fn.mousewheel) { g.unbind("mousewheel.fb"); j.length > 1 && g.bind("mousewheel.fb", function(a, d) { a.preventDefault(); h || d === 0 || (d > 0 ? b.fancybox.prev() : b.fancybox.next()) }) } if (c.showNavArrows) { if (c.cyclic && j.length > 1 || n !== 0) A.show(); if (c.cyclic && j.length > 1 || n != j.length - 1) B.show() } 
}, X = function() {
    var a, d; if (j.length - 1 > n) { a = j[n + 1].href; if (typeof a !== "undefined" && a.match(G)) { d = new Image; d.src = a } } if (n > 0) {
        a =
j[n - 1].href; if (typeof a !== "undefined" && a.match(G)) { d = new Image; d.src = a } 
    } 
}, L = function() {
    i.css("overflow", c.scrolling == "auto" ? c.type == "image" || c.type == "iframe" || c.type == "swf" ? "hidden" : "auto" : c.scrolling == "yes" ? "auto" : "visible"); if (!b.support.opacity) { i.get(0).style.removeAttribute("filter"); g.get(0).style.removeAttribute("filter") } b("#fancybox-title").show(); c.hideOnContentClick && i.one("click", b.fancybox.close); c.hideOnOverlayClick && x.one("click", b.fancybox.close); c.showCloseButton && z.show(); W(); b(window).bind("resize.fb",
b.fancybox.center); c.centerOnScroll ? b(window).bind("scroll.fb", b.fancybox.center) : b(window).unbind("scroll.fb"); b.isFunction(c.onComplete) && c.onComplete(j, n, c); h = false; X()
}, M = function(a) {
    var d = Math.round(k.width + (l.width - k.width) * a), f = Math.round(k.height + (l.height - k.height) * a), o = Math.round(k.top + (l.top - k.top) * a), t = Math.round(k.left + (l.left - k.left) * a); g.css({ width: d + "px", height: f + "px", top: o + "px", left: t + "px" }); d = Math.max(d - c.padding * 2, 0); f = Math.max(f - (c.padding * 2 + v * a), 0); i.css({ width: d + "px", height: f +
"px"
    }); if (typeof l.opacity !== "undefined") g.css("opacity", a < 0.5 ? 0.5 : a)
}, Y = function(a) { var d = a.offset(); d.top += parseFloat(a.css("paddingTop")) || 0; d.left += parseFloat(a.css("paddingLeft")) || 0; d.top += parseFloat(a.css("border-top-width")) || 0; d.left += parseFloat(a.css("border-left-width")) || 0; d.width = a.width(); d.height = a.height(); return d }, Q = function() {
    var a = e.orig ? b(e.orig) : false, d = {}; if (a && a.length) {
        a = Y(a); d = { width: a.width + c.padding * 2, height: a.height + c.padding * 2, top: a.top - c.padding - 20, left: a.left - c.padding -
20}
        } else { a = K(); d = { width: 1, height: 1, top: a[3] + a[1] * 0.5, left: a[2] + a[0] * 0.5} } return d
    }, N = function() {
        u.hide(); if (g.is(":visible") && b.isFunction(c.onCleanup)) if (c.onCleanup(j, n, c) === false) { b.event.trigger("fancybox-cancel"); h = false; return } j = q; n = p; c = e; i.get(0).scrollTop = 0; i.get(0).scrollLeft = 0; if (c.overlayShow) {
            O && b("select:not(#fancybox-tmp select)").filter(function() { return this.style.visibility !== "hidden" }).css({ visibility: "hidden" }).one("fancybox-cleanup", function() { this.style.visibility = "inherit" });
            x.css({ "background-color": c.overlayColor, opacity: c.overlayOpacity }).unbind().show()
        } l = T(); V(); if (g.is(":visible")) {
            b(z.add(A).add(B)).hide(); var a = g.position(), d; k = { top: a.top, left: a.left, width: g.width(), height: g.height() }; d = k.width == l.width && k.height == l.height; i.fadeOut(c.changeFade, function() {
                var f = function() { i.html(m.contents()).fadeIn(c.changeFade, L) }; b.event.trigger("fancybox-change"); i.empty().css("overflow", "hidden"); if (d) {
                    i.css({ top: c.padding, left: c.padding, width: Math.max(l.width - c.padding *
2, 1), height: Math.max(l.height - c.padding * 2 - v, 1)
                    }); f()
                } else { i.css({ top: c.padding, left: c.padding, width: Math.max(k.width - c.padding * 2, 1), height: Math.max(k.height - c.padding * 2, 1) }); y.prop = 0; b(y).animate({ prop: 1 }, { duration: c.changeSpeed, easing: c.easingChange, step: M, complete: f }) } 
            })
        } else {
            g.css("opacity", 1); if (c.transitionIn == "elastic") {
                k = Q(); i.css({ top: c.padding, left: c.padding, width: Math.max(k.width - c.padding * 2, 1), height: Math.max(k.height - c.padding * 2, 1) }).html(m.contents()); g.css(k).show(); if (c.opacity) l.opacity =
0; y.prop = 0; b(y).animate({ prop: 1 }, { duration: c.speedIn, easing: c.easingIn, step: M, complete: L })
            } else { i.css({ top: c.padding, left: c.padding, width: Math.max(l.width - c.padding * 2, 1), height: Math.max(l.height - c.padding * 2 - v, 1) }).html(m.contents()); g.css(l).fadeIn(c.transitionIn == "none" ? 0 : c.speedIn, L) } 
        } 
    }, F = function() { m.width(e.width); m.height(e.height); if (e.width == "auto") e.width = m.width(); if (e.height == "auto") e.height = m.height(); N() }, Z = function() {
        h = true; e.width = s.width; e.height = s.height; b("<img />").attr({ id: "fancybox-img",
            src: s.src, alt: e.title
        }).appendTo(m); N()
    }, C = function() {
        J(); var a = q[p], d, f, o, t, w; e = b.extend({}, b.fn.fancybox.defaults, typeof b(a).data("fancybox") == "undefined" ? e : b(a).data("fancybox")); o = a.title || b(a).title || e.title || ""; if (a.nodeName && !e.orig) e.orig = b(a).children("img:first").length ? b(a).children("img:first") : b(a); if (o === "" && e.orig) o = e.orig.attr("alt"); d = a.nodeName && /^(?:javascript|#)/i.test(a.href) ? e.href || null : e.href || a.href || null; if (e.type) { f = e.type; if (!d) d = e.content } else if (e.content) f = "html"; else if (d) if (d.match(G)) f =
"image"; else if (d.match(S)) f = "swf"; else if (b(a).hasClass("iframe")) f = "iframe"; else if (d.match(/#/)) { a = d.substr(d.indexOf("#")); f = b(a).length > 0 ? "inline" : "ajax" } else f = "ajax"; else f = "inline"; e.type = f; e.href = d; e.title = o; if (e.autoDimensions && e.type !== "iframe" && e.type !== "swf") { e.width = "auto"; e.height = "auto" } if (e.modal) { e.overlayShow = true; e.hideOnOverlayClick = false; e.hideOnContentClick = false; e.enableEscapeButton = false; e.showCloseButton = false } if (b.isFunction(e.onStart)) if (e.onStart(q, p, e) === false) {
            h = false;
            return
        } m.css("padding", 20 + e.padding + e.margin); b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change", function() { b(this).replaceWith(i.children()) }); switch (f) {
            case "html": m.html(e.content); F(); break; case "inline": b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup", function() { b(this).replaceWith(i.children()) }).bind("fancybox-cancel", function() { b(this).replaceWith(m.children()) }); b(a).appendTo(m); F(); break; case "image": h = false; b.fancybox.showActivity();
                s = new Image; s.onerror = function() { P() }; s.onload = function() { s.onerror = null; s.onload = null; Z() }; s.src = d; break; case "swf": t = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + e.width + '" height="' + e.height + '"><param name="movie" value="' + d + '"></param>'; w = ""; b.each(e.swf, function(r, R) { t += '<param name="' + r + '" value="' + R + '"></param>'; w += " " + r + '="' + R + '"' }); t += '<embed src="' + d + '" type="application/x-shockwave-flash" width="' + e.width + '" height="' + e.height + '"' + w + "></embed></object>"; m.html(t);
                F(); break; case "ajax": a = d.split("#", 2); f = e.ajax.data || {}; if (a.length > 1) { d = a[0]; if (typeof f == "string") f += "&selector=" + a[1]; else f.selector = a[1] } h = false; b.fancybox.showActivity(); E = b.ajax(b.extend(e.ajax, { url: d, data: f, error: P, success: function(r) { if (E.status == 200) { m.html(r); F() } } })); break; case "iframe": b('<iframe id="fancybox-frame" name="fancybox-frame' + (new Date).getTime() + '" frameborder="0" hspace="0" scrolling="' + e.scrolling + '" src="' + e.href + '"></iframe>').appendTo(m); N(); break
        } 
    }, $ = function() {
        if (u.is(":visible")) {
            b("div",
u).css("top", I * -40 + "px"); I = (I + 1) % 12
        } else clearInterval(H)
    }, aa = function() {
        if (!b("#fancybox-wrap").length) {
            b("body").append(m = b('<div id="fancybox-tmp"></div>'), u = b('<div id="fancybox-loading"><div></div></div>'), x = b('<div id="fancybox-overlay"></div>'), g = b('<div id="fancybox-wrap"></div>')); if (!b.support.opacity) { g.addClass("fancybox-ie"); u.addClass("fancybox-ie") } D = b('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(g);
            D.append(i = b('<div id="fancybox-inner"></div>'), z = b('<a id="fancybox-close"></a>'), A = b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), B = b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')); z.click(b.fancybox.close); u.click(b.fancybox.cancel); A.click(function(a) { a.preventDefault(); b.fancybox.prev() }); B.click(function(a) { a.preventDefault(); b.fancybox.next() }); if (O) {
                x.get(0).style.setExpression("height",
"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'"); u.get(0).style.setExpression("top", "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'"); D.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>')
            } 
        } 
    };
    b.fn.fancybox = function(a) { b(this).data("fancybox", b.extend({}, a, b.metadata ? b(this).metadata() : {})).unbind("click.fb").bind("click.fb", function(d) { d.preventDefault(); if (!h) { h = true; b(this).blur(); q = []; p = 0; d = b(this).attr("rel") || ""; if (!d || d == "" || d === "nofollow") q.push(this); else { q = b("a[rel=" + d + "], area[rel=" + d + "]"); p = q.index(this) } C(); return false } }); return this }; b.fancybox = function(a, d) {
        if (!h) {
            h = true; d = typeof d !== "undefined" ? d : {}; q = []; p = d.index || 0; if (b.isArray(a)) {
                for (var f = 0, o = a.length; f < o; f++) if (typeof a[f] ==
"object") b(a[f]).data("fancybox", b.extend({}, d, a[f])); else a[f] = b({}).data("fancybox", b.extend({ content: a[f] }, d)); q = jQuery.merge(q, a)
            } else { if (typeof a == "object") b(a).data("fancybox", b.extend({}, d, a)); else a = b({}).data("fancybox", b.extend({ content: a }, d)); q.push(a) } if (p > q.length || p < 0) p = 0; C()
        } 
    }; b.fancybox.showActivity = function() { clearInterval(H); u.show(); H = setInterval($, 66) }; b.fancybox.hideActivity = function() { u.hide() }; b.fancybox.next = function() { return b.fancybox.pos(n + 1) }; b.fancybox.prev = function() {
        return b.fancybox.pos(n -
1)
    }; b.fancybox.pos = function(a) { if (!h) { a = parseInt(a, 10); if (a > -1 && j.length > a) { p = a; C() } if (c.cyclic && j.length > 1 && a < 0) { p = j.length - 1; C() } if (c.cyclic && j.length > 1 && a >= j.length) { p = 0; C() } } }; b.fancybox.cancel = function() { if (!h) { h = true; b.event.trigger("fancybox-cancel"); J(); e && b.isFunction(e.onCancel) && e.onCancel(q, p, e); h = false } }; b.fancybox.close = function() {
        function a() { x.fadeOut("fast"); g.hide(); b.event.trigger("fancybox-cleanup"); i.empty(); b.isFunction(c.onClosed) && c.onClosed(j, n, c); j = e = []; n = p = 0; c = e = {}; h = false }
        if (!(h || g.is(":hidden"))) {
            h = true; if (c && b.isFunction(c.onCleanup)) if (c.onCleanup(j, n, c) === false) { h = false; return } J(); b(z.add(A).add(B)).hide(); b("#fancybox-title").remove(); g.add(i).add(x).unbind(); b(window).unbind("resize.fb scroll.fb"); b(document).unbind("keydown.fb"); i.css("overflow", "hidden"); if (c.transitionOut == "elastic") {
                k = Q(); var d = g.position(); l = { top: d.top, left: d.left, width: g.width(), height: g.height() }; if (c.opacity) l.opacity = 1; y.prop = 1; b(y).animate({ prop: 0 }, { duration: c.speedOut, easing: c.easingOut,
                    step: M, complete: a
                })
            } else g.fadeOut(c.transitionOut == "none" ? 0 : c.speedOut, a)
        } 
    }; b.fancybox.resize = function() { var a, d; if (!(h || g.is(":hidden"))) { h = true; a = i.wrapInner("<div style='overflow:auto'></div>").children(); d = a.height(); g.css({ height: d + c.padding * 2 + v }); i.css({ height: d }); a.replaceWith(a.children()); b.fancybox.center() } }; b.fancybox.center = function() {
        h = true; var a = K(), d = c.margin, f = {}; f.top = a[3] + (a[1] - (g.height() - v + 40)) * 0.5; f.left = a[2] + (a[0] - (g.width() + 40)) * 0.5; f.top = Math.max(a[3] + d, f.top); f.left = Math.max(a[2] +
d, f.left); g.css(f); h = false
    }; b.fn.fancybox.defaults = { padding: 10, margin: 20, opacity: false, modal: false, cyclic: false, scrolling: "auto", width: 560, height: 340, autoScale: true, autoDimensions: true, centerOnScroll: false, ajax: {}, swf: { wmode: "transparent" }, hideOnOverlayClick: true, hideOnContentClick: false, overlayShow: true, overlayOpacity: 0.8, overlayColor: "#000", titleShow: true, titlePosition: "outside", titleFormat: null, transitionIn: "fade", transitionOut: "fade", speedIn: 300, speedOut: 300, changeSpeed: 300, changeFade: "fast",
        easingIn: "swing", easingOut: "swing", showCloseButton: true, showNavArrows: true, enableEscapeButton: true, onStart: null, onCancel: null, onComplete: null, onCleanup: null, onClosed: null
    }; b(document).ready(function() { aa() })
})(jQuery);


/*
* jScrollPane - v2.0.0beta5 - 2010-09-18
* http://jscrollpane.kelvinluck.com/
*
* Copyright (c) 2010 Kelvin Luck
* Dual licensed under the MIT and GPL licenses.
*/
(function(b, a, c) {
    b.fn.jScrollPane = function(f) {
        function d(C, L) {
            var au, N = this, V, ah, v, aj, Q, W, y, q, av, aB, ap, i, H, h, j, X, R, al, U, t, A, am, ac, ak, F, l, ao, at, x, aq, aE, g, aA, ag = true, M = true, aD = false, k = false, Z = b.fn.mwheelIntent ? "mwheelIntent.jsp" : "mousewheel.jsp"; aE = C.css("paddingTop") + " " + C.css("paddingRight") + " " + C.css("paddingBottom") + " " + C.css("paddingLeft"); g = (parseInt(C.css("paddingLeft")) || 0) + (parseInt(C.css("paddingRight")) || 0); an(L); function an(aH) { var aL, aK, aJ, aG, aF, aI; au = aH; if (V == c) { C.css({ overflow: "hidden", padding: 0 }); ah = C.innerWidth() + g; v = C.innerHeight(); C.width(ah); V = b('<div class="jspPane" />').wrap(b('<div class="jspContainer" />').css({ width: ah + "px", height: v + "px" })); C.wrapInner(V.parent()); aj = C.find(">.jspContainer"); V = aj.find(">.jspPane"); V.css("padding", aE) } else { C.css("width", null); aI = C.outerWidth() + g != ah || C.outerHeight() != v; if (aI) { ah = C.innerWidth() + g; v = C.innerHeight(); aj.css({ width: ah + "px", height: v + "px" }) } aA = V.innerWidth(); if (!aI && V.outerWidth() == Q && V.outerHeight() == W) { if (aB || av) { V.css("width", aA + "px"); C.css("width", (aA + g) + "px") } return } V.css("width", null); C.css("width", (ah) + "px"); aj.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end() } aL = V.clone().css("position", "absolute"); aK = b('<div style="width:1px; position: relative;" />').append(aL); b("body").append(aK); Q = Math.max(V.outerWidth(), aL.outerWidth()); aK.remove(); W = V.outerHeight(); y = Q / ah; q = W / v; av = q > 1; aB = y > 1; if (!(aB || av)) { C.removeClass("jspScrollable"); V.css({ top: 0, width: aj.width() - g }); n(); D(); O(); w(); af() } else { C.addClass("jspScrollable"); aJ = au.maintainPosition && (H || X); if (aJ) { aG = ay(); aF = aw() } aC(); z(); E(); if (aJ) { K(aG); J(aF) } I(); ad(); if (au.enableKeyboardNavigation) { P() } if (au.clickOnTrack) { p() } B(); if (au.hijackInternalLinks) { m() } } if (au.autoReinitialise && !aq) { aq = setInterval(function() { an(au) }, au.autoReinitialiseDelay) } else { if (!au.autoReinitialise && aq) { clearInterval(aq) } } C.trigger("jsp-initialised", [aB || av]) } function aC() { if (av) { aj.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'), b('<div class="jspDragBottom" />'))), b('<div class="jspCap jspCapBottom" />'))); R = aj.find(">.jspVerticalBar"); al = R.find(">.jspTrack"); ap = al.find(">.jspDrag"); if (au.showArrows) { am = b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp", az(0, -1)).bind("click.jsp", ax); ac = b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp", az(0, 1)).bind("click.jsp", ax); if (au.arrowScrollOnHover) { am.bind("mouseover.jsp", az(0, -1, am)); ac.bind("mouseover.jsp", az(0, 1, ac)) } ai(al, au.verticalArrowPositions, am, ac) } t = v; aj.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function() { t -= b(this).outerHeight() }); ap.hover(function() { ap.addClass("jspHover") }, function() { ap.removeClass("jspHover") }).bind("mousedown.jsp", function(aF) { b("html").bind("dragstart.jsp selectstart.jsp", function() { return false }); ap.addClass("jspActive"); var s = aF.pageY - ap.position().top; b("html").bind("mousemove.jsp", function(aG) { S(aG.pageY - s, false) }).bind("mouseup.jsp mouseleave.jsp", ar); return false }); o() } } function o() { al.height(t + "px"); H = 0; U = au.verticalGutter + al.outerWidth(); V.width(ah - U - g); if (R.position().left == 0) { V.css("margin-left", U + "px") } } function z() {
                if (aB) {
                    aj.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'), b('<div class="jspDragRight" />'))), b('<div class="jspCap jspCapRight" />'))); ak = aj.find(">.jspHorizontalBar"); F = ak.find(">.jspTrack"); h = F.find(">.jspDrag"); if (au.showArrows) {
                        at = b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp", az(-1, 0)).bind("click.jsp", ax); x = b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp", az(1, 0)).bind("click.jsp", ax);
                        if (au.arrowScrollOnHover) { at.bind("mouseover.jsp", az(-1, 0, at)); x.bind("mouseover.jsp", az(1, 0, x)) } ai(F, au.horizontalArrowPositions, at, x)
                    } h.hover(function() { h.addClass("jspHover") }, function() { h.removeClass("jspHover") }).bind("mousedown.jsp", function(aF) { b("html").bind("dragstart.jsp selectstart.jsp", function() { return false }); h.addClass("jspActive"); var s = aF.pageX - h.position().left; b("html").bind("mousemove.jsp", function(aG) { T(aG.pageX - s, false) }).bind("mouseup.jsp mouseleave.jsp", ar); return false }); l = aj.innerWidth(); ae()
                } else { } 
            } function ae() { aj.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function() { l -= b(this).outerWidth() }); F.width(l + "px"); X = 0 } function E() { if (aB && av) { var aF = F.outerHeight(), s = al.outerWidth(); t -= aF; b(ak).find(">.jspCap:visible,>.jspArrow").each(function() { l += b(this).outerWidth() }); l -= s; v -= s; ah -= aF; F.parent().append(b('<div class="jspCorner" />').css("width", aF + "px")); o(); ae() } if (aB) { V.width((aj.outerWidth() - g) + "px") } W = V.outerHeight(); q = W / v; if (aB) { ao = 1 / y * l; if (ao > au.horizontalDragMaxWidth) { ao = au.horizontalDragMaxWidth } else { if (ao < au.horizontalDragMinWidth) { ao = au.horizontalDragMinWidth } } h.width(ao + "px"); j = l - ao; ab(X) } if (av) { A = 1 / q * t; if (A > au.verticalDragMaxHeight) { A = au.verticalDragMaxHeight } else { if (A < au.verticalDragMinHeight) { A = au.verticalDragMinHeight } } ap.height(A + "px"); i = t - A; aa(H) } } function ai(aG, aI, aF, s) { var aK = "before", aH = "after", aJ; if (aI == "os") { aI = /Mac/.test(navigator.platform) ? "after" : "split" } if (aI == aK) { aH = aI } else { if (aI == aH) { aK = aI; aJ = aF; aF = s; s = aJ } } aG[aK](aF)[aH](s) } function az(aF, s, aG) { return function() { G(aF, s, this, aG); this.blur(); return false } } function G(aH, aF, aK, aJ) { aK = b(aK).addClass("jspActive"); var aI, s = function() { if (aH != 0) { T(X + aH * au.arrowButtonSpeed, false) } if (aF != 0) { S(H + aF * au.arrowButtonSpeed, false) } }, aG = setInterval(s, au.arrowRepeatFreq); s(); aI = aJ == c ? "mouseup.jsp" : "mouseout.jsp"; aJ = aJ || b("html"); aJ.bind(aI, function() { aK.removeClass("jspActive"); clearInterval(aG); aJ.unbind(aI) }) } function p() { w(); if (av) { al.bind("mousedown.jsp", function(aH) { if (aH.originalTarget == c || aH.originalTarget == aH.currentTarget) { var aG = b(this), s = setInterval(function() { var aI = aG.offset(), aJ = aH.pageY - aI.top; if (H + A < aJ) { S(H + au.trackClickSpeed) } else { if (aJ < H) { S(H - au.trackClickSpeed) } else { aF() } } }, au.trackClickRepeatFreq), aF = function() { s && clearInterval(s); s = null; b(document).unbind("mouseup.jsp", aF) }; b(document).bind("mouseup.jsp", aF); return false } }) } if (aB) { F.bind("mousedown.jsp", function(aH) { if (aH.originalTarget == c || aH.originalTarget == aH.currentTarget) { var aG = b(this), s = setInterval(function() { var aI = aG.offset(), aJ = aH.pageX - aI.left; if (X + ao < aJ) { T(X + au.trackClickSpeed) } else { if (aJ < X) { T(X - au.trackClickSpeed) } else { aF() } } }, au.trackClickRepeatFreq), aF = function() { s && clearInterval(s); s = null; b(document).unbind("mouseup.jsp", aF) }; b(document).bind("mouseup.jsp", aF); return false } }) } } function w() { F && F.unbind("mousedown.jsp"); al && al.unbind("mousedown.jsp") } function ar() { b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp"); ap && ap.removeClass("jspActive"); h && h.removeClass("jspActive") } function S(s, aF) { if (!av) { return } if (s < 0) { s = 0 } else { if (s > i) { s = i } } if (aF == c) { aF = au.animateScroll } if (aF) { N.animate(ap, "top", s, aa) } else { ap.css("top", s); aa(s) } } function aa(aF) { if (aF == c) { aF = ap.position().top } aj.scrollTop(0); H = aF; var aI = H == 0, aG = H == i, aH = aF / i, s = -aH * (W - v); if (ag != aI || aD != aG) { ag = aI; aD = aG; C.trigger("jsp-arrow-change", [ag, aD, M, k]) } u(aI, aG); V.css("top", s); C.trigger("jsp-scroll-y", [-s, aI, aG]) } function T(aF, s) { if (!aB) { return } if (aF < 0) { aF = 0 } else { if (aF > j) { aF = j } } if (s == c) { s = au.animateScroll } if (s) { N.animate(h, "left", aF, ab) } else { h.css("left", aF); ab(aF) } } function ab(aF) { if (aF == c) { aF = h.position().left } aj.scrollTop(0); X = aF; var aI = X == 0, aH = X == j, aG = aF / j, s = -aG * (Q - ah); if (M != aI || k != aH) { M = aI; k = aH; C.trigger("jsp-arrow-change", [ag, aD, M, k]) } r(aI, aH); V.css("left", s); C.trigger("jsp-scroll-x", [-s, aI, aH]) } function u(aF, s) { if (au.showArrows) { am[aF ? "addClass" : "removeClass"]("jspDisabled"); ac[s ? "addClass" : "removeClass"]("jspDisabled") } } function r(aF, s) {
                if (au.showArrows) {
                    at[aF ? "addClass" : "removeClass"]("jspDisabled");
                    x[s ? "addClass" : "removeClass"]("jspDisabled")
                } 
            } function J(s, aF) { var aG = s / (W - v); S(aG * i, aF) } function K(aF, s) { var aG = aF / (Q - ah); T(aG * j, s) } function Y(aN, aL, aF) { var aJ, aH, s = 0, aG, aK, aM; try { aJ = b(aN) } catch (aI) { return } aH = aJ.outerHeight(); aj.scrollTop(0); while (!aJ.is(".jspPane")) { s += aJ.position().top; aJ = aJ.offsetParent(); if (/^body|html$/i.test(aJ[0].nodeName)) { return } } aG = aw(); aK = aG + v; if (s < aG || aL) { aM = s - au.verticalGutter } else { if (s + aH > aK) { aM = s - v + aH + au.verticalGutter } } if (aM) { J(aM, aF) } } function ay() { return -V.position().left } function aw() { return -V.position().top } function ad() { aj.unbind(Z).bind(Z, function(aI, aJ, aH, aF) { var aG = X, s = H; T(X + aH * au.mouseWheelSpeed, false); S(H - aF * au.mouseWheelSpeed, false); return aG == X && s == H }) } function n() { aj.unbind(Z) } function ax() { return false } function I() { V.unbind("focusin.jsp").bind("focusin.jsp", function(s) { if (s.target === V[0]) { return } Y(s.target, false) }) } function D() { V.unbind("focusin.jsp") } function P() { var aF, s; C.attr("tabindex", 0).unbind("keydown.jsp").bind("keydown.jsp", function(aJ) { if (aJ.target !== C[0]) { return } var aH = X, aG = H, aI = aF ? 2 : 16; switch (aJ.keyCode) { case 40: S(H + aI, false); break; case 38: S(H - aI, false); break; case 34: case 32: J(aw() + Math.max(32, v) - 16); break; case 33: J(aw() - v + 16); break; case 35: J(W - v); break; case 36: J(0); break; case 39: T(X + aI, false); break; case 37: T(X - aI, false); break } if (!(aH == X && aG == H)) { aF = true; clearTimeout(s); s = setTimeout(function() { aF = false }, 260); return false } }); if (au.hideFocus) { C.css("outline", "none"); if ("hideFocus" in aj[0]) { C.attr("hideFocus", true) } } else { C.css("outline", ""); if ("hideFocus" in aj[0]) { C.attr("hideFocus", false) } } } function O() { C.attr("tabindex", "-1").removeAttr("tabindex").unbind("keydown.jsp") } function B() { if (location.hash && location.hash.length > 1) { var aG, aF; try { aG = b(location.hash) } catch (s) { return } if (aG.length && V.find(aG)) { if (aj.scrollTop() == 0) { aF = setInterval(function() { if (aj.scrollTop() > 0) { Y(location.hash, true); b(document).scrollTop(aj.position().top); clearInterval(aF) } }, 50) } else { Y(location.hash, true); b(document).scrollTop(aj.position().top) } } } } function af() { b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack") } function m() { af(); b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack", function() { var s = this.href.split("#"), aF; if (s.length > 1) { aF = s[1]; if (aF.length > 0 && V.find("#" + aF).length > 0) { Y("#" + aF, true); return false } } }) } b.extend(N, { reinitialise: function(aF) { aF = b.extend({}, aF, au); an(aF) }, scrollToElement: function(aG, aF, s) { Y(aG, aF, s) }, scrollTo: function(aG, s, aF) { K(aG, aF); J(s, aF) }, scrollToX: function(aF, s) { K(aF, s) }, scrollToY: function(s, aF) { J(s, aF) }, scrollBy: function(aF, s, aG) { N.scrollByX(aF, aG); N.scrollByY(s, aG) }, scrollByX: function(s, aG) { var aF = ay() + s, aH = aF / (Q - ah); T(aH * j, aG) }, scrollByY: function(s, aG) { var aF = aw() + s, aH = aF / (W - v); S(aH * i, aG) }, animate: function(aF, aI, s, aH) { var aG = {}; aG[aI] = s; aF.animate(aG, { duration: au.animateDuration, ease: au.animateEase, queue: false, step: aH }) }, getContentPositionX: function() { return ay() }, getContentPositionY: function() { return aw() }, getIsScrollableH: function() { return aB }, getIsScrollableV: function() { return av }, getContentPane: function() { return V }, scrollToBottom: function(s) { S(i, s) }, hijackInternalLinks: function() { m() } })
        } f = b.extend({}, b.fn.jScrollPane.defaults, f); var e; this.each(function() { var g = b(this), h = g.data("jsp"); if (h) { h.reinitialise(f) } else { h = new d(g, f); g.data("jsp", h) } e = e ? e.add(g) : g }); return e
    }; b.fn.jScrollPane.defaults = { showArrows: false, maintainPosition: true, clickOnTrack: true, autoReinitialise: false, autoReinitialiseDelay: 500, verticalDragMinHeight: 0, verticalDragMaxHeight: 99999, horizontalDragMinWidth: 0, horizontalDragMaxWidth: 99999, animateScroll: false, animateDuration: 300, animateEase: "linear", hijackInternalLinks: false, verticalGutter: 4, horizontalGutter: 4, mouseWheelSpeed: 10, arrowButtonSpeed: 10, arrowRepeatFreq: 100, arrowScrollOnHover: false, trackClickSpeed: 30, trackClickRepeatFreq: 100, verticalArrowPositions: "split", horizontalArrowPositions: "split", enableKeyboardNavigation: true, hideFocus: false}
})(jQuery, this);
/*jquery.mousewheel.js*/
(function($) {
    var types = ['DOMMouseScroll', 'mousewheel']; $.event.special.mousewheel = { setup: function() { if (this.addEventListener) { for (var i = types.length; i; ) { this.addEventListener(types[--i], handler, false); } } else { this.onmousewheel = handler; } }, teardown: function() { if (this.removeEventListener) { for (var i = types.length; i; ) { this.removeEventListener(types[--i], handler, false); } } else { this.onmousewheel = null; } } }; $.fn.extend({ mousewheel: function(fn) { return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); }, unmousewheel: function(fn) { return this.unbind("mousewheel", fn); } }); function handler(event) {
        var orgEvent = event || window.event, args = [].slice.call(arguments, 1), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; event = $.event.fix(orgEvent); event.type = "mousewheel"; if (event.wheelDelta) { delta = event.wheelDelta / 120; }
        if (event.detail) { delta = -event.detail / 3; }
        deltaY = delta; if (orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) { deltaY = 0; deltaX = -1 * delta; }
        if (orgEvent.wheelDeltaY !== undefined) { deltaY = orgEvent.wheelDeltaY / 120; }
        if (orgEvent.wheelDeltaX !== undefined) { deltaX = -1 * orgEvent.wheelDeltaX / 120; }
        args.unshift(event, delta, deltaX, deltaY); return $.event.handle.apply(this, args);
    }
})(jQuery);
/*mwheelIntent.js*/
(function($) {
    var mwheelI = { pos: [-260, -260] }, minDif = 3, doc = document, root = doc.documentElement, body = doc.body, longDelay, shortDelay; function unsetPos() { if (this === mwheelI.elem) { mwheelI.pos = [-260, -260]; mwheelI.elem = false; minDif = 3; } }
    $.event.special.mwheelIntent = { setup: function() {
        var jElm = $(this).bind('mousewheel', $.event.special.mwheelIntent.handler); if (this !== doc && this !== root && this !== body) { jElm.bind('mouseleave', unsetPos); }
        jElm = null; return true;
    }, teardown: function() { $(this).unbind('mousewheel', $.event.special.mwheelIntent.handler).unbind('mouseleave', unsetPos); return true; }, handler: function(e, d) { var pos = [e.clientX, e.clientY]; if (this === mwheelI.elem || Math.abs(mwheelI.pos[0] - pos[0]) > minDif || Math.abs(mwheelI.pos[1] - pos[1]) > minDif) { mwheelI.elem = this; mwheelI.pos = pos; minDif = 250; clearTimeout(shortDelay); shortDelay = setTimeout(function() { minDif = 10; }, 200); clearTimeout(longDelay); longDelay = setTimeout(function() { minDif = 3; }, 1500); e = $.extend({}, e, { type: 'mwheelIntent' }); return $.event.handle.apply(this, arguments); } } 
    }; $.fn.extend({ mwheelIntent: function(fn) { return fn ? this.bind("mwheelIntent", fn) : this.trigger("mwheelIntent"); }, unmwheelIntent: function(fn) { return this.unbind("mwheelIntent", fn); } }); $(function() { body = doc.body; $(doc).bind('mwheelIntent.mwheelIntentDefault', $.noop); });
})(jQuery);

/*/jquery.maphilight.min.js*/
(function(f) { var b, c, j, m, l, i, g, e, h, a, k; b = document.namespaces; has_canvas = !!document.createElement("canvas").getContext; if (!(has_canvas || b)) { f.fn.maphilight = function() { return this }; return } if (has_canvas) { g = function(p, o, n) { if (o <= 1) { p.style.opacity = o; window.setTimeout(g, 10, p, o + 0.1, 10) } }; e = function(n) { return Math.max(0, Math.min(parseInt(n, 16), 255)) }; h = function(n, o) { return "rgba(" + e(n.substr(0, 2)) + "," + e(n.substr(2, 2)) + "," + e(n.substr(4, 2)) + "," + o + ")" }; c = function(n) { var o = f('<canvas style="width:' + n.width + "px;height:" + n.height + 'px;"></canvas>').get(0); o.getContext("2d").clearRect(0, 0, o.width, o.height); return o }; j = function(q, n, t, p, o) { var s, r = q.getContext("2d"); r.beginPath(); if (n == "rect") { r.rect(t[0], t[1], t[2] - t[0], t[3] - t[1]) } else { if (n == "poly") { r.moveTo(t[0], t[1]); for (s = 2; s < t.length; s += 2) { r.lineTo(t[s], t[s + 1]) } } else { if (n == "circ") { r.arc(t[0], t[1], t[2], 0, Math.PI * 2, false) } } } r.closePath(); if (p.fill) { r.fillStyle = h(p.fillColor, p.fillOpacity); r.fill() } if (p.stroke) { r.strokeStyle = h(p.strokeColor, p.strokeOpacity); r.lineWidth = p.strokeWidth; r.stroke() } if (p.fade) { g(q, 0) } }; m = function(n) { n.getContext("2d").clearRect(0, 0, n.width, n.height) } } else { c = function(n) { return f('<var style="zoom:1;overflow:hidden;display:block;width:' + n.width + "px;height:" + n.height + 'px;"></var>').get(0) }; j = function(o, r, s, v, n) { var t, u, p, q; t = '<v:fill color="#' + v.fillColor + '" opacity="' + (v.fill ? v.fillOpacity : 0) + '" />'; u = (v.stroke ? 'strokeweight="' + v.strokeWidth + '" stroked="t" strokecolor="#' + v.strokeColor + '"' : 'stroked="f"'); p = '<v:stroke opacity="' + v.strokeOpacity + '"/>'; if (r == "rect") { q = f('<v:rect name="' + n + '" filled="t" ' + u + ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + s[0] + "px;top:" + s[1] + "px;width:" + (s[2] - s[0]) + "px;height:" + (s[3] - s[1]) + 'px;"></v:rect>') } else { if (r == "poly") { q = f('<v:shape name="' + n + '" filled="t" ' + u + ' coordorigin="0,0" coordsize="' + o.width + "," + o.height + '" path="m ' + s[0] + "," + s[1] + " l " + s.join(",") + ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + o.width + "px;height:" + o.height + 'px;"></v:shape>') } else { if (r == "circ") { q = f('<v:oval name="' + n + '" filled="t" ' + u + ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + (s[0] - s[2]) + "px;top:" + (s[1] - s[2]) + "px;width:" + (s[2] * 2) + "px;height:" + (s[2] * 2) + 'px;"></v:oval>') } } } q.get(0).innerHTML = t + p; f(o).append(q) }; m = function(n) { f(n).find("[name=highlighted]").remove() } } l = function(o) { var n, p = o.getAttribute("coords").split(","); for (n = 0; n < p.length; n++) { p[n] = parseFloat(p[n]) } return [o.getAttribute("shape").toLowerCase().substr(0, 4), p] }; k = function(p, o) { var n = f(p); return f.extend({}, o, f.metadata ? n.metadata() : false, n.data("maphilight")) }; a = function(n) { if (!n.complete) { return false } if (typeof n.naturalWidth != "undefined" && n.naturalWidth == 0) { return false } return true }; i = { position: "absolute", left: 0, top: 0, padding: 0, border: 0 }; var d = false; f.fn.maphilight = function(p) { p = f.extend({}, f.fn.maphilight.defaults, p); if (f.browser.msie && !d) { document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); var o = document.createStyleSheet(); var n = ["shape", "rect", "oval", "circ", "fill", "stroke", "imagedata", "group", "textbox"]; f.each(n, function() { o.addRule("v\\:" + this, "behavior: url(#default#VML); antialias:true") }); d = true } return this.each(function() { var v, s, z, r, u, w, y, t, x; v = f(this); if (!a(this)) { return window.setTimeout(function() { v.maphilight(p) }, 200) } z = f.extend({}, p, f.metadata ? v.metadata() : false, v.data("maphilight")); x = v.get(0).getAttribute("usemap"); r = f('map[name="' + x.substr(1) + '"]'); if (!(v.is("img") && x && r.size() > 0)) { return } if (v.hasClass("maphilighted")) { var q = v.parent(); v.insertBefore(q); q.remove(); f(r).unbind(".maphilight").find("area[coords]").unbind(".maphilight") } s = f("<div></div>").css({ display: "block", background: "url(" + this.src + ")", position: "relative", padding: 0, width: this.width, height: this.height }); if (z.wrapClass) { if (z.wrapClass === true) { s.addClass(f(this).attr("class")) } else { s.addClass(z.wrapClass) } } v.before(s).css("opacity", 0).css(i).remove(); if (f.browser.msie) { v.css("filter", "Alpha(opacity=0)") } s.append(v); u = c(this); f(u).css(i); u.height = this.height; u.width = this.width; y = function(C) { var A, B; B = k(this, z); if (!B.neverOn && !B.alwaysOn) { A = l(this); j(u, A[0], A[1], B, "highlighted"); if (B.groupBy && f(this).attr(B.groupBy)) { var D = this; r.find("area[" + B.groupBy + "=" + f(this).attr(B.groupBy) + "]").each(function() { if (this != D) { var F = k(this, z); if (!F.neverOn && !F.alwaysOn) { var E = l(this); j(u, E[0], E[1], F, "highlighted") } } }) } } }; f(r).bind("alwaysOn.maphilight", function() { if (w) { m(w) } if (!has_canvas) { f(u).empty() } f(r).find("area[coords]").each(function() { var A, B; B = k(this, z); if (B.alwaysOn) { if (!w && has_canvas) { w = c(v.get()); f(w).css(i); w.width = v.width(); w.height = v.height(); v.before(w) } A = l(this); if (has_canvas) { j(w, A[0], A[1], B, "") } else { j(u, A[0], A[1], B, "") } } }) }); if (z.alwaysOn) { f(r).find("area[coords]").each(y) } else { f(r).find("area[coords]").trigger("alwaysOn.maphilight").bind("mouseover.maphilight", y).bind("mouseout.maphilight", function(A) { m(u) }) } v.before(u); v.addClass("maphilighted") }) }; f.fn.maphilight.defaults = { fill: true, fillColor: "000000", fillOpacity: 0.2, stroke: true, strokeColor: "ff0000", strokeOpacity: 1, strokeWidth: 1, fade: true, alwaysOn: false, neverOn: false, groupBy: false, wrapClass: true} })(jQuery);
