
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console) {
    arguments.callee = arguments.callee.caller;
    var newarr = [].slice.call(arguments);
    (typeof console.log === 'object' ? log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
  }
};

// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
{console.log();return window.console;}catch(err){return window.console={};}})());


// place any jQuery/helper plugins in here, instead of separate, slower script files.


//jQuery Easing 1.3
jQuery.easing.jswing=jQuery.easing.swing;
jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,a,c,b,d){return jQuery.easing[jQuery.easing.def](e,a,c,b,d)},easeInQuad:function(e,a,c,b,d){return b*(a/=d)*a+c},easeOutQuad:function(e,a,c,b,d){return-b*(a/=d)*(a-2)+c},easeInOutQuad:function(e,a,c,b,d){if((a/=d/2)<1)return b/2*a*a+c;return-b/2*(--a*(a-2)-1)+c},easeInCubic:function(e,a,c,b,d){return b*(a/=d)*a*a+c},easeOutCubic:function(e,a,c,b,d){return b*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(e,a,c,b,d){if((a/=d/2)<1)return b/
2*a*a*a+c;return b/2*((a-=2)*a*a+2)+c},easeInQuart:function(e,a,c,b,d){return b*(a/=d)*a*a*a+c},easeOutQuart:function(e,a,c,b,d){return-b*((a=a/d-1)*a*a*a-1)+c},easeInOutQuart:function(e,a,c,b,d){if((a/=d/2)<1)return b/2*a*a*a*a+c;return-b/2*((a-=2)*a*a*a-2)+c},easeInQuint:function(e,a,c,b,d){return b*(a/=d)*a*a*a*a+c},easeOutQuint:function(e,a,c,b,d){return b*((a=a/d-1)*a*a*a*a+1)+c},easeInOutQuint:function(e,a,c,b,d){if((a/=d/2)<1)return b/2*a*a*a*a*a+c;return b/2*((a-=2)*a*a*a*a+2)+c},easeInSine:function(e,
a,c,b,d){return-b*Math.cos(a/d*(Math.PI/2))+b+c},easeOutSine:function(e,a,c,b,d){return b*Math.sin(a/d*(Math.PI/2))+c},easeInOutSine:function(e,a,c,b,d){return-b/2*(Math.cos(Math.PI*a/d)-1)+c},easeInExpo:function(e,a,c,b,d){return a==0?c:b*Math.pow(2,10*(a/d-1))+c},easeOutExpo:function(e,a,c,b,d){return a==d?c+b:b*(-Math.pow(2,-10*a/d)+1)+c},easeInOutExpo:function(e,a,c,b,d){if(a==0)return c;if(a==d)return c+b;if((a/=d/2)<1)return b/2*Math.pow(2,10*(a-1))+c;return b/2*(-Math.pow(2,-10*--a)+2)+c},
easeInCirc:function(e,a,c,b,d){return-b*(Math.sqrt(1-(a/=d)*a)-1)+c},easeOutCirc:function(e,a,c,b,d){return b*Math.sqrt(1-(a=a/d-1)*a)+c},easeInOutCirc:function(e,a,c,b,d){if((a/=d/2)<1)return-b/2*(Math.sqrt(1-a*a)-1)+c;return b/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(a==0)return c;if((a/=d)==1)return c+b;f||(f=d*0.3);if(g<Math.abs(b)){g=b;e=f/4}else e=f/(2*Math.PI)*Math.asin(b/g);return-(g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f))+c},easeOutElastic:function(e,
a,c,b,d){e=1.70158;var f=0,g=b;if(a==0)return c;if((a/=d)==1)return c+b;f||(f=d*0.3);if(g<Math.abs(b)){g=b;e=f/4}else e=f/(2*Math.PI)*Math.asin(b/g);return g*Math.pow(2,-10*a)*Math.sin((a*d-e)*2*Math.PI/f)+b+c},easeInOutElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(a==0)return c;if((a/=d/2)==2)return c+b;f||(f=d*0.3*1.5);if(g<Math.abs(b)){g=b;e=f/4}else e=f/(2*Math.PI)*Math.asin(b/g);if(a<1)return-0.5*g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f)+c;return g*Math.pow(2,-10*(a-=1))*Math.sin((a*
d-e)*2*Math.PI/f)*0.5+b+c},easeInBack:function(e,a,c,b,d,f){if(f==undefined)f=1.70158;return b*(a/=d)*a*((f+1)*a-f)+c},easeOutBack:function(e,a,c,b,d,f){if(f==undefined)f=1.70158;return b*((a=a/d-1)*a*((f+1)*a+f)+1)+c},easeInOutBack:function(e,a,c,b,d,f){if(f==undefined)f=1.70158;if((a/=d/2)<1)return b/2*a*a*(((f*=1.525)+1)*a-f)+c;return b/2*((a-=2)*a*(((f*=1.525)+1)*a+f)+2)+c},easeInBounce:function(e,a,c,b,d){return b-jQuery.easing.easeOutBounce(e,d-a,0,b,d)+c},easeOutBounce:function(e,a,c,b,d){return(a/=
d)<1/2.75?b*7.5625*a*a+c:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+0.75)+c:a<2.5/2.75?b*(7.5625*(a-=2.25/2.75)*a+0.9375)+c:b*(7.5625*(a-=2.625/2.75)*a+0.984375)+c},easeInOutBounce:function(e,a,c,b,d){if(a<d/2)return jQuery.easing.easeInBounce(e,a*2,0,b,d)*0.5+c;return jQuery.easing.easeOutBounce(e,a*2-d,0,b,d)*0.5+b*0.5+c}});




/*
 * Royal Slider  v5.1
 *
 * Copyright 2011, Dmitry Semenov
 * 
 */
