﻿// Custom Innovah JS
$(document).ready(function() {
    initJQuery();
});
function initJQuery() {
    var isIE = jQuery.browser.msie;
    var isIE6 = (jQuery.browser.version < 7);
    // Tooltip
    $("div.mediathumb").hover(
		function() {
		    var item = $(this);
		    var tooltip = item.parent().find(".tooltip");
		    var toolP = tooltip.offset();
		    var toolH = tooltip.height();
		    var offset = 10;
		    var toolT = -toolH;
		    var toolL = (item.width() / 2) - (tooltip.width() / 2);
		    tooltip.animate({ "left": -5000 }, { queue: false, duration: 800, complete:
		        function() {
		            tooltip.css({ "display": "inline", "top": -toolH, "left": toolL });
		            tooltip.find("div.tooltipbg,div.tooltipfooter").ifixpng();
		        }
		    });
		},
		function() {
		    var item = $(this);
		    var tooltip = item.parent().find(".tooltip");
		    var toolH = tooltip.height();
		    tooltip.stop();
		    tooltip.hide();
		}
	);
    // ColorBox IE Config
    var videoH;
    if (isIE) {
        videoH = 481;
        if (isIE6) {
            $("a[rel='instructions'],a[rel='terms'],a[rel='video'],a[rel='photo'],a[rel='rejectedphoto'],a[rel='searchphoto'],a[rel='upload'],a.supply").click(function() { $("#cboxOverlay").css({ "height": $(window).height(), "top": $(window).scrollTop() }); });
        }
    } else {
        videoH = 449;
    }
    // ColorBox
    $("a[rel='upload']").colorbox({ width: 500, height: 380, iframe: true, overlayClose: false });
    $("a[rel='instructions']").colorbox({ width: 800, height: 500, iframe: true });
    $("a[rel='terms']").colorbox({ width: 800, height: 500, iframe: true });
    $("a[rel='photo'],a[rel='rejectedphoto'],a[rel='searchphoto']").colorbox();
    $("a[rel='video']").colorbox({ width: 482, height: videoH, iframe: true });
    $("a[rel='video'],a[rel='photo']").each(function() {
        $(this).colorbox({ title: $(this).find('span').text() });
    });
    if (isIE) {
        $("a.supply").click(function() {
            var url = $(this).attr('href');
            popUp(url, 990, 600);
            return false;
        });
    } else {
        $("a.supply").colorbox({ width: 990, height: 600, iframe: true });
        $("a.supply").click(function() {
            $("#cboxLoadedContent").css({ "background": "#fff" });
        });
    }

    // Vote Hover
    $(".vote").hover(
		function() {
		    $(this).addClass("voteover");
		},
		function() {
		    $(this).removeClass("voteover");
		}
	);
    // Vote Message
    function displayVoteMsg(votemessage, str, dur) {
        votemessage.html(str).css({ "display": "inline" });
        votemessage.animate({ opacity: 1 }, { queue: false, duration: dur, complete: function() { votemessage.fadeOut(1000); } });
    }
    // Vote AJAX
    function voteAjax(item, mediatype, mediaid) {
        var votemessage = item.find("span.votemessage");
        $.ajax({
            type: "POST",
            url: "/ws/derby_ws.asmx/Vote" + mediatype,
            contentType: "application/json; charset=utf-8",
            data: "{mediaid:" + mediaid + "}",
            dataType: "json",
            success: AjaxSucceeded,
            error: AjaxFailed
        });
        function AjaxSucceeded(result) {
            var itemid = item.attr("id");
            var votenumber = item.find("span.votenumber");
            var voteT = item.css("top");
            var voteL = item.css("left");
            var resultArr = result.d.split("|");
            var votes = resultArr[0];
            var remaining = resultArr[1];
            if (votes == "-2") {
                // Not Logged In
                displayVoteMsg(votemessage, "<a href='/login'>Login or Register</a><br/>to vote!", 4000);
            } else if (votes == "-1") {
                // No Votes Left
                displayVoteMsg(votemessage, "Today's " + mediatype.toLowerCase() + " votes<br/>have been used...", 4000);
            } else {
                // Voted
                votenumber.text(votes).css({ opacity: 0 }).animate({ opacity: 1 }, { queue: false, duration: 500 });
                if (remaining < 4) {
                    displayVoteMsg(votemessage, (remaining - 1) + " " + mediatype.toLowerCase() + " votes left...", 2500);
                }
            }
        }
        function AjaxFailed(result) {
            displayVoteMsg(votemessage, "Error Voting!", 2500);
        }
    }
    // Vote Click
    $("div.vote").click(function() {
        var item = $(this);
        var votenumber = item.find("span.votenumber");
        var votemessage = item.find("span.votemessage");
        var mediaid = votenumber.attr("id").substring(3);
        var isAuth = $("#welcome").length > 0;
        var isAnim = votenumber.is(":animated");
        if (isAuth) {
            if (votemessage.is(":hidden") && !isAnim) {
                var mediatype = $("#mediaType").val();
                voteAjax(item, mediatype, mediaid);
            }
        } else {
            displayVoteMsg(votemessage, "<a href='/login'>Login or Register</a><br/>to vote!", 4000);
        }
    });
    function popUp(url, w, h) {
        var l = ($(window).width() / 2) - (w / 2);
        var t = ($(window).height() / 2) - (h / 2);
        var day = new Date();
        var id = day.getTime();
        eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + w + ",height=" + h + ",left = " + l + ",top = " + t + "');");
    }
};
/*
* jQuery ifixpng plugin
* (previously known as pngfix)
* Version 2.1  (23/04/2008)
* @requires jQuery v1.1.3 or above
*
* Examples at: http://jquery.khurshid.com
* Copyright (c) 2007 Kush M.
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
    $.ifixpng = function(customPixel) { $.ifixpng.pixel = customPixel; }; $.ifixpng.getPixel = function() { return $.ifixpng.pixel || 'images/pixel.gif'; }; var hack = { ltie7: $.browser.msie && $.browser.version < 7, filter: function(src) { return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='" + src + "')"; } }; $.fn.ifixpng = hack.ltie7 ? function() {
        return this.each(function() {
            var $$ = $(this); var base = $('base').attr('href'); if (base) { base = base.replace(/\/[^\/]+$/, '/'); }
            if ($$.is('img') || $$.is('input')) { if ($$.attr('src')) { if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { var source = (base && $$.attr('src').search(/^(\/|http:)/i)) ? base + $$.attr('src') : $$.attr('src'); $$.css({ filter: hack.filter(source), width: $$.width(), height: $$.height() }).attr({ src: $.ifixpng.getPixel() }).positionFix(); } } } else { var image = $$.css('backgroundImage'); if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) { image = RegExp.$1; image = (base && image.substring(0, 1) != '/') ? base + image : image; $$.css({ backgroundImage: 'none', filter: hack.filter(image) }).children().children().positionFix(); } } 
        });
    } : function() { return this; }; $.fn.iunfixpng = hack.ltie7 ? function() { return this.each(function() { var $$ = $(this); var src = $$.css('filter'); if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { src = RegExp.$1; if ($$.is('img') || $$.is('input')) { $$.attr({ src: src }).css({ filter: '' }); } else { $$.css({ filter: '', background: 'url(' + src + ')' }); } } }); } : function() { return this; }; $.fn.positionFix = function() { return this.each(function() { var $$ = $(this); var position = $$.css('position'); if (position != 'absolute' && position != 'relative') { $$.css({ position: 'relative' }); } }); };
})(jQuery);

/*

FREESTYLE MENUS v1.0 RC (c) 2001-2009 Angus Turnbull, http://www.twinhelix.com
Altering this notice or redistributing this file is prohibited.*/
var isDOM = document.getElementById ? 1 : 0, isIE = document.all ? 1 : 0, isNS4 = navigator.appName == 'Netscape' && !isDOM ? 1 : 0, isOp = self.opera ? 1 : 0, isDyn = isDOM || isIE || isNS4; function getRef(i, p) { p = !p ? document : p.navigator ? p.document : p; return isIE ? p.all[i] : isDOM ? (p.getElementById ? p : p.ownerDocument).getElementById(i) : isNS4 ? p.layers[i] : null }; function getSty(i, p) { var r = getRef(i, p); return r ? isNS4 ? r : r.style : null }; if (!self.LayerObj) var LayerObj = new Function('i', 'p', 'this.ref=getRef(i,p);this.sty=getSty(i,p);return this'); function getLyr(i, p) { return new LayerObj(i, p) }; function LyrFn(n, f) { LayerObj.prototype[n] = new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){' + f + '}') }; LyrFn('x', 'if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)'); LyrFn('y', 'if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)'); if (typeof addEvent != 'function') { var addEvent = function(o, t, f, l) { var d = 'addEventListener', n = 'on' + t; if (o[d] && !l) return o[d](t, f, false); if (!o._evts) o._evts = {}; if (!o._evts[t]) { o._evts[t] = {}; if (o[n]) addEvent(o, t, o[n], l); o[n] = new Function('e', 'var r=true,o=this,a=o._evts["' + t + '"],i;for(i in a){o._f=a[i];if(o._f._i)r=o._f(e||window.event)!=false&&r}o._f=null;return r') } if (!f._i) f._i = addEvent._i++; o._evts[t][f._i] = f; if (t != 'unload') addEvent(window, 'unload', function() { removeEvent(o, t, f, l) }) }; addEvent._i = 1; var removeEvent = function(o, t, f, l) { var d = 'removeEventListener'; if (o[d] && !l) return o[d](t, f, false); if (o._evts && o._evts[t] && f._i) delete o._evts[t][f._i] } } var addReadyEvent = function(f) { var a = addReadyEvent, n = null; addEvent(a, 'ready', f); if (!a.r) { a.r = function() { clearInterval(t); if (a.r) a.onready(); a.r = null }; addEvent(document, 'DOMContentLoaded', a.r); addEvent(window, 'load', a.r); var t = setInterval(function() { if (/complete|loaded/.test(document.readyState)) { if (!n) a.r(); else try { n.doScroll('left'); n = null; a.r() } catch (e) { } } }, 50) } }; function FSMenu(myName, nested, cssProp, cssVis, cssHid) { this.myName = myName; this.nested = nested; this.cssProp = cssProp; this.cssVis = cssVis; this.cssHid = cssHid; this.cssLitClass = 'highlighted'; this.menus = nested ? {} : { root: new FSMenuNode('root', true, this) }; this.menuToShow = []; this.mtsTimer = null; this.showDelay = 0; this.switchDelay = 125; this.hideDelay = 500; this.showOnClick = 0; this.hideOnClick = true; this.animInSpeed = 0.2; this.animOutSpeed = 0.2; this.animations = [] }; FSMenu.prototype.show = function(mN) { with (this) { menuToShow.length = arguments.length; for (var i = 0; i < arguments.length; i++) menuToShow[i] = arguments[i]; clearTimeout(mtsTimer); if (!nested) mtsTimer = setTimeout(myName + '.menus.root.over()', 10) } }; FSMenu.prototype.hide = function(mN) { with (this) { clearTimeout(mtsTimer); if (menus[mN]) menus[mN].out() } }; FSMenu.prototype.hideAll = function() { with (this) { for (var m in menus) if (menus[m].visible && !menus[m].isRoot) menus[m].hide(true) } }; function FSMenuNode(id, isRoot, obj) { this.id = id; this.isRoot = isRoot; this.obj = obj; this.lyr = this.child = this.par = this.timer = this.visible = null; this.args = []; var node = this; this.over = function(evt) { with (node) with (obj) { if (isNS4 && evt && lyr.ref) lyr.ref.routeEvent(evt); clearTimeout(timer); clearTimeout(mtsTimer); if (!isRoot && !visible) node.show(); if (menuToShow.length) { var a = menuToShow, m = a[0]; if (!menus[m] || !menus[m].lyr.ref) menus[m] = new FSMenuNode(m, false, obj); var c = menus[m]; if (c == node) { menuToShow.length = 0; return } clearTimeout(c.timer); if (c != child && c.lyr.ref) { c.args.length = a.length; for (var i = 0; i < a.length; i++) c.args[i] = a[i]; var delay = child ? switchDelay : showDelay; c.timer = setTimeout('with(' + myName + '){menus["' + c.id + '"].par=menus["' + node.id + '"];menus["' + c.id + '"].show()}', delay ? delay : 1) } menuToShow.length = 0 } if (!nested && par) par.over() } }; this.out = function(evt) { with (node) with (obj) { if (isNS4 && evt && lyr && lyr.ref) lyr.ref.routeEvent(evt); clearTimeout(timer); if (!isRoot && hideDelay >= 0) { timer = setTimeout(myName + '.menus["' + id + '"].hide()', hideDelay); if (!nested && par) par.out() } } }; if (id != 'root') with (this) with (lyr = getLyr(id)) if (ref) { if (isNS4) ref.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT); addEvent(ref, 'mouseover', this.over); addEvent(ref, 'mouseout', this.out); if (obj.nested) { addEvent(ref, 'focus', this.over, 1); addEvent(ref, 'click', this.over); addEvent(ref, 'blur', this.out, 1) } } }; FSMenuNode.prototype.show = function(forced) { with (this) with (obj) { if (!lyr || !lyr.ref) return; if (par) { if (par.child && par.child != this) par.child.hide(); par.child = this } var offR = args[1], offX = args[2], offY = args[3], lX = 0, lY = 0, doX = '' + offX != 'undefined', doY = '' + offY != 'undefined'; if (self.page && offR && (doX || doY)) { with (page.elmPos(offR, par.lyr ? par.lyr.ref : 0)) lX = x, lY = y; if (doX) lyr.x(lX + eval(offX)); if (doY) lyr.y(lY + eval(offY)) } if (offR) lightParent(offR, 1); visible = 1; if (obj.onshow) obj.onshow(id); lyr.ref.parentNode.style.zIndex = '2'; setVis(1, forced) } }; FSMenuNode.prototype.hide = function(forced) { with (this) with (obj) { if (!lyr || !lyr.ref || !visible) return; if (isNS4 && self.isMouseIn && isMouseIn(lyr.ref)) return show(); if (args[1]) lightParent(args[1], 0); if (child) child.hide(); if (par && par.child == this) par.child = null; if (lyr) { visible = 0; if (obj.onhide) obj.onhide(id); lyr.ref.parentNode.style.zIndex = '1'; setVis(0, forced) } } }; FSMenuNode.prototype.lightParent = function(elm, lit) { with (this) with (obj) { if (!cssLitClass || isNS4) return; if (lit) elm.className += (elm.className ? ' ' : '') + cssLitClass; else elm.className = elm.className.replace(new RegExp('(\\s*' + cssLitClass + ')+$'), '') } }; FSMenuNode.prototype.setVis = function(sh, forced) { with (this) with (obj) { if (lyr.forced && !forced) return; lyr.forced = forced; lyr.timer = lyr.timer || 0; lyr.counter = lyr.counter || 0; with (lyr) { clearTimeout(timer); var speed = sh ? animInSpeed : animOutSpeed; if (!counter) sty[cssProp] = sh ? cssVis : cssHid; if (isDOM && (speed < 1)) for (var a = 0; a < animations.length; a++) animations[a](ref, counter, sh); if (isDOM && (sh ? counter < 1 : counter > 0)) timer = setTimeout(myName + '.menus["' + id + '"].setVis(' + sh + ',' + (forced || 0) + ')', 50); else lyr.forced = false; counter = counter + speed * (sh ? 1 : -1); if (counter < 0.001) counter = 0; if (counter > 0.999) counter = 1 } } }; FSMenu.animSwipeDown = function(ref, counter, show) { var elm = ref.firstChild.style ? ref.firstChild : ref.firstChild.nextSibling, isOldIE = /MSIE\s(5|6|7)\./.test(navigator.userAgent); if (!elm) return; if (show && (counter == 0)) { if (!elm._fsm_marg) elm._fsm_marg = { 'top': elm.style.marginTop }; ref._fsm_height = ref.offsetHeight } if (counter == 1 || (counter < 0.01 && !show)) { ref.style.overflow = 'visible'; elm.style.marginTop = elm._fsm_marg.top; if (isOldIE) ref.style.height = '' } else { var cP = Math.pow(Math.sin(Math.PI * counter / 2), 0.75); ref.style.overflow = 'hidden'; if (isOldIE) ref.style.height = (ref._fsm_height * cP) + 'px'; else elm.style.marginTop = (0 - ref._fsm_height * (1 - cP)) + 'px' } }; FSMenu.animFade = function(ref, counter, show) { if (typeof ref.filters == 'unknown') return; var f = ref.filters, done = (show ? counter == 1 : counter < 0.01), a = /MSIE\s(4|5)/.test(navigator.userAgent) ? 'alpha' : 'DXImageTransform.Microsoft.Alpha'; if (f) { if (!done && ref.style.filter.indexOf(a) == -1) ref.style.filter += ' ' + (a == 'alpha' ? a : 'progid:' + a) + '(opacity=' + (counter * 100) + ')'; else if (f.length && f[a]) { if (done) f[a].enabled = false; else { f[a].opacity = (counter * 100); f[a].enabled = true } } } else ref.style.opacity = ref.style.MozOpacity = counter * 0.999 }; FSMenu.animClipDown = function(ref, counter, show) { var cP = Math.pow(Math.sin(Math.PI * counter / 2), 0.75); ref.style.clip = (counter == 1 ? ((window.opera || navigator.userAgent.indexOf('KHTML') > -1) ? '' : 'rect(auto,auto,auto,auto)') : 'rect(0,' + ref.offsetWidth + 'px,' + (ref.offsetHeight * cP) + 'px,0px)') }; FSMenu.prototype.activateMenu = function(id, subInd) { with (this) { if (!isDOM || !document.documentElement) return; var fsmFB = getRef('fsmenu-fallback'); if (fsmFB) { fsmFB.rel = 'alternate stylesheet'; fsmFB.disabled = true } var a, ul, li, parUL, mRoot = getRef(id), nodes; if (!FSMenu._count) FSMenu._count = 1; var evtProp = navigator.userAgent.indexOf('Safari') > -1 || isOp ? 'safRtnVal' : 'returnValue'; var lists = mRoot.getElementsByTagName('ul'); for (var i = 0; i < lists.length; i++) { li = ul = lists[i]; while (li) { if (li.nodeName.toLowerCase() == 'li') break; li = li.parentNode } if (!li) continue; parUL = li; while (parUL) { if (parUL.nodeName.toLowerCase() == 'ul') break; parUL = parUL.parentNode } a = li.getElementsByTagName('a'); if (!a) continue; a = a.item(0); var menuID; if (ul.id) menuID = ul.id; else { menuID = myName + '-id-' + FSMenu._count++; ul.setAttribute('id', menuID) } if (menus[menuID] && menus[menuID].lyr.ref == ul) continue; menus[menuID] = new FSMenuNode(menuID, false, this); var rootItem = (li.parentNode == mRoot) ? 1 : 0; var eShow = new Function('with(' + myName + '){var m=menus["' + menuID + '"],pM=menus["' + parUL.id + '"];if(!showOnClick||(showOnClick==1&&!' + rootItem + ')||((showOnClick<=2)&&((pM&&pM.child)||(m&&m.visible))))show("' + menuID + '",this)}'); var eHide = new Function('e', 'if(e.' + evtProp + '!=false)' + myName + '.hide("' + menuID + '")'); addEvent(a, 'mouseover', eShow); addEvent(a, 'mouseout', eHide); addEvent(a, 'focus', eShow); addEvent(a, 'blur', eHide); addEvent(a, 'click', new Function('e', 'var s=' + myName + '.showOnClick,m=' + myName + '.menus["' + menuID + '"];if(!((s==1&&' + rootItem + ')||s>=2))return;' + myName + '[m&&m.visible?"hide":"show"]("' + menuID + '",this);if(e.cancelable&&e.preventDefault)e.preventDefault();e.' + evtProp + '=false;return false')); if (subInd) a.insertBefore(subInd.cloneNode(true), a.firstChild) } var aNodes = mRoot.getElementsByTagName('a'); for (var i = 0; i < aNodes.length; i++) { addEvent(aNodes[i], 'focus', new Function('e', 'var node=this.parentNode;while(node){if(node.onfocus)node.onfocus(e);node=node.parentNode}')); addEvent(aNodes[i], 'blur', new Function('e', 'var node=this.parentNode;while(node){if(node.onblur)node.onblur(e);node=node.parentNode}')) } if (hideOnClick) addEvent(mRoot, 'click', new Function('e', 'if(e.' + evtProp + '!=false)' + myName + '.hideAll()')); menus[id] = new FSMenuNode(id, true, this) } }; var page = { win: self, minW: 0, minH: 0, MS: isIE && !isOp, db: document.compatMode && document.compatMode.indexOf('CSS') > -1 ? 'documentElement' : 'body' }; page.elmPos = function(e, p) { var x = 0, y = 0, w = p ? p : this.win; e = e ? (e.substr ? (isNS4 ? w.document.anchors[e] : getRef(e, w)) : e) : p; if (isNS4) { if (e && (e != p)) { x = e.x; y = e.y }; if (p) { x += p.pageX; y += p.pageY } } if (e && this.MS && navigator.platform.indexOf('Mac') > -1 && e.tagName == 'A') { e.onfocus = new Function('with(event){self.tmpX=clientX-offsetX;self.tmpY=clientY-offsetY}'); e.focus(); x = tmpX; y = tmpY; e.blur() } else while (e) { x += e.offsetLeft; y += e.offsetTop; e = e.offsetParent } return { x: x, y: y} }; if (isNS4) { var fsmMouseX, fsmMouseY, fsmOR = self.onresize, nsWinW = innerWidth, nsWinH = innerHeight; document.fsmMM = document.onmousemove; self.onresize = function() { if (fsmOR) fsmOR(); if (nsWinW != innerWidth || nsWinH != innerHeight) location.reload() }; document.captureEvents(Event.MOUSEMOVE); document.onmousemove = function(e) { fsmMouseX = e.pageX; fsmMouseY = e.pageY; return document.fsmMM ? document.fsmMM(e) : document.routeEvent(e) }; function isMouseIn(sty) { with (sty) return ((fsmMouseX > left) && (fsmMouseX < left + clip.width) && (fsmMouseY > top) && (fsmMouseY < top + clip.height)) } }

