




/* Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * jQueryLastChangedDate: 2007-12-20 09:02:08 -0600 (Thu, 20 Dec 2007) jQuery
 * jQueryRev: 4265 jQuery
 *
 * Version: 3.0
 * 
 * Requires: jQuery 1.2.2+
 */

(function(jQuery) {

jQuery.event.special.mousewheel = {
	setup: function() {
		var handler = jQuery.event.special.mousewheel.handler;
		
		// Fix pageX, pageY, clientX and clientY for mozilla
		if ( jQuery.browser.mozilla )
			jQuery(this).bind('mousemove.mousewheel', function(event) {
				jQuery.data(this, 'mwcursorposdata', {
					pageX: event.pageX,
					pageY: event.pageY,
					clientX: event.clientX,
					clientY: event.clientY
				});
			});
	
		if ( this.addEventListener )
			this.addEventListener( (jQuery.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
		else
			this.onmousewheel = handler;
	},
	
	teardown: function() {
		var handler = jQuery.event.special.mousewheel.handler;
		
		jQuery(this).unbind('mousemove.mousewheel');
		
		if ( this.removeEventListener )
			this.removeEventListener( (jQuery.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
		else
			this.onmousewheel = function(){};
		
		jQuery.removeData(this, 'mwcursorposdata');
	},
	
	handler: function(event) {
		var args = Array.prototype.slice.call( arguments, 1 );
		
		event = jQuery.event.fix(event || window.event);
		// Get correct pageX, pageY, clientX and clientY for mozilla
		jQuery.extend( event, jQuery.data(this, 'mwcursorposdata') || {} );
		var delta = 0, returnValue = true;
		
		if ( event.wheelDelta ) delta = event.wheelDelta/120;
		if ( event.detail     ) delta = -event.detail/3;
//		if ( jQuery.browser.opera  ) delta = -event.wheelDelta;
		
		event.data  = event.data || {};
		event.type  = "mousewheel";
		
		// Add delta to the front of the arguments
		args.unshift(delta);
		// Add event to the front of the arguments
		args.unshift(event);

		return jQuery.event.handle.apply(this, args);
	}
};

jQuery.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},
	
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});

})(jQuery);


/* Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * jQueryId: jScrollPane.js 78 2009-07-03 19:16:36Z kelvin.luck@gmail.com jQuery
 */

/**
 * Replace the vertical scroll bars on any matched elements with a fancy
 * styleable (via CSS) version. With JS disabled the elements will
 * gracefully degrade to the browsers own implementation of overflow:auto.
 * If the mousewheel plugin has been included on the page then the scrollable areas will also
 * respond to the mouse wheel.
 *
 * @example jQuery(".scroll-pane").jScrollPane();
 *
 * @name jScrollPane
 * @type jQuery
 * @param Object	settings	hash with options, described below.
 *								scrollbarWidth	-	The width of the generated scrollbar in pixels
 *								scrollbarMargin	-	The amount of space to leave on the side of the scrollbar in pixels
 *								wheelSpeed		-	The speed the pane will scroll in response to the mouse wheel in pixels
 *								showArrows		-	Whether to display arrows for the user to scroll with
 *								arrowSize		-	The height of the arrow buttons if showArrows=true
 *								animateTo		-	Whether to animate when calling scrollTo and scrollBy
 *								dragMinHeight	-	The minimum height to allow the drag bar to be
 *								dragMaxHeight	-	The maximum height to allow the drag bar to be
 *								animateInterval	-	The interval in milliseconds to update an animating scrollPane (default 100)
 *								animateStep		-	The amount to divide the remaining scroll distance by when animating (default 3)
 *								maintainPosition-	Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
 *								tabIndex		-	The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0)
 *								enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true)
 *								animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false)
 *								scrollbarOnLeft	-	Display the scrollbar on the left side?  (needs stylesheet changes, see examples.html)
 *								reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false)
 * @return jQuery
 * @cat Plugins/jScrollPane
 * @author Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 */

(function(jQuery) {

jQuery.jScrollPane = {
	active : []
};
jQuery.fn.jScrollPane = function(settings)
{
	settings = jQuery.extend({}, jQuery.fn.jScrollPane.defaults, settings);

	var rf = function() { return false; };
	
	return this.each(
		function()
		{
			var jQuerythis = jQuery(this);
			var paneEle = this;
			
			if (jQuery(this).parent().is('.jScrollPaneContainer')) {
				var currentScrollPosition = settings.maintainPosition ? jQuerythis.position().top : 0;
				var jQueryc = jQuery(this).parent();
				var paneWidth = jQueryc.innerWidth();
				var paneHeight = jQueryc.outerHeight();
				var trackHeight = paneHeight;
				jQuery('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown', jQueryc).remove();
				jQuerythis.css({'top':0});
			} else {
				jQuerythis.data('originalStyleTag', jQuerythis.attr('style'));
				// Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
				jQuerythis.css('overflow', 'hidden');
				var currentScrollPosition = 0;
				this.originalPadding = jQuerythis.css('paddingTop') + ' ' + jQuerythis.css('paddingRight') + ' ' + jQuerythis.css('paddingBottom') + ' ' + jQuerythis.css('paddingLeft');
				this.originalSidePaddingTotal = (parseInt(jQuerythis.css('paddingLeft')) || 0) + (parseInt(jQuerythis.css('paddingRight')) || 0);
				var paneWidth = jQuerythis.innerWidth();
				var paneHeight = jQuerythis.innerHeight();
				var trackHeight = paneHeight;
				var jQuerycontainer = jQuery('<div></div>')
					.attr({'className':'jScrollPaneContainer'})
					.css(
						{
							'height':paneHeight+'px', 
							'width':paneWidth+'px'
						}
					);
				if (settings.enableKeyboardNavigation) {
					jQuerycontainer.attr(
						'tabindex', 
						settings.tabIndex
					);
				}
				jQuerythis.wrap(jQuerycontainer);
				// deal with text size changes (if the jquery.em plugin is included)
				// and re-initialise the scrollPane so the track maintains the
				// correct size
				jQuery(document).bind(
					'emchange', 
					function(e, cur, prev)
					{
						jQuerythis.jScrollPane(settings);
					}
				);
				
			}
			
			if (settings.reinitialiseOnImageLoad) {
				// code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
				// except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
				// TODO: Do I even need to store it in jQuery.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
				var jQueryimagesToLoad = jQuery.data(paneEle, 'jScrollPaneImagesToLoad') || jQuery('img', jQuerythis);
				var loadedImages = [];
				
				if (jQueryimagesToLoad.length) {
					jQueryimagesToLoad.each(function(i, val)	{
						jQuery(this).bind('load readystatechange', function() {
							if(jQuery.inArray(i, loadedImages) == -1){ //don't double count images
								loadedImages.push(val); //keep a record of images we've seen
								jQueryimagesToLoad = jQuery.grep(jQueryimagesToLoad, function(n, i) {
									return n != val;
								});
								jQuery.data(paneEle, 'jScrollPaneImagesToLoad', jQueryimagesToLoad);
								var s2 = jQuery.extend(settings, {reinitialiseOnImageLoad:false});
								jQuerythis.jScrollPane(s2); // re-initialise
							}
						}).each(function(i, val) {
							if(this.complete || this.complete===undefined) { 
								//needed for potential cached images
								this.src = this.src; 
							} 
						});
					});
				};
			}

			var p = this.originalSidePaddingTotal;
			var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;

			var cssToApply = {
				'height':'auto',
				'width': realPaneWidth + 'px'
			}

			if(settings.scrollbarOnLeft) {
				cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
			} else {
				cssToApply.paddingRight = settings.scrollbarMargin + 'px';
			}

			jQuerythis.css(cssToApply);

			var contentHeight = jQuerythis.outerHeight();
			var percentInView = paneHeight / contentHeight;

			if (percentInView < .99) {
				var jQuerycontainer = jQuerythis.parent();
				jQuerycontainer.append(
					jQuery('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(
						jQuery('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(
							jQuery('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),
							jQuery('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'})
						)
					)
				);
				
				var jQuerytrack = jQuery('>.jScrollPaneTrack', jQuerycontainer);
				var jQuerydrag = jQuery('>.jScrollPaneTrack .jScrollPaneDrag', jQuerycontainer);
				
				
				var currentArrowDirection;
				var currentArrowTimerArr = [];// Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
				var currentArrowInc;
				var whileArrowButtonDown = function() 
				{
					if (currentArrowInc > 4 || currentArrowInc % 4 == 0) {
						positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
					}
					currentArrowInc++;
				};

				if (settings.enableKeyboardNavigation) {
					jQuerycontainer.bind(
						'keydown.jscrollpane',
						function(e) 
						{
							switch (e.keyCode) {
								case 38: //up
									currentArrowDirection = -1;
									currentArrowInc = 0;
									whileArrowButtonDown();
									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
									return false;
								case 40: //down
									currentArrowDirection = 1;
									currentArrowInc = 0;
									whileArrowButtonDown();
									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
									return false;
								case 33: // page up
								case 34: // page down
									// TODO
									return false;
								default:
							}
						}
					).bind(
						'keyup.jscrollpane',
						function(e) 
						{
							if (e.keyCode == 38 || e.keyCode == 40) {
								for (var i = 0; i < currentArrowTimerArr.length; i++) {
									clearInterval(currentArrowTimerArr[i]);
								}
								return false;
							}
						}
					);
				}

				if (settings.showArrows) {
					
					var currentArrowButton;
					var currentArrowInterval;

					var onArrowMouseUp = function(event)
					{
						jQuery('html').unbind('mouseup', onArrowMouseUp);
						currentArrowButton.removeClass('jScrollActiveArrowButton');
						clearInterval(currentArrowInterval);
					};
					var onArrowMouseDown = function() {
						jQuery('html').bind('mouseup', onArrowMouseUp);
						currentArrowButton.addClass('jScrollActiveArrowButton');
						currentArrowInc = 0;
						whileArrowButtonDown();
						currentArrowInterval = setInterval(whileArrowButtonDown, 100);
					};
					jQuerycontainer
						.append(
							jQuery('<a></a>')
								.attr({'href':'javascript:;', 'className':'jScrollArrowUp', 'tabindex':-1})
								.css({'width':settings.scrollbarWidth+'px'})
								.html('Scroll up')
								.bind('mousedown', function()
								{
									currentArrowButton = jQuery(this);
									currentArrowDirection = -1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf),
							jQuery('<a></a>')
								.attr({'href':'javascript:;', 'className':'jScrollArrowDown', 'tabindex':-1})
								.css({'width':settings.scrollbarWidth+'px'})
								.html('Scroll down')
								.bind('mousedown', function()
								{
									currentArrowButton = jQuery(this);
									currentArrowDirection = 1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf)
						);
					var jQueryupArrow = jQuery('>.jScrollArrowUp', jQuerycontainer);
					var jQuerydownArrow = jQuery('>.jScrollArrowDown', jQuerycontainer);
					if (settings.arrowSize) {
						trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
						jQuerytrack
							.css({'height': trackHeight+'px', top:settings.arrowSize+'px'})
					} else {
						var topArrowHeight = jQueryupArrow.height();
						settings.arrowSize = topArrowHeight;
						trackHeight = paneHeight - topArrowHeight - jQuerydownArrow.height();
						jQuerytrack
							.css({'height': trackHeight+'px', top:topArrowHeight+'px'})
					}
				}
				
				var jQuerypane = jQuery(this).css({'position':'absolute', 'overflow':'visible'});
				
				var currentOffset;
				var maxY;
				var mouseWheelMultiplier;
				// store this in a seperate variable so we can keep track more accurately than just updating the css property..
				var dragPosition = 0;
				var dragMiddle = percentInView*paneHeight/2;
				
				// pos function borrowed from tooltip plugin and adapted...
				var getPos = function (event, c) {
					var p = c == 'X' ? 'Left' : 'Top';
					return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
				};
				
				var ignoreNativeDrag = function() {	return false; };
				
				var initDrag = function()
				{
					ceaseAnimation();
					currentOffset = jQuerydrag.offset(false);
					currentOffset.top -= dragPosition;
					maxY = trackHeight - jQuerydrag[0].offsetHeight;
					mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
				};
				
				var onStartDrag = function(event)
				{
					initDrag();
					dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
					jQuery('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
					if (jQuery.browser.msie) {
						jQuery('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
					}
					return false;
				};
				var onStopDrag = function()
				{
					jQuery('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
					dragMiddle = percentInView*paneHeight/2;
					if (jQuery.browser.msie) {
						jQuery('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
					}
				};
				var positionDrag = function(destY)
				{
					destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
					dragPosition = destY;
					jQuerydrag.css({'top':destY+'px'});
					var p = destY / maxY;
					jQuerythis.data('jScrollPanePosition', (paneHeight-contentHeight)*-p);
					jQuerypane.css({'top':((paneHeight-contentHeight)*p) + 'px'});
					jQuerythis.trigger('scroll');
					if (settings.showArrows) {
						jQueryupArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
						jQuerydownArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
					}
				};
				var updateScroll = function(e)
				{
					positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
				};
				
				var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight);
				
				jQuerydrag.css(
					{'height':dragH+'px'}
				).bind('mousedown', onStartDrag);
				
				var trackScrollInterval;
				var trackScrollInc;
				var trackScrollMousePos;
				var doTrackScroll = function()
				{
					if (trackScrollInc > 8 || trackScrollInc%4==0) {
						positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
					}
					trackScrollInc ++;
				};
				var onStopTrackClick = function()
				{
					clearInterval(trackScrollInterval);
					jQuery('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
				};
				var onTrackMouseMove = function(event)
				{
					trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
				};
				var onTrackClick = function(event)
				{
					initDrag();
					onTrackMouseMove(event);
					trackScrollInc = 0;
					jQuery('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
					trackScrollInterval = setInterval(doTrackScroll, 100);
					doTrackScroll();
					return false;
				};
				
				jQuerytrack.bind('mousedown', onTrackClick);
				
				jQuerycontainer.bind(
					'mousewheel',
					function (event, delta) {
						delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
-event.detail/3 : 0);
						initDrag();
						ceaseAnimation();
						var d = dragPosition;
						positionDrag(dragPosition - delta * mouseWheelMultiplier);
						var dragOccured = d != dragPosition;
						return !dragOccured;
					}
				);

				var _animateToPosition;
				var _animateToInterval;
				function animateToPosition()
				{
					var diff = (_animateToPosition - dragPosition) / settings.animateStep;
					if (diff > 1 || diff < -1) {
						positionDrag(dragPosition + diff);
					} else {
						positionDrag(_animateToPosition);
						ceaseAnimation();
					}
				}
				var ceaseAnimation = function()
				{
					if (_animateToInterval) {
						clearInterval(_animateToInterval);
						delete _animateToPosition;
					}
				};
				var scrollTo = function(pos, preventAni)
				{
					if (typeof pos == "string") {
						jQuerye = jQuery(pos, jQuerythis);
						if (!jQuerye.length) return;
						pos = jQuerye.offset().top - jQuerythis.offset().top;
					}
					jQuerycontainer.scrollTop(0);
					ceaseAnimation();
					var maxScroll = contentHeight - paneHeight;
					pos = pos > maxScroll ? maxScroll : pos;
					jQuerythis.data('jScrollPaneMaxScroll', maxScroll);
					var destDragPosition = pos/maxScroll * maxY;
					if (preventAni || !settings.animateTo) {
						positionDrag(destDragPosition);
					} else {
						_animateToPosition = destDragPosition;
						_animateToInterval = setInterval(animateToPosition, settings.animateInterval);
					}
				};
				jQuerythis[0].scrollTo = scrollTo;
				
				jQuerythis[0].scrollBy = function(delta)
				{
					var currentPos = -parseInt(jQuerypane.css('top')) || 0;
					scrollTo(currentPos + delta);
				};
				
				initDrag();
				
				scrollTo(-currentScrollPosition, true);
			
				// Deal with it when the user tabs to a link or form element within this scrollpane
				jQuery('*', this).bind(
					'focus',
					function(event)
					{
						var jQuerye = jQuery(this);
						
						// loop through parents adding the offset top of any elements that are relatively positioned between
						// the focused element and the jScrollPaneContainer so we can get the true distance from the top
						// of the focused element to the top of the scrollpane...
						var eleTop = 0;
						
						while (jQuerye[0] != jQuerythis[0]) {
							eleTop += jQuerye.position().top;
							jQuerye = jQuerye.offsetParent();
						}
						
						var viewportTop = -parseInt(jQuerypane.css('top')) || 0;
						var maxVisibleEleTop = viewportTop + paneHeight;
						var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
						if (!eleInView) {
							var destPos = eleTop - settings.scrollbarMargin;
							if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
								destPos += jQuery(this).height() + 15 + settings.scrollbarMargin - paneHeight;
							}
							scrollTo(destPos);
						}
					}
				)
				
				
				if (location.hash) {
					setTimeout(function() {scrollTo(location.hash);}, jQuery.browser.safari ? 100 : 0);
				}
				
				// use event delegation to listen for all clicks on links and hijack them if they are links to
				// anchors within our content...
				jQuery(document).bind(
					'click',
					function(e)
					{
						jQuerytarget = jQuery(e.target);
						if (jQuerytarget.is('a')) {
							var h = jQuerytarget.attr('href');
							if (h && h.substr(0, 1) == '#' && h.length > 1) {
								setTimeout(function() {scrollTo(h, !settings.animateToInternalLinks);}, jQuery.browser.safari ? 100 : 0);
							}
						}
					}
				); 
				
				// Deal with dragging and selecting text to make the scrollpane scroll...
				function onSelectScrollMouseDown(e)
				{
				   jQuery(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
				   jQuery(document).bind('mouseup.jScrollPaneDragging',   onSelectScrollMouseUp);
				  
				}
				
				var textDragDistanceAway;
				var textSelectionInterval;
				
				function onTextSelectionInterval()
				{
					direction = textDragDistanceAway < 0 ? -1 : 1;
					jQuerythis[0].scrollBy(textDragDistanceAway / 2);
				}

				function clearTextSelectionInterval()
				{
					if (textSelectionInterval) {
						clearInterval(textSelectionInterval);
						textSelectionInterval = undefined;
					}
				}
				
				function onTextSelectionScrollMouseMove(e)
				{
					var offset = jQuerythis.parent().offset().top;
					var maxOffset = offset + paneHeight;
					var mouseOffset = getPos(e, 'Y');
					textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
					if (textDragDistanceAway == 0) {
						clearTextSelectionInterval();
					} else {
						if (!textSelectionInterval) {
							textSelectionInterval  = setInterval(onTextSelectionInterval, 100);
						}
					}
				}

				function onSelectScrollMouseUp(e)
				{
				   jQuery(document)
					  .unbind('mousemove.jScrollPaneDragging')
					  .unbind('mouseup.jScrollPaneDragging');
				   clearTextSelectionInterval();
				}

				jQuerycontainer.bind('mousedown.jScrollPane', onSelectScrollMouseDown);

				
				jQuery.jScrollPane.active.push(jQuerythis[0]);
				
			} else {
				jQuerythis.css(
					{
						'height':paneHeight+'px',
						'width':paneWidth-this.originalSidePaddingTotal+'px',
						'padding':this.originalPadding
					}
				);
				jQuerythis[0].scrollTo = jQuerythis[0].scrollBy = function() {};
				// clean up listeners
				jQuerythis.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');
			}
			
		}
	)
};

jQuery.fn.jScrollPaneRemove = function()
{
	jQuery(this).each(function()
	{
		jQuerythis = jQuery(this);
		var jQueryc = jQuerythis.parent();
		if (jQueryc.is('.jScrollPaneContainer')) {
			jQuerythis.css(
				{
					'top':'',
					'height':'',
					'width':'',
					'padding':'',
					'overflow':'',
					'position':''
				}
			);
			jQuerythis.attr('style', jQuerythis.data('originalStyleTag'));
			jQueryc.after(jQuerythis).remove();
		}
	});
}

jQuery.fn.jScrollPane.defaults = {
	scrollbarWidth : 10,
	scrollbarMargin : 5,
	wheelSpeed : 18,
	showArrows : false,
	arrowSize : 0,
	animateTo : false,
	dragMinHeight : 1,
	dragMaxHeight : 99999,
	animateInterval : 100,
	animateStep: 3,
	maintainPosition: true,
	scrollbarOnLeft: false,
	reinitialiseOnImageLoad: false,
	tabIndex : 0,
	enableKeyboardNavigation: true,
	animateToInternalLinks: false
};

// clean up the scrollTo expandos
jQuery(window)
	.bind('unload', function() {
		var els = jQuery.jScrollPane.active; 
		for (var i=0; i<els.length; i++) {
			els[i].scrollTo = els[i].scrollBy = null;
		}
	}
);

})(jQuery);


/**
 * History/Remote - jQuery plugin for enabling history support and bookmarking
 * @requires jQuery v1.0.3
 *
 * http://stilbuero.de/jquery/history/
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 0.2.3
 */

(function(jQuery) { // block scope

/**
 * Initialize the history manager. Subsequent calls will not result in additional history state change 
 * listeners. Should be called soonest when the DOM is ready, because in IE an iframe needs to be added
 * to the body to enable history support.
 *
 * @example jQuery.ajaxHistory.initialize();
 *
 * @param Function callback A single function that will be executed in case there is no fragment
 *                          identifier in the URL, for example after navigating back to the initial
 *                          state. Use to restore such an initial application state.
 *                          Optional. If specified it will overwrite the default action of 
 *                          emptying all containers that are used to load content into.
 * @type undefined
 *
 * @name jQuery.ajaxHistory.initialize()
 * @cat Plugins/History
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.ajaxHistory = new function() {

    var RESET_EVENT = 'historyReset';

    var _currentHash = location.hash;
    var _intervalId = null;
    var _observeHistory; // define outside if/else required by Opera

    this.update = function() { }; // empty function body for graceful degradation

    // create custom event for state reset
    var _defaultReset = function() {
        jQuery('.remote-output').empty();
    };
    jQuery(document).bind(RESET_EVENT, _defaultReset);
    
    // TODO fix for Safari 3
    // if (jQuery.browser.msie)
    // else if hash != _currentHash
    // else check history length

    if (jQuery.browser.msie) {

        var _historyIframe, initialized = false; // for IE

        // add hidden iframe
        jQuery(function() {
            _historyIframe = jQuery('<iframe style="display: none;"></iframe>').appendTo(document.body).get(0);
            var iframe = _historyIframe.contentWindow.document;
            // create initial history entry
            iframe.open();
            iframe.close();
            if (_currentHash && _currentHash != '#') {
                iframe.location.hash = _currentHash.replace('#', '');
            }
        });

        this.update = function(hash) {
            _currentHash = hash;
            var iframe = _historyIframe.contentWindow.document;
            iframe.open();
            iframe.close();
            iframe.location.hash = hash.replace('#', '');
        };

        _observeHistory = function() {
            var iframe = _historyIframe.contentWindow.document;
            var iframeHash = iframe.location.hash;
            if (iframeHash != _currentHash) {
                _currentHash = iframeHash;
                if (iframeHash && iframeHash != '#') {
                    // order does matter, set location.hash after triggering the click...
                    jQuery('a[@hrefjQuery="' + iframeHash + '"]').click();
                    location.hash = iframeHash;
                } else if (initialized) {
                    location.hash = '';
                    jQuery(document).trigger(RESET_EVENT);
                }
            }
            initialized = true;
        };

    } else if (jQuery.browser.mozilla || jQuery.browser.opera) {

 //       this.update = function(hash) {
  //          _currentHash = hash;
  //      };

        _observeHistory = function() {
            if (location.hash) {
                if (_currentHash != location.hash) {
                    _currentHash = location.hash;
                    jQuery('a[@hrefjQuery="' + _currentHash + '"]').click();
                }
            } else if (_currentHash) {
                _currentHash = '';
                jQuery(document).trigger(RESET_EVENT);
            }
        };

    } else if (jQuery.browser.safari) {

        var _backStack, _forwardStack, _addHistory; // for Safari

        // etablish back/forward stacks
        jQuery(function() {
            _backStack = [];
            _backStack.length = history.length;
            _forwardStack = [];

        });
        var isFirst = false, initialized = false;
        _addHistory = function(hash) {
            _backStack.push(hash);
            _forwardStack.length = 0; // clear forwardStack (true click occured)
            isFirst = false;
        };

        this.update = function(hash) {
            _currentHash = hash;
            _addHistory(_currentHash);
        };

        _observeHistory = function() {
            var historyDelta = history.length - _backStack.length;
            if (historyDelta) { // back or forward button has been pushed
                isFirst = false;
                if (historyDelta < 0) { // back button has been pushed
                    // move items to forward stack
                    for (var i = 0; i < Math.abs(historyDelta); i++) _forwardStack.unshift(_backStack.pop());
                } else { // forward button has been pushed
                    // move items to back stack
                    for (var i = 0; i < historyDelta; i++) _backStack.push(_forwardStack.shift());
                }
                var cachedHash = _backStack[_backStack.length - 1];
                jQuery('a[@hrefjQuery="' + cachedHash + '"]').click();
                _currentHash = location.hash;
            } else if (_backStack[_backStack.length - 1] == undefined && !isFirst) {
                // back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
                // document.URL doesn't change in Safari
                if (document.URL.indexOf('#') >= 0) {
                    jQuery('a[@hrefjQuery="' + '#' + document.URL.split('#')[1] + '"]').click();
                } else if (initialized) {
                    jQuery(document).trigger(RESET_EVENT);
                }
                isFirst = true;
            }
            initialized = true;
        };

    }

    this.initialize = function(callback) {
        // custom callback to reset app state (no hash in url)
        if (typeof callback == 'function') {
            jQuery(document).unbind(RESET_EVENT, _defaultReset).bind(RESET_EVENT, callback);
        }
        // look for hash in current URL (not Safari)
        if (location.hash && typeof _addHistory == 'undefined') {
            jQuery('a[@hrefjQuery="' + location.hash + '"]').trigger('click');
        }
        // start observer
        if (_observeHistory && _intervalId == null) {
            _intervalId = setInterval(_observeHistory, 200); // Safari needs at least 200 ms
        }
    };

};

/**
 * Implement Ajax driven links in a completely unobtrusive and accessible manner (also known as "Hijax")
 * with support for the browser's back/forward navigation buttons and bookmarking.
 *
 * The link's href attribute gets altered to a fragment identifier, such as "#remote-1", so that the browser's
 * URL gets updated on each click, whereas the former value of that attribute is used to load content via
 * XmlHttpRequest from and update the specified element. If no target element is found, a new div element will be
 * created and appended to the body to load the content into. The link informs the history manager of the 
 * state change on click and adds an entry to the browser's history.
 *
 * jQuery's Ajax implementation adds a custom request header of the form "X-Requested-With: XmlHttpRequest"
 * to any Ajax request so that the called page can distinguish between a standard and an Ajax (XmlHttpRequest)
 * request.
 *
 * @example jQuery('a.remote').remote('#output');
 * @before <a class="remote" href="/path/to/content.html">Update</a>
 * @result <a class="remote" href="#remote-1">Update</a>
 * @desc Alter a link of the class "remote" to an Ajax-enhanced link and let it load content from
 *       "/path/to/content.html" via XmlHttpRequest into an element with the id "output".
 * @example jQuery('a.remote').remote('#output', {hashPrefix: 'chapter'});
 * @before <a class="remote" href="/path/to/content.html">Update</a>
 * @result <a class="remote" href="#chapter-1">Update</a>
 * @desc Alter a link of the class "remote" to an Ajax-enhanced link and let it load content from
 *       "/path/to/content.html" via XmlHttpRequest into an element with the id "output".
 *
 * @param String expr A string containing a CSS selector or basic XPath specifying the element to load
 *                    content into via XmlHttpRequest.
 * @param Object settings An object literal containing key/value pairs to provide optional settings.
 * @option String hashPrefix A String that is used for constructing the hash the link's href attribute
 *                           gets altered to, such as "#remote-1". Default value: "remote-".
 * @param Function callback A single function that will be executed when the request is complete. 
 * @type jQuery
 *
 * @name remote
 * @cat Plugins/Remote
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Implement Ajax driven links in a completely unobtrusive and accessible manner (also known as "Hijax")
 * with support for the browser's back/forward navigation buttons and bookmarking.
 *
 * The link's href attribute gets altered to a fragment identifier, such as "#remote-1", so that the browser's
 * URL gets updated on each click, whereas the former value of that attribute is used to load content via
 * XmlHttpRequest from and update the specified element. If no target element is found, a new div element will be
 * created and appended to the body to load the content into. The link informs the history manager of the 
 * state change on click and adds an entry to the browser's history.
 *
 * jQuery's Ajax implementation adds a custom request header of the form "X-Requested-With: XmlHttpRequest"
 * to any Ajax request so that the called page can distinguish between a standard and an Ajax (XmlHttpRequest)
 * request.
 *
 * @example jQuery('a.remote').remote( jQuery('#output > div')[0] );
 * @before <a class="remote" href="/path/to/content.html">Update</a>
 * @result <a class="remote" href="#remote-1">Update</a>
 * @desc Alter a link of the class "remote" to an Ajax-enhanced link and let it load content from
 *       "/path/to/content.html" via XmlHttpRequest into an element with the id "output".
 * @example jQuery('a.remote').remote('#output', {hashPrefix: 'chapter'});
 * @before <a class="remote" href="/path/to/content.html">Update</a>
 * @result <a class="remote" href="#chapter-1">Update</a>
 * @desc Alter a link of the class "remote" to an Ajax-enhanced link and let it load content from
 *       "/path/to/content.html" via XmlHttpRequest into an element with the id "output".
 *
 * @param Element elem A DOM element to load content into via XmlHttpRequest.
 * @param Object settings An object literal containing key/value pairs to provide optional settings.
 * @option String hashPrefix A String that is used for constructing the hash the link's href attribute
 *                           gets altered to, such as "#remote-1". Default value: "remote-".
 * @param Function callback A single function that will be executed when the request is complete. 
 * @type jQuery
 *
 * @name remote
 * @cat Plugins/Remote
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.fn.remote = function(output, settings, callback) {

    callback = callback || function() {};
    if (typeof settings == 'function') { // shift arguments
        callback = settings;
    }
    
    settings = jQuery.extend({
        hashPrefix: 'remote-'
    }, settings || {});

    var target = jQuery(output).size() && jQuery(output) || jQuery('<div></div>').appendTo('body');
    target.addClass('remote-output');

    return this.each(function(i) {
        var href = this.href, hash = '#' + (this.title && this.title.replace(/\s/g, '_') || settings.hashPrefix + (i + 1)),
            a = this;
        this.href = hash;
        jQuery(this).click(function(e) {
            // lock target to prevent double loading in Firefox
            if (!target['locked']) {
                // add to history only if true click occured, not a triggered click
                if (e.clientX) {
                    jQuery.ajaxHistory.update(hash);
                }
                target.load(href, function() {
                    target['locked'] = null;
                    callback.apply(a);
                });
            }
        });
    });

};

/**
 * Provides the ability to use the back/forward navigation buttons in a DHTML application.
 * A change of the application state is reflected by a change of the URL fragment identifier.
 *
 * The link's href attribute needs to point to a fragment identifier within the same resource,
 * although that fragment id does not need to exist. On click the link changes the URL fragment
 * identifier, informs the history manager of the state change and adds an entry to the browser's
 * history.
 *
 * @param Function callback A single function that will be executed as the click handler of the 
 *                          matched element. It will be executed on click (adding an entry to 
 *                          the history) as well as in case the history manager needs to trigger 
 *                          it depending on the value of the URL fragment identifier, e.g. if its 
 *                          current value matches the href attribute of the matched element.
 *                           
 * @type jQuery
 *
 * @name history
 * @cat Plugins/History
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.fn.history = function(callback) {
    return this.click(function(e) {        
		// add to history only if true click occured,
		// not a triggered click...
        if (e.clientX) {
	        // ...and die if already active
			if (this.hash == location.hash) {
				return false;
			} 
           	jQuery.ajaxHistory.update(this.hash);
        }
		if (typeof callback == 'function') {
			callback.call(this);
		}
    });
};

})(jQuery);

/*
var logger;
jQuery(function() {
    logger = jQuery('<div style="position: fixed; top: 0; overflow: hidden; border: 1px solid; padding: 3px; width: 120px; height: 150px; background: #fff; color: red;"></div>').appendTo(document.body);
});
function log(m) {    
    logger.prepend(m + '<br />');
};
*/



/*
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2009 M. Alsup
 * Version: 2.65 (07-APR-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.65";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.fn.cycle=function(options,arg2){var o={s:this.selector,c:this.context};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;}log("terminating; zero elements found by selector"+(jQuery.isReady?"":" (DOM not ready)"));return this;}return this.each(function(){options=handleArguments(this,options,arg2);if(options===false){return;}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(opts.timeout||opts.continuous){this.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},opts.continuous?10:opts.timeout+(opts.delay||0));}});};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++;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){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){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(cont.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){}}}function buildOptions(jQuerycont,jQueryslides,els,options,o){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;});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);if(!jQuery.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix(jQueryslides);}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(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;}}opts.currSlide=opts.startingSlide=opts.startingSlide||0;var first=opts.startingSlide;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);});jQuery(els[first]).css("opacity",1).show();removeFilter(els[first],opts);if(opts.fit&&opts.width){jQueryslides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){jQueryslides.height(opts.height);}var reshape=opts.containerResize&&!jQuerycont.innerHeight();if(reshape){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;}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;}}}var requeue=false;options.requeueAttempts=options.requeueAttempts||0;jQueryslides.each(function(){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")){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);if(loadingIE||loadingOp||loadingOther){if(o.s&&opts.requeueOnImageNotLoaded&&++options.requeueAttempts<100){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;}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);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){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;}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;}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;if(opts.fx.indexOf(",")>0){opts.multiFx=true;opts.fxs=opts.fx.replace(/\s*/g,"").split(",");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(!opts.fxs.length){log("No valid transitions named; slideshow terminating.");return false;}}else{if(opts.fx=="all"){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){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;}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);}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();}};}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);});var init=jQuery.fn.cycle.transitions[fx];if(jQuery.isFunction(init)){init(opts.jQuerycont,jQuery(opts.elements),opts);}};function go(els,opts,manual,fwd){if(manual&&opts.busy&&opts.manualTrump){jQuery(els).stop(true,true);opts.busy=false;}if(opts.busy){return;}var p=opts.jQuerycont[0],curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleStop!=opts.stopCount||p.cycleTimeout===0&&!manual){return;}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(manual||!p.cyclePause){var fx=opts.fx;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();if(opts.multiFx){if(opts.lastFx==undefined||++opts.lastFx>=opts.fxs.length){opts.lastFx=0;}fx=opts.fxs[opts.lastFx];opts.currFx=fx;}if(opts.oneTimeFx){fx=opts.oneTimeFx;opts.oneTimeFx=null;}jQuery.fn.cycle.resetState(opts,fx);if(opts.before.length){jQuery.each(opts.before,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});}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){opts.busy=1;if(opts.fxFn){opts.fxFn(curr,next,opts,after,fwd);}else{if(jQuery.isFunction(jQuery.fn.cycle[opts.fx])){jQuery.fn.cycle[opts.fx](curr,next,opts,after);}else{jQuery.fn.cycle.custom(curr,next,opts,after,manual&&opts.fastOnEvent);}}}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{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);}}var ms=0;if(opts.timeout&&!opts.continuous){ms=getTimeout(curr,next,opts,fwd);}else{if(opts.continuous&&p.cyclePause){ms=10;}}if(ms>0){p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},ms);}}jQuery.fn.cycle.updateActivePagerLink=function(pager,currSlide){jQuery(pager).find("a").removeClass("activeSlide").filter("a:eq("+currSlide+")").addClass("activeSlide");};function getTimeout(curr,next,opts,fwd){if(opts.timeoutFn){var t=opts.timeoutFn(curr,next,opts,fwd);if(t!==false){return t;}}return opts.timeout;}jQuery.fn.cycle.next=function(opts){advance(opts,opts.rev?-1:1);};jQuery.fn.cycle.prev=function(opts){advance(opts,opts.rev?1:-1);};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){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);if(jQuerya.parents("body").length==0){var arr=[];if(jQueryp.length>1){jQueryp.each(function(){var jQueryclone=jQuerya.clone(true);jQuery(this).append(jQueryclone);arr.push(jQueryclone);});jQuerya=jQuery(arr);}else{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);return false;});if(opts.pauseOnPagerHover){jQuerya.hover(function(){opts.jQuerycont[0].cyclePause++;},function(){opts.jQuerycont[0].cyclePause--;});}};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;};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));});}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));};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();}};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:0};opts.cssBefore={top:0,left:0};}};jQuery.fn.cycle.ver=function(){return ver;};jQuery.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!jQuery.support.opacity,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250};})(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){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};};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};};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;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());}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};};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};};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};};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};};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};};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};};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};};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};};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};};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};};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};};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};};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};};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);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};};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);


