// ProPhoto4 build #914, generated at Sat, 14 Jan 2012 05:48:52 +0000
// do not edit this file, it is created by the theme, any edits will be lost

	var isTouchDevice = ( "ontouchstart" in document.documentElement );
	var ppSetupSlideshows, ppLightboxGallery, ppJSForContext, ppGrid;
	var ppCssIsLoaded = function() {
		var cssTestRule = jQuery('body').css( 'border-left-color' );
		return ( cssTestRule == 'rgb(255, 0, 0)' || cssTestRule == '#ff0000' ); 
	};if ( typeof jQuery != "undefined" ) {jQuery(document).ready(function($){var ppAjaxFetchSlideDown = {

	init: function(context){
		afs = this;
		
		$('a.ajax-fetch-slidedown',context).click(function(){
			afs.clicked = $(this);
			
			var target = $(this).parent().attr('id').match(/primary_nav_/) ? $('#primary-nav-ajax-receptacle') : $('#secondary-nav-ajax-receptacle')
			
			if ( afs.clicked.hasClass('loaded-and-showing' ) ) {
				target.removeClass('slideshow-init-complete');
				target.slideUp();
				afs.clicked.removeClass('loaded-and-showing' );
			
			} else {
				if ( target.is(':visible') ) {
					$('a.ajax-fetch-slidedown').removeClass('loaded-and-showing');
					target.removeClass('slideshow-init-complete');
					target.slideUp(function(){
						afs.ajaxLoad(target);
					});
				} else {
					afs.ajaxLoad(target);
				}
			}
			return false;
		});
	},
	
	ajaxLoad: function(target){
		
		ppThrob.start(afs.clicked);
		
		var ajaxUrl = afs.clicked.attr('href'),
			getSep  = ( ajaxUrl.indexOf( '?' ) === -1 ) ? '?' : '&';
		
		$.ajax({
			type: 'GET',
			url: ajaxUrl + getSep + 'ajaxFetching=1',
			timeout: 5000,
			success: function(response){
				var markup = $('.article-content',response);
				if ( !markup.length ) {
					markup = $(response).filter('.article-content');
				}
				if ( markup.length ) {
					target.html(markup).delay(750).slideDown();
					afs.clicked.addClass('loaded-and-showing');
					ppJSForContext(target);
				} else {
					this.error();
				}
				ppThrob.stop(afs.clicked);
			},
			error: function(){
				afs.clicked.text('Loading error');
			}
		});
	}
};

ppAjaxFetchSlideDown.init($('body'));


var contentWidth = $('body').attr('class').match(/content-width-[0-9]+/)[0].replace('content-width-','');
var fullWidth    = $('body').attr('class').match(/full-width-[0-9]+/)[0].replace('full-width-','');




/* the main slideshow function */
ppSetupSlideshows = function(context) {
	if ( context.hasClass('slideshow-init-complete') ) {
		return;
	}
	context.addClass('slideshow-init-complete');

	
	if ( !isTouchDevice ) {
		$('a.popup-slideshow',context).click(function(){
			var clicked, width, height, params, dims, offset = '';
			clicked = $(this);
			if ( clicked.hasClass('fullscreen') ) {
				width  = screen.availWidth;
				height = screen.availHeight;
			} else {
				dims   = clicked.attr('rel').split('x');
				width  = dims[0];
				height = dims[1];
				offset = ',left=20,screenX=20,top=20,screenY=20';
			}
			params = "location=0,menubar=0,height="+height+",width="+width+",toolbar=0,scrollbars=0,status=0,resizable=0"+offset;
			window.open( clicked.attr('href'), 'PopupWindow', params );
			return false;
		});
	};
	

	$('.pp-slideshow-not-loaded img',context).imageLoaded(function(){
		if ( $(this).attr('lazyload-src') && !$(this).hasClass('lazy-load-initiated') ) {
			return;
		}
		
		$(this).parent().removeClass('pp-slideshow-not-loaded');

		var _this = {}; // function-scoped stand-in for 'this'
		
		var ppSlideshow = {
			
			/* some object-scoped vars */
			midTransitionDelay: 0,
			delayTime: 1000,
			simulateSlowLoad: 0,
			visibleImgIndex: 0,
			stagedImgIndex: 1,
			showPlaying: false,
			clickedIndex: null,
			browserCantAa: ( $('body').hasClass('cant-antialias-downsized-imgs') ),
			isMobile: ( $('body').hasClass('mobile') ),
			isIpad: ( $('body').hasClass('ipad') ),
			click: isTouchDevice ? 'touchend' : 'click',
			isFullScreened: ( window.location.href.indexOf('fullscreen=1') !== -1 ),
			iPadFadeControlsDelayed: function(){},
			
			// ---------------------------- //
			// -- INITIATIZATION METHODS -- //
			// ---------------------------- //
			
			/* initiation method */
			init: function($startImg){
				_this = this;
				_this.$startImg    = $startImg;
				_this.$showWrap    = _this.$startImg.parents('.pp-slideshow');
				_this.id           = _this.$showWrap.attr('id').replace('pp-slideshow-','');
				_this.isPopup      = ( window.location.href.indexOf( 'popup=1' ) !== -1 );
				_this.autoStart    = ( window.location.href.indexOf( 'fullscreen=1' ) !== -1 || _this.$showWrap.hasClass('autostart') );
				_this.$startImg.unbind('load');
			
				// load data from external json file
				_this.loadJSONData(function(){
					_this
						.markup.init()
						.css.init()
						.sortImages()
						.initImgPreloading()
						.events.init()
						.defineTransition();
					if ( _this.autoStart ) {
						_this.startShow();
					}
				});
				return _this;
			},
			
			
			/* load the per-instance slideshow data from external json file/s */
			loadJSONData: function(callback){
				if ( _this.isFullScreened ) {
					contentWidth = 'fullscreen';
				}
				var slideshowWidth = _this.$showWrap.parents('.nav-ajax-receptacle').length ? fullWidth : contentWidth;
				
				if ( _this.isMobile ) {
					slideshowWidth = $('body').attr('class').match(/mobile-display-width-[0-9]+/)[0].replace('mobile-display-width-','');
				}

				if ( /unitTesting=1/.test(window.location.href) ) {
					var unitGet = '&unitTesting=1';
					var method = window.location.href.match(/&method=[a-zA-Z0-9_]*/)[0].replace('&method=','');
					var slideshowFile = prophoto_info.wpurl+'/wp-content/uploads/test-slideshow/slideshow-test-method-'+method+'.js';
					var mastheadFile = prophoto_info.wpurl+'/wp-content/uploads/test-masthead-slideshow/masthead-test-method-'+method+'.js?';
				} else {
					var unitGet = '';
					var slideshowFile = _this.$showWrap.attr('data-options-file');
					var mastheadFile = prophoto_info.wpurl+'/?staticfile=masthead.js&';
					if ( typeof pp_preview_design_id !== "undefined" ) {
						mastheadFile += 'preview_design=' + pp_preview_design_id + '&';
						if ( slideshowFile ) {
							var sep = ( slideshowFile.indexOf( '?' ) === -1 ) ? '?' : '&';
							slideshowFile += sep + 'preview_design=' + pp_preview_design_id;
						}
					}
				}

				// masthead slideshow
				if ( _this.$showWrap.attr('id') == 'masthead_image' ) {
					_this.isMasthead = true;
					$.getJSON(mastheadFile+'cb='+_this.currentTime()+unitGet,function(loadedData){
						_this.params = loadedData;
						_this.opts = ( _this.isMobile && _this.params.mobile_opts ) ? _this.params.mobile_opts : _this.params.opts;
						if ( _this.isMobile ) {
							_this.params.imgs = $('body').hasClass('retina-display') ? _this.params.retina_imgs : _this.params.mobile_imgs;
						}
						_this.showThumbstrip = false;
						callback();
					});
				
				// regular slideshow
				} else {
					_this.isMasthead = false;
					var getGlobalData = function(){
						sep = ( slideshowFile.indexOf('?') !== -1 ) ? '&' : '?' 
						$.getJSON(slideshowFile+sep+'cb='+_this.currentTime()+unitGet,function(globalData){
							_this.params = globalData;
							_this.opts = _this.params.opts;
						});
					};
					var getLocalData = function(){
						var local = prophoto_info.url+'/?slideshow_gallery_js='+_this.id+'&content_width='+slideshowWidth+'&cb='+_this.currentTime();
						if ( unitGet ) {
							local = local + unitGet+'&class='+classNamePartial+'&className='+className+'&method='+testMethod+'&vistest=1';
						}
						$.getJSON(local, function(localData){
							_this.overrideParams = localData;
							_this.overrideParams.imageOrder = 'sequential';
							_this.showThumbstrip = ( !_this.isMobile );
							_this.showMobileControls = true;
							mergeData();
						});
					};
					
					var mergeData = function(){
						if ( !_this.params ) {
							setTimeout(function(){ mergeData(); },100);
							return;
						}
						$.extend(true,_this.params,_this.overrideParams);
						if ( _this.overrideParams.holdTime && _this.overrideParams.holdTime != "" ) {
							_this.opts.holdTime = _this.overrideParams.holdTime;
						}
						_this.opts.holdTime = _this.opts.holdTime * 1000;
						callback();
						if ( _this.isMobile ) {
							_this.mobileControls.init();
						}
					};
					
					getGlobalData();
					getLocalData();
				}
			},
			
			
			/*  sort images */
			sortImages: function(){
				if ( _this.opts.imageOrder == 'random' ) {
					var nonFirstImgs = [];
					var firstImgSrc = _this.$startImg.attr('src');
					var firstImgStart = firstImgSrc.replace('.'+firstImgSrc.split('.').pop(),'');
					for (var i=0; i < _this.params.imgs.length; i++) {
						if ( _this.params.imgs[i].fullsizeSrc.indexOf(firstImgStart) !== -1 ) {
							var firstImg = [ _this.params.imgs[i] ];
						} else {
							nonFirstImgs.push(_this.params.imgs[i]);
						}
					};
					nonFirstImgs = nonFirstImgs.sort(function(){return 0.5 - Math.random();});
					nonFirstImgs = nonFirstImgs.sort(function(){return 0.5 - Math.random();});
					_this.params.imgs = ( typeof firstImg == "undefined" ) ? nonFirstImgs : firstImg.concat(nonFirstImgs);
				}
				return _this;
			},
			
			
			/* initiate all image preloading */
			initImgPreloading: function(){
				
				// first image we know is loaded, set it up manually
				_this.params.imgs[0].isPreloaded = true;
				_this.params.imgs[0].width  = _this.$startImg.attr('width');
				_this.params.imgs[0].height = _this.$startImg.attr('height');
				_this.setImgDimensions(_this.$startImg[0],0);
				_this.applyImgDisplayDimensions(_this.$startImg,0);
				
				// preload the rest of the images
				for (var i=1; i < _this.params.imgs.length; i++) {
					_this.params.imgs[i].isPreloaded = false;
				};
				setTimeout(function(){
					_this.preloadImg(1);
				},_this.simulateSlowLoad);
				return _this;
			},
			
			
			/* recursive function to preload all images in order */
			preloadImg: function(imgIndex){
				var debug = false;
				if ( !_this.params.imgs[imgIndex] ) return false;
				
				var preloadNextImg = function(imgIndex){
					if ( ( imgIndex + 1 ) >= _this.params.imgs.length ) {
						if ( _this.opts.loopImages ) {
							var firstImg = new Image();
							$(firstImg).load().attr('src',_this.imgSrc(0));
						}
						return false;
					}
					if ( _this.$showWrap.hasClass('showingSplashScreen') && imgIndex > 0 ) {
						return false;
					}
					return true;
				};
				
				var preloadedImage = new Image();
				
				$(preloadedImage).load(function(){
					_this.params.imgs[imgIndex].isPreloaded = true;
					_this.setImgDimensions(preloadedImage,imgIndex);
					
					if ( preloadNextImg(imgIndex) ) {
						setTimeout(function(){
							_this.preloadImg( imgIndex + 1 );
						},_this.simulateSlowLoad);
					}
					
				}).attr('src',_this.imgSrc(imgIndex));
				
				return _this;
			},
			
			
			/* note orig and calculate display dimensions */
			setImgDimensions: function(img,imgIndex){
				var displayWidth, displayHeight;
				displayWidth  = _this.params.imgs[imgIndex].width  = img.width;
				displayHeight = _this.params.imgs[imgIndex].height = img.height;
				
				// get and record natural dimensions for first image, for mobile reorientation resizing
				if ( imgIndex == 0 && _this.isMobile ) {
					if ( 'naturalHeight' in img ) {
						displayWidth  = _this.params.imgs[imgIndex].width  = img.naturalWidth;
						displayHeight = _this.params.imgs[imgIndex].height = img.naturalHeight;
					}
				}
				
				
				if ( displayWidth > _this.viewingAreaWidth ) {
					displayWidth  = _this.viewingAreaWidth;
					displayHeight = Math.round( displayWidth / ( img.width / img.height ) );
				}
				if ( displayHeight > _this.viewingAreaHeight ) {
					displayHeight = _this.viewingAreaHeight;
					displayWidth  = Math.round( displayHeight / ( img.height / img.width ) );
				}

				
				// stretch full-screened images to fit slideshow
				if ( _this.isFullScreened && displayWidth < _this.slideshowWidth && displayHeight < _this.slideshowHeight ) {
					wDiff = _this.slideshowWidth - displayWidth;
					hDiff = _this.slideshowHeight - displayHeight;
					if ( wDiff <= hDiff ) {
						displayWidth  = _this.slideshowWidth;
						displayHeight = Math.round( displayWidth / ( img.width / img.height ) );
					} else {
						displayHeight = _this.slideshowHeight;
						displayWidth  = Math.round( displayHeight / ( img.height / img.width ) );
					}
				} 

				// correct rounding errors
				if ( _this.viewingAreaWidth - displayWidth == 1 ) {
					displayWidth = _this.viewingAreaWidth;
				}
				if ( _this.viewingAreaHeight - displayHeight == 1 ) {
					displayHeight = _this.viewingAreaHeight;
				}
				
				_this.params.imgs[imgIndex].displayWidth  = displayWidth;
				_this.params.imgs[imgIndex].displayHeight = displayHeight;
				_this.params.imgs[imgIndex].topPadding    = ( _this.viewingAreaHeight - displayHeight ) / 2;
			},
			
			
			
			
			mobileControls: {
				
				hideBtnsTimeout: 0,
				showingBtns: false,
				
				init: function(){
					if ( !_this.isMasthead ) {
						_this.mobileControls.markup();
						_this.mobileControls.css();
						_this.mobileControls.events();
					}
				},
				
				markup: function(){
					_this.$showWrap.append('<div class="mobileControls"><a class="prevNext prev"><span><em>prev</em></span></a><a class="playPause"><span><em>play</em></span></a><a class="prevNext next"><span><em>next</em></a></div>');
					_this.$mobileControls = $('.mobileControls',_this.$showWrap);
				},
				
				css: function(){
					$('.playPause span, .prevNext em', _this.$mobileControls ).css( 'background-image','url('+_this.params.btnsSrcs['sprite']+')' );
					$('.playPause',_this.$mobileControls).css('left', ( _this.viewingAreaWidth - 64 ) / 2 );
					$('.prevNext',_this.$mobileControls).css('top', ( _this.viewingAreaHeight - 50 ) / 2 );
				},
				
				events: function(){
					var touchstart = /force_mobile=1/.test(window.location.href) ? 'click' : 'click';
					
					if ( _this.$splashScreen ) {
						_this.$splashScreen.bind('splashscreenremoved',function(){
							_this.mobileControls.showBtns();
							_this.$mobileControls.bind('click',function(event){
								_this.mobileControls.showingBtns ? _this.mobileControls.hideBtns() : _this.mobileControls.showBtns();
							});
						});
					}
					
					_this.$mobileControls.bind('swipeleft',function(event){
						_this.touchPrevNext(true);
					});
					
					_this.$mobileControls.bind('swiperight',function(event){
						_this.touchPrevNext(false);
					});
					
					$('.playPause',_this.$mobileControls).bind(touchstart,function(){
						if ( !_this.showPlaying ) {
							_this.mobileControls.hideBtns($('.prevNext',_this.$mobileControls));
							_this.mobileControls.showBtns($('.playPause',_this.$mobileControls));
						} else {
							_this.mobileControls.showBtns($('a',_this.$mobileControls));
						}
						_this.showPlaying ? _this.stopShow() : _this.startShow();
						return false;
					});
					
					$('.prevNext',_this.$mobileControls).bind(touchstart,function(){
						_this.touchPrevNext($(this).hasClass('next'));
						_this.mobileControls.showBtns($('a',_this.$mobileControls));
						return false;
					});
				},
				
				
				showBtns: function(toShow){
					if ( undefined == toShow ) {
						toShow = _this.showPlaying ? $('.playPause',_this.$mobileControls) : $('a',_this.$mobileControls);
					}
					toShow.show();
					_this.mobileControls.showingBtns = true;
					clearTimeout( _this.mobileControls.hideBtnsTimeout );
					_this.mobileControls.hideBtnsTimeout = setTimeout(function(){
						_this.mobileControls.hideBtns($('a',_this.$mobileControls));
					},4000);
				},
				
				
				hideBtns: function(btns){
					if ( btns == undefined ) {
						btns = $('a',_this.$mobileControls);
					}
					btns.fadeTo('fast',0,function(){
						$(this).hide().css('opacity',0.65);
						_this.mobileControls.showingBtns = false;
					});
				}	
			},
			
			
			// ----------------------- //
			// -- MARKUP/CSS/EVENTS -- //
			// ----------------------- //
			
			/* setup all the markup we need for the show */
			markup: {
				
				/* call markup-writing submethods */
				init: function(){
					this.mainShowMarkup();
					this.splashScreenMarkup();
					_this.setupDimensions(); // controls markup needs to know show dimensions
					this.controlsMarkup();
					return _this;
				},

				
				/* write markup for main show */
				mainShowMarkup: function(){
					
					// private function to wrap img tag in wrapping a tag html
					var wrapImg = function($img,imgIndex){
						var aClass = ( imgIndex == 0 ) ? 'currentImg' : 'nextImg';
						$img.wrap('<a class="imgWrap ' + aClass  + '" href="#"></a>');
						_this.setImgLinkTo($img.parent(),imgIndex);
						$img.before('<img class="blankOverlay" src="'+prophoto_info.theme_url+'/images/blank.gif" />');
						if ( _this.imgSrc(imgIndex).indexOf('.png') !== -1 ) {
							$img.parent().addClass('png');
						}
					};

					// setup main image and wrapping divs
					_this.$showWrap.addClass('showWrap');
					_this.$startImg.wrap('<div class="imgViewingArea"></div>');
					wrapImg(_this.$startImg,0);
					_this.$visibleImg     = _this.$startImg;
					_this.$visibleImgWrap = _this.$startImg.parents('.imgWrap');
					_this.$imgViewingArea = _this.$startImg.parents('.imgViewingArea');
					
					// setup staged image markup
					_this.$visibleImgWrap.after('<img src="'+_this.imgSrc(1)+'" />');
					_this.$stagedImg = _this.$visibleImgWrap.next();
					wrapImg(_this.$stagedImg,1);
					_this.$stagedImgWrap = _this.$visibleImgWrap.next();
					_this.$imgWraps = $('.imgWrap',_this.$showWrap);

					// ajax loading spinner
					_this.$showWrap.prepend('<img class="loadingSpinner" src="'+prophoto_info.theme_url+'/images/ajaxLoadingSpinner.gif" />');
					_this.$loadingSpinner = $('.loadingSpinner',_this.$showWrap);

					// timer
					if ( _this.params.showTimer ) {
						_this.$imgViewingArea.append('<div class="timer"></div>');
						_this.$timer = $('.timer',_this.$imgViewingArea);
					}
				},


				/* write markup for splash screen */
				splashScreenMarkup: function(){
					
					if ( _this.autoStart || _this.isFullScreened ) {
						return;
					}
					
					// basic markup
					_this.$showWrap.addClass('showingSplashScreen');
					_this.$imgViewingArea.prepend('<div class="initialOverlay"><div class="content"><img class="startBtn" src="'+_this.params.btnsSrcs[ _this.browserCantAa ? 'start_aa' : 'start' ]+'" /></div><div class="bg"></div></div>');
					_this.$splashScreen        = $('.initialOverlay',_this.$showWrap);
					_this.$splashScreenContent = $('.content',_this.$splashScreen);
					_this.$splashScreenBg      = $('.bg',_this.$splashScreen);
					
					// optionally add SubTitle
					if ( _this.params.subtitle ) {
						_this.$splashScreenContent.prepend('<h4>'+_this.params.subtitle+'</h4>');
					}
					
					// optionally add Title
					if ( _this.params.title ) {
						_this.$splashScreenContent.prepend('<h3>'+_this.params.title+'</h3>');
					}
					
					// optionally add Logo
					if ( _this.params.splashScreenLogo ) {
						_this.$splashScreenContent.prepend( '<img class="logo" src="'+_this.params.splashScreenLogo.src+'" '+_this.params.splashScreenLogo.htmlAttr+' />');
					}
					
					_this.splashScreenVisible = true;
				},


				/* write markup for controls area */
				controlsMarkup: function(){
					_this.c = {}, _this.c.btnsArea = {};
					
					if ( !_this.showThumbstrip ) {
						_this.c.longDimName = 'width';
						_this.c.showParallelDim = _this.slideshowWidth;
						_this.c.isVertical = false;
						return;
					}
					
					// min sizes for iPad
					if ( _this.isIpad ) {
						_this.params.thumbSize    = _this.params.thumbSize >= 100    ? _this.params.thumbSize    : 100;
						_this.params.thumbPadding = _this.params.thumbPadding >= 15  ? _this.params.thumbPadding : 15;
					}
					
					// start building object-scoped controls data sub-object
					_this.c.thumbUnitSize      = _this.params.thumbSize + 2*_this.params.thumbBorderWidth
					_this.c.shortDim           = _this.params.thumbSize + 2*( _this.params.thumbBorderWidth + _this.params.thumbPadding );
					_this.c.isVertical         = ( _this.params.controlsPosition == 'left' || _this.params.controlsPosition == 'right' );
					_this.c.isHorizontal       = !_this.c.isVertical;
					_this.c.overlaid           = _this.isFullScreened ? true : _this.params.controlsOverlaid;
					_this.c.primaryBtnHeight   = _this.isIpad ? 40 : 20;
					_this.c.thumbUnitPadded    = _this.c.thumbUnitSize + _this.params.thumbPadding;
					_this.c.thumbPageBtnWidth  = _this.isIpad ? 44 : 22;
					_this.c.currentThumbPage   = 1;
					_this.c.userControlsThumbs = false;
					_this.c.autoHide           = _this.params.controlsAutoHide;
					
					// build basic controls markup
					var btnsSprite = '<img src="'+_this.params.btnsSrcs[ _this.browserCantAa ? 'sprite_aa' : 'sprite' ]+'" />';
					_this.$showWrap[(_this.params.controlsPosition == 'bottom') ? 'append' : 'prepend' ]
						('<div class="controls"><div class="controls-bg"></div><div class="thumbStrip"><div class="thumbsViewport"><div class="thumbsWrap"></div></div><a class="prevPage disabled"><div>'+btnsSprite+'</div></a><a class="nextPage"><div>'+btnsSprite+'</div></a></div><div class="btns"><a class="playPause">'+btnsSprite+'</a></div></div>');
					_this.$controls       = $('.controls', _this.$showWrap);
					_this.$controlsBg     = $('.controls-bg', _this.$controls);
					_this.$thumbStrip     = $('.thumbStrip', _this.$showWrap);
					_this.$thumbsViewport = $('.thumbsViewport', _this.$showWrap);
					_this.$thumbsWrap     = $('.thumbsWrap', _this.$showWrap);
					_this.$thumbPageBtns  = $('.prevPage,.nextPage',_this.$thumbStrip);
					
					// thumbs markup
					for (var i=0; i < _this.params.imgs.length; i++) {
						active = ( i == 0 ) ? 'active' : '';
						 _this.$thumbsWrap.append('<img src="'+_this.params.imgs[i].thumbSrc+'" index="'+i+'" class="'+active+'">' );
					};
					_this.$thumbs = $('img', _this.$thumbsWrap);
					$('img[index='+_this.visibleImgIndex+']',_this.$thumbsWrap).addClass('active');
					
					// primary buttons area
					_this.$primaryBtnsArea  = $('.btns',_this.$controls);
					_this.$playPauseBtn     = $('.playPause',_this.$primaryBtnsArea);
					_this.$showWrap.addClass((_this.autoStart) ? 'playing' : 'paused' );
					if ( !_this.params.disableFullScreen ) {
						_this.$primaryBtnsArea.append('<a class="fullscreen">'+btnsSprite+'</a>');
						_this.$fullscreenBtn = $('.fullscreen',_this.$primaryBtnsArea);
					}
					if ( _this.params.shoppingCartUrl ) {
						_this.$primaryBtnsArea.append('<a class="cart-url" href="'+_this.params.shoppingCartUrl+'">'+btnsSprite+'</a>');
						_this.$shoppingCartBtn = $('.cart-url',_this.$primaryBtnsArea);
					}
					if ( _this.params.mp3Url ) {
						var playingClass = _this.params.mp3Autostart ? 'playing' : 'paused';
						_this.$primaryBtnsArea.append('<a class="mp3player '+playingClass+'">'+btnsSprite+'</a>');
						_this.$mp3Player = $('.mp3player',_this.$primaryBtnsArea);
					}
					_this.$controlBtns = $('a',_this.$controls);
					_this.$primaryBtns = $('.btns a',_this.$controls);
					
					// more info into the controls data object
					_this.c.showParallelDim       = _this.c.isHorizontal ? _this.slideshowWidth  : _this.slideshowHeight;
					_this.c.showPerpDim           = _this.c.isHorizontal ? _this.slideshowHeight : _this.slideshowWidth;
					_this.c.shortDimName          = _this.c.isHorizontal ? 'height' : 'width';
					_this.c.longDimName           = _this.c.isHorizontal ? 'width'  : 'height';
					_this.c.btnsArea.width        = ( _this.c.primaryBtnHeight * 1.5 ) * ( _this.$primaryBtns.length > 1 ? 2 : 1 );
					_this.c.btnsArea.height       =  _this.$primaryBtns.length < 3 ? _this.c.primaryBtnHeight : 2*_this.c.primaryBtnHeight + 6;
					_this.c.btnsArea.xPosDir      = _this.c.isHorizontal ? 'right' : 'bottom';
					_this.c.btnsArea.centerPosDir = _this.c.isHorizontal ? 'top'   : 'left';
					_this.c.fromOpposite          = _this.c.showPerpDim - _this.c.shortDim;
					var opposites                 = { top:'bottom', bottom:'top', left:'right', right:'left' };
					_this.c.oppositeDir           = opposites[_this.params.controlsPosition];

					// paging of thumbnaiils
					var btnsOffset = _this.c.isHorizontal ? _this.c.btnsArea.width : _this.c.btnsArea.height;
					_this.c.thumbsPerPage = Math.floor( ( _this.c.showParallelDim - btnsOffset - 2*( _this.params.thumbPadding + _this.c.thumbPageBtnWidth ) ) / _this.c.thumbUnitPadded );
					_this.c.thumbPages = Math.ceil( _this.params.imgs.length / _this.c.thumbsPerPage );
					_this.c.thumbsViewportSize = _this.c.thumbUnitPadded * _this.c.thumbsPerPage - _this.params.thumbPadding;
				}
			},
	
			
			/* apply css to created markup */
			css: {
				
				/* call CSS-applying sub-methods */
				init: function(){
					if ( _this.params.showTimer ) {
						_this.$timer.css('opacity',0.35); 
					}
					this.splashScreenCss();
					this.controlsCss();
					return _this;
				},


				/* apply CSS to splash screen */
				splashScreenCss: function(){
					
					if ( _this.autoStart || _this.isFullScreened ) {
						return;
					}
					
					// height of contact area
					var verticalPadding, splashScreenTotalHeight, splashScreenFromTop;
					var innerHeight = _this.isIpad ? 70 : 35; // 35 is height of start button graphic
					if ( _this.params.title ) innerHeight += parseInt( $('h3',_this.$splashScreenContent).css('font-size') ) + 12;
					if ( _this.params.subtitle ) innerHeight += parseInt( $('h4',_this.$splashScreenContent).css('font-size') ) + 12;
					if ( _this.params.splashScreenLogo ) innerHeight += $('.logo',_this.$splashScreenContent).height() + 12;
					
					// calculate padding to add to splash screen
					var requestedHeight = parseInt( _this.viewingAreaHeight * _this.params.splashScreenHeight );
					if ( requestedHeight < innerHeight + 20 ) {
						verticalPadding = 10;
					} else if ( _this.params.splashScreenHeight == 1 ) {
						verticalPadding = ( _this.slideshowHeight - innerHeight ) / 2
					} else {
						verticalPadding = parseInt( ( requestedHeight - innerHeight ) / 2 )
					}
					
					// calculate position of splashscreen
					splashScreenTotalHeight = innerHeight + 2*verticalPadding;
					switch ( _this.params.splashScreenPosition ) {
						case 'top':
							splashScreenFromTop = 0;
							break;
						case 'bottom':
							splashScreenFromTop = _this.viewingAreaHeight - splashScreenTotalHeight;
							break;
						case 'middle':
							splashScreenFromTop = ( _this.viewingAreaHeight - splashScreenTotalHeight ) / 2;
							break;
					}
					
					// apply splash screen css
					_this.$splashScreen.css({
						width: _this.viewingAreaWidth+'px',
						top: splashScreenFromTop+'px',
						height: splashScreenTotalHeight+'px'
					});
					_this.$splashScreenContent.css({
						height: innerHeight+'px',
						padding: verticalPadding+'px 20px',
						width:(_this.viewingAreaWidth-40)+'px'
					});
				},


				/* apply CSS to controls area */
				controlsCss: function(){
					
					if ( !_this.showThumbstrip ) {
						return;
					}
					
					// controls position specific classes for css
					_this.$showWrap
						.addClass('controlsPos-'+_this.params.controlsPosition)
						.addClass( _this.c.isHorizontal ? 'controlsHorizontal' : 'controlsVertical' );

					// primary buttons area
					var btnsAreaCss = {
						width:_this.c.btnsArea.width+'px',
						height:_this.c.btnsArea.height+'px'
					};
					btnsAreaCss[_this.c.btnsArea.xPosDir] = _this.params.thumbPadding+'px';
					btnsAreaCss[_this.c.btnsArea.centerPosDir] = ( 0.5*( _this.c.thumbUnitSize - ( _this.c.isHorizontal ? _this.c.btnsArea.height : _this.c.btnsArea.width ) ) + _this.params.thumbPadding ) + 'px';
					_this.$primaryBtnsArea.css(btnsAreaCss);

					// controls areas widths and heights
					var shortSideDimCss = {}, longSideDimCss = {};
					shortSideDimCss[_this.c.shortDimName] = _this.c.thumbUnitSize+'px';
					longSideDimCss[_this.c.longDimName]  = _this.c.thumbsViewportSize+'px';
					_this.cssToArgs(shortSideDimCss,_this.$controls,_this.$thumbsViewport,_this.$thumbPageBtns);
					_this.cssToArgs(longSideDimCss,_this.$thumbsViewport,_this.$thumbStrip);

					// make room for and show thumb page buttons
					if ( _this.c.thumbPages > 1 ) {
						
						_this.$controls.addClass('pagedThumbs');

						// center thumb paging buttons
						var marginDir = _this.c.isVertical ? 'left' : 'top';
						$('div',_this.$thumbPageBtns).css('margin-'+marginDir,((_this.c.thumbUnitSize-_this.c.primaryBtnHeight)/2) + 'px');

						// visually adjust for prevPage button space
						var shrunkPadding       = Math.round( _this.c.thumbPageBtnWidth / 10 );
						var shrunkPaddingOffset = parseInt(_this.$controls.css('padding-left')) - shrunkPadding;
						var paddingDir          =  _this.c.isVertical ? 'top' : 'left';
						_this.$controls.css('padding-'+paddingDir,shrunkPadding+'px');

					// thumbs fit in one page
					} else {
						var shrunkPaddingOffset = 0;
					}
					
					// controls width and height
					var controlsCss = {};
					controlsCss[_this.c.longDimName] = ( _this.c.showParallelDim - 2*_this.params.thumbPadding + shrunkPaddingOffset ) + 'px';
					
					// controls overlaying slideshow
					if ( _this.c.overlaid ) {
						_this.$showWrap.addClass('controlsOverlaid');
						controlsCss[_this.c.oppositeDir] = _this.c.fromOpposite + 'px';
						
					// controls NOT overlaying
					} else {
						_this.$showWrap.addClass('controlsNotOverlaid');
					}
					_this.$controls.css(controlsCss);
				}
			},

			
			/* bind all slideshow events */
			events: {
				
				/* call event-binding sub-methods */
				init: function(){
					_this.$imgWraps.click(function(){
						_this.$showWrap.click();
						return ( !$(this).hasClass('no-link') );
					});
					
					this.splashScreenEvents();
					this.controlsEvents();
					this.orientationChange();
					if ( _this.isIpad ) {
						this.iPadEvents();
					}
					return _this;
				},
				
				
				orientationChange: function(){
					$(window).bind('orientationchange',function(){
						_this.setupDimensions();
						for (var i=0; i < _this.params.imgs.length; i++) {
							_this.setImgDimensions(_this.params.imgs[i],i);
						};

						_this.applyImgDisplayDimensions(_this.$stagedImg,_this.stagedImgIndex);
						_this.applyImgDisplayDimensions(_this.$visibleImg,_this.visibleImgIndex);
						
						if ( _this.$controls ) {
							_this.$controls
								.css((_this.params.controlsPosition == 'top') ? 'bottom' : 'top','')
								.css((_this.params.controlsPosition == 'top') ? 'top' : 'bottom','0');
						}
						if ( _this.$showWrap.hasClass('showingSplashScreen') ) {
							_this.css.splashScreenCss();
						}
						if ( _this.isMobile ) {
							_this.defineTransition();
							if ( !_this.isMasthead ) {
								_this.mobileControls.css();
							}
						}
					});
				},
				
				
				iPadEvents: function(){
					_this.$showWrap.swipe({
						triggerOnTouchEnd: false,
						allowPageScroll:"vertical",
						swipe: function(e,dir){
							_this.$showWrap.addClass('swiping');
							if ( dir != 'up' && dir != 'down' ) {
								if ( _this.swipingThumbs || _this.$showWrap.hasClass('transitioning') ) {
									return false;
								}
								var isNext = ( dir == 'left' );
								_this.touchPrevNext(isNext);
								return false;
							}
						}
					});
				},
				
				
				/* bind events related to splash screen */
				splashScreenEvents: function(){
					
					if ( !_this.$splashScreen ) {
						return;
					}
					
					// func to hide splash screen and optionally start show
					_this.hideSplashScreen = function(directClick){
						_this.splashScreenVisible = false;
						_this.$showWrap.removeClass('showingSplashScreen');
						_this.preloadImg(2); // finish preloading
						_this.$splashScreen.fadeOut(function(){
							_this.$showWrap.mousemove();
							if ( _this.params.startPlaying && directClick ) {
								_this.startShow();
							}
							_this.$splashScreen.trigger('splashscreenremoved').remove();
						});
					};
					
					// splash screen clicks
					_this.$splashScreen.bind( _this.click, function(){
						_this.hideSplashScreen(true);
						return false;
					});
				},


				/* bind events related to controls area */
				controlsEvents: function(){
					
					if ( !_this.showThumbstrip ) {
						return;
					}
					
					// hover over thumb
					var thumbOrigOpacity = $('.thumbsWrap img:not(.active):first').css('opacity');
					_this.$thumbs.hover(function(){
						$(this).animate({opacity:1},'fast');
					},function(){
						$(this).animate({opacity:thumbOrigOpacity},'fast');
					});
					
					// click on a thumb
					_this.$thumbs.bind(_this.click,function(e){
						var index = parseInt($(this).attr('index'));
						if ( index == _this.clickedIndex || _this.swipingThumbs ) {
							return;
						}
						_this.clickedIndex = index;
						_this.stopShow().showImg(_this.clickedIndex);
						if ( _this.$splashScreen ) {
							_this.hideSplashScreen();
						}
					});
					
					// thumbnail page prev/next button clicks
					_this.$thumbPageBtns.bind(_this.click,function(e){
						if ( $(this).hasClass('disabled') ) {
							return false;
						}
						
						// give user control of thumb paging, return to slideshow after 3.5 sec
						_this.c.userControlsThumbs = true;
						if ( _this.returnControlTimeout ) {
							clearTimeout( _this.returnControlTimeout );
						}
						_this.returnControlTimeout = setTimeout(function(){
							_this.c.userControlsThumbs = false;
						},3500);
						
						// move to requested page of thumbnails
						var toPage = ( $(this).hasClass('nextPage') ) ? _this.c.currentThumbPage + 1 : _this.c.currentThumbPage - 1;
						_this.gotoThumbPage( toPage );
						e.preventDefault();
						return false;
					});
					if ( _this.isIpad ) {
						$('.thumbsViewport',_this.$controls).swipe({
							threshold: 35,
							triggerOnTouchEnd: false,
							swipe: function(e,dir){
								if ( dir == 'up' || dir == 'down' ) {
									return false;
								}
								$( ( dir == 'right' ) ? '.prevPage' : '.nextPage', _this.$controls).trigger('touchend');
								e.preventDefault();
								_this.swipingThumbs = true;
								setTimeout(function(){ _this.swipingThumbs = false; }, 850 );
								return false;
							}
						});
					}
					
					
					// play/pause button clicks
					_this.$playPauseBtn.bind(_this.click,function(){
						if ( _this.$splashScreen ) {
							_this.hideSplashScreen();
						}
						_this.showPlaying ? _this.stopShow() : _this.startShow();
						return false;
					});
					
					// fullscreen button click
					if ( _this.$fullscreenBtn ) {
						_this.$fullscreenBtn.bind(_this.click,function(){
							if ( _this.isFullScreened ) {
								_this.isIpad ? history.go(-1) : window.close();
							} else {
								var url = prophoto_info.url + '?pp_slideshow_id=' + _this.id + '&fullscreen=1';
								if ( !isTouchDevice ) {
									window.open( url, '', 'height='+screen.availHeight+', width='+screen.availWidth+',directories=no, scrollbars=no, menubar=no, toolbar=no, location=no, resizeable=no, status=no, personalbar=no' );
								} else {
									window.location.href = url;
								}
								_this.stopShow();
							}
						});
					}
					
					// fullscreen-mode events
					if ( _this.isFullScreened ) {
						
						// escape key to exit fullscreen
						$(window).bind('keydown', function(e){
							var keyCode = e.keyCode || e.which; 
							  if ( keyCode == 27 ) {
							    window.close();
							  }
						});
					}
					
					// autoHiding of controls
					if ( _this.c.overlaid && _this.c.autoHide ) {
						
						if ( !_this.isIpad ) {
							
							// object holds controls show/hide methods
							var animateControls = {

								showHideControlsSpeed: 265,

								visibleControlsCss: function(){
									var css = {};
									css[_this.c.oppositeDir] = _this.c.fromOpposite + 'px';
									return css;
								},

								hiddenControlsCss: function(){
									var css = {};
									css[_this.c.oppositeDir] = _this.c.showPerpDim + 'px';
									return css;
								},

								show: function(){
									_this.$controls.animate(
										this.visibleControlsCss(),
										this.showHideControlsSpeed,
										'easeOutExpo',
										function(){ _this.controlsHidden = false; }
									);
								},

								hide: function(){
									_this.$controls.animate(
										this.hiddenControlsCss(),
										this.showHideControlsSpeed * 0.9,
										'easeInQuart',
										function(){ _this.controlsHidden = true; }
									);
								}
							};

							// mousemove event
							_this.$showWrap.mousemove(function(){
								if ( _this.splashScreenVisible ) {
									return;
								}
								if ( _this.controlsHidden ) {
									animateControls.show();
								}
								clearTimeout(_this.controlsHideTimeout);
								_this.controlsHideTimeout = setTimeout(function(){animateControls.hide();},_this.params.controlsAutoHideTime);
							}).mousemove();
							
							
						// ipad show/hide controls	
						} else {
							_this.iPadFadeControlsTimeout = 0;
							_this.iPadFadeControlsDelayed = function(){
								_this.$controls.show();
								_this.iPadFadeControlsTimeout = setTimeout(function(){
									_this.$controls.fadeOut();
								},4500);
							}
							$('a',_this.$controls).bind('touchend',function(){
								clearTimeout(_this.iPadFadeControlsTimeout);
								_this.iPadFadeControlsDelayed();
							});
							_this.$showWrap.bind('touchend',function(e){
								if ( _this.$showWrap.hasClass('swiping') || _this.$showWrap.hasClass('showingSplashScreen') ) {
									return false;
								}
								clearTimeout(_this.iPadFadeControlsTimeout);
								if ( _this.$controls.css('display') == 'block' ) {
									_this.$controls.hide();
								} else {
									_this.iPadFadeControlsDelayed();
								}
							});
							// prevent stray clicks on controls area from hiding them
							_this.$controls.bind('touchend',function(){
								return false;
							});
						}
					}
				}
			},
			

			/* retrieve and apply dimension info */
			setupDimensions: function(){
				
				if ( _this.isFullScreened ) {
					if( typeof( window.innerWidth ) == 'number' ) {
						_this.slideshowWidth    = window.innerWidth;
						_this.slideshowHeight   = window.innerHeight;
						_this.viewingAreaHeight = window.innerHeight;
						_this.viewingAreaWidth  = window.innerWidth;	
					} else {
						_this.slideshowWidth    = document.documentElement.clientWidth;
						_this.slideshowHeight   = document.documentElement.clientHeight;
						_this.viewingAreaHeight = document.documentElement.clientHeight;
						_this.viewingAreaWidth  = document.documentElement.clientWidth;
					}
				
				} else {
					if ( _this.isMobile ) {
						var dims = ( $('html').hasClass('portrait') ) ? _this.params.mobile_portrait_dims : _this.params.mobile_landscape_dims;
						dims.slideshowHeight   = dims.mobileSlideshowHeight;
						dims.slideshowWidth    = dims.mobileSlideshowWidth;
						dims.viewingAreaHeight = dims.mobileSlideshowHeight;
						dims.viewingAreaWidth  = dims.mobileSlideshowWidth;
					} else if ( _this.isIpad && !_this.isMasthead ) {
						var dims = {};
						dims.slideshowHeight   = _this.params.iPadSlideshowHeight;
						dims.slideshowWidth    = _this.params.iPadSlideshowWidth;
						dims.viewingAreaHeight = _this.params.iPadViewingAreaHeight;
						dims.viewingAreaWidth  = _this.params.iPadViewingAreaWidth;
					} else {
						var dims = _this.params;
					}
					_this.slideshowHeight   = dims.slideshowHeight;
					_this.slideshowWidth    = dims.slideshowWidth;
					_this.viewingAreaHeight = dims.viewingAreaHeight;
					_this.viewingAreaWidth  = dims.viewingAreaWidth;
				}
				
				if ( _this.isIpad && !_this.isFullScreened ) {
					_this.slideshowHeight = _this.params.iPadSlideshowHeight;
				}
				
				var showCss = { height:_this.slideshowHeight+'px', width:_this.slideshowWidth+'px' };
				_this.$showWrap.css( showCss );
				$('.blankOverlay',_this.$imgViewingArea).css( showCss );
				
				var imgViewingAreaDimsCss = { height:_this.viewingAreaHeight+'px', width:_this.viewingAreaWidth+'px' };
				_this.$imgViewingArea.css(imgViewingAreaDimsCss);
				_this.$imgWraps.css(imgViewingAreaDimsCss);
				return _this;
			},
			
			
			/* apply calculated display dimension to an img element */
			applyImgDisplayDimensions: function($img,imgIndex){
				$img.attr('width',_this.params.imgs[imgIndex].displayWidth);
				$img.attr('height',_this.params.imgs[imgIndex].displayHeight);
				$img.parent().css('padding-top',_this.params.imgs[imgIndex].topPadding+'px');
			},
			
			
			
			
			// ----------------------- //
			// -- SLIDESHOW METHODS -- //
			// ----------------------- //
			
			/* start the slideshow */
			startShow: function(){
				_this.showPlaying = true;
				_this.$showWrap.addClass('playing').removeClass('paused');
				_this.iPadFadeControlsDelayed();
				_this.triggerTimedAdvance();
				return _this;
			},
			
			
			/* stop the slideshow */
			stopShow: function(){
				_this.showPlaying = false;
				_this.$showWrap.removeClass('playing').addClass('paused');
				_this.timer.stop();
				clearTimeout(_this.nextAdvance);
				return _this;
			},
			
			
			/* boolean test, are we continuing the show */
			continueShow: function(){
				if ( !_this.showPlaying ) return false;
				if ( _this.nextImgInShowIndex() == 0 && _this.opts.loopImages == false ) return false;
				return true;
			},
			
			
			/* trigger hold then advance */
			triggerTimedAdvance: function(){
				_this.nextAdvance = setTimeout(function(){
					_this.showImg(_this.nextImgInShowIndex());
				},_this.opts.holdTime);
				
				if ( _this.params.showTimer ) {
					_this.timer.start();
				}
				return _this;
			},
			
			
			/* start/stop timer */
			timer: {
				start: function(){
					if ( !_this.$timer ) return;
					var timerCss = {};
					timerCss[_this.c.longDimName] = _this.c.showParallelDim + 'px';
					_this.$timer.show().animate(timerCss,_this.opts.holdTime,'linear',_this.timer.stop);
				},
				stop: function(){
					if ( !_this.$timer ) return;
					if ( !_this.showPlaying ) {
						_this.$timer.stop();
					}
					_this.$timer.fadeOut(function(){ _this.$timer.css(_this.c.isVertical ? 'height' : 'width','0'); });
				}
			}, 
			
			
			/* animate to requested thumb page */
			gotoThumbPage: function(pageNum) {
				var toWhere = ( _this.c.thumbsViewportSize + _this.params.thumbPadding ) * ( pageNum - 1 );
				var dir = _this.c.isVertical ? 'top' : 'left'
				var animateCss = {};
				animateCss[dir] = '-'+toWhere+'px';
				if ( _this.c.currentThumbPage != pageNum ) {
					_this.animatingThumbPages = true;
					_this.$thumbsWrap.animate(
						animateCss,
						_this.params.thumbsPagingAnimation.speed,
						_this.params.thumbsPagingAnimation.easing,
						function(){ _this.animatingThumbPages = false; }
					);
				}
				_this.c.currentThumbPage = pageNum;
				_this.$thumbPageBtns.removeClass('disabled');
				if ( _this.c.currentThumbPage == _this.c.thumbPages ) {
					$('.nextPage',_this.$controls).addClass('disabled');
				}
				if ( _this.c.currentThumbPage == 1 ) {
					$('.prevPage',_this.$controls).addClass('disabled');
				}
			},
			



			// ------------------------ //
			// -- TRANSITION METHODS -- //
			// ------------------------ //
			
			/* transition from one img to next */
			showImg: function(imgIndex){
				if ( _this.params.imgs[imgIndex].isPreloaded ) {
					_this.loadingDelayIndication.hide();
					_this.stageImgForTransition(imgIndex);
					_this.animateTransition(_this.showPlaying);
				} else {
					_this.loadingDelayIndication.show(imgIndex);
					_this.delayTransition = setTimeout(function(){
						_this.showImg(imgIndex);
					},_this.delayTime);
				}
				return _this;
			},
			
			
			/* preparation for animating */
			stageImgForTransition: function(imgIndex){
				var stagedCss = _this.nextImgAnimateSetup;
				if ( _this.isTouchTransition && !_this.showPlaying ) {
					stagedCss = _this.touchedStagedImgSetup;
				}
				_this.$stagedImgWrap.css(stagedCss);
				_this.$stagedImg.attr('src',_this.imgSrc(imgIndex));
				_this.setImgLinkTo(_this.$stagedImgWrap,imgIndex);
				_this.applyImgDisplayDimensions(_this.$stagedImg,imgIndex);
				if ( _this.imgSrc(imgIndex).indexOf('.png') !== -1 ) {
					_this.$stagedImgWrap.addClass('png');
				} else {
					_this.$stagedImgWrap.removeClass('png');
				}
				_this.stagedImgIndex = imgIndex;
				return _this;
			},
			
			
			/* handle optional link-to URL for slideshow images */
			setImgLinkTo: function($imgWrap,imgIndex){
				if ( _this.params.imgs[imgIndex].linkToUrl ) {
					$imgWrap.attr('href',_this.params.imgs[imgIndex].linkToUrl).removeClass('no-link');
				} else {
					$imgWrap.attr('href','#').addClass('no-link');
				}
			},
			
			
			/* the actual animation of the img */
			animateTransition: function(playingWhenStarted){
				var currentImgAnimation, nextImgAnimation, transitionTime, easing;
				if ( _this.isTouchTransition && !_this.showPlaying ) {
					currentImgAnimation = ( _this.touchTransitionDir == 'next' ) ? _this.touchedNext_currentImgAnimation : _this.touchedPrev_currentImgAnimation;
					nextImgAnimation    = ( _this.touchTransitionDir == 'next' ) ? _this.touchedNext_nextImgAnimation    : _this.touchedPrev_nextImgAnimation;
					transitionTime      = 300;
					midTransitionDelay  = 0;
					easing              = 'jswing';
				} else {
					currentImgAnimation = _this.currentImgAnimation;
					nextImgAnimation    = _this.nextImgAnimation;
					transitionTime      = _this.opts.transitionTime;
					midTransitionDelay  = _this.midTransitionDelay;
					easing              = ( _this.opts.transitionType == 'steadyslide' ) ? 'linear' : 'jswing';
				}
				
				_this.$showWrap.addClass('transitioning');
				setTimeout(function(){
					_this.transitionHalfComplete();
				},_this.opts.transitionTime/2);
				_this.$visibleImgWrap.animate(currentImgAnimation,transitionTime,easing);
				setTimeout(function(){
					_this.$stagedImgWrap.animate(nextImgAnimation,transitionTime,easing,function(){
						_this.transitionComplete(playingWhenStarted);
					});
				},midTransitionDelay);
				_this.isTouchTransition = false;
				return _this;
			},
			
			
			/* method _this runs when transition half complete */
			transitionHalfComplete: function(){
				_this.visibleImgIndex = _this.stagedImgIndex;
				if ( _this.showThumbstrip ) {
					if ( !_this.c.userControlsThumbs ) {
						var goToThumbPage = Math.floor( ( _this.visibleImgIndex ) / _this.c.thumbsPerPage ) + 1;
						_this.gotoThumbPage( goToThumbPage );
					}
					$('img',_this.$thumbsViewport)
						.removeClass('active')
						.filter('img[index='+_this.visibleImgIndex+']')
						.addClass('active');
				}
			},
			
			
			/* method _this runs after transition completes */
			transitionComplete: function(playingWhenStarted){
				_this.$showWrap.removeClass('transitioning swiping');
				if ( playingWhenStarted == _this.showPlaying ) {
					_this.switchVisibleStaged();
					if ( _this.continueShow() ) {
						_this.triggerTimedAdvance();
					} else {
						_this.stopShow();
					}
					return _this;
				}
			},
			
			
			/* make current next and vice-versa */
			switchVisibleStaged: function(){
				
				// switch $ references
				var $newVisibleImgWrap, $newStagedImgWrap, $newVisibleImg, $newStagedImg;
				$newVisibleImgWrap    = _this.$stagedImgWrap;
				$newStagedImgWrap     = _this.$visibleImgWrap;
				_this.$visibleImgWrap = $newVisibleImgWrap;
				_this.$stagedImgWrap  = $newStagedImgWrap;
				$newVisibleImg        = _this.$stagedImg;
				$newStagedImg         = _this.$visibleImg;
				_this.$visibleImg     = $newVisibleImg;
				_this.$stagedImg      = $newStagedImg;
				
				// switch classes and CSS
				_this.$visibleImgWrap
					.removeClass('nextImg')
					.addClass('currentImg')
					.css('z-index','1');
				_this.$stagedImgWrap
					.removeClass('currentImg')
					.addClass('nextImg')
					.hide();
				return _this;
			},
			
			
			/* define specific transition */
			defineTransition: function(){
				switch ( _this.opts.transitionType ) {
					case 'steadyslide': // fallthrough
					case 'slide':
						_this.currentImgAnimation = { left: '-'+_this.slideshowWidth+'px' };
						_this.nextImgAnimation    = { left: '0' };
						_this.nextImgAnimateSetup = { left: _this.slideshowWidth+'px', display:'block', zIndex:'2' };
						if ( _this.opts.transitionType == 'steadyslide' && _this.opts.holdTime !== 0 ) {
							_this.opts.transitionTime = _this.opts.holdTime;
							_this.opts.holdTime = 0;
						}
						break;
					case 'topslide':
						_this.currentImgAnimation = { top: _this.slideshowHeight+'px' };
						_this.nextImgAnimation    = { top: '0' };
						_this.nextImgAnimateSetup = { top: '-'+_this.slideshowHeight+'px', display:'block', zIndex:'2' };
						break;
					case 'fade': // fallthrough
					case 'crossfade':
					default:
						_this.currentImgAnimation = { opacity: ( _this.opts.transitionType == 'crossfade' && _this.isMasthead ) ? 1 : 0 };
						_this.nextImgAnimation    = { opacity: 1 };
						_this.nextImgAnimateSetup = { top:'0', left:'0', opacity:'0', display:'block', zIndex:'2' };
						if ( _this.opts.transitionType == 'fade' ) {
							_this.midTransitionDelay = _this.opts.transitionTime;
						}
						break;
						
				}
				if ( _this.isMobile || _this.isIpad ) {
					_this.touchedNext_currentImgAnimation = { opacity: 1, left: '-'+_this.slideshowWidth+'px', right: 'auto' };
					_this.touchedNext_nextImgAnimation    = { opacity: 1, left: '0', right: 'auto' };
					_this.touchedNext_nextImgAnimateSetup = { opacity: 1, left: _this.slideshowWidth+'px', display:'block', zIndex:'2', right: 'auto' };
					_this.touchedPrev_currentImgAnimation = { opacity: 1, left: ''+_this.slideshowWidth+'px' };
					_this.touchedPrev_nextImgAnimation    = { opacity: 1, right: '0', left: 'auto' };
					_this.touchedPrev_nextImgAnimateSetup = { opacity: 1, right: _this.slideshowWidth+'px', display:'block', zIndex:'2', left: 'auto' };
				}
				return _this;
			},
			
			
			touchPrevNext: function(isNext){
				_this.stopShow();
				if ( _this.$showWrap.hasClass('transitioning') ) {
					return false;
				}
				_this.isTouchTransition = true;
				if ( isNext ) {
					_this.touchTransitionDir = 'next';
					_this.touchedStagedImgSetup = _this.touchedNext_nextImgAnimateSetup;
					_this.showImg(_this.nextImgInShowIndex());
				} else {
					_this.touchTransitionDir = 'prev';
					_this.touchedStagedImgSetup = _this.touchedPrev_nextImgAnimateSetup;
					_this.showImg(_this.prevImgInShowIndex());
				}
			},
			
			
			/* turn on/off delaying state */
			loadingDelayIndication: {
				show: function(imgIndex){
					_this.$showWrap.addClass('delaying');
					_this.$loadingSpinner.fadeIn();
				},
				hide: function(){
					_this.$showWrap.removeClass('delaying');
					_this.$loadingSpinner.fadeOut();
				}
			},
	
			
			
			
			// --------------------- //
			// -- UTILITY METHODS -- //
			// --------------------- //
			
			/* return src attribute based on index */
			imgSrc: function(imgIndex){
				return _this.params.imgs[imgIndex].fullsizeSrc;
			},
			
			
			cssToArgs: function(css){
				for ( var i = 1; i < arguments.length; i++ ) {
					arguments[i].css(css);
				};
				return _this;
			},

			
			/* return src attribute of next image to be shown */
			nextImgSrc: function(){
				return imgIndex.imgSrc(_this.nextImgInShowIndex());
			},


			/* return index of next image in order */
			nextImgInShowIndex: function(){
				return ( ( _this.visibleImgIndex + 1 ) > ( _this.params.imgs.length - 1 ) ) ? 0 : _this.visibleImgIndex + 1;
			},
			
			/* return index of prev image in order */
			prevImgInShowIndex: function(){
				return ( ( _this.visibleImgIndex - 1 ) < 0 ) ? _this.params.imgs.length - 1 : _this.visibleImgIndex - 1;
			},

			
			/* (int) get current milleseconds */
			currentTime: function(){
				var now = new Date();
				return now.getTime();
			}
		};
		
		ppSlideshow.init($(this));

	});
	
};

/* lazyloader modified, from: http://pastebin.com/eegD9UHf */
(function($) {

    $.fn.lazyload = function(options) {
        var settings = {
            threshold : 2250
        };
                
        if( options ) {
            $.extend(settings, options);
        }
		
        var elements  = this;
		var positions = {};
		var cantFade  = $('body').hasClass('cant-fade-imgs-with-black');
		var lazyloadShow = function(loadedImg){
			cantFade ? loadedImg.show() : loadedImg.css('opacity',0).animate({opacity:1},300);
		};
		
		// on window scroll, check position of images + cause those within threshold to appear
		$(window).bind("scroll", function(event) {
			var _top = $(window).scrollTop();
			var _bottom = _top + $(window).height() + settings.threshold;
			for (var pos in positions) {
				if ( pos <= _bottom ) {
					for (var ele in positions[pos]) {
						ele = positions[pos][ele]
						$(ele).addClass("lazyload-loading").trigger("appear");
					}
					// unset triggered position so that we don't trigger it again
					positions[pos] = [];
				}
			}

			// remove loaded images from elements to loop through
			var temp = $.grep(elements, function(element) {
				return !element.loaded;
			});
			elements = $(temp);
		});
        
		// initialize every lazy-loaded image.  hide, store loaded var, then bind appear event
        this.each(function() {
            var _self = this;
            _self.loaded = false;
            
            // bind the actual appear event
            $(_self).one("appear", function() {
				/* we call the slideshow function before actually loading to workaround
				   an IE8 issue where the imageLoaded function was being called before
				   lazyloader was able to clean up by removing lazyloading class */
				if ( $(_self).hasClass('ss-first-img' ) ) {
					$(_self).addClass('lazy-load-initiated');
					ppSetupSlideshows($(_self).parent());
				}
                if (!this.loaded) {
                    $("<img />").bind("load", function() {
    		            $(_self)
		                    .attr("src", $(_self).attr("lazyload-src"))
							.removeClass("lazyload-loading");
						lazyloadShow($(_self));
		                _self.loaded = true;
						
		            })
		            .attr("src", $(_self).attr("lazyload-src"));
                };
            });
        });

		// create lookup table of positions for all lazyloaded imgs
		elements.each(function() {
			_p = $(this).offset().top;
			if(positions[_p]==undefined) {
				positions[_p] = [];
			}
			positions[_p].push(this);
		});
        
        // trigger window scroll to force any images to appear before any scrolling
        $(window).trigger("scroll");
        return this;
    };
})(jQuery);
var cf = {};
var ppContactForm = {
	
	init: function(){
		cf = this;
		cf.formValid = true;
		cf.validationEvents();
		cf.menuLinkClicks();
		cf.submitEvent();
		cf.handleHash();
	},
	
	
	handleHash: function(){
		var hash = window.location.hash.substr(1);
		if ( hash === 'contact-form' ) {
			cf.toggleDisplay();
		}
		if ( hash === 'error' ) {
			$('#pp-contact-error-msg')
				.css('display', 'block')
				.animate({opacity: 1.0}, 3500, function(){cf.toggleDisplay()})
				.fadeTo(500,0)
				.slideUp(300)
				.html('<p>Error submitting form, please try again.</p>');
		}
		if ( hash === 'success' ) {
			$('#pp-contact-success-msg')
				.css('display', 'block')
				.delay(3500)
				.fadeTo(500,0)
				.slideUp(300)
				.html('<p>Form submitted successfully, thank you.</p>');
		}
		
		$('a[href*=#contact-form]').live('click',function(){
			cf.toggleDisplay();
		});
	},

	
	menuLinkClicks: function(){
		$('a.show-hidden-contact_form').click(function(){
			cf.toggleDisplay($(this));
			return false;
		});
	},
	
	
	toggleDisplay: function(clicked){
		if ( !$('#contactform').length ) {
			ppThrob.start(clicked);
			$('#contact-form').load(prophoto_info.theme_url+'/includes/contact-form.php?ajax=1', function(){
				cf.scrollToFormTop(function(){
					if ( $('#contact-form .pp-html-twitter-widget').length ) {
						ppTwitterWidgetsGetTweets( $('#contact-form' ) );
						ppSlidingTwitterControls( $('#contact-form' ) );
					 }
					ppThrob.stop(clicked);
					$('#contact-form').slideToggle(500);
					$('#referpage').val(window.location);
					$('a.show-hidden-contact_form').unbind('click').click(function(){
						$('#contact-form').slideToggle(500);
					});
					cf.validationEvents();
					ppJSForContext( $('#contact-form') );
				});
				$('html').animate( { scrollTop:$('header').height() + 74 }, 450, 'swing', function(){
					
				});
			});
		} else {
			cf.scrollToFormTop(function(){
				jQuery('#contact-form').slideToggle(500);
			});
		}
	},
	
	
	scrollToFormTop: function(callback){
		$('body').animate( { scrollTop:$('header').height() + 74 }, 450, 'swing', function(){
			callback();
		});
	},


	validationEvents: function(){
		$('#contactform .pp-required-field input[type=text],#contactform textarea').blur(function(){
			
			if ( !$('#contactform').hasClass('submitted') ) {
				return;
			}
			
			var field = $(this);

			if ( field.val() == '' || ( field.attr('id') == 'email' && !cf.emailValid() ) ) {
				field.parents('div.pp-field').addClass('p4-has-error');
				cf.formValid = false;
			
			} else {
				field.parents('div.pp-field').removeClass('p4-has-error');
			}
		});
	},
	
	submitEvent: function(){
		$('#contactform').submit(function(){
			$(this).addClass('submitted');
			cf.formValid = true;
			$('#contactform input[type=text], #contactform textarea').blur();
			return cf.formValid;
		});
	},
	
	emailValid: function() {
		return $('#contact-form input#email').val().match(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	}
	
};

ppContactForm.init();
	



function ppFormatCmtMargins() {
	jQuery('.comments-body div.pp-comment p').not(':last-child').css('margin-bottom', '.6em');
	jQuery('.comments-body div.pp-comment').not(':last-child').css('border-bottom-width', '1');
	jQuery('.comments-body div.pp-comment:last-child').addClass('last-comment');
}function ppAjaxAddComment() {

	jQuery('.addacomment a').click(function(){

		

		// data about comment area, passed to callbacks
		var c = new Object;
		c.clicked_btn  = jQuery(this);
		c.permalink    = c.clicked_btn.attr('href');
		c.section      = c.clicked_btn.parents('.article-comments');
		c.form_holder  = c.section.next();
		c.form_load_url     = c.permalink.replace('#', ' #');
		c.comments_load_url = c.permalink.replace('#addcomment', ' .comments-body-inner');		
		c.count_load_url    = c.permalink.replace('#addcomment', ' .comments-count');

		// form already loaded, show it
		if ( jQuery('.add-comment-form-wrap', c.form_holder).length ) {
			c.form_holder.slideDown();

		// ajax load comment submission form
		} else {
			ppThrob.start(c.clicked_btn);
			c.form_holder.load(c.form_load_url, function(){
				ppCommentFormAjaxLoaded(c);
			});
		}

		return false; // disable normal click behavior
	});
}


/* when contact form is loaded via ajax: show form and bind ajax submit to it */
function ppCommentFormAjaxLoaded(c) {
	c.form = jQuery('form', c.form_holder);
	ppThrob.stop(c.clicked_btn);

	// add cancel reply button
	jQuery('input#submit', c.form)
		.after('<input class="cancel-reply" type="submit" value="Cancel Reply" />')
		.next()
		.click(function(){
			c.form_holder.slideUp();
			return false;
		});

	// show form
	c.form_holder.slideDown();

	// bind an ajax form submission
	c.form.submit(function(){
		ppCommentFormAjaxSubmit(c);
		return false; // disable normal submission of form
	});
}


/* our custom ajax hijack of comment form submission */
function ppCommentFormAjaxSubmit(c) {
	ppThrob.start(jQuery('#submit', c.form));
	jQuery.ajax({
		type: "POST",
		url: c.form.attr('action'),
		data: c.form.serialize(),
		timeout: 6000,
		success: function(){
			ppCommentAjaxUpdate(c);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			setTimeout( function(){
				var comment = encodeURIComponent(jQuery('textarea', c.form).val());
				window.location.href = c.permalink+'-error-'+comment;
			}, 500 );
			// try to log error
			jQuery.post( prophoto_info.url+'/', { 
				'ajax_comment_error' : '1', 
				'XMLHttpRequest' : XMLHttpRequest, 
				'textStatus' : textStatus, 
				'errorThrown' : errorThrown 
			});
		}
	});
}


/* after commented submitted via ajax: update the comment area accordingly */
function ppCommentAjaxUpdate(c) {
	// reload and show the comments area via ajax, also hide comment form
	c.section.children('.comments-body').load(c.comments_load_url, function(){

		ppFormatCmtMargins();

		// update the comments count
		jQuery('.comments-count', c.section).load(c.count_load_url);

		// show the comments, including new one, scrolled to bottom
		jQuery(this).slideDown(function(){

			// scroll to bottom of comment section
			jQuery(this).attr({scrollTop:jQuery(this).attr('scrollHeight')});

			// throb the new comment for two seconds
			ppThrob.start(jQuery('.comments-body-inner .pp-comment:last', c.section));
			setTimeout(function(){
				ppThrob.stop(jQuery('.comments-body-inner .pp-comment:last', c.section));
			}, 2000);

			// hide and remove comment form
			c.form_holder.slideUp(function(){
				jQuery('.add-comment-form-wrap', this).remove();
			});
		});

		// set the comment count to active state
		jQuery(c.section).addClass('comments-shown');

	});
}


/* handle redirects from ajax comment submission errors */
function ppAjaxCmtSubmitError() {
	if ( /#addcomment-error-/.test(window.location.hash) == false ) return;
	var comment = window.location.hash.replace('#addcomment-error-', '');
	jQuery('textarea').focus().val(comment.replace(/%0A/g, "\n"));
	jQuery('#addcomment-error').show();
	jQuery(window).scrollTop(jQuery('#addcomment').offset().top);
}

ppAjaxAddComment();
ppAjaxCmtSubmitError();
ppFormatCmtMargins();



	function ppShowHideComments() {
		jQuery('.comments-count').click(function(){
			var comments_section = jQuery(this).parents(".article-comments");
			if ( jQuery('.comments-body-inner div', comments_section).length ) {
				comments_section.toggleClass('comments-shown');
				jQuery('.comments-body', comments_section).slideToggle(400);
			}
		});
	}
	ppShowHideComments();

	function ppMinimaCountHover() {
		jQuery('.comments-count p:not(.no-comments)').mouseover(function(){
			old_hover = jQuery(this).css('color');
			old_dec = jQuery(this).css('text-decoration');
			jQuery(this).css('color', '#36e4da' );
			jQuery(this).css('text-decoration', 'none');
		}).mouseout(function(){
			jQuery(this).css('color', old_hover);
			jQuery(this).css('text-decoration', old_dec); 
		});
	}
	ppMinimaCountHover();		
		function ppSlidingTwitterControls(context) {
			if ( context == undefined ) {
				context = jQuery('body')
			}
			jQuery('.sliding .controls a',context).click(function(){
				ppSlidingTwitterControlClick(jQuery(this));
			});
		}
		
		function ppSlidingTwitterControlClick(this_click) {
			if ( this_click.hasClass('disabled') ) return false;
			var click_type    = ( this_click.hasClass('prev') ) ? 'prev' : 'next';
			var this_widget   = this_click.parents('.pp-twitter-slider');
			var tweet_height  = parseInt(jQuery('.tweet_height', this_widget).text()) + 5; // 5 = padding below
			var current_tweet = parseInt(jQuery('.twitter_current', this_widget).text());
			var num_tweets    = parseInt(jQuery('.twitter_count', this_widget).text());
			( click_type == 'prev' ) ? current_tweet-- : current_tweet++;
			var new_top = -(current_tweet * tweet_height);
			jQuery('.controls a', this_widget).removeClass('disabled');
			// disable prev/next button when appropriate
			if ( current_tweet == 0 ) {
				jQuery('.prev', this_widget).addClass('disabled');
			} else if ( current_tweet == ( num_tweets - 1 ) ) {
				jQuery('.next', this_widget).addClass('disabled');
			}
			jQuery('.twitter_current', this_widget).text(current_tweet);
			jQuery('.viewer ul', this_widget).animate({top: new_top+'px'},210,'swing');
		}
		
		ppSlidingTwitterControls();

// subroutine for building the list of tweets from the .json data
function ppTwitterHtml( tweets, li_height ) {
	var height = ( li_height ) ? ' style="height:'+li_height+'px;"' : '';
	var twitter_html = [];
	for ( var i = 0; i<tweets.length; i++ ) {
		var username = tweets[i].user.screen_name;
		var status = tweets[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
	 		return '<a href="'+url+'">'+url+'</a>';
		}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
	 		return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
		});
		twitter_html.push('<li'+height+'><span>'+status+'</span> <a class="twitter-time" href="http://twitter.com/#!/'+username+'/status/'+tweets[i].id_str+'">'+ppTwitterTime(tweets[i].created_at)+'</a></li>');
	}
	return twitter_html.join('');
}



// subroutine for returning nicely formatted time since tweeting
function ppTwitterTime(time_value) {
	var values = time_value.split(" ");
	time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
	var parsed_date = Date.parse(time_value);
	var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
	var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
	delta = delta + (relative_to.getTimezoneOffset() * 60);

	if (delta < 60) {
		return 'less than a minute ago';
	} else if (delta < 120) {
		return 'about a minute ago';
	} else if (delta < (60*60)) {
		return (parseInt(delta / 60)).toString() + ' minutes ago';
	} else if (delta < (120*60)) {
		return 'about an hour ago';
	} else if (delta < (24*60*60)) {
		return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
	} else if (delta < (48*60*60)) {
		return '1 day ago';
	} else {
		return (parseInt(delta / 86400)).toString() + ' days ago';
	}
}



// requests .json twitter info for each html widget, passes object to correct callback
function ppTwitterWidgetsGetTweets( context ) {
	$('.pp-html-twitter-widget',context).each(function(){
		var twitter_name  = $('.twitter_name',this).text();
		var twitter_count = $('.twitter_count',this).text();
		var this_widget   = $(this);
		// set context - which widget area?
		if ( this_widget.parents('#bio').length ) {
			var context = 'Bio';
		} else if ( this_widget.parents('#sidebar').length ) {
			var context = 'Sidebar';
		} else if ( this_widget.parents('.drawer').length ) {
			var context = 'Drawer';
		} else if ( this_widget.parents('#contact-form').length ) {
			var context = 'Contact';
		} else {
			var context = 'Footer';
		}
		$.getScript( 'http://twitter.com/statuses/user_timeline/' + twitter_name + '.json?callback=pp'+context+'TwitterHtml&count='+ twitter_count );
	});
}
ppTwitterWidgetsGetTweets($('body'));



// wrapper functions to call the twitter html function for the right widget context
window.ppBioTwitterHtml = function(tweets) {
	ppLoadTwitterHtml(tweets, '#bio');
}
window.ppSidebarTwitterHtml = function(tweets) {
	ppLoadTwitterHtml(tweets, '#sidebar');
}
window.ppDrawerTwitterHtml = function(tweets) {
	ppLoadTwitterHtml(tweets, '.drawer');
}
window.ppFooterTwitterHtml = function(tweets) {
	ppLoadTwitterHtml(tweets, '#footer');
}
window.ppContactTwitterHtml = function(tweets) {
	ppLoadTwitterHtml(tweets, '#contact-form');
}



// subroutine for printing twitter html update list in correct widget
function ppLoadTwitterHtml(tweets, id) {
	var this_widget = $(id+' .pp-html-twitter-widget-'+tweets[0].user.screen_name.toLowerCase());
	if ( $('.tweet_height', this_widget ).length ) {
		var height = parseInt( $( '.tweet_height', this_widget ).text());
	} else {
		var height = '';
	}
	$('ul', this_widget ).html( ppTwitterHtml( tweets, height ) );
	$('.sliding .controls a', this_widget ).css('display','block');
}window.ppNavTwitter = function(tweets) {
	var ID = tweets[0].user.screen_name;
	$('li.twitter-id-'+ID+' ul').html(ppTwitterHtml(tweets));
}
function ppNavTwitterDropdown() {
	$('li.mi-twitter').each(function(){
		var twitterID = $('.twitterID',$(this)).text();
		var numTweets = $('.numTweets',$(this)).text();
		$.getScript( 'http://twitter.com/statuses/user_timeline/'+twitterID+'.json?callback=ppNavTwitter&count='+numTweets );
	});
}
ppNavTwitterDropdown();
var ppLightBoxInfo = {
	img_loading      : 'http://www.thepetproject.com.au/wp-content/themes/prophoto4/images/lightbox-ico-loading.gif',
	img_btn_prev     : 'http://www.thepetproject.com.au/wp-content/themes/prophoto4/images/lightbox-btn-prev.gif',
	img_btn_next     : 'http://www.thepetproject.com.au/wp-content/themes/prophoto4/images/lightbox-btn-next.gif',
	img_btn_close    : 'http://www.thepetproject.com.au/wp-content/themes/prophoto4/images/lightbox-btn-close.gif',
	img_blank        : 'http://www.thepetproject.com.au/wp-content/themes/prophoto4/images/lightbox-blank.gif',
	img_fadespeed    : 400,
	border_width     : '10',
	resize_speed     : 400,
	fixed_navigation : false,
	btns_opacity     : 0.65,
	btn_fadespeed    : 200,
	overlay_color    : '#000000',
	overlay_opacity  : 0.8,
	translate_image  : 'Image',
	translate_of     : 'of'
};


ppLightboxGallery = function(context) {

	$('.pp-lightbox-not-loaded',context).each(function(){

		$('a',$(this)).prophotoLightbox(ppLightBoxInfo);
		
		$('.pp-lightbox-thumbs a',$(this)).css('opacity', 0.65).hover(function(){
			$(this).stop().animate({opacity:1},200);
		}, function(){
			$(this).stop().animate({opacity:0.65},200);
		});
		
		$(this).removeClass('pp-lightbox-not-loaded');
	});
	
};
	function ppNavMenuOpacity() {	
		if (!$.browser.msie) {	
			$('nav .primary-nav-menu li ul').css('opacity', 0.93);
		}
	}
	ppNavMenuOpacity();function ppFormatNavMenu() {
	// remove tooltips
	$('nav .primary-nav-menu li ul a').attr('title','');
	
	// add arrow to dropdown with nested menu
	$('nav .primary-nav-menu li ul li:has(ul)').each(function(){
		var link = $(this).children('a');
		var linktext = link.html();
		link.html(linktext+' &raquo;');
	});
	// add underline to parent while child is being viewed
	$('nav .primary-nav-menu li ul li ul').hover(function(){
		$(this).parent().children('a').css('text-decoration','underline');
	},function(){
		$(this).parent().children('a').css('text-decoration','none');
	});

	$('body.headerlayout-pptclassic #primary-nav-ajax-receptacle').remove().insertAfter('#logo-wrap');
	
}
ppFormatNavMenu();	
	var centerMenuCount = 0;
	
	var centerMenu = function(context){
		
		if ( ppCssIsLoaded() ) {
			
			var menu      = $('ul.'+context+'-nav-menu'),
			    wrapWidth = menu.parent().width(),
				rightPad  = $('li:first',menu).css('margin-right'),
				menuWidth = menu.width() - parseInt( rightPad );
				
			menu.css( 'padding-left', parseInt( (wrapWidth - menuWidth) / 2 ) + 'px' );
			
			// run additional times to correct miscalculations based on 
			// custom fonts that have not completely loaded
			centerMenuCount = centerMenuCount + 1;
			if ( centerMenuCount < 5 ) {
				setTimeout( function(){ centerMenu(context); }, 150 );
			} else if ( centerMenuCount > 100 ) {
				return;
			}
			
		} else {
			setTimeout( function(){ centerMenu(context); }, 50 );
		}
		
	};
	centerMenu('primary');

	if ( "ontouchstart" in document.documentElement ) {
		
		var touchstartTimeout = false;
		$('.suckerfish li').bind('touchstart',function(e){
			clearTimeout(touchstartTimeout);
			var touchedItem = $(this);
			$('.suckerfish li').not(touchedItem.parents()).removeClass('sfhover');
			touchedItem.addClass('sfhover');
			if ( !$(e.target).parent().hasClass('has-children') ) {
				e.stopPropagation();
				return true;
			}
			touchstartTimeout = setTimeout(function(){
				$('.suckerfish li').removeClass('sfhover');
			},6000);
			e.stopPropagation();
			return false;
		});
		$(document).bind('touchstart', function(){
			if ( $('.suckerfish li.sfhover').length ) {
				$('.suckerfish li').removeClass('sfhover');
			}
		});
	}

	
	$('a.show-hidden-bio').click(function(){
		$('#bio').slideToggle(350);
		return false;
	});	
		
	function ppImageProtection(context) {
		if ( !$('body').is('.pp-dev, .pp-tech') ) {
			$('.article-content img',context)
				.not('.exclude, .thumbnail, .attachment-thumbnail')
				.add('.pp-lightbox-thumbs img')
				.bind('contextmenu', function(){return false;});
			$('#lightbox-nav a,#lightbox-nav,.pp-slideshow').live('contextmenu',function(){return false;});
		}
	}
	

$('.post:last').addClass('last-post');


$('a.no-link').click(function(){
	return false;
});


 if ( !$("body").hasClass("mobile") ) {
	$('.article-content img[lazyload-src]').lazyload();
 }

function ppUnObfuscate(context) {
	var toHTML = function(codes){
		var chars = codes.split(','), HTML = '';
		for ( i = 0; i <= chars.length; i++ ) {
			if ( chars[i] ) {
				HTML = HTML + String.fromCharCode(chars[i]);
			}
		}
		return HTML;
	};
	$('.jsobf',context).each(function(){
		var aTag  = $(this).parents('a');
		var inner = ( $(this).hasClass('img') ) ? $(this).html() : toHTML($(this).text());
		aTag.attr('href',toHTML(aTag.attr('href')));
		aTag.html(inner);
	});
}


$('a[href="#top"]').click(function(){
	$('html, body').animate( { scrollTop:0 }, 500, 'easeOutQuad' );
	return false;
});

$('a.type-share_on_facebook,a.type-tweet_this_url,a.type-subscribe_by_email').click(function(){
	var height = $(this).hasClass('type-subscribe_by_email') ? 550 : 250;
	window.open($(this).attr('href'),$(this).attr('href'),'location=0,menubar=0,height='+height+',width=600,toolbar=0,scrollbars=0,status=0');
	return false;
});



/* instrument the animations for the sidebar tabs */
function ppSidebarDrawers() {
	
	// we need to know the stylesheet is loaded so we can calculate widths accurately
	if ( !ppCssIsLoaded() ) {
		setTimeout( function(){ ppSidebarDrawers(); }, 200 );
		return;
	}
	
	var drawer_padding = 40;

	// set initial opacity and height of drawers
	$('.drawer_content, .tab').css('opacity', 0.85);
	$('.drawer_content').css('height', ($(window).height() - 40) + 'px' ); 

	// function-scoped timeout var object
	var p4_close_drawer_timeout = new Object();

	// instrument each drawer
	$('.drawer').each(function(){
		var drawer = $(this);
		var id     = drawer.attr('id');
		var tab    = $('.tab', this);
		var width  = parseInt( $('.drawer_content', drawer).css( 'width' ) ) + 40;
		var speed  = parseInt( width * 0.75 );

		// show the drawer on tab mouseover
		tab.mouseover(function(){
			drawer
				.css( 'z-index', '181' )
				.animate( { left:'0px' }, speed, 'swing' )
				.addClass( 'open' );
		});

		// handle iphone/ipad show/hides
		if ( isTouchDevice ) {
			$('#inner-wrap').unbind('touchstart').bind('touchstart',function(){
				drawer.mouseleave();
			});
			tab.bind('touchstart',function(){
				if ( drawer.hasClass('open') ) drawer.trigger('mouseleave');
			});
		}

		// set the timeout to close drawer on mouseleave
		drawer.mouseleave(function(){
			var delay = isTouchDevice ? 1 : 1000;
			clearTimeout( p4_close_drawer_timeout[id] );
			p4_close_drawer_timeout[id] = setTimeout( function(){
				drawer.animate( { left:'-' + width + 'px' }, speed, 'swing', function(){
					drawer.css( 'z-index', '180' ).removeClass('open');
				} );
			}, delay );
		});

		// restart the close drawer timout on mouseenter
		drawer.mouseenter(function(){
			clearTimeout( p4_close_drawer_timeout[id] );
		});
	});	
}

ppSidebarDrawers();

	ppGrid = {
		
		events: function(context){

			if ( !isTouchDevice ) {
				$('.grid-style-img_rollover_text .grid-item',context).click(function(){
					var innerLink = $('a:first',this);
					if ( innerLink.hasClass('popup-slideshow') ) {
						innerLink.click();
					} else {
						window.location.href = innerLink.attr('href');
					}
				});
				$('.grid-style-img_rollover_text .grid-item',context).hover(function(){
					$('.grid-overlay',this).fadeIn('fast');
				},function(){
					$('.grid-overlay',this).fadeOut('fast');
				});

			} else {
				$('.grid-style-img_rollover_text .grid-item',context).bind('touchstart',function(e){
					$('.grid-overlay',this).fadeIn('fast').delay(4000).fadeOut('fast');
					return ( e.target.nodeName = 'A' );
				});
			}
		}
	};

	
	ppJSForContext = function( context ) {
		window.ppSetupSlideshows( context );
		window.ppLightboxGallery( context );
		ppImageProtection( context );
		ppUnObfuscate( context );
		ppGrid.events( context );
		context.trigger('contextual_js_complete');
	};
	
	ppJSForContext($('body'));
	
	
});var prophoto_info = {"url":"http://www.thepetproject.com.au","theme_url":"http://www.thepetproject.com.au/wp-content/themes/prophoto4","wpurl":"http://www.thepetproject.com.au","folder_url":"http://www.thepetproject.com.au/wp-content/uploads/p4","static_resource_url":"http://prophoto.s3.amazonaws.com","content_margin":"20","is_dev":false,"is_tech":false,"wpversion":"331","svn":"914","payer_email":"alex@savvystudios.com.au","txn_id":"2EB4297894058494N","purch_time":"1278918818","plugins":"akismet/akismet.php post-to-facebook/post-to-facebook.php sem-dofollow/sem-dofollow.php wp-db-backup/wp-db-backup.php"};/* allow some console usage in IE, prevent js errors if console.x() calls left in production code */
if (  typeof console == 'undefined' ) {
	window.console = {
		log: function(msg){
			if ( /ieconsole/.test(window.location.href) || prophoto_info.is_dev ) {
				if ( !jQuery('#ielog').length ) {
					jQuery('body').append('<p id="ielog"></p>');
					jQuery('#ielog').append('<strong>CONSOLE:</strong>');
				}
				jQuery('#ielog').append('&nbsp;'+msg+'<hr />');
			}
		},
		error: function(){},
		trace: function(){},
		dir: function(){},
		warning: function(){}
	};
}/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 *//* 
 image loaded function, works like $.load() func, except
 always fires an event, even with cached images
 marginally modified from orig here: http://gist.github.com/268257
 */


jQuery.fn.imageLoaded = function(callback){
	var elems = this.filter('img'),
	len   = elems.length;

	elems.bind('load error',function(){
		callback.call(this);
	
	}).each(function(){
		
		// cached images don't fire load sometimes, so we reset src.
		if (this.complete || this.complete === undefined || ( this.complete === false && navigator.appVersion.indexOf( 'MSIE 9' ) !== -1 ) ) {
			var src = this.src;
			
			// webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
			// data uri bypasses webkit log warning (thx doug jones)
			this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
			this.src = src;
		}  
	}); 
	
	return this;
};(function($) {
    $.fn.prophotoLightbox = function(ppLightboxInfo) {
		var pp = ppLightboxInfo;
		var isMobile = $('body').hasClass('mobile');
        settings = {
            overlayBgColor: pp.overlay_color,
            overlayOpacity: pp.overlay_opacity,
            fixedNavigation: pp.fixed_navigation,
            imageLoading: pp.img_loading,
            imageBtnPrev: pp.img_btn_prev,
            imageBtnNext: pp.img_btn_next,
            imageBtnClose: pp.img_btn_close,
            imageBlank: pp.img_blank,
            containerBorderSize: isMobile ? 5 : pp.border_width,
            containerResizeSpeed: pp.resize_speed,
            txtImage: pp.translate_image,
            txtOf: pp.translate_of,
            keyToClose: 'c',
            keyToPrev: 'p',
            keyToNext: 'n',
            imageArray: [],
            activeImage: 0
        };
        var jQueryMatchedObj = this;

        function _initialize() {
            _start(this, jQueryMatchedObj);
			$(window).bind('orientationchange',function(){
				__resize();
				_set_image_to_view();
			});
            return false;
        }

        function _start(objClicked, jQueryMatchedObj) {
            $('embed, object, select').css({
                'visibility': 'hidden'
            });
            _set_interface();
            settings.imageArray.length = 0;
            settings.activeImage = 0;
			var href, actual_title, use_title;
            if (jQueryMatchedObj.length == 1) {
				href = objClicked.getAttribute('href');
				actual_title = objClicked.getAttribute('title');
				use_title = ( href.indexOf(actual_title) != -1 ) ? '' : actual_title;
                settings.imageArray.push(new Array(href, use_title));
            } else {
                for (var i = 0; i < jQueryMatchedObj.length; i++) {
					href = jQueryMatchedObj[i].getAttribute('href');
					actual_title = jQueryMatchedObj[i].getAttribute('title');
					use_title = ( href.indexOf(actual_title) != -1 ) ? '' : actual_title;
                    settings.imageArray.push(new Array(href, use_title));
                }
            }
            while (settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href')) {
                settings.activeImage++;
            }
            _set_image_to_view();
        }

        function _set_interface() {
            $('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box" class="unsized"><div id="lightbox-container-image"><div id="lb-img-wrap"><img id="lightbox-image"></div><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box" style="display:none"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
            var arrPageSizes = ___getPageSize();
            $('#jquery-overlay').css({
                backgroundColor: settings.overlayBgColor,
                opacity: settings.overlayOpacity,
                width: arrPageSizes[0],
                height: arrPageSizes[1]
            }).fadeIn();
            var arrPageScroll = ___getPageScroll();
			var topPad = isMobile ? 10 : 20;
            $('#jquery-lightbox').css({
                top: arrPageScroll[1] + 10,
                left: arrPageScroll[0]
            }).show();
            $('#jquery-overlay,#jquery-lightbox').click(function() {
                _finish();
            });
            $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
                _finish();
                return false;
            });
            $(window).resize(function() {
				if ( isMobile ) {
					return;
				}
                __resize();
            });
        }

		function __resize() {
			var arrPageSizes = ___getPageSize();
            $('#jquery-overlay').css({
                width: arrPageSizes[0],
                height: arrPageSizes[1]
            });
            var arrPageScroll = ___getPageScroll();
            $('#jquery-lightbox').css({
                top: arrPageScroll[1] + (arrPageSizes[3] / 10),
                left: isMobile ? 0 : arrPageScroll[0]
            });
		}

        function _set_image_to_view() {
	
            if (settings.fixedNavigation || isTouchDevice ) {
                $('#lightbox-image').fadeTo(pp.img_fadespeed, 0,
                function() {
					if (window.attachEvent) $('#lb-img-wrap').removeClass('loaded');
                    $('#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
					$('#lightbox-nav-btnPrev, #lightbox-nav-btnNext').show();
					if ( settings.activeImage == 0 ) $('#lightbox-nav-btnPrev').hide();
					if (settings.activeImage == (settings.imageArray.length - 1)) $('#lightbox-nav-btnNext').hide();
                    $('#lightbox-loading').show();
                    var objImagePreloader = new Image();
                    objImagePreloader.onload = function() {
                        $('#lightbox-image').attr('src', settings.imageArray[settings.activeImage][0]);
                        _resize_container_image_box(objImagePreloader.width, objImagePreloader.height);
                        objImagePreloader.onload = function() {};
                    };
                    objImagePreloader.src = settings.imageArray[settings.activeImage][0];
                });
            } else {
                $('#lightbox-image').fadeTo(pp.img_fadespeed, 0,
                function() {
                    $('#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
					if (window.attachEvent) $('#lb-img-wrap').removeClass('loaded');
					$('#lightbox-loading').show();
                    var objImagePreloader = new Image();
                    objImagePreloader.onload = function() {
                        $('#lightbox-image').attr('src', settings.imageArray[settings.activeImage][0]);
                        _resize_container_image_box(objImagePreloader.width, objImagePreloader.height);
                        objImagePreloader.onload = function() {};
                    };
                    objImagePreloader.src = settings.imageArray[settings.activeImage][0];
                });
            }

        };

        function _resize_container_image_box(intImageWidth, intImageHeight) {
			if ( isMobile ) {
				if ( $('html').hasClass('portrait') ) {
					if ( intImageWidth > 255 ) {
						intImageHeight = parseInt( ( 255 * intImageHeight ) / intImageWidth );
						intImageWidth  = 255;
					}
				} else {
					if ( intImageHeight > 225 ) {
						intImageWidth  = parseInt( ( 225 * intImageWidth ) / intImageHeight );
						intImageHeight = 225;
					}
				}
			}
            var intCurrentWidth  = $('#lightbox-container-image-box').width();
            var intCurrentHeight = $('#lightbox-container-image-box').height();
            var intWidth  = (intImageWidth + (settings.containerBorderSize * 2));
            var intHeight = (intImageHeight + (settings.containerBorderSize * 2));
            var intDiffW  = intCurrentWidth - intWidth;
            var intDiffH  = intCurrentHeight - intHeight;
            $('#lightbox-container-image-box').animate({
                width: intWidth,
                height: intHeight
            },
            settings.containerResizeSpeed,
            function() {
                _show_image();
				$('#lightbox-container-image-box').removeClass('unsized');
            });
            if ((intDiffW == 0) && (intDiffH == 0)) {
                if ($.browser.msie) {
                    ___pause(250);
                } else {
                    ___pause(100);
                }
            }
            $('#lightbox-container-image-data-box').css({
                width: intImageWidth
            });
            $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({
                height: intImageHeight + (settings.containerBorderSize * 2)
            });
        };
        function _show_image() {
            $('#lightbox-loading').hide();
			if (window.attachEvent) $('#lb-img-wrap').addClass('loaded');
            $('#lightbox-image').fadeTo(pp.img_fadespeed, 1,
            function() {
                _show_image_data();
                _set_navigation();
            });
            _preload_neighbor_images();
        };
        function _show_image_data() {
            $('#lightbox-container-image-data-box').fadeIn(500);
            $('#lightbox-image-details-caption').hide();
            if (settings.imageArray[settings.activeImage][1]) {
                $('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
            }
            if (settings.imageArray.length > 1) {
                $('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + (settings.activeImage + 1) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
            }
        }
        function _set_navigation() {
			$('#lightbox-nav').show();
            $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({
                'background': 'transparent url(' + settings.imageBlank + ') no-repeat'
            });
            if (settings.activeImage != 0) {
                if (settings.fixedNavigation || isTouchDevice ) {
                    $('#lightbox-nav-btnPrev').css({
                        'background': 'url(' + settings.imageBtnPrev + ') left 15% no-repeat',
                        'opacity': pp.btns_opacity
                    })
                    .unbind()
                    .bind('click',
                    function() {
                        settings.activeImage = settings.activeImage - 1;
                        _set_image_to_view();
                        return false;
                    });
                } else {
                    $('#lightbox-nav-btnPrev').unbind().hover(function() {
                        $(this).css({
                            'background': 'url(' + settings.imageBtnPrev + ') left 15% no-repeat',
                            'opacity': 0
                        }).fadeTo(pp.btn_fadespeed, pp.btns_opacity);
                    },
                    function() {
                        $(this).fadeTo(pp.btn_fadespeed, 0,
                        function() {
                            $(this).css({
                                'background': 'transparent url(' + settings.imageBlank + ') no-repeat'
                            });
                        });
                    }).show().bind('click',
                    function() {
                        settings.activeImage = settings.activeImage - 1;
                        _set_image_to_view();
                        return false;
                    });
                }
            } else {
				jQuery('#lightbox-nav-btnPrev').unbind().hide();
			}

            if (settings.activeImage != (settings.imageArray.length - 1)) {
                if (settings.fixedNavigation || isTouchDevice) {
                    $('#lightbox-nav-btnNext').css({
                        'background': 'url(' + settings.imageBtnNext + ') right 15% no-repeat',
                        'opacity': pp.btns_opacity
                    })
                    .unbind()
                    .bind('click',
                    function() {
                        settings.activeImage = settings.activeImage + 1;
                        _set_image_to_view();
                        return false;
                    });
                } else {
                    $('#lightbox-nav-btnNext').unbind().hover(function() {
                        $(this).css({
                            'background': 'url(' + settings.imageBtnNext + ') right 15% no-repeat',
                            'opacity': 0
                        }).fadeTo(pp.btn_fadespeed, pp.btns_opacity);
                    },
                    function() {
                        $(this).fadeTo(pp.btn_fadespeed, 0,
                        function() {
                            $(this).css({
                                'background': 'transparent url(' + settings.imageBlank + ') no-repeat'
                            });
                        });
                    }).show().bind('click',
                    function() {
                        settings.activeImage = settings.activeImage + 1;
                        _set_image_to_view();
                        return false;
                    });
                }
            } else {
				jQuery('#lightbox-nav-btnNext').unbind().hide();
			}
            _enable_keyboard_navigation();
        }
        function _enable_keyboard_navigation() {
            $(document).keydown(function(objEvent) {
                _keyboard_action(objEvent);
            });
        }
        function _disable_keyboard_navigation() {
            $(document).unbind('keydown');
        }
        function _keyboard_action(objEvent) {
            if (objEvent == null) {
                keycode = event.keyCode;
                escapeKey = 27;
            } else {
                keycode = objEvent.keyCode;
                escapeKey = objEvent.DOM_VK_ESCAPE;
            }
            key = String.fromCharCode(keycode).toLowerCase();
            if ((key == settings.keyToClose) || (key == 'x') || (keycode == escapeKey)) {
                _finish();
            }
            if ((key == settings.keyToPrev) || (keycode == 37)) {
                if (settings.activeImage != 0) {
                    settings.activeImage = settings.activeImage - 1;
                    _set_image_to_view();
                    _disable_keyboard_navigation();
                }
            }
            if ((key == settings.keyToNext) || (keycode == 39)) {
                if (settings.activeImage != (settings.imageArray.length - 1)) {
                    settings.activeImage = settings.activeImage + 1;
                    _set_image_to_view();
                    _disable_keyboard_navigation();
                }
            }
        }

        function _preload_neighbor_images() {
            if ((settings.imageArray.length - 1) > settings.activeImage) {
                objNext = new Image();
                objNext.src = settings.imageArray[settings.activeImage + 1][0];
            }
            if (settings.activeImage > 0) {
                objPrev = new Image();
                objPrev.src = settings.imageArray[settings.activeImage - 1][0];
            }
        }

        function _finish() {
			_disable_keyboard_navigation();
            $('#jquery-lightbox').remove();
            $('#jquery-overlay').fadeOut(function() {
                $('#jquery-overlay').remove();
            });
            $('embed, object, select').css({
                 'visibility': 'visible'
            });
        }

        function ___getPageSize() {
            var xScroll,
            yScroll;
            if (window.innerHeight && window.scrollMaxY) {
                xScroll = window.innerWidth + window.scrollMaxX;
                yScroll = window.innerHeight + window.scrollMaxY;
            } else if (document.body.scrollHeight > document.body.offsetHeight) {
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
            } else {
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
            }
            var windowWidth,
            windowHeight;
            if (self.innerHeight) {
                if (document.documentElement.clientWidth) {
                    windowWidth = document.documentElement.clientWidth;
                } else {
                    windowWidth = self.innerWidth;
                }
                windowHeight = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) {
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
            } else if (document.body) {
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }
            if (yScroll < windowHeight) {
                pageHeight = windowHeight;
            } else {
                pageHeight = yScroll;
            }
            if (xScroll < windowWidth) {
                pageWidth = xScroll;
            } else {
                pageWidth = windowWidth;
            }
            arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
            return arrayPageSize;
        };

        function ___getPageScroll() {
            var xScroll,
            yScroll;
            if (self.pageYOffset) {
                yScroll = self.pageYOffset;
                xScroll = self.pageXOffset;
            } else if (document.documentElement && document.documentElement.scrollTop) {
                yScroll = document.documentElement.scrollTop;
                xScroll = document.documentElement.scrollLeft;
            } else if (document.body) {
                yScroll = document.body.scrollTop;
                xScroll = document.body.scrollLeft;
            }
            arrayPageScroll = new Array(xScroll, yScroll);
            return arrayPageScroll;
        };

        function ___pause(ms) {
            var date = new Date();
            curDate = null;
            do {
                var curDate = new Date();
            }
            while (curDate - date < ms);
        };
        return this.unbind('click').click(_initialize);
    };
})(jQuery);var ppThrobIntervals = [];

var ppThrob = {
	
	start: function(item){
		if ( item == undefined ) {
			return;
		}
		item.addClass('throbbing');
		item.fadeOut(350);
		setInterval(function(){
			item.fadeIn(350);
		},350);
		ppThrobIntervals[this._uniqueID(item)] = setInterval(function(){
			if ( item.hasClass('throbbing') ) {
				item.fadeOut(350);
			}
		},700);
	},
	
	stop: function(item){
		if ( item == undefined ) {
			return;
		}
		item.removeClass('throbbing');
		clearInterval( ppThrobIntervals[this._uniqueID(item)] );
	},
	
	_uniqueID: function(item){
		return item.text() + item.attr('class') + item.parent().attr('id') + item.text().length + item.attr('class').length;
	}
}
var iconsole;

jQuery(document).ready(function($){
	
	window.iconsole = {

		initialized: false,

		log: function(msg,size){
			if ( !$('#iconsole').length ) {
				this.initialize();
			}
			this.console.append('<div>'+msg+'</div>');
			if ( size != "undefined") {
				$('#iconsole,#iconsole div').css('font-size',size+'px');
			}
		},

		initialize: function(){
			$('body').prepend('<div id="iconsole"></div>');
			this.console = $('#iconsole');
			$('div',this.console).live('touchend',function(){
				$(this).remove();
				return false;
			});
			$('<style>'+this.css+'</style>').appendTo('head');
			this.initialized = true;
		},
		
		css: 'body.ipad #console {font-size:6px;} body.ipad #iconsole div {padding:4px 5px; margin:0;} #iconsole { font-size:13px; position:absolute; background:#7490A3; top:0; right:0; color:#fff; width:100%; display:block; text-shadow:0 1px 0 #444; z-index:5000; overflow:none; font-family:Courier; font-weight:700; -webkit-box-shadow: 0 2px 5px #333; } #iconsole div { border-bottom:1px #333 solid; padding:6px 10px; line-height:1em; }'

	};
});



/* user-js */
try { eval(''); } catch(e) {}}
