
(function($) {                                          // Compliant with jquery.noConflict()
    $.fn.jCarouselLite = function(o) {
	o = $.extend({
	    btnPrev: null,
	    btnNext: null,
	    btnGo: null,
	    mouseWheel: false,
	    auto: null,

	    speed: 200,
	    easing: null,

	    vertical: false,
	    circular: true,
	    visible: 3,
	    start: 0,
	    scroll: 1,

	    beforeStart: null,
	    afterEnd: null
	}, o || {});

	return this.each(function() {                           // Returns the element collection. Chainable.

	    var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
	    var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

	    if(o.circular) {
		ul.prepend(tLi.slice(tl-v-1+1).clone())
		.append(tLi.slice(0,v).clone());
		o.start += v;
	    }

	    var li = $("li", ul), itemLength = li.size(), curr = o.start;
	    div.css("visibility", "visible");

	    li.css({
		overflow: "hidden",
		float: o.vertical ? "none" : "left"
	    });
	    ul.css({
		margin: "0",
		padding: "0",
		position: "relative",
		"list-style-type": "none",
		"z-index": "1"
	    });
	    div.css({
		overflow: "hidden",
		position: "relative",
		"z-index": "2",
		left: "0px"
	    });

	    var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
	    var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
	    var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

	    li.css({
		width: li.width(),
		height: li.height()
	    });
	    ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));

	    div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images

	    if(o.btnPrev)
		$(o.btnPrev).click(function() {
		    return go(curr-o.scroll);
		});

	    if(o.btnNext)
		$(o.btnNext).click(function() {
		    return go(curr+o.scroll);
		});

	    if(o.btnGo)
		$.each(o.btnGo, function(i, val) {
		    $(val).click(function() {
			return go(o.circular ? o.visible+i : i);
		    });
		});

	    if(o.mouseWheel && div.mousewheel)
		div.mousewheel(function(e, d) {
		    return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
		});

	    if(o.auto)
		setInterval(function() {
		    go(curr+o.scroll);
		}, o.auto+o.speed);

	    function vis() {
		return li.slice(curr).slice(0,v);
	    };

	    function go(to) {
		if(!running) {

		    if(o.beforeStart)
			o.beforeStart.call(this, vis());

		    if(o.circular) {            // If circular we are in first or last, then goto the other end
			if(to<=o.start-v-1) {           // If first, then goto last
			    ul.css(animCss, -((itemLength-(v*2))*liSize)+"px");
			    // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
			    curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll;
			} else if(to>=itemLength-v+1) { // If last, then goto first
			    ul.css(animCss, -( (v) * liSize ) + "px" );
			    // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
			    curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
			} else curr = to;
		    } else {                    // If non-circular and to points to first or last, we just return.
			if(to<0 || to>itemLength-v) return;
			else curr = to;
		    }                           // If neither overrides it, the curr will still be "to" and we can proceed.

		    running = true;

		    ul.animate(
			animCss == "left" ? {
			    left: -(curr*liSize)
			} : {
			    top: -(curr*liSize)
			} , o.speed, o.easing,
			function() {
			    if(o.afterEnd)
				o.afterEnd.call(this, vis());
			    running = false;
			}
			);
		    // Disable buttons when the carousel reaches the last/first, and enable when not
		    if(!o.circular) {
			$(o.btnPrev + "," + o.btnNext).removeClass("disabled");
			$( (curr-o.scroll<0 && o.btnPrev)
			    ||
			    (curr+o.scroll > itemLength-v && o.btnNext)
			    ||
			    []
			    ).addClass("disabled");
		    }

		}
		return false;
	    };
	});
    };

    function css(el, prop) {
	return parseInt($.css(el[0], prop)) || 0;
    };
    function width(el) {
	return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
    };
    function height(el) {
	return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
    };

})(jQuery);