function navclear() {

jQuery("#idigit-web-design-work-bg").css({backgroundPosition: '0px 0px'});
jQuery("#idigit-web-design-about-bg").css({backgroundPosition: '0px -114px'});
jQuery("#idigit-web-design-services-bg").css({backgroundPosition: '0px -228px'});
jQuery("#idigit-web-design-contact-bg").css({backgroundPosition: '0px -342px'});
jQuery("#blog-btn").css({backgroundPosition: '0px -456px'});
jQuery("#about-content, #services-content, #contact-content, #work-portfolio").stop().animate({marginLeft : '125%'}, 1000);
};

function imgresizeover () {

jQuery(".work-example-1 img, .work-example-2 img, .work-example-3 img, .work-example-4 img, .work-example-5 img, .work-example-6 img, .work-example-7 img, .work-example-8 img, .work-example-9 img, .work-example-10 img").animate({width: '40%', height: '40%', marginTop : '30px'}, 500);
};

function imgresizeup () {

jQuery(".work-example-1 img, .work-example-2 img, .work-example-3 img, .work-example-4 img, .work-example-5 img, .work-example-6 img, .work-example-7 img, .work-example-8 img, .work-example-9 img, .work-example-10 img").stop().animate({height: '100%', width: '100%', marginTop: '0px'}, 500);
};

