/*
Watermark v3.0.8 (December 3, 2010) plugin for jQuery
http://jquery-watermark.googlecode.com/
Copyright (c) 2009-2011 Todd Northrop
http://www.speednet.biz/
Dual licensed under the MIT or GPL Version 2 licenses.
*/
(function(a, j) { var n = "function", k = "password", d = "maxLength", f = "type", c = true, b = "", m = "placeholder", e = false, v = "watermark", o = v, i = "watermarkClass", s = "watermarkFocus", l = "watermarkSubmit", q = "watermarkMaxLength", h = "watermarkPassword", g = "watermarkText", u = ":data(" + o + ")", p = ":text,:password,:search,textarea", r = ["Page_ClientValidate"], t = e, w = m in document.createElement("input"); a.extend(a.expr[":"], { search: function(a) { return "search" === (a.type || b) }, data: function(c, d, b) { return !!a.data(c, b[3]) } }); a.watermark = { version: "3.0.8", options: { className: v, useNative: c, hideBeforeUnload: c }, hide: function(b) { a(b).filter(u).each(function() { a.watermark._hide(a(this)) }) }, _hide: function(a, o) { var n = a.val() || b, l = a.data(g) || b, m = a.data(q) || 0, k = a.data(i); if (l.length && n == l) { a.val(b); if (a.data(h)) if ((a.attr(f) || b) === "text") { var e = a.data(h) || [], c = a.parent() || []; if (e.length && c.length) { c[0].removeChild(a[0]); c[0].appendChild(e[0]); a = e } } if (m) { a.attr(d, m); a.removeData(q) } if (o) { a.attr("autocomplete", "off"); j.setTimeout(function() { a.select() }, 1) } } k && a.removeClass(k) }, show: function(b) { a(b).filter(u).each(function() { a.watermark._show(a(this)) }) }, _show: function(e) { var r = e.val() || b, j = e.data(g) || b, o = e.attr(f) || b, p = e.data(i); if ((r.length == 0 || r == j) && !e.data(s)) { t = c; if (e.data(h)) if (o === k) { var n = e.data(h) || [], m = e.parent() || []; if (n.length && m.length) { m[0].removeChild(e[0]); m[0].appendChild(n[0]); e = n; e.attr(d, j.length) } } if (o === "text" || o === "search") { var l = e.attr(d) || 0; if (l > 0 && j.length > l) { e.data(q, l); e.attr(d, j.length) } } p && e.addClass(p); e.val(j) } else a.watermark._hide(e) }, hideAll: function() { if (t) { a.watermark.hide(p); t = e } }, showAll: function() { a.watermark.show(p) } }; a.fn.watermark = function(t, q) { var r = "string"; if (!this.length) return this; var u = e, v = typeof t === r; if (typeof q === "object") { u = typeof q.className === r; q = a.extend({}, a.watermark.options, q) } else if (typeof q === r) { u = c; q = a.extend({}, a.watermark.options, { className: q }) } else q = a.watermark.options; if (typeof q.useNative !== n) q.useNative = q.useNative ? function() { return c } : function() { return e }; return this.each(function() { var y = "dragleave", x = "dragenter", A = this, e = a(A); if (!e.is(p)) return; if (e.data(o)) { if (v || u) { a.watermark._hide(e); v && e.data(g, t); u && e.data(i, q.className) } } else { if (w && q.useNative.call(A, e) && (e.attr("tagName") || b) !== "TEXTAREA") { v && e.attr(m, t); return } e.data(g, v ? t : b); e.data(i, q.className); e.data(o, 1); if ((e.attr(f) || b) === k) { var B = e.wrap("<span>").parent(), n = a(B.html().replace(/type=["']?password["']?/i, 'type="text"')); n.data(g, e.data(g)); n.data(i, e.data(i)); n.data(o, 1); n.attr(d, t.length); n.focus(function() { a.watermark._hide(n, c) }).bind(x, function() { a.watermark._hide(n) }).bind("dragend", function() { j.setTimeout(function() { n.blur() }, 1) }); e.blur(function() { a.watermark._show(e) }).bind(y, function() { a.watermark._show(e) }); n.data(h, e); e.data(h, n) } else e.focus(function() { e.data(s, 1); a.watermark._hide(e, c) }).blur(function() { e.data(s, 0); a.watermark._show(e) }).bind(x, function() { a.watermark._hide(e) }).bind(y, function() { a.watermark._show(e) }).bind("dragend", function() { j.setTimeout(function() { a.watermark._show(e) }, 1) }).bind("drop", function(c) { var a = c.originalEvent.dataTransfer.getData("Text"); e.val().replace(a, b) === e.data(g) && e.val(a); e.focus() }); if (A.form) { var r = A.form, z = a(r); if (!z.data(l)) { z.submit(a.watermark.hideAll); if (r.submit) { z.data(l, r.submit); r.submit = function(c, b) { return function() { var d = b.data(l); a.watermark.hideAll(); if (d.apply) d.apply(c, Array.prototype.slice.call(arguments)); else d() } } (r, z) } else { z.data(l, 1); r.submit = function(b) { return function() { a.watermark.hideAll(); delete b.submit; b.submit() } } (r) } } } } a.watermark._show(e) }) }; r.length && a(function() { for (var b, c, d = r.length - 1; d >= 0; d--) { b = r[d]; c = j[b]; if (typeof c === n) j[b] = function(b) { return function() { a.watermark.hideAll(); return b.apply(null, Array.prototype.slice.call(arguments)) } } (c) } }); a(j).bind("beforeunload", function() { a.watermark.options.hideBeforeUnload && a.watermark.hideAll() }) })(jQuery, window);

/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
* Licensed under the MIT license.
*/

// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time) {
    time = time.replace("+0000", "");
    var date = new Date((time || "").replace(/-/g, "/").replace(/[TZ]/g, " ")),
		diff = (((new Date()).getTime() - date.getTime()) / 1000),
		day_diff = Math.floor(diff / 86400);

    if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31)
        return " ";

    return day_diff == 0 && (
			diff < 60 && "just now" ||
			diff < 120 && "1 minute ago" ||
			diff < 3600 && Math.floor(diff / 60) + " minutes ago" ||
			diff < 7200 && "1 hour ago" ||
			diff < 86400 && Math.floor(diff / 3600) + " hours ago") ||
		day_diff == 1 && "Yesterday" ||
		day_diff < 7 && day_diff + " days ago" ||
		day_diff < 31 && Math.ceil(day_diff / 7) + " weeks ago";

}

// If jQuery is included in the page, adds a jQuery plugin to handle it as well
if (typeof jQuery != "undefined")
    jQuery.fn.prettyDate = function() {
        return this.each(function() {
            var date = prettyDate($(this).text());
            if (date)
                jQuery(this).text(date);
        });
    };


/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/

(function(jQuery) {

    // We override the animation for all of these color styles
    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i, attr) {
        jQuery.fx.step[attr] = function(fx) {
            if (fx.state == 0) {
                fx.start = getColor(fx.elem, attr);
                fx.end = getRGB(fx.end);
            }

            fx.elem.style[attr] = "rgb(" + [
				Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
				Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
				Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
			].join(",") + ")";
        }
    });

    // Color Conversion functions from highlightFade
    // By Blair Mitchelmore
    // http://jquery.offput.ca/highlightFade/

    // Parse strings looking for color tuples [255,255,255]
    function getRGB(color) {
        var result;

        // Check if we're already dealing with an array of colors
        if (color && color.constructor == Array && color.length == 3)
            return color;

        // Look for rgb(num,num,num)
        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
            return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

        // Look for rgb(num%,num%,num%)
        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
            return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];

        // Look for #a0b1c2
        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
            return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];

        // Look for #fff
        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
            return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];

        // Otherwise, we're most likely dealing with a named color
        return colors[jQuery.trim(color).toLowerCase()];
    }

    function getColor(elem, attr) {
        var color;

        do {
            color = jQuery.curCSS(elem, attr);

            // Keep going until we find an element that has color, or we hit the body
            if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body"))
                break;

            attr = "backgroundColor";
        } while (elem = elem.parentNode);

        return getRGB(color);
    };

    // Some named colors to work with
    // From Interface by Stefan Petre
    // http://interface.eyecon.ro/

    var colors = {
        aqua: [0, 255, 255],
        azure: [240, 255, 255],
        beige: [245, 245, 220],
        black: [0, 0, 0],
        blue: [0, 0, 255],
        brown: [165, 42, 42],
        cyan: [0, 255, 255],
        darkblue: [0, 0, 139],
        darkcyan: [0, 139, 139],
        darkgrey: [169, 169, 169],
        darkgreen: [0, 100, 0],
        darkkhaki: [189, 183, 107],
        darkmagenta: [139, 0, 139],
        darkolivegreen: [85, 107, 47],
        darkorange: [255, 140, 0],
        darkorchid: [153, 50, 204],
        darkred: [139, 0, 0],
        darksalmon: [233, 150, 122],
        darkviolet: [148, 0, 211],
        fuchsia: [255, 0, 255],
        gold: [255, 215, 0],
        green: [0, 128, 0],
        indigo: [75, 0, 130],
        khaki: [240, 230, 140],
        lightblue: [173, 216, 230],
        lightcyan: [224, 255, 255],
        lightgreen: [144, 238, 144],
        lightgrey: [211, 211, 211],
        lightpink: [255, 182, 193],
        lightyellow: [255, 255, 224],
        lime: [0, 255, 0],
        magenta: [255, 0, 255],
        maroon: [128, 0, 0],
        navy: [0, 0, 128],
        olive: [128, 128, 0],
        orange: [255, 165, 0],
        pink: [255, 192, 203],
        purple: [128, 0, 128],
        violet: [128, 0, 128],
        red: [255, 0, 0],
        silver: [192, 192, 192],
        white: [255, 255, 255],
        yellow: [255, 255, 0]
    };

})(jQuery);


/**
* jQuery Opacity Rollover plugin
*
* Copyright (c) 2009 Trent Foley (http://trentacular.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*/
; (function($) {
    var defaults = {
        mouseOutOpacity: 0.67,
        mouseOverOpacity: 1.0,
        fadeSpeed: 'fast',
        exemptionSelector: '.selected'
    };
    $.fn.opacityrollover = function(settings) {
        // Initialize the effect
        $.extend(this, defaults, settings);
        var config = this;
        function fadeTo(element, opacity) {
            var $target = $(element);
            if (config.exemptionSelector)
                $target = $target.not(config.exemptionSelector);
            $target.fadeTo(config.fadeSpeed, opacity);
        }
        this.css('opacity', this.mouseOutOpacity)
.hover(
function() {
    fadeTo(this, config.mouseOverOpacity);
},
function() {
    fadeTo(this, config.mouseOutOpacity);
});
        return this;
    };
})(jQuery); 



/*
Image Scale 
*/
(function(a) { a.fn.scaleImage = function(c) { var d = a.extend({ parent: false, scale: "fill", center: true, fade: 0 }, c); return this.each(function() { var g = a(this); var h = d.parent ? g.parents(d.parent) : g.parent(); h.css({ opacity: 0, overflow: "hidden" }); if (h.length > 0) { g.removeAttr("height").removeAttr("width"); if (this.complete) { f(g, h) } else { g.load(function() { f(g, h) }) } } }); function f(h, k) { var r = b(h), s = r.width, j = r.height, t = k.width(), m = k.height(), u = parseInt(h.css("borderLeftWidth"), 10) + parseInt(h.css("borderRightWidth"), 10), n = parseInt(h.css("borderTopWidth"), 10) + parseInt(h.css("borderBottomWidth"), 10), q, o, p, l, g; if (m === 0 || t === 0) { var i = e(k); t = i.width; m = i.height } u = isNaN(u) ? 0 : u; n = isNaN(n) ? 0 : n; q = t / s; o = m / j; if (d.scale === "fit") { p = q < o ? q : o } else { if (d.scale === "fill") { p = q > o ? q : o } } l = parseInt(s * p, 10) - u; g = parseInt(j * p, 10) - n; h.css({ width: l, height: g }).attr({ width: l, height: g }); if (d.center) { h.css("margin-left", Math.floor((t - l) / 2)); h.css("margin-top", Math.floor((m - g) / 2)) } if (d.fade > 0) { k.animate({ opacity: 1 }, d.fade) } else { k.css("opacity", 1) } } function b(h) { var g = new Image(); g.src = h.attr("src"); return { width: g.width, height: g.height} } function e(h) { var i = h.clone().css({ visibility: "hidden", display: "block", position: "absolute" }); a("body").append(i); var g = { width: i.width(), height: i.height() }; i.remove(); return g } } })(jQuery);