/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 *
 * Open source under the BSD License.
 *
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 *
 * Neither the name of the author nor the names of contributors may be used to endorse
 * or promote products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
    def: 'easeOutQuad',
    swing: function (x, t, b, c, d) {
	//alert(jQuery.easing.default);
	return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
	return c*(t/=d)*t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
	return -c *(t/=d)*(t-2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
    },
    easeInCubic: function (x, t, b, c, d) {
	return c*(t/=d)*t*t + b;
    },
    easeOutCubic: function (x, t, b, c, d) {
	return c*((t=t/d-1)*t*t + 1) + b;
    },
    easeInOutCubic: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t + b;
	return c/2*((t-=2)*t*t + 2) + b;
    },
    easeInQuart: function (x, t, b, c, d) {
	return c*(t/=d)*t*t*t + b;
    },
    easeOutQuart: function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
    },
    easeInOutQuart: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
	return -c/2 * ((t-=2)*t*t*t - 2) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
	return c*(t/=d)*t*t*t*t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
	return c/2*((t-=2)*t*t*t*t + 2) + b;
    },
    easeInSine: function (x, t, b, c, d) {
	return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
    },
    easeOutSine: function (x, t, b, c, d) {
	return c * Math.sin(t/d * (Math.PI/2)) + b;
    },
    easeInOutSine: function (x, t, b, c, d) {
	return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
	return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
	return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
	if (t==0) return b;
	if (t==d) return b+c;
	if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
	return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function (x, t, b, c, d) {
	return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
    },
    easeOutCirc: function (x, t, b, c, d) {
	return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
    },
    easeInOutCirc: function (x, t, b, c, d) {
	if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
	return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
    },
    easeInElastic: function (x, t, b, c, d) {
	var s=1.70158;
	var p=0;
	var a=c;
	if (t==0) return b;
	if ((t/=d)==1) return b+c;
	if (!p) p=d*.3;
	if (a < Math.abs(c)) {
	    a=c;
	    var s=p/4;
	}
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
    },
    easeOutElastic: function (x, t, b, c, d) {
	var s=1.70158;
	var p=0;
	var a=c;
	if (t==0) return b;
	if ((t/=d)==1) return b+c;
	if (!p) p=d*.3;
	if (a < Math.abs(c)) {
	    a=c;
	    var s=p/4;
	}
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
    },
    easeInOutElastic: function (x, t, b, c, d) {
	var s=1.70158;
	var p=0;
	var a=c;
	if (t==0) return b;
	if ((t/=d/2)==2) return b+c;
	if (!p) p=d*(.3*1.5);
	if (a < Math.abs(c)) {
	    a=c;
	    var s=p/4;
	}
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
    },
    easeInBack: function (x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
    },
    easeOutBack: function (x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
    },
    easeInOutBack: function (x, t, b, c, d, s) {
	if (s == undefined) s = 1.70158;
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
    },
    easeInBounce: function (x, t, b, c, d) {
	return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
    },
    easeOutBounce: function (x, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
	    return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
	    return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
	    return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
	    return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
    },
    easeInOutBounce: function (x, t, b, c, d) {
	if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
	return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
    }
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 *
 * Open source under the BSD License.
 *
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 *
 * Neither the name of the author nor the names of contributors may be used to endorse
 * or promote products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */


/**
 * jQuery Gallery Plugin
 *   http://code.google.com/p/jquery-gallery-plugin/
 *
 * Copyright (c) 2009 Yusuke Horie
 *
 * Released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since  : 0.1.0 - 08/02/2009
 * Version: 0.3.0 - 08/25/2009
 */
(function(jQuery) {

    /** private properties **/

    var _inc = 0;

    /** public methods **/

    jQuery.fn.gallery = function (options) {
	var options = jQuery.extend({}, jQuery.fn.gallery.defaults, options);

	return this.each(function(i, e) {
	    var
	    $this = jQuery(e),
	    id = options.prefix + _inc,
	    i = 0,
	    n = 0,
	    limit = 5,
	    step = 1,
	    duration = Math.ceil(options.interval*0.3),
	    timeId = null;

	    var height;
	    if (!options.height) {
		if (!parseInt($this.css('height'), 10)) {
		    height = '450px';
		} else {
		    height = $this.height();
		}
	    } else {
		height = options.height;
	    }

	    var
	    width = (!options.width) ? $this.width(): options.width,
	    paddingTop = parseInt($this.css('padding-top'), 10),
	    paddingBottom = parseInt($this.css('padding-bottom'), 10),
	    pheight = parseInt(height, 10),
	    contentHeight = pheight - options.thumbHeight + paddingTop,
	    o = $this.offset(),
	    barWidth = jQuery(window).width() - o.left;

	    // thumbnail bar
	    var barTop = (options.barPosition == 'top') ? paddingTop: contentHeight;

	    if (options.toggleBar) {
		if (options.barPosition == 'top') {
		    $this.hover(
			function() {
			    $('#thumbnails_' + id).animate({
				top: paddingTop
			    }, {
				queue: false,
				duration: 300
			    });
			},
			function() {
			    $('#thumbnails_' + id).animate({
				top: barTop
			    }, {
				queue: false,
				duration: 300
			    });
			});
		    barTop = (options.thumbHeight + paddingTop) * (-1);
		} else {
		    var outerHeight = pheight + paddingTop + paddingBottom;
		    $this.hover(
			function() {
			    $('#thumbnails_' + id).animate({
				top: contentHeight
			    }, {
				queue: false,
				duration: 300
			    });
			},
			function() {
			    $('#thumbnails_' + id).animate({
				top: outerHeight
			    }, {
				queue: false,
				duration: 300
			    });
			});
		    barTop = outerHeight;
		}
	    }

	    $this
	    .css({
		width: width,
		height: height,
		zIndex: options.zIndex
	    })
	    .prepend('<div id="' + id + '"></div>')
	    .find('ul')
	    .attr('id', 'thumbnails_' + id)
	    .addClass(options.barClass)
	    .css({
		top: barTop,
		height: options.thumbHeight + 'px',
		width: barWidth + 'px',
		zIndex: options.zIndex + 2000
	    })
	    .find('li')
	    .css({
		width: options.thumbWidth + 'px',
		height: options.thumbHeight + 'px'
	    })
	    .each(function (index) {
		jQuery.data(this, 'index', index);
	    })
	    .click(function (event) {
		event.preventDefault();
		if (options.slideshow) clearInterval(timeId);

		if ($.isFunction(options.onSelect))
		    options.onSelect.apply(this, [event]);

		var $e = this;
		bar.find('li').each(function (index, e) {
		    if (e == $e) {
			step = index;
			return false;
		    }
		});

		i = jQuery.data(this, 'index');

		// pre load
		for (var j=i; j<i+limit; j++) {
		    var o = pictures.eq(j);
		    if (o.length > 0 && typeof o.data('loaded') == 'undefined') {
			preLoad(o.attr('href'));
			o.data('loaded', true);
		    }
		}

		display();
		if (options.slideshow)
		    timeId = setInterval(display, options.interval);
	    });

	    if (options.showOverlay) {
		var
		itop = pheight*(1-options.ratio) + paddingTop,
		ileft = $this.css('padding-left'),
		iheight = (pheight*options.ratio) + paddingTop;

		// screen
		$('<div />')
		.addClass(options.screenClass)
		.css({
		    opacity: 0.5,
		    top: itop,
		    left: 0,
		    height: iheight,
		    width: $this.outerWidth(),
		    zIndex: options.zIndex + 1000
		})
		.insertAfter('#' + id);

		$('<div />')
		.addClass(options.infoClass)
		.html('<div id="gtitle_' + id + '" class="' + options.titleClass + '" style="display:none;"></div>' +
		    '<div id="gdesc_' + id + '" class="' + options.descClass + '" style="display:none;"></div>')
		.css({
		    top: itop,
		    left: 0,
		    height: iheight,
		    zIndex: options.zIndex + 1500
		})
		.insertAfter('#' + id);
	    }

	    // content container
	    var c = jQuery('#' + id).css({
		position: 'relative',
		width: width,
		height: height,
		overflow: 'hidden'
	    }).addClass(options.contentClass);

	    var
	    bar = $this.find('ul').show(),
	    thumbnails = bar.find('img'),
	    pictures = $this.find('a').bind('click.gallery', function (e) {
		e.preventDefault();
	    }),
	    gtitle = $('#gtitle_' + id),
	    gdesc = $('#gdesc_' + id),
	    len =  thumbnails.length,
	    w = $this.find('li:first').outerWidth(true);

	    var display = function () {
		var t = thumbnails.eq(i);
		var pict = pictures.eq(i);
		var p = pict.attr('href');
		var pid = id + '_' + i;

		// pre load
		var next = pictures.eq(i+limit);
		if (next.length > 0 && typeof next.data('loaded') == 'undefined') {
		    preLoad(next.attr('href'));
		}

		// delete previous picture
		c.find('img').animate({
		    opacity: 0.0
		}, {
		    queue: false,
		    duration: duration,
		    easing: 'linear',
		    complete: function() {
			jQuery(this).remove();
		    }
		});

		// append new picture
		jQuery('<img />')
		.attr('src', p)
		.attr('id', pid)
		.css({
		    position: 'absolute',
		    top: 0,
		    left: 0,
		    opacity: 0.0
		})
		.bind('click.gallery', function (event) {
		    options.onClick.apply(this, [event, pict.get()]);
		})
		.appendTo('#' + id)
		.animate({
		    opacity: 1.0
		}, {
		    queue: false,
		    duration: duration,
		    easing: 'linear'
		})
		.load(function () {
		    pict.data('loaded', true);
		});

		var title = t.attr('title');
		var id_of_desc = pict.attr('rel');
		var desc = (id_of_desc && $('#' + id_of_desc).length > 0)
		? $('#' + id_of_desc).html(): pict.attr('title');

		if (n != 0) {
		    // title
		    if (typeof title != 'undefined')
			gtitle.fadeOut(duration*0.3, function () {
			    jQuery(this).html(title).show();
			});

		    // description
		    if (typeof desc != 'undefined')
			gdesc.fadeOut(duration*0.3, function () {
			    jQuery(this).html(desc).show();
			});

		    // scrolle
		    bar.animate({
			left: w*(-1)*step
		    }, {
			queue: false,
			duration: 300,
			easing: options.easing,
			complete: function () {
			    var $t = jQuery(this).css({
				left: 0
			    });
			    var f = $t.find('li').slice(0, step);
			    var indexes = f.map(function () {
				return jQuery.data(this, 'index');
			    });
			    var cln = f.clone(true).each(function (j) {
				jQuery.data(this, 'index', indexes[j]);
			    }).hide().appendTo(this).fadeIn(duration);
			    f.remove();
			    step = 1;
			}
		    });
		} else {
		    // title & description
		    if (typeof title != 'undefined') gtitle.html(title).show();
		    if (typeof desc != 'undefined') gdesc.html(desc).show();
		}

		options.onChange.apply($this.get(), [i, pict.get()]);

		if (i < (len-1)) {
		    i++;
		} else {
		    i = 0;
		}
		n++;
	    };

	    // pre load
	    for (var j=0; j<limit; j++) {
		var o = pictures.eq(j);
		if (o.length > 0) {
		    preLoad(o.attr('href'));
		    o.data('loaded', true);
		}
	    }

	    display();
	    if (options.slideshow)
		timeId = setInterval(display, options.interval);

	    _inc++;
	});
    };

    jQuery.fn.gallery.defaults = {
	width: null,
	height: null,
	thumbWidth: 55,
	thumbHeight: 55,
	zIndex: 1000,
	interval: 4500,
	prefix: 'gallery_',
	easing: 'linear',
	ratio: 0.35,
	slideshow: true,
	toggleBar: true,
	showOverlay: true,
	barPosition: null,
	barClass: 'galleryBar',
	contentClass: 'galleryContent',
	infoClass: 'galleryInfo',
	screenClass: 'galleryScreen',
	titleClass: 'galleryTitle',
	descClass: 'galleryDesc',
	onClick: function () {
	    return;
	},
	onSelect: function () {
	    return;
	},
	onChange: function () {
	    return;
	}
    };

    /** private methods **/

    var preLoad = function (url) {
	jQuery('<img />').attr('src', url);
    };

})(jQuery);


/*
 * Facebox (for jQuery)
 * version: 1.2 (05/05/2008)
 * @requires jQuery v1.2 or later
 *
 * Examples at http://famspam.com/facebox/
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
 *
 * Usage:
 *
 *  jQuery(document).ready(function() {
 *    jQuery('a[rel*=facebox]').facebox()
 *  })
 *
 *  <a href="#terms" rel="facebox">Terms</a>
 *    Loads the #terms div in the box
 *
 *  <a href="terms.html" rel="facebox">Terms</a>
 *    Loads the terms.html page in the box
 *
 *  <a href="terms.png" rel="facebox">Terms</a>
 *    Loads the terms.png image in the box
 *
 *
 *  You can also use it programmatically:
 *
 *    jQuery.facebox('some html')
 *
 *  The above will open a facebox with "some html" as the content.
 *
 *    jQuery.facebox(function($) {
 *      $.get('blah.html', function(data) { $.facebox(data) })
 *    })
 *
 *  The above will show a loading screen before the passed function is called,
 *  allowing for a better ajaxy experience.
 *
 *  The facebox function can also display an ajax page or image:
 *
 *    jQuery.facebox({ ajax: 'remote.html' })
 *    jQuery.facebox({ image: 'dude.jpg' })
 *
 *  Want to close the facebox?  Trigger the 'close.facebox' document event:
 *
 *    jQuery(document).trigger('close.facebox')
 *
 *  Facebox also has a bunch of other hooks:
 *
 *    loading.facebox
 *    beforeReveal.facebox
 *    reveal.facebox (aliased as 'afterReveal.facebox')
 *    init.facebox
 *
 *  Simply bind a function to any of these hooks:
 *
 *   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
 *
 */
(function($) {
    $.facebox = function(data, klass) {
	$.facebox.loading()

	if (data.ajax) fillFaceboxFromAjax(data.ajax)
	else if (data.image) fillFaceboxFromImage(data.image)
	else if (data.div) fillFaceboxFromHref(data.div)
	else if ($.isFunction(data)) data.call($)
	else $.facebox.reveal(data, klass)
    }

    /*
   * Public, $.facebox methods
   */

    $.extend($.facebox, {
	settings: {
	    opacity      : 0,
	    overlay      : true,
	    loadingImage : 'facebox/loading.gif',
	    closeImage   : 'facebox/closelabel.gif',
	    imageTypes   : [ 'png', 'jpg', 'jpeg', 'gif' ],
	    faceboxHtml  : '\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content"> \
                </div> \
                <div class="footer"> \
                  <a href="#" class="close"> \
                    <img src="facebox/closelabel.gif" class="close_image" /> \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
	},

	loading: function() {
	    init()
	    if ($('#facebox .loading').length == 1) return true
	    showOverlay()

	    $('#facebox .content').empty()
	    $('#facebox .body').children().hide().end().
	    append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')

	    $('#facebox').css({
		top:	getPageScroll()[1] + (getPageHeight() / 10),
		left:	385.5
	    }).show()

	    $(document).bind('keydown.facebox', function(e) {
		if (e.keyCode == 27) $.facebox.close()
		return true
	    })
	    $(document).trigger('loading.facebox')
	},

	reveal: function(data, klass) {
	    $(document).trigger('beforeReveal.facebox')
	    if (klass) $('#facebox .content').addClass(klass)
	    $('#facebox .content').append(data)
	    $('#facebox .loading').remove()
	    $('#facebox .body').children().fadeIn('normal')
	    $('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2))
	    $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
	},

	close: function() {
	    $(document).trigger('close.facebox')
	    return false
	}
    })

    /*
   * Public, $.fn methods
   */

    $.fn.facebox = function(settings) {
	init(settings)

	function clickHandler() {
	    $.facebox.loading(true)

	    // support for rel="facebox.inline_popup" syntax, to add a class
	    // also supports deprecated "facebox[.inline_popup]" syntax
	    var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
	    if (klass) klass = klass[1]

	    fillFaceboxFromHref(this.href, klass)
	    return false
	}

	return this.click(clickHandler)
    }

    /*
   * Private methods
   */

    // called one time to setup facebox on this page
    function init(settings) {
	if ($.facebox.settings.inited) return true
	else $.facebox.settings.inited = true

	$(document).trigger('init.facebox')
	makeCompatible()

	var imageTypes = $.facebox.settings.imageTypes.join('|')
	$.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i')

	if (settings) $.extend($.facebox.settings, settings)
	$('body').append($.facebox.settings.faceboxHtml)

	var preload = [ new Image(), new Image() ]
	preload[0].src = $.facebox.settings.closeImage
	preload[1].src = $.facebox.settings.loadingImage

	$('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() {
	    preload.push(new Image())
	    preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
	})

	$('#facebox .close').click($.facebox.close)
	$('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
    }

    // getPageScroll() by quirksmode.com
    function getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
	    yScroll = self.pageYOffset;
	    xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
	    yScroll = document.documentElement.scrollTop;
	    xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
	    yScroll = document.body.scrollTop;
	    xScroll = document.body.scrollLeft;
	}
	return new Array(xScroll,yScroll)
    }

    // Adapted from getPageSize() by quirksmode.com
    function getPageHeight() {
	var windowHeight
	if (self.innerHeight) {	// all except Explorer
	    windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	    windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
	    windowHeight = document.body.clientHeight;
	}
	return windowHeight
    }

    // Backwards compatibility
    function makeCompatible() {
	var $s = $.facebox.settings

	$s.loadingImage = $s.loading_image || $s.loadingImage
	$s.closeImage = $s.close_image || $s.closeImage
	$s.imageTypes = $s.image_types || $s.imageTypes
	$s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
    }

    // Figures out what you want to display and displays it
    // formats are:
    //     div: #id
    //   image: blah.extension
    //    ajax: anything else
    function fillFaceboxFromHref(href, klass) {
	// div
	if (href.match(/#/)) {
	    var url    = window.location.href.split('#')[0]
	    var target = href.replace(url,'')
	    $.facebox.reveal($(target).clone().show(), klass)

	// image
	} else if (href.match($.facebox.settings.imageTypesRegexp)) {
	    fillFaceboxFromImage(href, klass)
	// ajax
	} else {
	    fillFaceboxFromAjax(href, klass)
	}
    }

    function fillFaceboxFromImage(href, klass) {
	var image = new Image()
	image.onload = function() {
	    $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
	}
	image.src = href
    }

    function fillFaceboxFromAjax(href, klass) {
	$.get(href, function(data) {
	    $.facebox.reveal(data, klass)
	})
    }

    function skipOverlay() {
	return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
    }

    function showOverlay() {
	if (skipOverlay()) return

	if ($('facebox_overlay').length == 0)
	    $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')

	$('#facebox_overlay').hide().addClass("facebox_overlayBG")
	.css('opacity', $.facebox.settings.opacity)
	.click(function() {
	    $(document).trigger('close.facebox')
	})
	.fadeIn(200)
	return false
    }

    function hideOverlay() {
	if (skipOverlay()) return

	$('#facebox_overlay').fadeOut(200, function(){
	    $("#facebox_overlay").removeClass("facebox_overlayBG")
	    $("#facebox_overlay").addClass("facebox_hide")
	    $("#facebox_overlay").remove()
	})

	return false
    }

    /*
   * Bindings
   */

    $(document).bind('close.facebox', function() {
	$(document).unbind('keydown.facebox')
	$('#facebox').fadeOut(function() {
	    $('#facebox .content').removeClass().addClass('content')
	    hideOverlay()
	    $('#facebox .loading').remove()
	})
    })

})(jQuery);