function idigitwork () {
jQuery("#work-portfolio").stop().animate({marginLeft : '-40px'}, 1000);
jQuery("#next, #prev").animate({opacity : 0.8}, 400);
jQuery("#nav-arrow").animate({marginLeft: 45+'px'}, 450);
jQuery("#idigit-web-design-work-bg").css({backgroundPosition: '0px -57px'});
{work = 1; about = 0; services = 0; contact=0; };
document.title = 'Some of Our Recent Work - iDIGIT Web Design';
};

function idigitabout () {
jQuery("#next, #prev").animate({opacity : 0}, 400);
jQuery("#nav-arrow").animate({marginLeft: 145+'px'}, 450);
jQuery("#about-content").stop().animate({marginLeft : '0px'}, 1000);
jQuery("#idigit-web-design-about-bg").css({backgroundPosition: '0px -171px'});
{work = 0; about = 1; services = 0; contact=0; };
document.title = 'About Us - iDIGIT Web Design';
};

function idigitservices () {
jQuery("#services-content").stop().animate({marginLeft : '0px'}, 1000);
jQuery("#next, #prev").animate({opacity : 0}, 400);
jQuery("#nav-arrow").animate({marginLeft: 245+'px'}, 450);
jQuery("#idigit-web-design-services-bg").css({backgroundPosition: '0px -285px'});
{work = 0; about = 0; services = 1; contact=0; };
if (category != "services") {
document.title = 'Our Services - iDIGIT Web Design';
};
};

