/*
 * FancyBox - simple and fancy jQuery plugin
 * Examples and documentation at: http://fancy.klade.lv/
 * Version: 1.2.1 (13/03/2009)
 * Copyright (c) 2009 Janis Skarnelis
 * Licensed under the MIT License: http://en.wikipedia.org/wiki/MIT_License
 * Requires: jQuery v1.3+
*/
;(function(jQuery) {

	jQuery.fn.fixPNG = function() {
		return this.each(function () {
			var image = jQuery(this).css('backgroundImage');

			if (image.match(/^url\(["']?(.*\.png)["']?\)jQuery/i)) {
				image = RegExp.jQuery1;
				jQuery(this).css({
					'backgroundImage': 'none',
					'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=" + (jQuery(this).css('backgroundRepeat') == 'no-repeat' ? 'crop' : 'scale') + ", src='" + image + "')"
				}).each(function () {
					var position = jQuery(this).css('position');
					if (position != 'absolute' && position != 'relative')
						jQuery(this).css('position', 'relative');
				});
			}
		});
	};

	var elem, opts, busy = false, imagePreloader = new Image, loadingTimer, loadingFrame = 1, imageRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?jQuery/i;
	var isIE = (jQuery.browser.msie && parseInt(jQuery.browser.version.substr(0,1)) < 8);

	jQuery.fn.fancybox = function(settings) {
		settings = jQuery.extend({}, jQuery.fn.fancybox.defaults, settings);

		var matchedGroup = this;

		function _initialize() {
			elem = this;
			opts = settings;

			_start();

			return false;
		};

		function _start() {
			if (busy) return;

			if (jQuery.isFunction(opts.callbackOnStart)) {
				opts.callbackOnStart();
			}

			opts.itemArray		= [];
			opts.itemCurrent	= 0;

			if (settings.itemArray.length > 0) {
				opts.itemArray = settings.itemArray;

			} else {
				var item = {};

				if (!elem.rel || elem.rel == '') {
					var item = {href: elem.href, title: elem.title};

					if (jQuery(elem).children("img:first").length) {
						item.orig = jQuery(elem).children("img:first");
					}

					opts.itemArray.push( item );

				} else {
					
					var subGroup = jQuery(matchedGroup).filter("a[rel=" + elem.rel + "]");

					var item = {};

					for (var i = 0; i < subGroup.length; i++) {
						item = {href: subGroup[i].href, title: subGroup[i].title};

						if (jQuery(subGroup[i]).children("img:first").length) {
							item.orig = jQuery(subGroup[i]).children("img:first");
						}

						opts.itemArray.push( item );
					}

					while ( opts.itemArray[ opts.itemCurrent ].href != elem.href ) {
						opts.itemCurrent++;
					}
				}
			}

			if (opts.overlayShow) {
				if (isIE) {
					jQuery('embed, object, select').css('visibility', 'hidden');
				}

				jQuery("#fancy_overlay").css('opacity', opts.overlayOpacity).show();
			}

			_change_item();
		};

		function _change_item() {
			jQuery("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();

			var href = opts.itemArray[ opts.itemCurrent ].href;

			if (href.match(/#/)) {
				var target = window.location.href.split('#')[0]; target = href.replace(target, ''); target = target.substr(target.indexOf('#'));

				_set_content('<div id="fancy_div">' + jQuery(target).html() + '</div>', opts.frameWidth, opts.frameHeight);

			} else if (href.match(imageRegExp)) {
				imagePreloader = new Image; imagePreloader.src = href;

				if (imagePreloader.complete) {
					_proceed_image();

				} else {
					jQuery.fn.fancybox.showLoading();

					jQuery(imagePreloader).unbind().bind('load', function() {
						jQuery(".fancy_loading").hide();

						_proceed_image();
					});
				}

			 } else if (href.match("iframe") || elem.className.indexOf("iframe") >= 0) {
				_set_content('<iframe id="fancy_frame" onload="jQuery.fn.fancybox.showIframe()" name="fancy_iframe' + Math.round(Math.random()*1000) + '" frameborder="0" hspace="0" src="' + href + '"></iframe>', opts.frameWidth, opts.frameHeight);

			} else {
				jQuery.get(href, function(data) {
					_set_content( '<div id="fancy_ajax">' + data + '</div>', opts.frameWidth, opts.frameHeight );
				});
			}
		};

		function _proceed_image() {
			if (opts.imageScale) {
				var w = jQuery.fn.fancybox.getViewport();

				var r = Math.min(Math.min(w[0] - 36, imagePreloader.width) / imagePreloader.width, Math.min(w[1] - 60, imagePreloader.height) / imagePreloader.height);

				var width = Math.round(r * imagePreloader.width);
				var height = Math.round(r * imagePreloader.height);

			} else {
				var width = imagePreloader.width;
				var height = imagePreloader.height;
			}

			_set_content('<img alt="" id="fancy_img" src="' + imagePreloader.src + '" />', width, height);
		};

		function _preload_neighbor_images() {
			if ((opts.itemArray.length -1) > opts.itemCurrent) {
				var href = opts.itemArray[opts.itemCurrent + 1].href;

				if (href.match(imageRegExp)) {
					objNext = new Image();
					objNext.src = href;
				}
			}

			if (opts.itemCurrent > 0) {
				var href = opts.itemArray[opts.itemCurrent -1].href;

				if (href.match(imageRegExp)) {
					objNext = new Image();
					objNext.src = href;
				}
			}
		};

		function _set_content(value, width, height) {
			busy = true;

			var pad = opts.padding;

			if (isIE) {
				jQuery("#fancy_content")[0].style.removeExpression("height");
				jQuery("#fancy_content")[0].style.removeExpression("width");
			}

			if (pad > 0) {
				width	+= pad * 2;
				height	+= pad * 2;

				jQuery("#fancy_content").css({
					'top'		: pad + 'px',
					'right'		: pad + 'px',
					'bottom'	: pad + 'px',
					'left'		: pad + 'px',
					'width'		: 'auto',
					'height'	: 'auto'
				});

				if (isIE) {
					jQuery("#fancy_content")[0].style.setExpression('height',	'(this.parentNode.clientHeight - 20)');
					jQuery("#fancy_content")[0].style.setExpression('width',		'(this.parentNode.clientWidth - 20)');
				}

			} else {
				jQuery("#fancy_content").css({
					'top'		: 0,
					'right'		: 0,
					'bottom'	: 0,
					'left'		: 0,
					'width'		: '100%',
					'height'	: '100%'
				});
			}

			if (jQuery("#fancy_outer").is(":visible") && width == jQuery("#fancy_outer").width() && height == jQuery("#fancy_outer").height()) {
				jQuery("#fancy_content").fadeOut("fast", function() {
					jQuery("#fancy_content").empty().append(jQuery(value)).fadeIn("normal", function() {
						_finish();
					});
				});

				return;
			}

			var w = jQuery.fn.fancybox.getViewport();

			var itemLeft	= (width + 36)	> w[0] ? w[2] : (w[2] + Math.round((w[0] - width - 36) / 2));
			var itemTop		= (height + 50)	> w[1] ? w[3] : (w[3] + Math.round((w[1] - height - 50) / 2));

			var itemOpts = {
				'left':		itemLeft,
				'top':		itemTop,
				'width':	width + 'px',
				'height':	height + 'px'
			};

			if (jQuery("#fancy_outer").is(":visible")) {
				jQuery("#fancy_content").fadeOut("normal", function() {
					jQuery("#fancy_content").empty();
					jQuery("#fancy_outer").animate(itemOpts, opts.zoomSpeedChange, opts.easingChange, function() {
						jQuery("#fancy_content").append(jQuery(value)).fadeIn("normal", function() {
							_finish();
						});
					});
				});

			} else {

				if (opts.zoomSpeedIn > 0 && opts.itemArray[opts.itemCurrent].orig !== undefined) {
					jQuery("#fancy_content").empty().append(jQuery(value));

					var orig_item	= opts.itemArray[opts.itemCurrent].orig;
					var orig_pos	= jQuery.fn.fancybox.getPosition(orig_item);

					jQuery("#fancy_outer").css({
						'left':		(orig_pos.left - 18) + 'px',
						'top':		(orig_pos.top  - 18) + 'px',
						'width':	jQuery(orig_item).width(),
						'height':	jQuery(orig_item).height()
					});

					if (opts.zoomOpacity) {
						itemOpts.opacity = 'show';
					}

					jQuery("#fancy_outer").animate(itemOpts, opts.zoomSpeedIn, opts.easingIn, function() {
						_finish();
					});

				} else {

					jQuery("#fancy_content").hide().empty().append(jQuery(value)).show();
					jQuery("#fancy_outer").css(itemOpts).fadeIn("normal", function() {
						_finish();
					});
				}
			}
		};

		function _set_navigation() {
			if (opts.itemCurrent != 0) {
				jQuery("#fancy_left, #fancy_left_ico").unbind().bind("click", function(e) {
					e.stopPropagation();

					opts.itemCurrent--;
					_change_item();

					return false;
				});

				jQuery("#fancy_left").show();
			}

			if (opts.itemCurrent != ( opts.itemArray.length -1)) {
				jQuery("#fancy_right, #fancy_right_ico").unbind().bind("click", function(e) {
					e.stopPropagation();

					opts.itemCurrent++;
					_change_item();

					return false;
				});

				jQuery("#fancy_right").show();
			}
		};

		function _finish() {
			_set_navigation();

			_preload_neighbor_images();

			jQuery(document).keydown(function(e) {
				if (e.keyCode == 27) {
					jQuery.fn.fancybox.close();
					jQuery(document).unbind("keydown");

				} else if(e.keyCode == 37 && opts.itemCurrent != 0) {
					opts.itemCurrent--;
					_change_item();
					jQuery(document).unbind("keydown");

				} else if(e.keyCode == 39 && opts.itemCurrent != (opts.itemArray.length - 1)) {
 					opts.itemCurrent++;
					_change_item();
					jQuery(document).unbind("keydown");
				}
			});

			if (opts.centerOnScroll) {
				jQuery(window).bind("resize scroll", jQuery.fn.fancybox.scrollBox);
			} else {
				jQuery("div#fancy_outer").css("position", "absolute");
			}

			if (opts.hideOnContentClick) {
				jQuery("#fancy_wrap").click(jQuery.fn.fancybox.close);
			}

			jQuery("#fancy_overlay, #fancy_close").bind("click", jQuery.fn.fancybox.close);

			jQuery("#fancy_close").show();

			if (opts.itemArray[ opts.itemCurrent ].title !== undefined && opts.itemArray[ opts.itemCurrent ].title.length > 0) {
				jQuery('#fancy_title div').html(opts.itemArray[ opts.itemCurrent ].title);
				jQuery('#fancy_title').show();
			}

			if (opts.overlayShow && isIE) {
				jQuery('embed, object, select', jQuery('#fancy_content')).css('visibility', 'visible');
			}

			if (jQuery.isFunction(opts.callbackOnShow)) {
				opts.callbackOnShow();
			}

			busy = false;
		};

		return this.unbind('click').click(_initialize);
	};

	jQuery.fn.fancybox.scrollBox = function() {
		var pos = jQuery.fn.fancybox.getViewport();

		jQuery("#fancy_outer").css('left', ((jQuery("#fancy_outer").width()	+ 36) > pos[0] ? pos[2] : pos[2] + Math.round((pos[0] - jQuery("#fancy_outer").width()	- 36)	/ 2)));
		jQuery("#fancy_outer").css('top',  ((jQuery("#fancy_outer").height()	+ 50) > pos[1] ? pos[3] : pos[3] + Math.round((pos[1] - jQuery("#fancy_outer").height()	- 50)	/ 2)));
	};

	jQuery.fn.fancybox.getNumeric = function(el, prop) {
		return parseInt(jQuery.curCSS(el.jquery?el[0]:el,prop,true))||0;
	};

	jQuery.fn.fancybox.getPosition = function(el) {
		var pos = el.offset();

		pos.top	+= jQuery.fn.fancybox.getNumeric(el, 'paddingTop');
		pos.top	+= jQuery.fn.fancybox.getNumeric(el, 'borderTopWidth');

		pos.left += jQuery.fn.fancybox.getNumeric(el, 'paddingLeft');
		pos.left += jQuery.fn.fancybox.getNumeric(el, 'borderLeftWidth');

		return pos;
	};

	jQuery.fn.fancybox.showIframe = function() {
		jQuery(".fancy_loading").hide();
		jQuery("#fancy_frame").show();
	};

	jQuery.fn.fancybox.getViewport = function() {
		return [jQuery(window).width(), jQuery(window).height(), jQuery(document).scrollLeft(), jQuery(document).scrollTop() ];
	};

	jQuery.fn.fancybox.animateLoading = function() {
		if (!jQuery("#fancy_loading").is(':visible')){
			clearInterval(loadingTimer);
			return;
		}

		jQuery("#fancy_loading > div").css('top', (loadingFrame * -40) + 'px');

		loadingFrame = (loadingFrame + 1) % 12;
	};

	jQuery.fn.fancybox.showLoading = function() {
		clearInterval(loadingTimer);

		var pos = jQuery.fn.fancybox.getViewport();

		jQuery("#fancy_loading").css({'left': ((pos[0] - 40) / 2 + pos[2]), 'top': ((pos[1] - 40) / 2 + pos[3])}).show();
		jQuery("#fancy_loading").bind('click', jQuery.fn.fancybox.close);

		loadingTimer = setInterval(jQuery.fn.fancybox.animateLoading, 66);
	};

	jQuery.fn.fancybox.close = function() {
		busy = true;

		jQuery(imagePreloader).unbind();

		jQuery("#fancy_overlay, #fancy_close").unbind();

		if (opts.hideOnContentClick) {
			jQuery("#fancy_wrap").unbind();
		}

		jQuery("#fancy_close, .fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();

		if (opts.centerOnScroll) {
			jQuery(window).unbind("resize scroll");
		}

		__cleanup = function() {
			jQuery("#fancy_overlay, #fancy_outer").hide();

			if (opts.centerOnScroll) {
				jQuery(window).unbind("resize scroll");
			}

			if (isIE) {
				jQuery('embed, object, select').css('visibility', 'visible');
			}

			if (jQuery.isFunction(opts.callbackOnClose)) {
				opts.callbackOnClose();
			}

			busy = false;
		};

		if (jQuery("#fancy_outer").is(":visible") !== false) {
			if (opts.zoomSpeedOut > 0 && opts.itemArray[opts.itemCurrent].orig !== undefined) {
				var orig_item	= opts.itemArray[opts.itemCurrent].orig;
				var orig_pos	= jQuery.fn.fancybox.getPosition(orig_item);

				var itemOpts = {
					'left':		(orig_pos.left - 18) + 'px',
					'top': 		(orig_pos.top  - 18) + 'px',
					'width':	jQuery(orig_item).width(),
					'height':	jQuery(orig_item).height()
				};

				if (opts.zoomOpacity) {
					itemOpts.opacity = 'hide';
				}

				jQuery("#fancy_outer").stop(false, true).animate(itemOpts, opts.zoomSpeedOut, opts.easingOut, __cleanup);

			} else {
				jQuery("#fancy_outer").stop(false, true).fadeOut("fast", __cleanup);
			}

		} else {
			__cleanup();
		}

		return false;
	};

	jQuery.fn.fancybox.build = function() {
		var html = '';

		html += '<div id="fancy_overlay"></div>';

		html += '<div id="fancy_wrap">';

		html += '<div class="fancy_loading" id="fancy_loading"><div></div></div>';

		html += '<div id="fancy_outer">';

		html += '<div id="fancy_inner">';

		html += '<div id="fancy_close"></div>';

		html +=  '<div id="fancy_bg"><div class="fancy_bg fancy_bg_n"></div><div class="fancy_bg fancy_bg_ne"></div><div class="fancy_bg fancy_bg_e"></div><div class="fancy_bg fancy_bg_se"></div><div class="fancy_bg fancy_bg_s"></div><div class="fancy_bg fancy_bg_sw"></div><div class="fancy_bg fancy_bg_w"></div><div class="fancy_bg fancy_bg_nw"></div></div>';

		html +=  '<a href="javascript:;" id="fancy_left"><span class="fancy_ico" id="fancy_left_ico"></span></a><a href="javascript:;" id="fancy_right"><span class="fancy_ico" id="fancy_right_ico"></span></a>';

		html += '<div id="fancy_content"></div>';

		html +=  '<div id="fancy_title"></div>';

		html += '</div>';

		html += '</div>';

		html += '</div>';

		jQuery(html).appendTo("body");

		jQuery('<table cellspacing="0" cellpadding="0" border="0"><tr><td class="fancy_title" id="fancy_title_left"></td><td class="fancy_title" id="fancy_title_main"><div></div></td><td class="fancy_title" id="fancy_title_right"></td></tr></table>').appendTo('#fancy_title');

		if (isIE) {
			jQuery("#fancy_inner").prepend('<iframe class="fancy_bigIframe" scrolling="no" frameborder="0"></iframe>');
			jQuery("#fancy_close, .fancy_bg, .fancy_title, .fancy_ico").fixPNG();
		}
	};

	jQuery.fn.fancybox.defaults = {
		padding				:	10,
		imageScale			:	true,
		zoomOpacity			:	false,
		zoomSpeedIn			:	0,
		zoomSpeedOut		:	0,
		zoomSpeedChange		:	300,
		easingIn			:	'swing',
		easingOut			:	'swing',
		easingChange		:	'swing',
		frameWidth			:	425,
		frameHeight			:	355,
		overlayShow			:	true,
		overlayOpacity		:	0.3,
		hideOnContentClick	:	true,
		centerOnScroll		:	true,
		itemArray			:	[],
		callbackOnStart		:	null,
		callbackOnShow		:	null,
		callbackOnClose		:	null
	};

	jQuery(document).ready(function() {
		jQuery.fn.fancybox.build();
	});

})(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.sexy-combo-2.0.6.js

;(function(){jQuery.fn.sexyCombo=function(a){return this.each(function(){new jQuerysc(this,a)})};var i={skin:"sexy",suffix:"__sexyCombo",hiddenSuffix:"__sexyComboHidden",initialHiddenValue:"",emptyText:"",autoFill:false,triggerSelected:false,filterFn:null,dropUp:false,separator:",",showListCallback:null,hideListCallback:null,initCallback:null,initEventsCallback:null,changeCallback:null,textChangeCallback:null};jQuery.sexyCombo=function(b,d){if(b.nodeName!="SELECT")return;this.config=jQuery.extend({},i,d||{});this.selectbox=jQuery(b);this.options=this.selectbox.children().filter("option");this.wrapper=this.selectbox.wrap("<div>").hide().parent().addClass("combo").addClass(this.config.skin);this.input=jQuery("<input type='text' />").appendTo(this.wrapper).attr("autocomplete","off").attr("value","").attr("name",this.selectbox.attr("name")+this.config.suffix);this.hidden=jQuery("<input type='hidden' />").appendTo(this.wrapper).attr("autocomplete","off").attr("value",this.config.initialHiddenValue).attr("name",this.selectbox.attr("name")+this.config.hiddenSuffix);this.icon=jQuery("<div />").appendTo(this.wrapper).addClass("icon");this.listWrapper=jQuery("<div />").appendTo(this.wrapper).addClass("invisible").addClass("list-wrapper");this.updateDrop();this.list=jQuery("<ul />").appendTo(this.listWrapper);var c=this;this.options.each(function(){var a=jQuery.trim(jQuery(this).text());jQuery("<li />").appendTo(c.list).text(a).addClass("visible")});this.listItems=this.list.children();if(jQuery.browser.opera){this.wrapper.css({position:"relative",left:"0",top:"0"})}this.filterFn=("function"==typeof(this.config.filterFn))?this.config.filterFn:this.filterFn;this.lastKey=null;this.overflowCSS=jQuery.browser.opera?"overflow":"overflowY";this.multiple=this.selectbox.attr("multiple");this.notify("init");this.initEvents()};jQuerysc=jQuery.sexyCombo;jQuerysc.fn=jQuerysc.prototype={};jQuerysc.fn.extend=jQuerysc.extend=jQuery.extend;jQuerysc.fn.extend({initEvents:function(){var b=this;this.icon.bind("click",function(){b.iconClick()});this.listItems.bind("mouseover",function(a){b.highlight(a.target)});this.listItems.bind("click",function(a){b.listItemClick(jQuery(a.target))});this.input.bind("keyup",function(a){b.keyUp(a)});this.input.bind("keypress",function(a){if(jQuerysc.KEY.RETURN==a.keyCode)a.preventDefault();if(jQuerysc.KEY.TAB==a.keyCode)b.hideList()});jQuery(document).bind("click",function(a){if((b.icon.get(0)==a.target)||(b.input.get(0)==a.target))return;b.hideList()});this.triggerSelected();this.applyEmptyText();this.notify("initEvents")},getTextValue:function(){return this.__getValue("input")},getCurrentTextValue:function(){return this.__getCurrentValue("input")},getHiddenValue:function(){return this.__getValue("hidden")},getCurrentHiddenValue:function(){return this.__getCurrentValue("hidden")},__getValue:function(a){a=this[a];if(!this.multiple)return jQuery.trim(a.val());var b=a.val().split(this.config.separator);var d=[];for(var c=0,e=b.length;c<e;++c){d.push(jQuery.trim(b[c]))}d=jQuerysc.normalizeArray(d);return d},__getCurrentValue:function(a){a=this[a];if(!this.multiple)return jQuery.trim(a.val());return jQuery.trim(a.val().split(this.config.separator).pop())},iconClick:function(){if(this.listVisible())this.hideList();else this.showList();this.input.focus()},listVisible:function(){return this.listWrapper.hasClass("visible")},showList:function(){if(!this.listItems.filter(".visible").length)return;this.listWrapper.removeClass("invisible").addClass("visible");this.wrapper.css("zIndex","99999");this.listWrapper.css("zIndex","99999");this.setOverflow();this.setListHeight();this.highlightFirst();this.listWrapper.scrollTop(0);this.notify("showList")},hideList:function(){if(this.listWrapper.hasClass("invisible"))return;this.listWrapper.removeClass("visible").addClass("invisible");this.wrapper.css("zIndex","0");this.listWrapper.css("zIndex","99999");this.notify("hideList")},getListItemsHeight:function(){return this.listItems.height()*this.liLen()},setOverflow:function(){if(this.getListItemsHeight()>this.getListMaxHeight())this.listWrapper.css(this.overflowCSS,"scroll");else this.listWrapper.css(this.overflowCSS,"hidden")},highlight:function(a){if((jQuerysc.KEY.DOWN==this.lastKey)||(jQuerysc.KEY.UP==this.lastKey))return;this.listItems.removeClass("active");jQuery(a).addClass("active")},setComboValue:function(a,b,d){var c=this.input.val();var e="";if(this.multiple){e=this.getTextValue();if(b)e.pop();e.push(jQuery.trim(a));e=jQuerysc.normalizeArray(e);e=e.join(this.config.separator)+this.config.separator}else{e=jQuery.trim(a)}this.input.val(e);this.setHiddenValue(a);this.filter();if(d)this.hideList();this.input.removeClass("empty");if(this.multiple)this.input.focus();if(this.input.val()!=c)this.notify("textChange")},setHiddenValue:function(a){var b=false;a=jQuery.trim(a);var d=this.hidden.val();if(!this.multiple){for(var c=0,e=this.options.length;c<e;++c){if(a==this.options.eq(c).text()){this.hidden.val(this.options.eq(c).val());b=true;break}}}else{var f=this.getTextValue();var h=[];for(var c=0,e=f.length;c<e;++c){for(var g=0,j=this.options.length;g<j;++g){if(f[c]==this.options.eq(g).text()){h.push(this.options.eq(g).val())}}}if(h.length){b=true;this.hidden.val(h.join(this.config.separator))}}if(!b){this.hidden.val(this.config.initialHiddenValue)}if(d!=this.hidden.val())this.notify("change")},listItemClick:function(a){this.setComboValue(a.text(),true,true);this.inputFocus()},filter:function(){var d=this.input.val();var c=this;this.listItems.each(function(){var a=jQuery(this);var b=a.text();if(c.filterFn.call(c,c.getCurrentTextValue(),b,c.getTextValue())){a.removeClass("invisible").addClass("visible")}else{a.removeClass("visible").addClass("invisible")}});this.setOverflow();this.setListHeight()},filterFn:function(a,b,d){if(!this.multiple){return b.toLowerCase().search(a.toLowerCase())==0}else{for(var c=0,e=d.length;c<e;++c){if(b==d[c]){return false}}return b.toLowerCase().search(a.toLowerCase())==0}},getListMaxHeight:function(){return parseInt(this.listWrapper.css("maxHeight"),10)},setListHeight:function(){var a=this.getListItemsHeight();var b=this.getListMaxHeight();var d=this.listWrapper.height();if(a<d){this.listWrapper.height(a)}else if(a>d){this.listWrapper.height(Math.min(b,a))}},getActive:function(){return this.listItems.filter(".active")},keyUp:function(a){this.lastKey=a.keyCode;var b=jQuerysc.KEY;switch(a.keyCode){case b.RETURN:this.setComboValue(this.getActive().text(),true,true);if(!this.multiple)this.input.blur();break;case b.DOWN:this.highlightNext();break;case b.UP:this.highlightPrev();break;case b.ESC:this.hideList();break;default:this.inputChanged();break}},liLen:function(){return this.listItems.filter(".visible").length},inputChanged:function(){this.filter();if(this.liLen()){this.showList();this.setOverflow();this.setListHeight()}else{this.hideList()}this.setHiddenValue(this.input.val());this.notify("textChange")},highlightFirst:function(){this.listItems.removeClass("active").filter(".visible:eq(0)").addClass("active");this.autoFill()},highlightNext:function(){var a=this.getActive().next();while(a.hasClass("invisible")&&a.length){a=a.next()}if(a.length){this.listItems.removeClass("active");a.addClass("active");this.scrollDown()}},scrollDown:function(){if("scroll"!=this.listWrapper.css(this.overflowCSS))return;var a=this.getActiveIndex()+1;if(jQuery.browser.opera)++a;var b=this.listItems.height()*a-this.listWrapper.height();if(jQuery.browser.msie)b+=a;if(this.listWrapper.scrollTop()<b)this.listWrapper.scrollTop(b)},highlightPrev:function(){var a=this.getActive().prev();while(a.length&&a.hasClass("invisible"))a=a.prev();if(a.length){this.getActive().removeClass("active");a.addClass("active");this.scrollUp()}},getActiveIndex:function(){return jQuery.inArray(this.getActive().get(0),this.listItems.filter(".visible").get())},scrollUp:function(){if("scroll"!=this.listWrapper.css(this.overflowCSS))return;var a=this.getActiveIndex()*this.listItems.height();if(this.listWrapper.scrollTop()>a){this.listWrapper.scrollTop(a)}},applyEmptyText:function(){if(!this.config.emptyText.length)return;var a=this;this.input.bind("focus",function(){a.inputFocus()}).bind("blur",function(){a.inputBlur()});if(""==this.input.val()){this.input.addClass("empty").val(this.config.emptyText)}},inputFocus:function(){if(this.input.hasClass("empty")){this.input.removeClass("empty").val("")}},inputBlur:function(){if(""==this.input.val()){this.input.addClass("empty").val(this.config.emptyText)}},triggerSelected:function(){if(!this.config.triggerSelected)return;var a=this;this.options.each(function(){if(jQuery(this).attr("selected")){a.setComboValue(jQuery(this).text(),false,true)}})},autoFill:function(){if(!this.config.autoFill||(jQuerysc.KEY.BACKSPACE==this.lastKey)||this.multiple)return;var a=this.input.val();var b=this.getActive().text();this.input.val(b);this.selection(this.input.get(0),a.length,b.length)},selection:function(a,b,d){if(a.createTextRange){var c=a.createTextRange();c.collapse(true);c.moveStart("character",b);c.moveEnd("character",d);c.select()}else if(a.setSelectionRange){a.setSelectionRange(b,d)}else{if(a.selectionStart){a.selectionStart=b;a.selectionEnd=d}}},updateDrop:function(){if(this.config.dropUp)this.listWrapper.addClass("list-wrapper-up");else this.listWrapper.removeClass("list-wrapper-up")},setDropUp:function(a){this.config.dropUp=a;this.updateDrop()},notify:function(a){if(!jQuery.isFunction(this.config[a+"Callback"]))return;this.config[a+"Callback"].call(this)}});jQuerysc.extend({KEY:{UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8},log:function(a){var b=jQuery("#log");b.html(b.html()+a+"<br />")},createSelectbox:function(a){var b=jQuery("<select />").appendTo(a.container).attr({name:a.name,id:a.id,size:"1"});if(a.multiple)b.attr("multiple",true);var d=a.data;var c=false;for(var e=0,f=d.length;e<f;++e){c=d[e].selected||false;jQuery("<option />").appendTo(b).attr("value",d[e].value).text(d[e].text).attr("selected",c)}return b.get(0)},create:function(b){var d={name:"",id:"",data:[],multiple:false,container:jQuery(document),url:"",ajaxData:{}};b=jQuery.extend({},d,b||{});if(b.url){return jQuery.getJSON(b.url,b.ajaxData,function(a){delete b.url;delete b.ajaxData;b.data=a;return jQuerysc.create(b)})}b.container=jQuery(b.container);var c=jQuerysc.createSelectbox(b);return new jQuerysc(c,b)},normalizeArray:function(a){var b=[];for(var d=0,c=a.length;d<c;++d){if(""==a[d])continue;b.push(a[d])}return b}})})(jQuery);

// jquery.cycle.all.js

/*!
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2009 M. Alsup
 * Version: 2.63 (17-MAR-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.6 or later
 *
 * Originally based on the work of:
 *	1) Matt Oakes
 *	2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
 *	3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
 */
;(function(jQuery) {

var ver = '2.63';

// if jQuery.support is not defined (pre jQuery 1.3) add what I need
if (jQuery.support == undefined) {
	jQuery.support = {
		opacity: !(jQuery.browser.msie)
	};
}

function log() {
	if (window.console && window.console.log)
		window.console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
	//jQuery('body').append('<div>'+Array.prototype.join.call(arguments,' ')+'</div>');
};

// the options arg can be...
//   a number  - indicates an immediate transition should occur to the given slide index
//   a string  - 'stop', 'pause', 'resume', or the name of a transition effect (ie, 'fade', 'zoom', etc)
//   an object - properties to control the slideshow
//
// the arg2 arg can be...
//   the name of an fx (only used in conjunction with a numeric value for 'options')
//   the value true (only used in conjunction with a options == 'resume') and indicates
//     that the resume should occur immediately (not wait for next timeout)

jQuery.fn.cycle = function(options, arg2) {
	var o = { s: this.selector, c: this.context };

    // in 1.3+ we can fix mistakes with the ready state
	if (this.length == 0 && options != 'stop') {
        if (!jQuery.isReady && o.s) {
            log('DOM not ready, queuing slideshow')
            jQuery(function() {
                jQuery(o.s,o.c).cycle(options,arg2);
            });
            return this;
        }
		// is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_jQuery(document).ready()
		log('terminating; zero elements found by selector' + (jQuery.isReady ? '' : ' (DOM not ready)'));
		return this;
	}

    // iterate the matched nodeset
	return this.each(function() {
        options = handleArguments(this, options, arg2);
        if (options === false)
            return;

		// stop existing slideshow for this container (if there is one)
		if (this.cycleTimeout)
            clearTimeout(this.cycleTimeout);
		this.cycleTimeout = this.cyclePause = 0;

		var jQuerycont = jQuery(this);
		var jQueryslides = options.slideExpr ? jQuery(options.slideExpr, this) : jQuerycont.children();
		var els = jQueryslides.get();
		if (els.length < 2) {
			log('terminating; too few slides: ' + els.length);
			return;
		}

        var opts = buildOptions(jQuerycont, jQueryslides, els, options, o);
        if (opts === false)
            return;

        // if it's an auto slideshow, kick it off
		if (opts.timeout || opts.continuous)
			this.cycleTimeout = setTimeout(function(){go(els,opts,0,!opts.rev)},
				opts.continuous ? 10 : opts.timeout + (opts.delay||0));
	});
};

// process the args that were passed to the plugin fn
function handleArguments(cont, options, arg2) {
	if (cont.cycleStop == undefined)
		cont.cycleStop = 0;
	if (options === undefined || options === null)
		options = {};
	if (options.constructor == String) {
		switch(options) {
		case 'stop':
			cont.cycleStop++; // callbacks look for change
			if (cont.cycleTimeout)
                clearTimeout(cont.cycleTimeout);
			cont.cycleTimeout = 0;
			jQuery(cont).removeData('cycle.opts');
			return false;
		case 'pause':
			cont.cyclePause = 1;
			return false;
		case 'resume':
			cont.cyclePause = 0;
			if (arg2 === true) { // resume now!
				options = jQuery(cont).data('cycle.opts');
				if (!options) {
					log('options not found, can not resume');
					return false;
				}
				if (cont.cycleTimeout) {
					clearTimeout(cont.cycleTimeout);
					cont.cycleTimeout = 0;
				}
				go(options.elements, options, 1, 1);
			}
			return false;
		default:
			options = { fx: options };
		};
	}
	else if (options.constructor == Number) {
		// go to the requested slide
		var num = options;
		options = jQuery(cont).data('cycle.opts');
		if (!options) {
			log('options not found, can not advance slide');
			return false;
		}
		if (num < 0 || num >= options.elements.length) {
			log('invalid slide index: ' + num);
			return false;
		}
		options.nextSlide = num;
		if (cont.cycleTimeout) {
			clearTimeout(this.cycleTimeout);
			cont.cycleTimeout = 0;
		}
        if (typeof arg2 == 'string')
            options.oneTimeFx = arg2;
		go(options.elements, options, 1, num >= options.currSlide);
		return false;
	}
    return options;
};

function removeFilter(el, opts) {
	if (!jQuery.support.opacity && opts.cleartype && el.style.filter) {
		try { el.style.removeAttribute('filter'); }
		catch(smother) {} // handle old opera versions
	}
};

// one-time initialization
function buildOptions(jQuerycont, jQueryslides, els, options, o) {
	// support metadata plugin (v1.0 and v2.0)
	var opts = jQuery.extend({}, jQuery.fn.cycle.defaults, options || {}, jQuery.metadata ? jQuerycont.metadata() : jQuery.meta ? jQuerycont.data() : {});
	if (opts.autostop)
		opts.countdown = opts.autostopCount || els.length;

    var cont = jQuerycont[0];
	jQuerycont.data('cycle.opts', opts);
	opts.jQuerycont = jQuerycont;
	opts.stopCount = cont.cycleStop;
	opts.elements = els;
	opts.before = opts.before ? [opts.before] : [];
	opts.after = opts.after ? [opts.after] : [];
	opts.after.unshift(function(){ opts.busy=0; });

    // push some after callbacks
	if (!jQuery.support.opacity && opts.cleartype)
		opts.after.push(function() { removeFilter(this, opts); });
	if (opts.continuous)
		opts.after.push(function() { go(els,opts,0,!opts.rev); });

    saveOriginalOpts(opts);

	// clearType corrections
	if (!jQuery.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
		clearTypeFix(jQueryslides);

    // container requires non-static position so that slides can be position within
	if (jQuerycont.css('position') == 'static')
		jQuerycont.css('position', 'relative');
	if (opts.width)
		jQuerycont.width(opts.width);
	if (opts.height && opts.height != 'auto')
		jQuerycont.height(opts.height);

	if (opts.startingSlide)
        opts.startingSlide = parseInt(opts.startingSlide);

    // if random, mix up the slide array
	if (opts.random) {
		opts.randomMap = [];
		for (var i = 0; i < els.length; i++)
			opts.randomMap.push(i);
		opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
		opts.randomIndex = 0;
		opts.startingSlide = opts.randomMap[0];
	}
	else if (opts.startingSlide >= els.length)
		opts.startingSlide = 0; // catch bogus input
	opts.currSlide = opts.startingSlide = opts.startingSlide || 0;
	var first = opts.startingSlide;

    // set position and zIndex on all the slides
	jQueryslides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
		var z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
		jQuery(this).css('z-index', z)
	});

    // make sure first slide is visible
	jQuery(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
	removeFilter(els[first], opts);

    // stretch slides
	if (opts.fit && opts.width)
		jQueryslides.width(opts.width);
	if (opts.fit && opts.height && opts.height != 'auto')
		jQueryslides.height(opts.height);

    // stretch container
	var reshape = opts.containerResize && !jQuerycont.innerHeight();
	if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
		var maxw = 0, maxh = 0;
		for(var i=0; i < els.length; i++) {
			var jQuerye = jQuery(els[i]), e = jQuerye[0], w = jQuerye.outerWidth(), h = jQuerye.outerHeight();
            if (!w) w = e.offsetWidth;
            if (!h) h = e.offsetHeight;
			maxw = w > maxw ? w : maxw;
			maxh = h > maxh ? h : maxh;
		}
        if (maxw > 0 && maxh > 0)
		    jQuerycont.css({width:maxw+'px',height:maxh+'px'});
	}

	if (opts.pause)
		jQuerycont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});

    if (supportMultiTransitions(opts) === false)
		return false;

	// run transition init fn
	if (!opts.multiFx) {
		var init = jQuery.fn.cycle.transitions[opts.fx];
		if (jQuery.isFunction(init))
			init(jQuerycont, jQueryslides, opts);
		else if (opts.fx != 'custom' && !opts.multiFx) {
			log('unknown transition: ' + opts.fx,'; slideshow terminating');
			return false;
		}
	}

	// apparently a lot of people use image slideshows without height/width attributes on the images.
	// Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
	var requeue = false;
	options.requeueAttempts = options.requeueAttempts || 0;
	jQueryslides.each(function() {
        // try to get height/width of each slide
		var jQueryel = jQuery(this);
	    this.cycleH = (opts.fit && opts.height) ? opts.height : jQueryel.height();
		this.cycleW = (opts.fit && opts.width) ? opts.width : jQueryel.width();

		if ( jQueryel.is('img') ) {
			// sigh..  sniffing, hacking, shrugging...
			var loadingIE    = (jQuery.browser.msie  && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
			var loadingOp    = (jQuery.browser.opera && this.cycleW == 42 && this.cycleH == 19 && !this.complete);
			var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);

			// don't requeue for images that are still loading but have a valid size
			if (loadingIE || loadingOp || loadingOther) {
				if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
					log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
					setTimeout(function() {jQuery(o.s,o.c).cycle(options)}, opts.requeueTimeout);
					requeue = true;
					return false; // break each loop
				}
				else {
					log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
				}
			}
		}
		return true;
	});

	if (requeue)
		return false;

	opts.cssBefore = opts.cssBefore || {};
	opts.animIn = opts.animIn || {};
	opts.animOut = opts.animOut || {};

	jQueryslides.not(':eq('+first+')').css(opts.cssBefore);
	if (opts.cssFirst)
		jQuery(jQueryslides[first]).css(opts.cssFirst);

	if (opts.timeout) {
		opts.timeout = parseInt(opts.timeout);
		// ensure that timeout and speed settings are sane
		if (opts.speed.constructor == String)
			opts.speed = jQuery.fx.speeds[opts.speed] || parseInt(opts.speed);
		if (!opts.sync)
			opts.speed = opts.speed / 2;
		while((opts.timeout - opts.speed) < 250) // sanitize timeout
			opts.timeout += opts.speed;
	}
	if (opts.easing)
		opts.easeIn = opts.easeOut = opts.easing;
	if (!opts.speedIn)
		opts.speedIn = opts.speed;
	if (!opts.speedOut)
		opts.speedOut = opts.speed;

	opts.slideCount = els.length;
	opts.currSlide = opts.lastSlide = first;
	if (opts.random) {
		opts.nextSlide = opts.currSlide;
		if (++opts.randomIndex == els.length)
			opts.randomIndex = 0;
		opts.nextSlide = opts.randomMap[opts.randomIndex];
	}
	else
		opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;

	// fire artificial events
	var e0 = jQueryslides[first];
	if (opts.before.length)
		opts.before[0].apply(e0, [e0, e0, opts, true]);
	if (opts.after.length > 1)
		opts.after[1].apply(e0, [e0, e0, opts, true]);

	if (opts.next)
		jQuery(opts.next).click(function(){return advance(opts,opts.rev?-1:1)});
	if (opts.prev)
		jQuery(opts.prev).click(function(){return advance(opts,opts.rev?1:-1)});
	if (opts.pager)
		buildPager(els,opts);

    exposeAddSlide(opts, els);

    return opts;
};

// save off original opts so we can restore after clearing state
function saveOriginalOpts(opts) {
    opts.original = { before: [], after: [] };
    opts.original.cssBefore = jQuery.extend({}, opts.cssBefore);
    opts.original.cssAfter  = jQuery.extend({}, opts.cssAfter);
    opts.original.animIn    = jQuery.extend({}, opts.animIn);
    opts.original.animOut   = jQuery.extend({}, opts.animOut);
	jQuery.each(opts.before, function() { opts.original.before.push(this); });
	jQuery.each(opts.after,  function() { opts.original.after.push(this); });
};

function supportMultiTransitions(opts) {
    var txs = jQuery.fn.cycle.transitions;
	// look for multiple effects
	if (opts.fx.indexOf(',') > 0) {
		opts.multiFx = true;
		opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
		// discard any bogus effect names
		for (var i=0; i < opts.fxs.length; i++) {
			var fx = opts.fxs[i];
			var tx = txs[fx];
			if (!tx || !txs.hasOwnProperty(fx) || !jQuery.isFunction(tx)) {
				log('discarding unknown transition: ',fx);
				opts.fxs.splice(i,1);
				i--;
			}
		}
		// if we have an empty list then we threw everything away!
		if (!opts.fxs.length) {
			log('No valid transitions named; slideshow terminating.');
			return false;
		}
	}
	else if (opts.fx == 'all') {  // auto-gen the list of transitions
		opts.multiFx = true;
		opts.fxs = [];
		for (p in txs) {
			var tx = txs[p];
			if (txs.hasOwnProperty(p) && jQuery.isFunction(tx))
				opts.fxs.push(p);
		}
	}
	if (opts.multiFx && opts.randomizeEffects) {
		// munge the fxs array to make effect selection random
		var r1 = Math.floor(Math.random() * 20) + 30;
		for (var i = 0; i < r1; i++) {
			var r2 = Math.floor(Math.random() * opts.fxs.length);
			opts.fxs.push(opts.fxs.splice(r2,1)[0]);
		}
		log('randomized fx sequence: ',opts.fxs);
	}
	return true;
};

// provide a mechanism for adding slides after the slideshow has started
function exposeAddSlide(opts, els) {
	opts.addSlide = function(newSlide, prepend) {
		var jQuerys = jQuery(newSlide), s = jQuerys[0];
		if (!opts.autostopCount)
			opts.countdown++;
		els[prepend?'unshift':'push'](s);
		if (opts.els)
			opts.els[prepend?'unshift':'push'](s); // shuffle needs this
		opts.slideCount = els.length;

		jQuerys.css('position','absolute');
		jQuerys[prepend?'prependTo':'appendTo'](opts.jQuerycont);

		if (prepend) {
			opts.currSlide++;
			opts.nextSlide++;
		}

		if (!jQuery.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
			clearTypeFix(jQuerys);

		if (opts.fit && opts.width)
			jQuerys.width(opts.width);
		if (opts.fit && opts.height && opts.height != 'auto')
			jQueryslides.height(opts.height);
		s.cycleH = (opts.fit && opts.height) ? opts.height : jQuerys.height();
		s.cycleW = (opts.fit && opts.width) ? opts.width : jQuerys.width();

		jQuerys.css(opts.cssBefore);

		if (opts.pager)
			jQuery.fn.cycle.createPagerAnchor(els.length-1, s, jQuery(opts.pager), els, opts);

		if (jQuery.isFunction(opts.onAddSlide))
			opts.onAddSlide(jQuerys);
		else
			jQuerys.hide(); // default behavior
	};
}

// reset internal state; we do this on every pass in order to support multiple effects
jQuery.fn.cycle.resetState = function(opts, fx) {
    fx = fx || opts.fx;
	opts.before = []; opts.after = [];
	opts.cssBefore = jQuery.extend({}, opts.original.cssBefore);
	opts.cssAfter  = jQuery.extend({}, opts.original.cssAfter);
	opts.animIn    = jQuery.extend({}, opts.original.animIn);
	opts.animOut   = jQuery.extend({}, opts.original.animOut);
	opts.fxFn = null;
	jQuery.each(opts.original.before, function() { opts.before.push(this); });
	jQuery.each(opts.original.after,  function() { opts.after.push(this); });

	// re-init
	var init = jQuery.fn.cycle.transitions[fx];
	if (jQuery.isFunction(init))
		init(opts.jQuerycont, jQuery(opts.elements), opts);
};

// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
function go(els, opts, manual, fwd) {
    // opts.busy is true if we're in the middle of an animation
	if (manual && opts.busy && opts.manualTrump) {
        // let manual transitions requests trump active ones
		jQuery(els).stop(true,true);
		opts.busy = false;
	}
    // don't begin another timeout-based transition if there is one active
	if (opts.busy)
        return;

	var p = opts.jQuerycont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];

    // stop cycling if we have an outstanding stop request
	if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
		return;

    // check to see if we should stop cycling based on autostop options
	if (!manual && !p.cyclePause &&
		((opts.autostop && (--opts.countdown <= 0)) ||
		(opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
		if (opts.end)
			opts.end(opts);
		return;
	}

    // if slideshow is paused, only transition on a manual trigger
	if (manual || !p.cyclePause) {
        var fx = opts.fx;
		// keep trying to get the slide size if we don't have it yet
		curr.cycleH = curr.cycleH || jQuery(curr).height();
		curr.cycleW = curr.cycleW || jQuery(curr).width();
		next.cycleH = next.cycleH || jQuery(next).height();
		next.cycleW = next.cycleW || jQuery(next).width();

		// support multiple transition types
		if (opts.multiFx) {
			if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length)
				opts.lastFx = 0;
			fx = opts.fxs[opts.lastFx];
			opts.currFx = fx;
		}

        // one-time fx overrides apply to:  jQuery('div').cycle(3,'zoom');
        if (opts.oneTimeFx) {
            fx = opts.oneTimeFx;
            opts.oneTimeFx = null;
        }

        jQuery.fn.cycle.resetState(opts, fx);

        // run the before callbacks
		if (opts.before.length)
			jQuery.each(opts.before, function(i,o) {
				if (p.cycleStop != opts.stopCount) return;
				o.apply(next, [curr, next, opts, fwd]);
			});

        // stage the after callacks
		var after = function() {
			jQuery.each(opts.after, function(i,o) {
				if (p.cycleStop != opts.stopCount) return;
				o.apply(next, [curr, next, opts, fwd]);
			});
		};

		if (opts.nextSlide != opts.currSlide) {
            // get ready to perform the transition
			opts.busy = 1;
			if (opts.fxFn) // fx function provided?
				opts.fxFn(curr, next, opts, after, fwd);
			else if (jQuery.isFunction(jQuery.fn.cycle[opts.fx])) // fx plugin ?
				jQuery.fn.cycle[opts.fx](curr, next, opts, after);
			else
				jQuery.fn.cycle.custom(curr, next, opts, after, manual && opts.fastOnEvent);
		}

        // calculate the next slide
		opts.lastSlide = opts.currSlide;
		if (opts.random) {
			opts.currSlide = opts.nextSlide;
			if (++opts.randomIndex == els.length)
				opts.randomIndex = 0;
			opts.nextSlide = opts.randomMap[opts.randomIndex];
		}
		else { // sequence
			var roll = (opts.nextSlide + 1) == els.length;
			opts.nextSlide = roll ? 0 : opts.nextSlide+1;
			opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
		}

		if (opts.pager)
			jQuery.fn.cycle.updateActivePagerLink(opts.pager, opts.currSlide);
	}

    // stage the next transtion
    var ms = 0;
	if (opts.timeout && !opts.continuous)
        ms = getTimeout(curr, next, opts, fwd);
    else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
        ms = 10;
    if (ms > 0)
        p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.rev) }, ms);
};

// invoked after transition
jQuery.fn.cycle.updateActivePagerLink = function(pager, currSlide) {
	jQuery(pager).find('a').removeClass('activeSlide').filter('a:eq('+currSlide+')').addClass('activeSlide');
};

// calculate timeout value for current transition
function getTimeout(curr, next, opts, fwd) {
	if (opts.timeoutFn) {
        // call user provided calc fn
		var t = opts.timeoutFn(curr,next,opts,fwd);
		if (t !== false)
			return t;
	}
	return opts.timeout;
};

// expose next/prev function, caller must pass in state
jQuery.fn.cycle.next = function(opts) { advance(opts, opts.rev?-1:1); };
jQuery.fn.cycle.prev = function(opts) { advance(opts, opts.rev?1:-1);};

// advance slide forward or back
function advance(opts, val) {
    var els = opts.elements;
	var p = opts.jQuerycont[0], timeout = p.cycleTimeout;
	if (timeout) {
		clearTimeout(timeout);
		p.cycleTimeout = 0;
	}
	if (opts.random && val < 0) {
		// move back to the previously display slide
		opts.randomIndex--;
		if (--opts.randomIndex == -2)
			opts.randomIndex = els.length-2;
		else if (opts.randomIndex == -1)
			opts.randomIndex = els.length-1;
		opts.nextSlide = opts.randomMap[opts.randomIndex];
	}
	else if (opts.random) {
		if (++opts.randomIndex == els.length)
			opts.randomIndex = 0;
		opts.nextSlide = opts.randomMap[opts.randomIndex];
	}
	else {
		opts.nextSlide = opts.currSlide + val;
		if (opts.nextSlide < 0) {
			if (opts.nowrap) return false;
			opts.nextSlide = els.length - 1;
		}
		else if (opts.nextSlide >= els.length) {
			if (opts.nowrap) return false;
			opts.nextSlide = 0;
		}
	}

	if (jQuery.isFunction(opts.prevNextClick))
		opts.prevNextClick(val > 0, opts.nextSlide, els[opts.nextSlide]);
	go(els, opts, 1, val>=0);
	return false;
};

function buildPager(els, opts) {
	var jQueryp = jQuery(opts.pager);
	jQuery.each(els, function(i,o) {
		jQuery.fn.cycle.createPagerAnchor(i,o,jQueryp,els,opts);
	});
   jQuery.fn.cycle.updateActivePagerLink(opts.pager, opts.startingSlide);
};

jQuery.fn.cycle.createPagerAnchor = function(i, el, jQueryp, els, opts) {
	var a = (jQuery.isFunction(opts.pagerAnchorBuilder))
		? opts.pagerAnchorBuilder(i,el)
		: '<a href="#">'+(i+1)+'</a>';
	if (!a)
		return;
	var jQuerya = jQuery(a);
	// don't reparent if anchor is in the dom
	if (jQuerya.parents('body').length == 0)
		jQuerya.appendTo(jQueryp);

	jQuerya.bind(opts.pagerEvent, function() {
		opts.nextSlide = i;
		var p = opts.jQuerycont[0], timeout = p.cycleTimeout;
		if (timeout) {
			clearTimeout(timeout);
			p.cycleTimeout = 0;
		}
		if (jQuery.isFunction(opts.pagerClick))
			opts.pagerClick(opts.nextSlide, els[opts.nextSlide]);
		go(els,opts,1,opts.currSlide < i); // trigger the trans
		return false;
	});
	if (opts.pauseOnPagerHover)
		jQuerya.hover(function() { opts.jQuerycont[0].cyclePause++; }, function() { opts.jQuerycont[0].cyclePause--; } );
};

// helper fn to calculate the number of slides between the current and the next
jQuery.fn.cycle.hopsFromLast = function(opts, fwd) {
	var hops, l = opts.lastSlide, c = opts.currSlide;
	if (fwd)
		hops = c > l ? c - l : opts.slideCount - l;
	else
		hops = c < l ? l - c : l + opts.slideCount - c;
	return hops;
};

// fix clearType problems in ie6 by setting an explicit bg color
// (otherwise text slides look horrible during a fade transition)
function clearTypeFix(jQueryslides) {
	function hex(s) {
		s = parseInt(s).toString(16);
		return s.length < 2 ? '0'+s : s;
	};
	function getBg(e) {
		for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
			var v = jQuery.css(e,'background-color');
			if (v.indexOf('rgb') >= 0 ) {
				var rgb = v.match(/\d+/g);
				return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
			}
			if (v && v != 'transparent')
				return v;
		}
		return '#ffffff';
	};
	jQueryslides.each(function() { jQuery(this).css('background-color', getBg(this)); });
};

// reset common props before the next transition
jQuery.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
	jQuery(opts.elements).not(curr).hide();
	opts.cssBefore.opacity = 1;
	opts.cssBefore.display = 'block';
	if (w !== false && next.cycleW > 0)
		opts.cssBefore.width = next.cycleW;
	if (h !== false && next.cycleH > 0)
		opts.cssBefore.height = next.cycleH;
	opts.cssAfter = opts.cssAfter || {};
	opts.cssAfter.display = 'none';
	jQuery(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
	jQuery(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
};

// the actual fn for effecting a transition
jQuery.fn.cycle.custom = function(curr, next, opts, cb, speedOverride) {
	var jQueryl = jQuery(curr), jQueryn = jQuery(next);
	var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
	jQueryn.css(opts.cssBefore);
	if (speedOverride) {
		if (typeof speedOverride == 'number')
			speedIn = speedOut = speedOverride;
		else
			speedIn = speedOut = 1;
		easeIn = easeOut = null;
	}
	var fn = function() {jQueryn.animate(opts.animIn, speedIn, easeIn, cb)};
	jQueryl.animate(opts.animOut, speedOut, easeOut, function() {
		if (opts.cssAfter) jQueryl.css(opts.cssAfter);
		if (!opts.sync) fn();
	});
	if (opts.sync) fn();
};

// transition definitions - only fade is defined here, transition pack defines the rest
jQuery.fn.cycle.transitions = {
	fade: function(jQuerycont, jQueryslides, opts) {
		jQueryslides.not(':eq('+opts.currSlide+')').css('opacity',0);
		opts.before.push(function(curr,next,opts) {
			jQuery.fn.cycle.commonReset(curr,next,opts);
			opts.cssBefore.opacity = 0;
		});
		opts.animIn	   = { opacity: 1 };
		opts.animOut   = { opacity: 1 };
		opts.cssBefore = { top: 0, left: 0 };
	}
};

jQuery.fn.cycle.ver = function() { return ver; };

// override these globally if you like (they are all optional)
jQuery.fn.cycle.defaults = {
	fx:			  'fade', // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle)
	timeout:	   4000,  // milliseconds between slide transitions (0 to disable auto advance)
	timeoutFn:     null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
	continuous:	   0,	  // true to start next transition immediately after current one completes
	speed:		   1000,  // speed of the transition (any valid fx speed value)
	speedIn:	   null,  // speed of the 'in' transition
	speedOut:	   null,  // speed of the 'out' transition
	next:		   null,  // selector for element to use as click trigger for next slide
	prev:		   null,  // selector for element to use as click trigger for previous slide
	prevNextClick: null,  // callback fn for prev/next clicks:	function(isNext, zeroBasedSlideIndex, slideElement)
	pager:		   null,  // selector for element to use as pager container
	pagerClick:	   null,  // callback fn for pager clicks:	function(zeroBasedSlideIndex, slideElement)
	pagerEvent:	  'click', // name of event which drives the pager navigation
	pagerAnchorBuilder: null, // callback fn for building anchor links:  function(index, DOMelement)
	before:		   null,  // transition callback (scope set to element to be shown):     function(currSlideElement, nextSlideElement, options, forwardFlag)
	after:		   null,  // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag)
	end:		   null,  // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
	easing:		   null,  // easing method for both in and out transitions
	easeIn:		   null,  // easing for "in" transition
	easeOut:	   null,  // easing for "out" transition
	shuffle:	   null,  // coords for shuffle animation, ex: { top:15, left: 200 }
	animIn:		   null,  // properties that define how the slide animates in
	animOut:	   null,  // properties that define how the slide animates out
	cssBefore:	   null,  // properties that define the initial state of the slide before transitioning in
	cssAfter:	   null,  // properties that defined the state of the slide after transitioning out
	fxFn:		   null,  // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
	height:		  'auto', // container height
	startingSlide: 0,	  // zero-based index of the first slide to be displayed
	sync:		   1,	  // true if in/out transitions should occur simultaneously
	random:		   0,	  // true for random, false for sequence (not applicable to shuffle fx)
	fit:		   0,	  // force slides to fit container
	containerResize: 1,	  // resize container to fit largest slide
	pause:		   0,	  // true to enable "pause on hover"
	pauseOnPagerHover: 0, // true to pause when hovering over pager link
	autostop:	   0,	  // true to end slideshow after X transitions (where X == slide count)
	autostopCount: 0,	  // number of transitions (optionally used with autostop to define X)
	delay:		   0,	  // additional delay (in ms) for first transition (hint: can be negative)
	slideExpr:	   null,  // expression for selecting slides (if something other than all children is required)
	cleartype:	   !jQuery.support.opacity,  // true if clearType corrections should be applied (for IE)
	nowrap:		   0,	  // true to prevent slideshow from wrapping
	fastOnEvent:   0,	  // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
	randomizeEffects: 1,  // valid when multiple effects are used; true to make the effect sequence random
	rev:           0,     // causes animations to transition in reverse
	manualTrump:   true,  // causes manual transition to stop an active transition instead of being ignored
	requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
	requeueTimeout: 250   // ms delay for requeue
};

})(jQuery);


/*!
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2008 M. Alsup
 * Version:	 2.52
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function(jQuery) {

//
// These functions define one-time slide initialization for the named
// transitions. To save file size feel free to remove any of these that you
// don't need.
//

// scrollUp/Down/Left/Right
jQuery.fn.cycle.transitions.scrollUp = function(jQuerycont, jQueryslides, opts) {
	jQuerycont.css('overflow','hidden');
	opts.before.push(jQuery.fn.cycle.commonReset);
	var h = jQuerycont.height();
	opts.cssBefore ={ top: h, left: 0 };
	opts.cssFirst = { top: 0 };
	opts.animIn	  = { top: 0 };
	opts.animOut  = { top: -h };
};
jQuery.fn.cycle.transitions.scrollDown = function(jQuerycont, jQueryslides, opts) {
	jQuerycont.css('overflow','hidden');
	opts.before.push(jQuery.fn.cycle.commonReset);
	var h = jQuerycont.height();
	opts.cssFirst = { top: 0 };
	opts.cssBefore= { top: -h, left: 0 };
	opts.animIn	  = { top: 0 };
	opts.animOut  = { top: h };
};
jQuery.fn.cycle.transitions.scrollLeft = function(jQuerycont, jQueryslides, opts) {
	jQuerycont.css('overflow','hidden');
	opts.before.push(jQuery.fn.cycle.commonReset);
	var w = jQuerycont.width();
	opts.cssFirst = { left: 0 };
	opts.cssBefore= { left: w, top: 0 };
	opts.animIn	  = { left: 0 };
	opts.animOut  = { left: 0-w };
};
jQuery.fn.cycle.transitions.scrollRight = function(jQuerycont, jQueryslides, opts) {
	jQuerycont.css('overflow','hidden');
	opts.before.push(jQuery.fn.cycle.commonReset);
	var w = jQuerycont.width();
	opts.cssFirst = { left: 0 };
	opts.cssBefore= { left: -w, top: 0 };
	opts.animIn	  = { left: 0 };
	opts.animOut  = { left: w };
};
jQuery.fn.cycle.transitions.scrollHorz = function(jQuerycont, jQueryslides, opts) {
	jQuerycont.css('overflow','hidden').width();
	opts.before.push(function(curr, next, opts, fwd) {
		jQuery.fn.cycle.commonReset(curr,next,opts);
		opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
		opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
	});
	opts.cssFirst = { left: 0 };
	opts.cssBefore= { top: 0 };
	opts.animIn   = { left: 0 };
	opts.animOut  = { top: 0 };
};
jQuery.fn.cycle.transitions.scrollVert = function(jQuerycont, jQueryslides, opts) {
	jQuerycont.css('overflow','hidden');
	opts.before.push(function(curr, next, opts, fwd) {
		jQuery.fn.cycle.commonReset(curr,next,opts);
		opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
		opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
	});
	opts.cssFirst = { top: 0 };
	opts.cssBefore= { left: 0 };
	opts.animIn   = { top: 0 };
	opts.animOut  = { left: 0 };
};

// slideX/slideY
jQuery.fn.cycle.transitions.slideX = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery(opts.elements).not(curr).hide();
		jQuery.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.animIn.width = next.cycleW;
	});
	opts.cssBefore = { left: 0, top: 0, width: 0 };
	opts.animIn	 = { width: 'show' };
	opts.animOut = { width: 0 };
};
jQuery.fn.cycle.transitions.slideY = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery(opts.elements).not(curr).hide();
		jQuery.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.animIn.height = next.cycleH;
	});
	opts.cssBefore = { left: 0, top: 0, height: 0 };
	opts.animIn	 = { height: 'show' };
	opts.animOut = { height: 0 };
};

// shuffle
jQuery.fn.cycle.transitions.shuffle = function(jQuerycont, jQueryslides, opts) {
	var w = jQuerycont.css('overflow', 'visible').width();
	jQueryslides.css({left: 0, top: 0});
	opts.before.push(function(curr,next,opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,true,true);
	});
	opts.speed = opts.speed / 2; // shuffle has 2 transitions
	opts.random = 0;
	opts.shuffle = opts.shuffle || {left:-w, top:15};
	opts.els = [];
	for (var i=0; i < jQueryslides.length; i++)
		opts.els.push(jQueryslides[i]);

	for (var i=0; i < opts.currSlide; i++)
		opts.els.push(opts.els.shift());

	// custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
	opts.fxFn = function(curr, next, opts, cb, fwd) {
		var jQueryel = fwd ? jQuery(curr) : jQuery(next);
		jQuery(next).css(opts.cssBefore);
		var count = opts.slideCount;
		jQueryel.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
			var hops = jQuery.fn.cycle.hopsFromLast(opts, fwd);
			for (var k=0; k < hops; k++)
				fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
			if (fwd)
				for (var i=0, len=opts.els.length; i < len; i++)
					jQuery(opts.els[i]).css('z-index', len-i+count);
			else {
				var z = jQuery(curr).css('z-index');
				jQueryel.css('z-index', parseInt(z)+1+count);
			}
			jQueryel.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
				jQuery(fwd ? this : curr).hide();
				if (cb) cb();
			});
		});
	};
	opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 };
};

// turnUp/Down/Left/Right
jQuery.fn.cycle.transitions.turnUp = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.cssBefore.top = next.cycleH;
		opts.animIn.height = next.cycleH;
	});
	opts.cssFirst  = { top: 0 };
	opts.cssBefore = { left: 0, height: 0 };
	opts.animIn	   = { top: 0 };
	opts.animOut   = { height: 0 };
};
jQuery.fn.cycle.transitions.turnDown = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.animIn.height = next.cycleH;
		opts.animOut.top   = curr.cycleH;
	});
	opts.cssFirst  = { top: 0 };
	opts.cssBefore = { left: 0, top: 0, height: 0 };
	opts.animOut   = { height: 0 };
};
jQuery.fn.cycle.transitions.turnLeft = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.cssBefore.left = next.cycleW;
		opts.animIn.width = next.cycleW;
	});
	opts.cssBefore = { top: 0, width: 0  };
	opts.animIn	   = { left: 0 };
	opts.animOut   = { width: 0 };
};
jQuery.fn.cycle.transitions.turnRight = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.animIn.width = next.cycleW;
		opts.animOut.left = curr.cycleW;
	});
	opts.cssBefore = { top: 0, left: 0, width: 0 };
	opts.animIn	   = { left: 0 };
	opts.animOut   = { width: 0 };
};

// zoom
jQuery.fn.cycle.transitions.zoom = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,false,false,true);
		opts.cssBefore.top = next.cycleH/2;
		opts.cssBefore.left = next.cycleW/2;
		opts.animIn	   = { top: 0, left: 0, width: next.cycleW, height: next.cycleH };
		opts.animOut   = { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 };
	});
	opts.cssFirst = { top:0, left: 0 };
	opts.cssBefore = { width: 0, height: 0 };
};

// fadeZoom
jQuery.fn.cycle.transitions.fadeZoom = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,false,false);
		opts.cssBefore.left = next.cycleW/2;
		opts.cssBefore.top = next.cycleH/2;
		opts.animIn	= { top: 0, left: 0, width: next.cycleW, height: next.cycleH };
	});
	opts.cssBefore = { width: 0, height: 0 };
	opts.animOut  = { opacity: 0 };
};

// blindX
jQuery.fn.cycle.transitions.blindX = function(jQuerycont, jQueryslides, opts) {
	var w = jQuerycont.css('overflow','hidden').width();
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts);
		opts.animIn.width = next.cycleW;
		opts.animOut.left   = curr.cycleW;
	});
	opts.cssBefore = { left: w, top: 0 };
	opts.animIn = { left: 0 };
	opts.animOut  = { left: w };
};
// blindY
jQuery.fn.cycle.transitions.blindY = function(jQuerycont, jQueryslides, opts) {
	var h = jQuerycont.css('overflow','hidden').height();
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts);
		opts.animIn.height = next.cycleH;
		opts.animOut.top   = curr.cycleH;
	});
	opts.cssBefore = { top: h, left: 0 };
	opts.animIn = { top: 0 };
	opts.animOut  = { top: h };
};
// blindZ
jQuery.fn.cycle.transitions.blindZ = function(jQuerycont, jQueryslides, opts) {
	var h = jQuerycont.css('overflow','hidden').height();
	var w = jQuerycont.width();
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts);
		opts.animIn.height = next.cycleH;
		opts.animOut.top   = curr.cycleH;
	});
	opts.cssBefore = { top: h, left: w };
	opts.animIn = { top: 0, left: 0 };
	opts.animOut  = { top: h, left: w };
};

// growX - grow horizontally from centered 0 width
jQuery.fn.cycle.transitions.growX = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.cssBefore.left = this.cycleW/2;
		opts.animIn = { left: 0, width: this.cycleW };
		opts.animOut = { left: 0 };
	});
	opts.cssBefore = { width: 0, top: 0 };
};
// growY - grow vertically from centered 0 height
jQuery.fn.cycle.transitions.growY = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.cssBefore.top = this.cycleH/2;
		opts.animIn = { top: 0, height: this.cycleH };
		opts.animOut = { top: 0 };
	});
	opts.cssBefore = { height: 0, left: 0 };
};

// curtainX - squeeze in both edges horizontally
jQuery.fn.cycle.transitions.curtainX = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,false,true,true);
		opts.cssBefore.left = next.cycleW/2;
		opts.animIn = { left: 0, width: this.cycleW };
		opts.animOut = { left: curr.cycleW/2, width: 0 };
	});
	opts.cssBefore = { top: 0, width: 0 };
};
// curtainY - squeeze in both edges vertically
jQuery.fn.cycle.transitions.curtainY = function(jQuerycont, jQueryslides, opts) {
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,false,true);
		opts.cssBefore.top = next.cycleH/2;
		opts.animIn = { top: 0, height: next.cycleH };
		opts.animOut = { top: curr.cycleH/2, height: 0 };
	});
	opts.cssBefore = { left: 0, height: 0 };
};

// cover - curr slide covered by next slide
jQuery.fn.cycle.transitions.cover = function(jQuerycont, jQueryslides, opts) {
	var d = opts.direction || 'left';
	var w = jQuerycont.css('overflow','hidden').width();
	var h = jQuerycont.height();
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts);
		if (d == 'right')
			opts.cssBefore.left = -w;
		else if (d == 'up')
			opts.cssBefore.top = h;
		else if (d == 'down')
			opts.cssBefore.top = -h;
		else
			opts.cssBefore.left = w;
	});
	opts.animIn = { left: 0, top: 0};
	opts.animOut = { opacity: 1 };
	opts.cssBefore = { top: 0, left: 0 };
};

// uncover - curr slide moves off next slide
jQuery.fn.cycle.transitions.uncover = function(jQuerycont, jQueryslides, opts) {
	var d = opts.direction || 'left';
	var w = jQuerycont.css('overflow','hidden').width();
	var h = jQuerycont.height();
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,true,true);
		if (d == 'right')
			opts.animOut.left = w;
		else if (d == 'up')
			opts.animOut.top = -h;
		else if (d == 'down')
			opts.animOut.top = h;
		else
			opts.animOut.left = -w;
	});
	opts.animIn = { left: 0, top: 0 };
	opts.animOut = { opacity: 1 };
	opts.cssBefore = { top: 0, left: 0 };
};

// toss - move top slide and fade away
jQuery.fn.cycle.transitions.toss = function(jQuerycont, jQueryslides, opts) {
	var w = jQuerycont.css('overflow','visible').width();
	var h = jQuerycont.height();
	opts.before.push(function(curr, next, opts) {
		jQuery.fn.cycle.commonReset(curr,next,opts,true,true,true);
		// provide default toss settings if animOut not provided
		if (!opts.animOut.left && !opts.animOut.top)
			opts.animOut = { left: w*2, top: -h/2, opacity: 0 };
		else
			opts.animOut.opacity = 0;
	});
	opts.cssBefore = { left: 0, top: 0 };
	opts.animIn = { left: 0 };
};

// wipe - clip animation
jQuery.fn.cycle.transitions.wipe = function(jQuerycont, jQueryslides, opts) {
	var w = jQuerycont.css('overflow','hidden').width();
	var h = jQuerycont.height();
	opts.cssBefore = opts.cssBefore || {};
	var clip;
	if (opts.clip) {
		if (/l2r/.test(opts.clip))
			clip = 'rect(0px 0px '+h+'px 0px)';
		else if (/r2l/.test(opts.clip))
			clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
		else if (/t2b/.test(opts.clip))
			clip = 'rect(0px '+w+'px 0px 0px)';
		else if (/b2t/.test(opts.clip))
			clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
		else if (/zoom/.test(opts.clip)) {
			var t = parseInt(h/2);
			var l = parseInt(w/2);
			clip = 'rect('+t+'px '+l+'px '+t+'px '+l+'px)';
		}
	}

	opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';

	var d = opts.cssBefore.clip.match(/(\d+)/g);
	var t = parseInt(d[0]), r = parseInt(d[1]), b = parseInt(d[2]), l = parseInt(d[3]);

	opts.before.push(function(curr, next, opts) {
		if (curr == next) return;
		var jQuerycurr = jQuery(curr), jQuerynext = jQuery(next);
		jQuery.fn.cycle.commonReset(curr,next,opts,true,true,false);
    	opts.cssAfter.display = 'block';

		var step = 1, count = parseInt((opts.speedIn / 13)) - 1;
		(function f() {
			var tt = t ? t - parseInt(step * (t/count)) : 0;
			var ll = l ? l - parseInt(step * (l/count)) : 0;
			var bb = b < h ? b + parseInt(step * ((h-b)/count || 1)) : h;
			var rr = r < w ? r + parseInt(step * ((w-r)/count || 1)) : w;
			jQuerynext.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
			(step++ <= count) ? setTimeout(f, 13) : jQuerycurr.css('display', 'none');
		})();
	});
	opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 };
	opts.animIn	   = { left: 0 };
	opts.animOut   = { left: 0 };
};

})(jQuery);

// Textarea limit plugin
// http://www.unwrongest.com/projects/limit/
(function(jQuery){ 
     jQuery.fn.extend({  
         limit: function(limit,element) {
			
			var interval, f;
			var self = jQuery(this);
					
			jQuery(this).focus(function(){
				interval = window.setInterval(substring,100);
			});
			
			jQuery(this).blur(function(){
				clearInterval(interval);
				substring();
			});
			
			substringFunction = "function substring(){ var val = jQuery(self).val();var length = val.length;if(length > limit){jQuery(self).val(jQuery(self).val().substring(0,limit));}";
			if(typeof element != 'undefined')
				substringFunction += "if(jQuery(element).html() != limit-length){jQuery(element).html((limit-length<=0)?'0':limit-length);}"
				
			substringFunction += "}";
			
			eval(substringFunction);
			
			
			
			substring();
			
        } 
    }); 
})(jQuery);