/*	ColorBox v1.3.1 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 */
(function(A) { var p = "colorbox", n = "hover", w = true, R = false, X, l = !A.support.opacity, T = l && !window.XMLHttpRequest, W = "click.colorbox", x = "cbox_open", L = "cbox_load", s = "cbox_complete", K = "cbox_cleanup", m = "cbox_closed", O = "resize.cbox_resize", I = "resize.cboxie6 scroll.cboxie6", F, U, V, d, y, i, b, E, c, P, C, f, q, h, k, M, j, H, r, Y, g, e, a, v, N, o, z, Q, u, G, B = { transition: "elastic", speed: 350, width: R, height: R, initialWidth: "400", initialHeight: "400", maxWidth: R, maxHeight: R, scalePhotos: w, scrollbars: w, inline: R, html: R, iframe: R, photo: R, href: R, title: R, rel: R, opacity: 0.9, preloading: w, current: "image {current} of {total}", previous: "previous", next: "next", close: "close", open: R, overlayClose: w, slideshow: R, slideshowAuto: w, slideshowSpeed: 2500, slideshowStart: "start slideshow", slideshowStop: "stop slideshow" }; function J(Z) { if (Z.keyCode === 37) { Z.preventDefault(); H.click() } else { if (Z.keyCode === 39) { Z.preventDefault(); j.click() } } } function D(Z, aa) { aa = aa === "x" ? document.documentElement.clientWidth : document.documentElement.clientHeight; return (typeof Z === "string") ? (Z.match(/%/) ? (aa / 100) * parseInt(Z, 10) : parseInt(Z, 10)) : Z } function t(Z) { return Q.photo || Z.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i) } function S() { for (var Z in Q) { if (typeof (Q[Z]) === "function") { Q[Z] = Q[Z].call(o) } } } X = A.fn.colorbox = function(aa, Z) { if (this.length) { this.each(function() { var ab = A(this).data(p) ? A.extend({}, A(this).data(p), aa) : A.extend({}, B, aa); A(this).data(p, ab).addClass("cboxelement") }) } else { A(this).data(p, A.extend({}, B, aa)) } A(this).unbind(W).bind(W, function(ac) { o = this; Q = A(o).data(p); S(); A().bind("keydown.cbox_close", function(ad) { if (ad.keyCode === 27) { ad.preventDefault(); X.close() } }); if (Q.overlayClose) { F.css({ cursor: "pointer" }).one("click", X.close) } o.blur(); G = Z || R; var ab = Q.rel || o.rel; if (ab && ab !== "nofollow") { c = A(".cboxelement").filter(function() { var ad = A(this).data(p).rel || this.rel; return (ad === ab) }); z = c.index(o); if (z < 0) { c = c.add(o); z = c.length - 1 } } else { c = A(o); z = 0 } if (!u) { u = w; A.event.trigger(x); r.html(Q.close); F.css({ opacity: Q.opacity }).show(); X.position(D(Q.initialWidth, "x"), D(Q.initialHeight, "y"), 0); if (T) { P.bind(I, function() { F.css({ width: P.width(), height: P.height(), top: P.scrollTop(), left: P.scrollLeft() }) }).trigger(I) } } X.slideshow(); X.load(); ac.preventDefault() }); if (aa && aa.open) { A(this).triggerHandler(W) } return this }; X.init = function() { function Z(aa) { return A('<div id="cbox' + aa + '"/>') } P = A(window); U = A('<div id="colorbox"/>'); F = Z("Overlay").hide(); V = Z("Wrapper"); d = Z("Content").append(C = Z("LoadedContent").css({ width: 0, height: 0 }), f = Z("LoadingOverlay"), q = Z("LoadingGraphic"), h = Z("Title"), k = Z("Current"), M = Z("Slideshow"), j = Z("Next"), H = Z("Previous"), r = Z("Close")); V.append(A("<div/>").append(Z("TopLeft"), y = Z("TopCenter"), Z("TopRight")), A("<div/>").append(i = Z("MiddleLeft"), d, b = Z("MiddleRight")), A("<div/>").append(Z("BottomLeft"), E = Z("BottomCenter"), Z("BottomRight"))).children().children().css({ "float": "left" }); A("body").prepend(F, U.append(V)); if (l) { U.addClass("cboxIE"); if (T) { F.css("position", "absolute") } } d.children().addClass(n).mouseover(function() { A(this).addClass(n) }).mouseout(function() { A(this).removeClass(n) }).hide(); Y = y.height() + E.height() + d.outerHeight(w) - d.height(); g = i.width() + b.width() + d.outerWidth(w) - d.width(); e = C.outerHeight(w); a = C.outerWidth(w); U.css({ "padding-bottom": Y, "padding-right": g }).hide(); j.click(X.next); H.click(X.prev); r.click(X.close); d.children().removeClass(n) }; X.position = function(ac, ab, aa, ad) { var ae = document.documentElement.clientHeight, ag = ae / 2 - ab / 2, af = document.documentElement.clientWidth / 2 - ac / 2, Z; if (ab > ae) { ag -= (ab - ae) } if (ag < 0) { ag = 0 } if (af < 0) { af = 0 } ag += P.scrollTop(); af += P.scrollLeft(); ac = ac - g; ab = ab - Y; Z = (U.width() === ac && U.height() === ab) ? 0 : aa; V[0].style.width = V[0].style.height = "9999px"; function ah(ai) { y[0].style.width = E[0].style.width = d[0].style.width = ai.style.width; q[0].style.height = f[0].style.height = d[0].style.height = i[0].style.height = b[0].style.height = ai.style.height } U.dequeue().animate({ height: ab, width: ac, top: ag, left: af }, { duration: Z, complete: function() { ah(this); V[0].style.width = (ac + g) + "px"; V[0].style.height = (ab + Y) + "px"; if (ad) { ad() } }, step: function() { ah(this) } }) }; X.resize = function(ae) { if (!u) { return } var aa, al, af, ad, ab, ah, am, Z, aj, ac = Q.transition === "none" ? 0 : Q.speed; P.unbind(O); if (!ae) { aj = setTimeout(function() { al = C.children().outerHeight(w); C[0].style.height = al + "px"; X.position(C.width() + a + g, al + e + Y, ac) }, 1); return } C.remove(); C = A(ae); function ai() { aa = Q.width ? v : v && v < C.width() ? v : C.width(); return aa } function ag() { al = Q.height ? N : N && N < C.height() ? N : C.height(); return al } if (!Q.scrollbars) { C.css({ overflow: "hidden" }) } C.hide().appendTo("body").attr({ id: "cboxLoadedContent" }).css({ width: ai() }).css({ height: ag() }).prependTo(d); if (T) { A("select:not(#colorbox select)").filter(function() { return A(this).css("visibility") !== "hidden" }).css({ visibility: "hidden" }).one(K, function() { A(this).css({ visibility: "inherit" }) }) } Z = A("#cboxPhoto")[0]; if (Z && Q.height) { af = (al - parseInt(Z.style.height, 10)) / 2; Z.style.marginTop = (af > 0 ? af : 0) + "px" } function ak(ao) { var an = aa + a + g, ap = al + e + Y; A().unbind("keydown", J); X.position(an, ap, ao, function() { if (!u) { return } if (l) { if (Z) { C.fadeIn(100) } U[0].style.removeAttribute("filter") } d.children().show(); A("#cboxIframeTemp").after("<iframe id='cboxIframe' name='iframe_" + new Date().getTime() + "' frameborder=0 src='" + (Q.href || o.href) + "' />").remove(); f.hide(); q.hide(); M.hide(); if (c.length > 1) { k.html(Q.current.replace(/\{current\}/, z + 1).replace(/\{total\}/, c.length)); j.html(Q.next); H.html(Q.previous); A().bind("keydown", J); if (Q.slideshow) { M.show() } } else { k.hide(); j.hide(); H.hide() } h.html(Q.title || o.title); A.event.trigger(s); if (G) { G.call(o) } if (Q.transition === "fade") { U.fadeTo(ac, 1, function() { if (l) { U[0].style.removeAttribute("filter") } }) } P.bind(O, function() { X.position(an, ap, 0) }) }) } if ((Q.transition === "fade" && U.fadeTo(ac, 0, function() { ak(0) })) || ak(ac)) { } if (Q.preloading && c.length > 1) { ad = z > 0 ? c[z - 1] : c[c.length - 1]; ah = z < c.length - 1 ? c[z + 1] : c[0]; am = A(ah).data(p).href || ah.href; ab = A(ad).data(p).href || ad.href; if (t(am)) { A("<img />").attr("src", am) } if (t(ab)) { A("<img />").attr("src", ab) } } }; X.load = function() { var Z, ad, aa, ac, ab = X.resize; o = c[z]; Q = A(o).data(p); S(); A.event.trigger(L); Z = Q.height ? D(Q.height, "y") - e - Y : R; ad = Q.width ? D(Q.width, "x") - a - g : R; aa = Q.href || o.href; f.show(); q.show(); r.show(); if (Q.maxHeight) { N = Q.maxHeight ? D(Q.maxHeight, "y") - e - Y : R; Z = Z && Z < N ? Z : N } if (Q.maxWidth) { v = Q.maxWidth ? D(Q.maxWidth, "x") - a - g : R; ad = ad && ad < v ? ad : v } N = Z; v = ad; if (Q.inline) { A('<div id="cboxInlineTemp" />').hide().insertBefore(A(aa)[0]).bind(L + " " + K, function() { C.children().insertBefore(this); A(this).remove() }); ab(A(aa).wrapAll("<div/>").parent()) } else { if (Q.iframe) { ab(A("<div><div id='cboxIframeTemp' /></div>")) } else { if (Q.html) { ab(A("<div/>").html(Q.html)) } else { if (t(aa)) { ac = new Image(); ac.onload = function() { ac.onload = null; if ((N || v) && Q.scalePhotos) { var ag = this.width, ae = this.height, ai = 0, ah = this, af = function() { ae += ae * ai; ag += ag * ai; ah.height = ae; ah.width = ag }; if (v && ag > v) { ai = (v - ag) / ag; af() } if (N && ae > N) { ai = (N - ae) / ae; af() } } ab(A("<div />").css({ width: this.width, height: this.height }).append(A(this).css({ width: this.width, height: this.height, display: "block", margin: "auto", border: 0 }).attr("id", "cboxPhoto"))); if (c.length > 1) { A(this).css({ cursor: "pointer" }).click(X.next) } if (l) { this.style.msInterpolationMode = "bicubic" } }; ac.src = aa } else { A("<div />").load(aa, function(ae, af) { if (af === "success") { ab(A(this)) } else { ab(A("<p>Request unsuccessful.</p>")) } }) } } } } }; X.next = function() { z = z < c.length - 1 ? z + 1 : 0; X.load() }; X.prev = function() { z = z > 0 ? z - 1 : c.length - 1; X.load() }; X.slideshow = function() { var aa, Z, ab = "cboxSlideshow_"; M.bind(K, function() { clearTimeout(Z); M.unbind(s + " " + L + " click") }); function ac() { M.text(Q.slideshowStop).bind(s, function() { Z = setTimeout(X.next, Q.slideshowSpeed) }).bind(L, function() { clearTimeout(Z) }).one("click", function() { aa(); A(this).removeClass(n) }); U.removeClass(ab + "off").addClass(ab + "on") } aa = function() { clearTimeout(Z); M.text(Q.slideshowStart).unbind(s + " " + L).one("click", function() { ac(); Z = setTimeout(X.next, Q.slideshowSpeed); A(this).removeClass(n) }); U.removeClass(ab + "on").addClass(ab + "off") }; if (Q.slideshow && c.length > 1) { if (Q.slideshowAuto) { ac() } else { aa() } } }; X.close = function() { A.event.trigger(K); u = R; A().unbind("keydown", J).unbind("keydown.cbox_close"); P.unbind(O + " " + I); F.css({ cursor: "auto" }).fadeOut("fast"); U.stop(w, R).fadeOut("fast", function() { C.remove(); U.css({ opacity: 1 }); d.children().hide(); A.event.trigger(m) }) }; X.element = function() { return o }; X.settings = B; A(X.init) } (jQuery));