function idigitcontact () {
jQuery("#contact-content").stop().animate({marginLeft : '0px'}, 1000);
jQuery("#next, #prev").animate({opacity : 0}, 400);
jQuery("#nav-arrow").animate({marginLeft: 345+'px'}, 450);
jQuery("#idigit-web-design-contact-bg").css({backgroundPosition: '0px -399px'});
{work = 0; about = 0; services = 0; contact=1; };
document.title = 'Contact Us - iDIGIT Web Design';
};

var work=1; var about=0; var services=0; var contact=0; var workexample1=0; var workexample2=0; var workexample3=0; var workexample4=0; var workexample5=0;

var entrypage = location.hash;

jQuery(document).ready(function(jQuery){

jQuery("#work-portfolio").css({marginLeft : -40+'px'});
jQuery("#about-content, #services-content, #contact-content").css({marginLeft : 0+'px'});

jQuery("#work-portfolio").cycle({ 
    fx:   'shuffle', 
    pause:  1,
    cleartypeNoBg: true,

    next:   '#next', 
    prev:   '#prev',
    shuffle: { 
        top:  -300, 
        left:  500

    }, 
    delay: 3000
});



jQuery(function() {jQuery('#single-content').jScrollPane({dragMaxHeight:13, dragMinHeight: 13, scrollbarWidth:12, 	showArrows : true} );});
  
jQuery.ajaxHistory.initialize();
//initial settings 
jQuery("#header").hide();
jQuery("#nav-arrow").css({opacity: 0.6});
jQuery("#prev, #next").css({opacity: 0.8});
jQuery("#large-background-top, #large-background-side").css({opacity: 0.2});
jQuery("#about-content, #services-content, #contact-content, .website-details").css({marginLeft : '125%'});
jQuery("#idigit-web-design-work-bg").css({backgroundPosition: '0px -57px'});

if (entrypage == "#porfolio" || entrypage == "#my-portfolio/") {
navclear();
idigitwork();
jQuery("#idigit-web-design-work-bg").css({backgroundPosition: '0px -57px'});
}; // .entry

if (entrypage == "#about-us" || entrypage == "#my-about-us/" || category =="about") {
navclear();
idigitabout();
}; // .entry

if (entrypage == "#our-services" || entrypage == "#our-services/" || category =="services") {
navclear();
idigitservices();
}; // .entry

if (entrypage == "#contact-us" || entrypage == "#contact-us/" || category =="contact") {
navclear();
idigitcontact();
}; // .entry

jQuery("#idigit-web-design-work a").history(function(){
if (work == 0) {work = 1; about = 0; services = 0; contact=0; };
navclear();
idigitwork();
}); // .history

jQuery("#idigit-web-design-about a").history(function(){
if (about == 0) {work = 0;about = 1; services = 0; contact=0; };
navclear();
idigitabout();
}); // .history

jQuery("#idigit-web-design-services a").history(function(){
if (services == 0) {work = 0;about = 0; services = 1; contact=0; };
navclear();
idigitservices();
}); // .history

jQuery("#idigit-web-design-contact a").history(function(){
if (contact == 0) {work = 0;about = 0; services = 0; contact=1;}; 
navclear();
idigitcontact();
}); // .history



// ***********************************HOVER*****************************

jQuery("#idigit-web-design-work a").hover(function(){ 
jQuery("#idigit-web-design-work-bg").css({backgroundPosition: '0px -57px'});
},function(){
if (work == 0) { 
jQuery("#idigit-web-design-work-bg").css({backgroundPosition: '0px 0px'});
};
}); //  .hover

jQuery("#idigit-web-design-about a").hover(function(){ 
jQuery("#idigit-web-design-about-bg").css({backgroundPosition: '0px -171px'});
},function(){ 
if (about == 0) {
jQuery("#idigit-web-design-about-bg").css({backgroundPosition: '0px -114px'});
};
}); //  .hover

jQuery("#idigit-web-design-services a").hover(function(){ 
jQuery("#idigit-web-design-services-bg").css({backgroundPosition: '0px -285px'});
},function(){ 
if (services == 0) {
jQuery("#idigit-web-design-services-bg").css({backgroundPosition: '0px -228px'});

};
}); //  .hover

jQuery("#idigit-web-design-contact a").hover(function(){ 
jQuery("#idigit-web-design-contact-bg").css({backgroundPosition: '0px -399px'});
},function(){ 
if (contact == 0) {
jQuery("#idigit-web-design-contact-bg").css({backgroundPosition: '0px -342px'});
};
}); //  .hover

jQuery("#services-content ul li a").hover(function(){ 
jQuery(this).animate({marginLeft : '5px'}, 150)
},function(){ 
jQuery(this).animate({marginLeft : '0px'}, 150);
}); //  .hover

 jQuery('input[type=text], textarea').each(function() { jQuery(this).focus(function() {  if(jQuery(this).val() == this.defaultValue)    jQuery(this).val("");  });  jQuery(this).blur(function() {    if(jQuery(this).val() == "")      jQuery(this).val(this.defaultValue);  });});
 
jQuery("#form-name, #form-email, #message-area").hover(function(){ 
jQuery(this).css({borderColor : '#07a4ea', color : '#ffffff'});
},function(){ 
jQuery(this).css({borderColor : '#505050', color : '#919191'});
 }); //  .hover

jQuery(".btn").hover(function(){ 
jQuery(this).css({borderColor : '#ffffff', color : '#07a4ea'});
},function(){ 
jQuery(this).css({borderColor : '#07a4ea', color : '#ffffff'});
 }); //  .hover

jQuery("#blog-btn a").hover(function(){ 
jQuery("#blog-btn-bg").css({backgroundPosition: '0px -510px'});
},function(){ 
jQuery("#blog-btn-bg").css({backgroundPosition: '0px -456px'});
}); //  .hover

jQuery("#prev, #next").hover(function(){ 
jQuery(this).css({opacity : 1});
},function(){ 
jQuery(this).css({opacity : 0.8});
}); //  .hover

jQuery(".work-example-1").hover(function(){
imgresizeover ();
jQuery("#website-details-1").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-1").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-1").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
jQuery(".work-example-2").hover(function(){
imgresizeover ();
jQuery("#website-details-2").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-2").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-2").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-3").hover(function(){
imgresizeover ();
jQuery("#website-details-3").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-3").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-3").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-4").hover(function(){
imgresizeover ();
jQuery("#website-details-4").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-4").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-4").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-5").hover(function(){
imgresizeover ();
jQuery("#website-details-5").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-5").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-5").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-6").hover(function(){
imgresizeover ();
jQuery("#website-details-6").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-6").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-6").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-7").hover(function(){
imgresizeover ();
jQuery("#website-details-7").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-7").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-7").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-8").hover(function(){
imgresizeover ();
jQuery("#website-details-8").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-8").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-8").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-9").hover(function(){
imgresizeover ();
jQuery("#website-details-9").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-9").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-9").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
 jQuery(".work-example-10").hover(function(){
imgresizeover ();
jQuery("#website-details-10").stop().animate({marginLeft : '125%'}, 450).stop().animate({marginLeft : '0px'}, 750);
jQuery(".work-example-10").css({height: '371px', width: '485px'});
},function(){ 
jQuery("#website-details-10").stop().animate({marginLeft : '125%'}, 500);
imgresizeup ();
 }); //  .hover
 
jQuery("#email a").click(function(){;jQuery("#email a").attr('href','mailto:seanblakeley@idigitdesign.com');});  

}); // doc.ready close