(function($) {

	function RoyalSlider(element, options) {
			

		this.slider = $(element);
		var self = this;
		
		this.settings = $.extend({}, $.fn.royalSlider.defaults, options);

		if(this.hasTouch) {
			this.settings.directionNavAutoHide = false;
			this.settings.hideArrowOnLastSlide = true;
		}
		this.isSlideshowRunning = false;
		this._slideshowHoverLastState = false;

		this._dragContainer = this.slider.find(".royalSlidesContainer");
		this._slidesWrapper = this._dragContainer.wrap('<div class="royalWrapper"/>').parent();
		this.slides = this._dragContainer.find(".royalSlide");

		this._preloader = "<p class='royalPreloader'>Loading image...</p>";	
		
		
		this._useWebkitTransition = false;
		if("ontouchstart" in window) {
			if(!this.settings.disableTranslate3d) {				
				if(('WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix())) {	
					this._dragContainer.css({"-webkit-transform-origin":"0 0", "-webkit-transform": "translateZ(0)"});
					this._useWebkitTransition = true;
				}
			}			
			this.hasTouch = true;
			this._downEvent = "touchstart";
			this._moveEvent = "touchmove.rs";
			this._upEvent = "touchend.rs";
		} else {
			this.hasTouch = false;
			this._downEvent = "mousedown";
			this._moveEvent = "mousemove.rs";
			this._upEvent = "mouseup.rs";
		}	
		

		this.slidesArr = [];
		var	slideObj,
			jqSlide,
			dataSRC,
			slideImg;

		// parse slides
		this.slides.each(function() {			
			jqSlide = $(this);			

			slideObj = {};
			slideObj.slide = jqSlide;

			dataSRC = jqSlide.attr("data-src");

			if(dataSRC == undefined || dataSRC == "" || dataSRC == "none") {
				slideObj.preload = false;				
			} else {
				slideObj.preload = true;						
				slideObj.preloadURL = dataSRC;
			}			

			if(self.settings.captionAnimationEnabled) {
				slideObj.caption =  jqSlide.find(".royalCaption").css("display", "none");	
			}

			self.slidesArr.push(slideObj);
		});


		this._removeFadeAnimation = false;	
		if(this.settings.removeCaptionsOpacityInIE8) {
			if ($.browser.msie  && parseInt($.browser.version, 10) <= 8) {
				this._removeFadeAnimation = true;	
			}
		}


		this.slider.css("overflow","visible");

		this.sliderWidth = 0;
		this.sliderHeight = 0;


		this.slideshowTimer = '';

		this.numSlides = this.slides.length;

		this.currentSlideId = 0;
		this.lastSlideId = -1;

		this.isAnimating = true;
		
		this.wasSlideshowPlaying = false;
		
		// Used for checking back/forward drag direction
		this._currentDragPosition = 0;
		this._lastDragPosition = 0;	

		// Stores caption animations and clears after next slide is shown
		this._captionAnimateTimeouts = [];
		this._captionAnimateProperties = [];

		this._blockClickEvents = false;

		this._tx = 0;
		this._startMouseX = 0;
		//used for detecting horizonal or vertical drag move
		this._startMouseY = 0;
		this._startPos = 0;

		this._isDragging = false;

		
		

		this._isHovering = false;
		
		// Setup Slideshow
		if(this.settings.slideshowEnabled && this.settings.slideshowDelay > 0) {			
			if(this.settings.slideshowPauseOnHover) {				
				this.slider.hover(
						function() {
							self._isHovering = true;							
							self._stopSlideshow(true);
						},
						function() {
							self._isHovering = false;							
							self._resumeSlideshow(true);
						}
				);				
			}
			this.slideshowEnabled = true;						
		} else {
			this.slideshowEnabled = false;
		}


		// Adding grab/grabbing cursors
		var cursCoords = ""; 

		if($.browser.msie) {
			if(parseInt($.browser.version, 10) == 7) {
				this.isIE7 = true;
				this._dragContainer.css("cursor","move");
			}
		} else {
			this.isIE7 = false;
		}
		if($.browser.opera) {
			_grabCursor = "move";
			_grabbingCursor = "move";
		} else {
			if($.browser.mozilla) {
				_grabCursor = "-moz-grab";
				_grabbingCursor =  "-moz-grabbing";
			} else {
				_grabCursor =  "url(img/cursors/grab.cur), move";
				_grabbingCursor =  "url(img/cursors/grabbing.cur), move";
			}
			_grabCursor = $.browser.mozilla ? "-moz-grab" : "url(img/cursors/grab.cur), move";
			_grabbingCursor = $.browser.mozilla ? "-moz-grabbing" : "url(img/cursors/grabbing.cur), move";
		}
		this._setGrabCursor();



		// Setup control nav (thumbs/bullets)
		if(this.settings.controlNavEnabled) {
			var _navigation;
			var _navigationContainer;

			if(!self.settings.controlNavThumbs) {				
				_navigationContainer = $('<div class="royalControlNavOverflow"><div class="royalControlNavContainer"><div class="royalControlNavCenterer"></div></div></div>');
				_navigation = _navigationContainer.find('.royalControlNavCenterer');		
			} else {
				if(self.settings.controlNavThumbsNavigation) {
					
					
					this.thumbsArrowLeft = $("<a href='#' class='thumbsArrow left disabled'></a>");
					this.thumbsArrowRight = $("<a href='#' class='thumbsArrow right'></a>");
					
					this._slidesWrapper.after(this.thumbsArrowLeft);
					this._slidesWrapper.after(this.thumbsArrowRight);
					
					// get size of thumbs scroller based on slider size and thumbs arrows size
					var thumbArrowLeftWidth = parseInt(this.thumbsArrowLeft.outerWidth(), 10);					
					_navigationContainer = $('<div class="royalControlNavOverflow royalThumbs" style="left:'+thumbArrowLeftWidth+'px; width:'+(this.slider.width() - thumbArrowLeftWidth - parseInt(this.thumbsArrowRight.outerWidth(),10)) + 'px;"><div class="royalControlNavThumbsContainer"></div></div>');

					_navigation = _navigationContainer.find('.royalControlNavThumbsContainer');	
				} else {
					_navigationContainer = $('<div class="royalControlNavOverflow royalThumbs"><div class="royalControlNavContainer"><div class="royalControlNavCenterer"></div></div></div>');
					_navigation = _navigationContainer.find(".royalControlNavCenterer");		
				}

			}

			var cSlideId = 0;
			this.slides.each(function(){	
				if(self.settings.controlNavThumbs) {								
					_navigation.append("<a href='#' class='royalThumb' style='background-image:url("+ $(this).attr("data-thumb") +");'/>");				
				} else {					
					_navigation.append('<a href="#"/>');	
				}	
				cSlideId++;	
			});		

			this.navItems = _navigation.children();
			this.navItems.eq(0).addClass("current");			

			this._slidesWrapper.after(_navigationContainer);

			// Thumbnails navigation
			if(self.settings.controlNavThumbs && self.settings.controlNavThumbsNavigation) {
				this._thumbsArrowLeftBlocked = true;
				this._thumbsArrowRightBlocked = false;

				this._thumbsNavContainer = _navigation;
				
				if(this._useWebkitTransition) {
					this._thumbsNavContainer.css({'-webkit-transition-duration': this.settings.controlNavThumbsSpeed + "ms",
						'-webkit-transition-property': '-webkit-transform',
						'-webkit-transition-timing-function': "ease-in-out"
					});
				}
				
				this._thumbsContainerWidth = parseInt(_navigationContainer.width(), 10);

				this._numThumbItems = cSlideId;
				var firstItem = this.navItems.eq(0);
				this._outerThumbWidth = firstItem.outerWidth(true);
				this._thumbsTotalWidth = this._outerThumbWidth * this._numThumbItems;

				this._thumbsNavContainer.css("width",this._thumbsTotalWidth);
				this._thumbsSpacing = parseInt(firstItem.css("marginRight"), 10);
				this._thumbsTotalWidth -= this._thumbsSpacing;			

				this._currThumbsX = 0;
				this._minThumbsX = -(this._thumbsTotalWidth - this._thumbsContainerWidth);

				if(this._thumbsContainerWidth >= this._thumbsTotalWidth) {
					this._thumbsArrowRightBlocked = true;
					this.thumbsArrowRight.addClass("disabled");
					this.settings.controlNavThumbsNavigation = false;
				}


				this.thumbsArrowLeft.click(function(e){
					e.preventDefault();
					if(!self._thumbsArrowLeftBlocked)
						self._animateThumbs(self._currThumbsX + self._thumbsContainerWidth + self._thumbsSpacing);					
				});
				this.thumbsArrowRight.click(function(e){
					e.preventDefault();
					if(!self._thumbsArrowRightBlocked)
						self._animateThumbs(self._currThumbsX - self._thumbsContainerWidth - self._thumbsSpacing);					
				});
			}
		}



		//Direction navigation (arrows)
		if(this.settings.directionNavEnabled) {	
			this._slidesWrapper.after("<a href='#' class='arrow left'/>");
			this._slidesWrapper.after("<a href='#' class='arrow right'/>");


			this.arrowLeft = this.slider.find("a.arrow.left");
			this.arrowRight = this.slider.find("a.arrow.right");

			if(this.arrowLeft.length < 1 || this.arrowRight.length < 1) {
				this.settings.directionNavEnabled = false;
			} else if(this.settings.directionNavAutoHide) {
				this.arrowLeft.hide();
				this.arrowRight.hide();

				this.slider.one("mousemove.arrowshover",function() {
					self.arrowLeft.fadeIn("fast");
					self.arrowRight.fadeIn("fast");					
				});


				this.slider.hover(
						function() {
							self.arrowLeft.fadeIn("fast");
							self.arrowRight.fadeIn("fast");
						},
						function() {
							self.arrowLeft.fadeOut("fast");
							self.arrowRight.fadeOut("fast");				
						}
				);	
			}	
			if(this.settings.hideArrowOnLastSlide) {
				this._arrowLeftBlocked = true;
				this._arrowRightBloacked = false;
				this.arrowLeft.addClass("disabled");
			}	
		}



		// Manage window resize event with 100ms delay
		this.slidesWrapperWidth = 0;
		this.slidesWrapperHeight = 0;
		var resizeTimer;
		$(window).bind('resize.rs', function() {		
			if (resizeTimer) 
				clearTimeout(resizeTimer);			
			resizeTimer = setTimeout(function() { self.updateSliderSize(); }, 100);			
		});
		this.updateSliderSize();

		this.settings.beforeLoadStart.call(this);

		// loading screen handling
		var firstSlide = this.slidesArr[0];		
		if(this.settings.welcomeScreenEnabled) {
			// gets url of image to preload (background-image of slide)
			function hideWelcomeScreen() {	

				self.settings.loadingComplete.call(self);
				// start preloading second image
				if(self.settings.preloadNearbyImages) {						
					self._preloadImage(self.slidesArr[1]);
				}				

				self.slider.find(".royalLoadingScreen").fadeOut(self.settings.welcomeScreenShowSpeed);	
				setTimeout(function(){ self._startSlider(); }, self.settings.welcomeScreenShowSpeed + 100);		
			}


			if(firstSlide.preload) {				
				// lazy-load image								
				this._preloadImage(firstSlide, function(){						
					hideWelcomeScreen();								
				});

			} else {				
				var slideImg = firstSlide.slide.find("img.royalImage")[0];


				if(slideImg) {	
					if(this._isImageLoaded(slideImg)) {
						hideWelcomeScreen();							
					} else {						
						// create new image and wait it to load (IE bug)
						$('<img />').load( function(){							
							hideWelcomeScreen();	
						}).attr('src', slideImg.src);						
					}
				}
				else {
					// no image tag, just start slider					
					hideWelcomeScreen();	
				}				
			}			
		} else {	
			if(firstSlide.preload) {				
				// lazy-load image								
				this._preloadImage(firstSlide, function(){		
					self.settings.loadingComplete.call(self);
					if(self.settings.preloadNearbyImages) {						
						self._preloadImage(self.slidesArr[1]);
					}					
				});
			} else {
				this.settings.loadingComplete.call(this);
			}
			setTimeout(function(){ self._startSlider(); },100);	
		}


	} /* RoyalSlider Constructor End
	/* -------------------------------------RoyalSlider Prototype------------------------------------------------------*/
	RoyalSlider.prototype = {
			// Move to slide with specified id
			goTo:function(id, fromNav) {	
				if(!this.isAnimating) {
					this.isAnimating = true;
					var self = this;

					this.lastSlideId = this.currentSlideId;
					this.currentSlideId = id;	

					this._dragContainer.unbind(this._downEvent);

					this._blockClickEvents = true;
					
					if(this.lastSlideId != id) {	
						
						if(this.settings.controlNavEnabled) {					
							this.navItems.eq(this.lastSlideId).removeClass('current');

							this.navItems.eq(id).addClass("current");

							// thumbnails scroller navigation
							if(this.settings.controlNavThumbs && this.settings.controlNavThumbsNavigation) {					
								var _thumbX = this.navItems.eq(id).position().left;					
								var _currThumbVisiblePosition = _thumbX - Math.abs(this._currThumbsX);							
								
								if(_currThumbVisiblePosition > this._thumbsContainerWidth - this._outerThumbWidth * 2 - 1 - this._thumbsSpacing) {
									if(!fromNav) {
										this._animateThumbs(-_thumbX + this._outerThumbWidth);
									} else {
										this._animateThumbs(-_thumbX - this._outerThumbWidth * 2 + this._thumbsContainerWidth + this._thumbsSpacing);
									}								
								} else if (_currThumbVisiblePosition < this._outerThumbWidth * 2 - 1) {								
									if(!fromNav) {
										this._animateThumbs(-_thumbX - this._outerThumbWidth * 2 + this._thumbsContainerWidth + this._thumbsSpacing);
									} else {
										this._animateThumbs(-_thumbX + this._outerThumbWidth);
									}								
								}
							}
						}
						
						if(this.settings.preloadNearbyImages) {
							var self = this;				
							this._preloadImage(this.slidesArr[id], function() {					
								self._preloadImage(self.slidesArr[id + 1], function() {
									self._preloadImage(self.slidesArr[id - 1]);	
								});	
							});
						} else {				
							this._preloadImage(this.slidesArr[id]);	
						}								
					}



					if(this.settings.directionNavEnabled)
					{
						if(this.settings.hideArrowOnLastSlide) {						
							if(this.currentSlideId == 0) {
								this._arrowLeftBlocked = true;
								this.arrowLeft.addClass("disabled");	
								if(this._arrowRightBlocked) {
									this._arrowRightBlocked = false;
									this.arrowRight.removeClass("disabled");
								}
							} else if(this.currentSlideId == this.numSlides - 1) {
								this._arrowRightBlocked = true;							
								this.arrowRight.addClass("disabled");	
								if(this._arrowLeftBlocked) {
									this._arrowLeftBlocked = false;
									this.arrowLeft.removeClass("disabled");		
								}
							} else {
								if(this._arrowLeftBlocked) {								
									this._arrowLeftBlocked = false;
									this.arrowLeft.removeClass("disabled");				
								} else if(this._arrowRightBlocked) {								
									this._arrowRightBlocked = false;
									this.arrowRight.removeClass("disabled");		
								}
							}
						}
					}

					this.settings.beforeSlideChange.call(this);
					
					if(this.slideshowEnabled) {
						if(this.slideshowTimer != '') {
							this.wasSlideshowPlaying = true;
							this._stopSlideshow();
						} else {
							this.wasSlideshowPlaying = false;
						}
					}
					
					/*this._stopSlideshow();*/

					// Animate slide
					if(!this._useWebkitTransition) {
						if(parseInt(this._dragContainer.css("left"), 10) !== -this.currentSlideId * this.sliderWidth){
							this._dragContainer.animate(
									{left: -this.currentSlideId * this.sliderWidth}, 
									this.settings.slideTransitionSpeed,
									this.settings.slideTransitionEasing, 
									function(){self._onSlideAnimationComplete();
							});
						} else {						
							this._onSlideAnimationComplete();
						}
 						
					} else {						
						if(this._getWebkitTransformX() !==  -this.currentSlideId * this.sliderWidth) {					
							
							
							this._dragContainer.bind("webkitTransitionEnd", function(e) {								
								if(e.target == self._dragContainer.get(0)) {									
									self._onSlideAnimationComplete();		
									self._dragContainer.unbind("webkitTransitionEnd");
								}								
							});
							
							this._dragContainer.css({
								'-webkit-transition-duration': this.settings.slideTransitionSpeed + "ms",
								'-webkit-transition-property': '-webkit-transform',
								'-webkit-transition-timing-function': "ease-in-out",
								'-webkit-transform': 'translate3d(' + -this.currentSlideId * this.sliderWidth + 'px, 0, 0)'								
							});								
						} else {						
							this._onSlideAnimationComplete();
						}						
					}
				}
			},	
			// go to prev slide (cyclic)
			prev:function() {
				if(this.currentSlideId <= 0) { 
					this.goTo(this.numSlides - 1);				
				} else {
					this._moveSlideLeft();
				}	
			},
			// go to next slide (cyclic)
			next:function() {
				//go from last to first
				if(this.currentSlideId >= this.numSlides - 1) {				
					this.goTo(0);		
				} else {
					this._moveSlideRight();
				}	
			},
			// handling browser resize	onresize
			updateSliderSize:function() {
				var self = this;
				/*this.slidesWrapperWidth = this._slidesWrapper.width()  ;
				this.slidesWrapperHeight = this._slidesWrapper.height() ;*/
				this.slidesWrapperWidth = this.slider.width();
				this.slidesWrapperHeight = this.slider.height();	
				
				
				if(this.slidesWrapperWidth != this.sliderWidth || this.slidesWrapperHeight != this.sliderHeight) {
					this.sliderWidth = this.slidesWrapperWidth;
					this.sliderHeight = this.slidesWrapperHeight;
					
					var arLen=this.slidesArr.length;
					var _currItem, _currImg;					

					for ( var i=0, len=arLen; i<len; ++i ){
						_currItem = this.slidesArr[i];
						_currImg = _currItem.slide.find("img.royalImage")[0];
						if(_currImg && _currItem.preload == false) {							
							this._scaleImage($(_currImg), this.slidesWrapperWidth, this.slidesWrapperHeight);						
						}
						_currItem.slide.css({height: self.slidesWrapperHeight, width: self.slidesWrapperWidth});
					}
					if(!this._useWebkitTransition) {
						this._dragContainer.css({"left":-this.currentSlideId * this.sliderWidth, width:this.sliderWidth * this.numSlides});
					} else {
						this._dragContainer.css({'-webkit-transition-duration':'0ms',
							'-webkit-transition-property': 'none'});
						this._dragContainer.css({							
							'-webkit-transform': 'translate3d(' + -this.currentSlideId * this.sliderWidth + 'px, 0, 0)', 
							width:this.sliderWidth * this.numSlides
						});
					}
				}

			},
			stopSlideshow: function() {				
				this._stopSlideshow();
				this.slideshowEnabled = false;
			},
			resumeSlideshow: function() {
				this.slideshowEnabled = true;
				this._resumeSlideshow();
			},
			_resumeSlideshow: function(playedFromHover){
				if(this.slideshowEnabled) {
					if(this.slideshowTimer == '') {
						if(playedFromHover) {
							if(!this._slideshowHoverLastState) {
								return;
							}
						}		
						var self = this;
						this.slideshowTimer = setInterval(function() { self.next(); }, this.settings.slideshowDelay);
						this.isSlideshowRunning = true;							
					}
				}			
			},	
			_stopSlideshow: function(stoppedFromHover){
				if(this.slideshowEnabled) {
					if(stoppedFromHover) {
						this._slideshowHoverLastState = 	this.isSlideshowRunning;
					} else {
						this._slideshowHoverLastState = false;
						this.isSlideshowRunning = false;
					}
					clearInterval(this.slideshowTimer);
					this.slideshowTimer = '';					
				}					
			},				
			_preloadImage: function(slideObj, completeCallback) {				
				if(slideObj) {
					if(slideObj.preload) {
						var self = this;
						var img = new Image();
						var jqImg = $(img);
						jqImg.css("opacity",0);
						jqImg.addClass("royalImage");
						slideObj.slide.prepend(jqImg);		
						// add preloader
						slideObj.slide.prepend(this._preloader);					
						slideObj.preload = false;
						
						jqImg.load(function() {									
							self._scaleImage(jqImg, self.slidesWrapperWidth, self.slidesWrapperHeight);
							jqImg.animate({"opacity":1}, "fast");
							// remove preloader
							slideObj.slide.find(".royalPreloader").remove();
							if(completeCallback)
								completeCallback.call();					
						});
						img.src = slideObj.preloadURL;
					} else {
						if(completeCallback)
							completeCallback.call();					
					}
				} else {
					if(completeCallback)
						completeCallback.call();
				}
			},
			// animate thumbnails scroller
			_animateThumbs:function(newPosition) {	
				if(newPosition != this._currThumbsX) {
					if(newPosition <= this._minThumbsX) {
						newPosition = this._minThumbsX;
						this._thumbsArrowLeftBlocked = false;
						this._thumbsArrowRightBlocked = true;
						this.thumbsArrowRight.addClass("disabled");
						this.thumbsArrowLeft.removeClass("disabled");
					} else if(newPosition >= 0) {
						newPosition = 0;
						this._thumbsArrowLeftBlocked = true;
						this._thumbsArrowRightBlocked = false;
						this.thumbsArrowLeft.addClass("disabled");
						this.thumbsArrowRight.removeClass("disabled");
					} else {
						if(this._thumbsArrowLeftBlocked) {
							this._thumbsArrowLeftBlocked = false;
							this.thumbsArrowLeft.removeClass("disabled");
						} else if (this._thumbsArrowRightBlocked) {
							this._thumbsArrowRightBlocked = false;
							this.thumbsArrowRight.removeClass("disabled");
						}
					}
					if(!this._useWebkitTransition) {
						this._thumbsNavContainer.animate(
								{left: newPosition}, 
								this.settings.controlNavThumbsSpeed,
								this.settings.controlNavThumbsEasing
						);
					} else {	
						this._thumbsNavContainer.css({'-webkit-transform': 'translate3d(' + newPosition + 'px, 0, 0)'}); 
					}
					
					this._currThumbsX = newPosition;
				}
			},
			_startSlider:function() {
				var self = this;
				this.slider.find(".royalLoadingScreen").remove();

				if(this.settings.controlNavEnabled) {
					this.navItems.bind("click", function(e){ 
						e.preventDefault(); 
						if(!self._blockClickEvents)
							self._onNavItemClick(e);
					});
				}

				if(this.settings.directionNavEnabled) {
					this.arrowRight.click(function(e) {
						e.preventDefault();	
						if(!self._arrowRightBlocked && !self._blockClickEvents)
							self.next();
					});

					this.arrowLeft.click(function(e) {
						e.preventDefault();
						if(!self._arrowLeftBlocked && !self._blockClickEvents)
							self.prev();
					});	
				}
				// keyboard nav
				if(this.settings.keyboardNavEnabled) {
					$(document).bind("keydown", function(e) {
						if(!self._blockClickEvents) {
							if (e.keyCode === 37) {
								// left
								self.prev();
							}
							else if (e.keyCode === 39) {
								// right
								self.next();
							}
						}
					});
				}
				this.wasSlideshowPlaying = true;
				this._onSlideAnimationComplete();


				if(this.slideshowEnabled && !this.settings.slideshowAutoStart) {
					this._stopSlideshow();
				}

				this.settings.allComplete.call(this);
			},
			_setGrabCursor:function() {
				if (!this.isIE7) {
					this._dragContainer.css("cursor",_grabCursor);
				}
			},
			_setGrabbingCursor:function() {
				if (!this.isIE7) {
					this._dragContainer.css("cursor",_grabbingCursor);
				}
			},
			_moveSlideRight:function() {			
				if(this.currentSlideId < this.numSlides - 1) {
					this.goTo(this.currentSlideId+1);			
				} else {
					this.goTo(this.currentSlideId);
				}		
			},
			_moveSlideLeft:function() {
				if(this.currentSlideId > 0) { 
					this.goTo(this.currentSlideId-1);
				} else {
					this.goTo(this.currentSlideId);
				}			
			},
			
			_onNavItemClick:function(e) {		
				this.goTo($(e.currentTarget).index(), true);	
			},
			// Start dragging the slide
			_onDragStart:function(e) {	

				if(!this._isDragging) {	
					var point;

					if(this.hasTouch) {
						//parsing touch event
						var currTouches = e.originalEvent.touches;
						if(currTouches && currTouches.length > 0) {
							point = currTouches[0];
						}					
						else {	
							return false;						
						}
					} else {
						point = e;
						e.preventDefault();		
					}
					if(this.slideshowEnabled) {
						if(this.slideshowTimer != '') {
							this.wasSlideshowPlaying = true;
							this._stopSlideshow();
						} else {
							this.wasSlideshowPlaying = false;
						}
					}
					


					this._setGrabbingCursor();			
					this._isDragging = true;
					var self = this;
					if(this._useWebkitTransition) {
						self._dragContainer.css({'-webkit-transition-duration':'0ms', '-webkit-transition-property': 'none'});
					}
					$(document).bind(this._moveEvent, function(e) { self._onDragMove(e); });
					$(document).bind(this._upEvent, function(e) { self._onDragRelease(e); });		

					if(!this._useWebkitTransition) {
						this._startPos = this._tx = parseInt(this._dragContainer.css("left"), 10);	
					} else {						
						this._startPos = this._tx =  this._getWebkitTransformX();						
					}
					

					this._startMouseX = point.clientX;
					this._startMouseY = point.clientY;
				}	
				return false;	
			},			
			_getWebkitTransformX:function(){
				var transform = this._dragContainer.css("-webkit-transform");
				var explodedMatrix = transform.replace(/^matrix\(/i, '').split(/, |\)$/g);
				return parseInt(explodedMatrix[4], 10);
			},
			_onDragMove:function(e) {			
				var point;
				if(this.hasTouch) {
					var touches = e.originalEvent.touches;
					// If touches more then one, so stop sliding and allow browser do default action
					if(touches.length > 1) {
						return false;
					}
					point = touches[0];	
					// If drag direction on mobile is vertical, so stop sliding and allow browser to scroll
					if(Math.abs(point.clientY - this._startMouseY) + 10 > Math.abs(point.clientX - this._startMouseX)) {
						return false;
					}
					e.preventDefault();				
				} else {
					point = e;
					e.preventDefault();		
				}


				// Helps find last direction of drag move
				this._lastDragPosition = this._currentDragPosition;
				var distance = point.clientX - this._startMouseX;
				if(this._lastDragPosition != distance) {
					this._currentDragPosition = distance;
				}

				if(distance != 0)
				{			
					if(this.currentSlideId == 0) {			
						if(distance > 0) {
							distance = Math.sqrt(distance) * 5;
						}			
					} else if(this.currentSlideId == (this.numSlides -1)) {		
						if(distance < 0) {
							distance = -Math.sqrt(-distance) * 5;
						}	
					}
					if(!this._useWebkitTransition) {
						this._dragContainer.css("left", this._tx + distance);		
					} else {
						this._dragContainer.css({'-webkit-transform': 'translate3d(' +  (this._tx + distance) + 'px, 0, 0)'}); 
					}
				}			
				return false;		
			},
			_onDragRelease:function(e) {					
				if(this.wasSlideshowPlaying) {
					this._resumeSlideshow();
				}
				if(this._isDragging) {			
					this._isDragging = false;			
					this._setGrabCursor();
					if(!this._useWebkitTransition) {
						this.endPos = parseInt(this._dragContainer.css("left"), 10);
					} else {
						this.endPos = this._getWebkitTransformX();
					}
					
					this.isdrag = false;

					$(document).unbind(this._moveEvent).unbind(this._upEvent);					

					if(this.endPos == this._startPos) {
						return;	
					}	


					// calculate slide move direction
					if(this._startPos - this.settings.minSlideOffset > this.endPos) {		

						if(this._lastDragPosition < this._currentDragPosition) {		
							this.goTo(this.currentSlideId );
							return false;					
						}

						this._moveSlideRight();
					} else if(this._startPos + this.settings.minSlideOffset < this.endPos) {		
						if(this._lastDragPosition > this._currentDragPosition) {			
							this.goTo(this.currentSlideId );
							return false;
						}
						this._moveSlideLeft();

					} else {
						this.goTo(this.currentSlideId );
					}
				}

				return false;
			},		
			// Slide animation complete handler
			_onSlideAnimationComplete:function() {				
				var self = this;
				
				if(this.wasSlideshowPlaying) {
					this._resumeSlideshow();
					this.wasSlideshowPlaying = false;
				}
				
				this._blockClickEvents = false;

				this._dragContainer.bind(this._downEvent, function(e) {  self._onDragStart(e); });	

				if(this.settings.captionAnimationEnabled && this.lastSlideId != this.currentSlideId) {
					// hide last image caption
					if(this.lastSlideId != -1 ) {
						this.slidesArr[this.lastSlideId].caption.css("display", "none");					
					}
					setTimeout(function() { self._showCaption(self.currentSlideId);}, 10);			
				}
				this.isAnimating = false;
				this.settings.afterSlideChange.call(this);
			},			
			// Show caption with specified id
			_showCaption:function (id) {	
				
				var caption = this.slidesArr[id].caption;

				if(caption.length) {
					caption.css("display", "block");

					var self = this;	
					
					
					var currItem,
						fadeEnabled,
						moveEnabled,				
						effectName,	
						effectsObject,
						moveEffectProperty,
						currEffects,
						newEffectObj,	
						moveOffset,
						delay,
						speed,
						easing,
						moveProp;
					
					var captionItems = caption.children();
					
					// clear previous animations
					if(this._captionAnimateTimeouts.length > 0) {
						for(var a = this._captionAnimateTimeouts.length - 1; a > -1; a--) {  
							clearTimeout(this._captionAnimateTimeouts.splice(a, 1));
						}
					}
					if(this._captionAnimateProperties.length > 0) {						
						var cItemTemp;
						for(var k = this._captionAnimateProperties.length - 1; k > -1; k--) {  
							cItemTemp = this._captionAnimateProperties[k];							
							if(cItemTemp) {								
								if(!this._useWebkitTransition) {
									if(cItemTemp.running) {
										cItemTemp.captionItem.stop(true, true);
									} else {
										cItemTemp.captionItem.css(cItemTemp.css);
									}
								}		
							}
							this._captionAnimateProperties.splice(k, 1);
						}
						
					}
					
					
					// parse each caption item on slide
					for(var i = 0; i < captionItems.length; i++) {
						currItem = $(captionItems[i]);		

						effectsObject = {};
						fadeEnabled = false;
						moveEnabled = false;
						moveEffectProperty = "";
						
						if(currItem.attr("data-show-effect") == undefined) {
							currEffects = this.settings.captionShowEffects;	
						} else {
							currEffects = currItem.attr("data-show-effect").split(" ");
						}

						// parse each effect in caption
						for(var q = 0; q < currEffects.length; q++) {			

							if(fadeEnabled && moveEnabled) {
								break;	
							}			

							effectName = currEffects[q].toLowerCase();

							if(!fadeEnabled && effectName == "fade") {
								fadeEnabled = true;
								effectsObject['opacity'] = 1;
							} else if(moveEnabled) {
								break;
							} else if(effectName == "movetop") {
								moveEffectProperty = "margin-top";
							} else  if(effectName == "moveleft") {
								moveEffectProperty = "margin-left";
							} else  if(effectName == "movebottom") {						
								moveEffectProperty = "margin-bottom";
							} else  if(effectName == "moveright") {
								moveEffectProperty = "margin-right";
							}

							if(moveEffectProperty != "") {
								effectsObject['moveProp'] = moveEffectProperty;	
								if(!self._useWebkitTransition) { 
									effectsObject['moveStartPos'] = parseInt(currItem.css(moveEffectProperty), 10);
								} else {
									effectsObject['moveStartPos'] = 0;
								}
								
								moveEnabled = true;
							}



						}

						moveOffset = parseInt(currItem.attr("data-move-offset"), 10);					
						if(isNaN(moveOffset)) {					
							moveOffset = this.settings.captionMoveOffset;
						}

						delay = parseInt(currItem.attr("data-delay"), 10);		
						if(isNaN(delay)) {
							delay = self.settings.captionShowDelay * i + 10;
						}

						speed = parseInt(currItem.attr("data-speed"), 10);		
						if(isNaN(speed)) {
							speed = self.settings.captionShowSpeed;
						}

						easing = currItem.attr("data-easing");
						if(!easing) {
							easing = self.settings.captionShowEasing;
						}

						newEffectObj = {};

						if(moveEnabled) {	
							moveProp = effectsObject.moveProp;
							if(moveProp == "margin-right") {						
								moveProp = "margin-left";
								newEffectObj[moveProp] = effectsObject.moveStartPos + moveOffset;						
							} else if(moveProp == "margin-bottom") {
								moveProp = "margin-top";
								newEffectObj[moveProp] = effectsObject.moveStartPos + moveOffset;	
							} else {								
								newEffectObj[moveProp] = effectsObject.moveStartPos - moveOffset;				
							}
						}
						
						if(!self._removeFadeAnimation && fadeEnabled) {							
							currItem.css("opacity",0);							
						}
						
						if(!self._useWebkitTransition) {							
							currItem.css("visibility","hidden");
							currItem.css(newEffectObj);	
							if(moveEnabled) {	
								newEffectObj[moveProp] = effectsObject.moveStartPos; 
							}
							if(!self._removeFadeAnimation && fadeEnabled) {
								newEffectObj.opacity = 1;
							}
						} else {
							var cssObj = {};
							if(moveEnabled) {
								cssObj['-webkit-transition-duration'] = "0ms";
								cssObj['-webkit-transition-property'] = "none";
								
								cssObj["-webkit-transform"] = "translate3d("
									+ (isNaN(newEffectObj["margin-left"]) ? 0 : (newEffectObj["margin-left"] + "px")) 
									+ ", "
									+ (isNaN(newEffectObj["margin-top"]) ? 0 : (newEffectObj["margin-top"] + "px")) 
									+",0)";
								delete newEffectObj["margin-left"];
								delete newEffectObj["margin-top"];
								
								newEffectObj["-webkit-transform"] = "translate3d(0,0,0)";
								
							}
							newEffectObj.visibility = "visible";
							if(!self._removeFadeAnimation && fadeEnabled) {
								newEffectObj.opacity = 1;							
								cssObj["opacity"] = 0;
							}
							cssObj["visibility"] = "hidden";	
							currItem.css(cssObj);
						}
						
						
							

						this._captionAnimateProperties.push({captionItem:currItem, css:newEffectObj, running:false});
						// animate caption
						this._captionAnimateTimeouts.push(setTimeout((function (cItem, animateData, cSpeed, cEasing, cId, objFadeEnabled, objMoveEnabled) {	
							return function() {									
								self._captionAnimateProperties[cId].running = true;
								if(!self._useWebkitTransition) {
									cItem.css("visibility","visible").animate(animateData, cSpeed, cEasing, function(){										
										delete self._captionAnimateProperties[cId];
									});
								} else {									
									cItem.css({'-webkit-transition-duration': (speed + "ms"), 
										'-webkit-transition-property': 'opacity, -webkit-transform',
										'-webkit-transition-timing-function':'ease-out'});
									cItem.css(animateData);
								}
							};
						})(currItem, newEffectObj, speed, easing, i, fadeEnabled, moveEnabled), delay));				
					}		
				}		
			},	/* _showCaption end */
			// scale image and center it if needed
			_scaleImage:function(img, containerWidth, containerHeight) {	
				
				var imgScaleMode = this.settings.imageScaleMode;
				var imgAlignCenter = this.settings.imageAlignCenter;
				
				if(imgAlignCenter || imgScaleMode == "fill" || imgScaleMode == "fit") {			
					
					var isReloaded = false;			
					function scaleImg () {						
						var hRatio, vRatio, ratio, nWidth, nHeight;
						var _tempImg = new Image();
						_tempImg.src = img.attr("src");               
						
						var imgWidth = _tempImg.width;
						var imgHeight = _tempImg.height;
						var imgBorderSize = parseInt(img.css("borderWidth"), 10);            	
						imgBorderSize = isNaN(imgBorderSize) ? 0 : imgBorderSize;
						
						// fix bug, that prevents getting image real size
						if(isNaN(imgWidth) || isNaN(imgHeight) || imgWidth === 0 || imgHeight === 0) {
							if(!isReloaded) {								
								$('<img />').load( function(){
									isReloaded = true;
									scaleImg();
								}).attr('src', _tempImg.src);
								return;
							}							
						}
						
						
						if(imgScaleMode == "fill" || imgScaleMode == "fit") {						
							
	
							hRatio = containerWidth / imgWidth;
							vRatio = containerHeight / imgHeight;
	
							if (imgScaleMode  == "fill") {
								ratio = hRatio > vRatio ? hRatio : vRatio;                    			
							} else if (imgScaleMode  == "fit") {
								ratio = hRatio < vRatio ? hRatio : vRatio;             		   	
							} else {
								ratio = 1;
							}
	
							nWidth = parseInt(imgWidth * ratio, 10) - imgBorderSize;
							nHeight = parseInt(imgHeight * ratio, 10) - imgBorderSize;
	
							img.attr({"width":nWidth, "height":nHeight})
							.css({"width": nWidth, "height": nHeight});
						} else {
							nWidth = imgWidth - imgBorderSize;
							nHeight = imgHeight - imgBorderSize;
						}
						// center image in needed
						if (imgAlignCenter) {            		
							img.css({"margin-left": Math.floor((containerWidth - nWidth) / 2), "margin-top":Math.floor((containerHeight - nHeight) / 2)});            		
						}    		
						img.css("visibility","visible");
						
					};
					img.css("visibility","hidden");
					img.removeAttr('height').removeAttr('width');	
					
					if (!this._isImageLoaded(img.get(0))) { 
						
						$('<img />').load( function(){							
							scaleImg();
						}).attr('src', img.attr("src"));						
					} else {						
						scaleImg();
					}
				};
			},   /* _scaleImage end */
			_isImageLoaded:function (img) {
			    if (!img.complete) {
			        return false;
			    }
			    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
			        return false;
			    }
			    return true;
			} /* _isImageLoaded end */
	}; /* RoyalSlider.prototype end */

	$.fn.royalSlider = function(options) {    	
		return this.each(function(){
			var royalSlider = new RoyalSlider($(this), options);
			$(this).data("royalSlider", royalSlider);
		});
	};

	$.fn.royalSlider.defaults = {    
			preloadNearbyImages:true,               // Preloads two nearby images, if lazy loading is enabled.
			imageScaleMode:"none",                  // Scale mode of images. "fill", "fit" or "none"
			imageAlignCenter:false,					// Aligns all images to center.
			
			keyboardNavEnabled:false,				// Keyboard arrows navigation
			
			

			directionNavEnabled:true,               // Direction (arrow) navigation (true or false)
			directionNavAutoHide:false,             // Direction (arrow) navigation auto hide on hover. (On touch devices arrows are always shown)
			hideArrowOnLastSlide:false,             // Auto hide right arrow on last slide and left on first slide. Always true for touch devices.


			slideTransitionSpeed:400,               // Slide transition speed in ms (1000ms = 1s)
			slideTransitionEasing:"easeInOutSine",  // Easing type for slide transition. Types: http://hosted.zeh.com.br/tweener/docs/en-us/misc/transitions.html

			captionAnimationEnabled:true,           // Set to false if you want to remove all animations from captions  
			captionShowEffects:["fade","moveleft"], // Default array of effects: 
			// ["fade" or "" + "moveleft", or "moveright", or "movetop", or "movebottom"]
			captionMoveOffset:20,                   // Default distance for move effect in px
			captionShowSpeed:400,                   // Default caption show speed in ms
			captionShowEasing:"easeOutCubic",       // Default caption show easing
			captionShowDelay:200,                   // Default delay between captions on one slide show

			controlNavEnabled:true,                 // Control navigation (bullets, thumbs)  enabled
			controlNavThumbs:false,	                // Use thumbs for control navigation (use data-thumb="myThumb.jpg" attribute in html royalSlide item)
			controlNavThumbsNavigation:true,        // Enables navigation for thumbs
			controlNavThumbsSpeed:400,				// Thumbnails navigation move speed (1000ms = 1s)
			controlNavThumbsEasing:"easeInOutSine", // Thumbnails navigation easing type

			slideshowEnabled:false,                 // Autoslideshow enabled          
			slideshowDelay:5000,                    // Delay between slides in slideshow
			slideshowPauseOnHover:true,             // Pause slideshow on hover
			slideshowAutoStart:true,                // Auto start slideshow 

			welcomeScreenEnabled:true,              // Welcome (loading) screen enabled
			welcomeScreenShowSpeed:500,             // Welcome screen fade out speed

			minSlideOffset:20,                      // Minimum distance in pixels to show next slide while dragging
			
			disableTranslate3d:false,   			// Disables CSS3 transforms on touch devices

			removeCaptionsOpacityInIE8:false,        // If animated caption with fade effect has no background color, so turn this option on. 
			// Fix for pixelated text bug in IE8 and lower. Removes fade effect animation.

			beforeSlideChange: function(){},        // Callback, triggers before slide transition
			afterSlideChange: function(){},         // Callback, triggers after slide transition

			beforeLoadStart:function() {},			// Callback, triggers before first image loading starts
			loadingComplete: function() {},         // Callback, triggers after loading complete, but before welcome screen animation
			allComplete: function() {}				// Callback, triggers after loading and welcome screen animation
	}; /* default options end */

	$.fn.royalSlider.settings = {};

})(jQuery);










/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* 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.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
*
* Requires: 1.2.2+
*/

(function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=
f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);








/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 * 
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);

