var tb_pathToImage = "../images/loadingAnimation.gif";
/*!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
$(document).ready(function ()
{
    tb_init("a.thickbox, area.thickbox, input.thickbox");
    imgLoader = new Image();
    imgLoader.src = tb_pathToImage;
});
function tb_init(a)
{
    $(a).click(function ()
    {
        var c = this.title || this.name || null;
        var b = this.href || this.alt;
        var d = this.rel || false;
        tb_show(c, b, d);
        this.blur();
        return false;
    })
}
function tb_show(j, b, h)
{
    try
    {
        if (typeof document.body.style.maxHeight === "undefined")
        {
            $("body", "html").css({
                height : "100%", width : "100%"
            });
            $("html").css("overflow", "hidden");
            if (document.getElementById("TB_HideSelect") === null)
            {
                $("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
                $("#TB_overlay").click(tb_remove)
            }
        }
        else
        {
            if (document.getElementById("TB_overlay") === null)
            {
                $("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
                $("#TB_overlay").click(tb_remove)
            }
        }
        if (tb_detectMacXFF()) {
            $("#TB_overlay").addClass("TB_overlayMacFFBGHack")
        }
        else {
            $("#TB_overlay").addClass("TB_overlayBG")
        }
        if (j === null) {
            j = ""
        }
        $("body").append("<div id='TB_load'><img src='" + imgLoader.src + "' /></div>");
        $("#TB_load").show();
        var c;
        if (b.indexOf("?") !==- 1) {
            c = b.substr(0, b.indexOf("?"))
        }
        else {
            c = b
        }
        var f = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
        var k = c.toLowerCase().match(f);
        if (k == ".jpg" || k == ".jpeg" || k == ".png" || k == ".gif" || k == ".bmp")
        {
            TB_PrevCaption = "";
            TB_PrevURL = "";
            TB_PrevHTML = "";
            TB_NextCaption = "";
            TB_NextURL = "";
            TB_NextHTML = "";
            TB_imageCount = "";
            TB_FoundURL = false;
            if (h)
            {
                TB_TempArray = $("a[rel=" + h + "]").get();
                for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++)
                {
                    var g = TB_TempArray[TB_Counter].href.toLowerCase().match(f);
                    if (!(TB_TempArray[TB_Counter].href == b))
                    {
                        if (TB_FoundURL)
                        {
                            TB_NextCaption = TB_TempArray[TB_Counter].title;
                            TB_NextURL = TB_TempArray[TB_Counter].href;
                            TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>"
                        }
                        else
                        {
                            TB_PrevCaption = TB_TempArray[TB_Counter].title;
                            TB_PrevURL = TB_TempArray[TB_Counter].href;
                            TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
                        }
                    }
                    else {
                        TB_FoundURL = true;
                        TB_imageCount = "Image " + (TB_Counter + 1) + " of " + (TB_TempArray.length);
                    }
                }
            }
            imgPreloader = new Image();
            imgPreloader.onload = function ()
            {
                imgPreloader.onload = null;
                var n = tb_getPageSize();
                var l = n[0] - 150;
                var q = n[1] - 150;
                var m = imgPreloader.width;
                var e = imgPreloader.height;
                if (m > l) {
                    e = e * (l / m);
                    m = l;
                    if (e > q) {
                        m = m * (q / e);
                        e = q;
                    }
                }
                else {
                    if (e > q) {
                        m = m * (q / e);
                        e = q;
                        if (m > l) {
                            e = e * (l / m);
                            m = l;
                        }
                    }
                }
                TB_WIDTH = m + 30;
                TB_HEIGHT = e + 60;
                $("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='" + b + "' width='" + m + "' height='" + e + "' alt='" + j + "'/></a><div id='TB_caption'>" + j + "<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>");
                $("#TB_closeWindowButton").click(tb_remove);
                if (!(TB_PrevHTML === ""))
                {
                    function p()
                    {
                        if ($(document).unbind("click", p)) {
                            $(document).unbind("click", p)
                        }
                        $("#TB_window").remove();
                        $("body").append("<div id='TB_window'></div>");
                        tb_show(TB_PrevCaption, TB_PrevURL, h);
                        return false
                    }
                    $("#TB_prev").click(p)
                }
                if (!(TB_NextHTML === ""))
                {
                    function o()
                    {
                        $("#TB_window").remove();
                        $("body").append("<div id='TB_window'></div>");
                        tb_show(TB_NextCaption, TB_NextURL, h);
                        return false
                    }
                    $("#TB_next").click(o)
                }
                document.onkeydown = function (r)
                {
                    if (r == null) {
                        keycode = event.keyCode
                    }
                    else {
                        keycode = r.which
                    }
                    if (keycode == 27) {
                        tb_remove()
                    }
                    else
                    {
                        if (keycode == 190) {
                            if (!(TB_NextHTML == "")) {
                                document.onkeydown = "";
                                o()
                            }
                        }
                        else {
                            if (keycode == 188) {
                                if (!(TB_PrevHTML == "")) {
                                    document.onkeydown = "";
                                    p()
                                }
                            }
                        }
                    }
                };
                tb_position();
                $("#TB_load").remove();
                $("#TB_ImageOff").click(tb_remove);
                $("#TB_window").css({
                    display : "block"
                })
            };
            imgPreloader.src = b
        }
        else
        {
            var a = b.replace(/^[^\?]+\??/, "");
            var d = tb_parseQuery(a);
            TB_WIDTH = (d.width * 1) + 30 || 630;
            TB_HEIGHT = (d.height * 1) + 40 || 440;
            ajaxContentW = TB_WIDTH - 30;
            ajaxContentH = TB_HEIGHT - 45;
            if (b.indexOf("TB_iframe") !=- 1)
            {
                urlNoQuery = b.split("TB_");
                $("#TB_iframeContent").remove();
                if (d.modal != "true")
                {
                    $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + j + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;' > </iframe>")
                }
                else
                {
                    $("#TB_overlay").unbind();
                    $("#TB_window").append("<iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;'> </iframe>")
                }
            }
            else
            {
                if ($("#TB_window").css("display") != "block")
                {
                    if (d.modal != "true")
                    {
                        $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + j + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'></div>")
                    }
                    else
                    {
                        $("#TB_overlay").unbind();
                        $("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px;'></div>")
                    }
                }
                else
                {
                    $("#TB_ajaxContent")[0].style.width = ajaxContentW + "px";
                    $("#TB_ajaxContent")[0].style.height = ajaxContentH + "px";
                    $("#TB_ajaxContent")[0].scrollTop = 0;
                    $("#TB_ajaxWindowTitle").html(j)
                }
            }
            $("#TB_closeWindowButton").click(tb_remove);
            if (b.indexOf("TB_inline") !=- 1)
            {
                $("#TB_ajaxContent").append($("#" + d.inlineId).children());
                $("#TB_window").unload(function ()
                {
                    $("#" + d.inlineId).append($("#TB_ajaxContent").children())
                });
                tb_position();
                $("#TB_load").remove();
                $("#TB_window").css({
                    display : "block"
                })
            }
            else
            {
                if (b.indexOf("TB_iframe") !=- 1)
                {
                    tb_position();
                    if ($.browser.safari) {
                        $("#TB_load").remove();
                        $("#TB_window").css({
                            display : "block"
                        })
                    }
                }
                else
                {
                    $("#TB_ajaxContent").load(b += "&random=" + (new Date().getTime()), function ()
                    {
                        tb_position();
                        $("#TB_load").remove();
                        tb_init("#TB_ajaxContent a.thickbox");
                        $("#TB_window").css({
                            display : "block"
                        })
                    })
                }
            }
        }
        if (!d.modal)
        {
            document.onkeyup = function (l)
            {
                if (l == null) {
                    keycode = event.keyCode
                }
                else {
                    keycode = l.which
                }
                if (keycode == 27) {
                    tb_remove()
                }
            }
        }
    }
    catch (i) {}
}
function tb_showIframe()
{
    $("#TB_load").remove();
    $("#TB_window").css({
        display : "block"
    })
}
function tb_remove()
{
    $("#TB_imageOff").unbind("click");
    $("#TB_closeWindowButton").unbind("click");
    $("#TB_window").fadeOut("fast", function ()
    {
        $("#TB_window,#TB_overlay,#TB_HideSelect").trigger("unload").unbind().remove()
    });
    $("#TB_load").remove();
    if (typeof document.body.style.maxHeight == "undefined") {
        $("body", "html").css({
            height : "auto", width : "auto"
        });
        $("html").css("overflow", "")
    }
    document.onkeydown = "";
    document.onkeyup = "";
    return false
}
function tb_position()
{
    $("#TB_window").css({
        marginLeft : "-" + parseInt((TB_WIDTH / 2), 10) + "px", width : TB_WIDTH + "px"
    });
    if (!(jQuery.browser.msie && jQuery.browser.version < 7)) {
        $("#TB_window").css({
            marginTop : "-" + parseInt((TB_HEIGHT / 2), 10) + "px"
        })
    }
}
function tb_parseQuery(d)
{
    var e = {};
    if (!d) {
        return e
    }
    var a = d.split(/[;&]/);
    for (var c = 0; c < a.length; c++)
    {
        var g = a[c].split("=");
        if (!g || g.length != 2) {
            continue
        }
        var b = unescape(g[0]);
        var f = unescape(g[1]);
        f = f.replace(/\+/g, " ");
        e[b] = f
    }
    return e
}
function tb_getPageSize()
{
    var c = document.documentElement;
    var a = window.innerWidth || self.innerWidth || (c && c.clientWidth) || document.body.clientWidth;
    var b = window.innerHeight || self.innerHeight || (c && c.clientHeight) || document.body.clientHeight;
    arrayPageSize = [a, b];
    return arrayPageSize
}
function tb_detectMacXFF()
{
    var a = navigator.userAgent.toLowerCase();
    if (a.indexOf("mac") !=- 1 && a.indexOf("firefox") !=- 1) {
        return true;
    }
}
(function (b)
{
    var c = b.scrollTo = function (e, d, f)
    {
        c.window().scrollTo(e, d, f)
    };
    c.defaults = {
        axis : "y", duration : 1
    };
    c.window = function ()
    {
        return b(b.browser.safari ? "body" : "html");
    };
    b.fn.scrollTo = function (e, d, f)
    {
        if (typeof d == "object") {
            f = d;
            d = 0
        }
        f = b.extend({}, c.defaults, f);
        d = d || f.speed || f.duration;
        f.queue = f.queue && f.axis.length > 1;
        if (f.queue) {
            d /= 2
        }
        f.offset = a(f.offset);
        f.over = a(f.over);
        return this.each(function ()
        {
            var k = this, i = b(k), l = e, p, o = {}, j = i.is("html,body");
            switch (typeof l)
            {
                case "number":
                case "string":
                    if (/^([+-]=)?\d+(px)?$/.test(l)) {
                        l = a(l);
                        break
                    }
                    l = b(l, this);
                case "object":
                    if (l.is || l.style) {
                        p = (l = b(l)).offset();
                    }
            }
            b.each(f.axis.split(""), function (h, r)
            {
                var q = r == "x" ? "Left" : "Top", u = q.toLowerCase(), g = "scroll" + q, t = k[g], s = r == "x" ? "Width" : "Height";
                if (p)
                {
                    o[g] = p[u] + (j ? 0 : t - i.offset()[u]);
                    if (f.margin) {
                        o[g] -= parseInt(l.css("margin" + q)) || 0;
                        o[g] -= parseInt(l.css("border" + q + "Width")) || 0
                    }
                    o[g] += f.offset[u] || 0;
                    if (f.over[u]) {
                        o[g] += l[s.toLowerCase()]() * f.over[u]
                    }
                }
                else {
                    o[g] = l[u]
                }
                if (/^\d+$/.test(o[g])) {
                    o[g] = o[g] <= 0 ? 0 : Math.min(o[g], m(s))
                }
                if (!h && f.queue) {
                    if (t != o[g]) {
                        n(f.onAfterFirst)
                    }
                    delete o[g]
                }
            });
            n(f.onAfter);
            function n(g)
            {
                i.animate(o, d, f.easing, g && function ()
                {
                    g.call(this, e)
                })
            }
            function m(h)
            {
                var g = j ? b.browser.opera ? document.body : document.documentElement : k;
                return g["scroll" + h] - g["client" + h];
            }
        })
    };
    function a(d)
    {
        return typeof d == "object" ? d : 
        {
            top : d, left : d
        }
    }
})(jQuery);
(function (a)
{
    a.extend(a.fx.step, 
    {
        backgroundPosition : function (d)
        {
            if (d.state === 0 && typeof d.end == "string")
            {
                var f = a.curCSS(d.elem, "backgroundPosition");
                f = c(f);
                d.start = [f[0], f[2]];
                var b = c(d.end);
                d.end = [b[0], b[2]];
                d.unit = [b[1], b[3]]
            }
            var e = [];
            e[0] = ((d.end[0] - d.start[0]) * d.pos) + d.start[0] + d.unit[0];
            e[1] = ((d.end[1] - d.start[1]) * d.pos) + d.start[1] + d.unit[1];
            d.elem.style.backgroundPosition = e[0] + " " + e[1];
            function c(h)
            {
                h = h.replace(/left|top/g, "0px");
                h = h.replace(/right|bottom/g, "100%");
                h = h.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2");
                var g = h.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
                return [parseFloat(g[1], 10), g[2], parseFloat(g[3], 10), g[4]];
            }
        }
    })
})(jQuery);
