/* ------------------------------------------------------------------------
	Class: prettyPhoto2
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.5.5
------------------------------------------------------------------------- */

(function($) {
	$.prettyPhoto2 = {version: '2.5.5'};
	
	$.fn.prettyPhoto2 = function(settings2) {
		settings2 = jQuery.extend({
			animationSpeed: 'normal', /* fast/slow/normal */
			opacity: 0.80, /* Value between 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			default_width: 500,
			default_height: 344,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto2 */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){}, /* Called when prettyPhoto2 is closed */
			markup: '<div class="pp2_pic_holder"> \
						<div class="pp2_top"> \
							<div class="pp2_left"></div> \
							<div class="pp2_middle"></div> \
							<div class="pp2_right"></div> \
						</div> \
						<div class="pp2_content_container"> \
							<div class="pp2_left"> \
							<div class="pp2_right"> \
								<div class="pp2_content"> \
									<div class="pp2_fade"> \
										<a href="#" class="pp2_expand" title="Expand the image">Expand</a> \
										<div class="pp2_loaderIcon"></div> \
										<div class="pp2_hoverContainer"> \
											<a class="pp2_next" href="#">next</a> \
											<a class="pp2_previous" href="#">previous</a> \
										</div> \
										<div id="pp2_full_res"></div> \
										<div class="pp2_details clearfix"> \
											<a class="pp2_close" href="#">Close</a> \
											<p class="pp2_description"></p> \
											<div class="pp2_nav"> \
												<a href="#" class="pp2_arrow_previous">Previous</a> \
												<p class="currentTextHolder2">0/0</p> \
												<a href="#" class="pp2_arrow_next">Next</a> \
											</div> \
										</div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp2_bottom"> \
							<div class="pp2_left"></div> \
							<div class="pp2_middle"></div> \
							<div class="pp2_right"></div> \
						</div> \
					</div> \
					<div class="pp2_overlay"></div> \
					<div class="ppt2"></div>',
			image_markup: '<img id="fullResImage2" src="" />',
			flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
			quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
			iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
			inline_markup: '<div class="pp2_inline clearfix">{content}</div>'
		}, settings2);
		
		// Fallback to a supported theme for IE6
		if($.browser.msie && $.browser.version == 6){
			settings2.theme = "light_square";
		}

		if(!$pp2_overlay) _buildOverlay2(); // If the overlay is not there, inject it!

		// Global variables accessible only by prettyPhoto2
		var doresize = true, percentBased2 = false, correctSizes2,
		
		// Cached selectors
		$pp2_pic_holder, $ppt2, $pp2_overlay,
		
		// prettyPhoto2 container specific
		pp2_contentHeight, pp2_contentWidth, pp2_containerHeight, pp2_containerWidth,
		
		// Window size
		windowHeight = $(window).height(), windowWidth = $(window).width(),
	
		//Gallery specific
		setPosition2 = 0,

		// Global elements
		scrollPos2 = _getScroll2();
	
		// Window/Keyboard events
		$(window).scroll(function(){ scrollPos2 = _getScroll2(); _centerOverlay2(); _resizeOverlay2(); });
		$(window).resize(function(){ _centerOverlay2(); _resizeOverlay2(); });
		$(document).keydown(function(e){
			if($pp2_pic_holder.is(':visible'))
			switch(e.keyCode){
				case 37:
					$.prettyPhoto2.changePage('previous');
					break;
				case 39:
					$.prettyPhoto2.changePage('next');
					break;
				case 27:
					if(!settings2.modal)
					$.prettyPhoto2.close();
					break;
			};
	    });
	
		// Bind the code to each links
		$(this).each(function(){
			$(this).bind('click',function(){
				_self = this; // Fix scoping
				
				// Find out if the picture is part of a set
				theRel = $(this).attr('rel');
				galleryRegExp = /\[(?:.*)\]/;
				theGallery = galleryRegExp.exec(theRel);

				// Build the gallery array
				var images = new Array(), titles = new Array(), descriptions = new Array();
				if(theGallery){
					$('a[rel*='+theGallery+']').each(function(i){
						if($(this)[0] === $(_self)[0]) setPosition2 = i; // Get the position in the set
						images.push($(this).attr('href'));
						titles.push($(this).find('img').attr('alt'));
						descriptions.push($(this).attr('title'));
					});
				}else{
					images = $(this).attr('href');
					titles = ($(this).find('img').attr('alt')) ?  $(this).find('img').attr('alt') : '';
					descriptions = ($(this).attr('title')) ?  $(this).attr('title') : '';
				}

				$.prettyPhoto2.open(images,titles,descriptions);
				return false;
			});
		});
	
		
		/**
		* Opens the prettyPhoto2 modal box.
		* @param image {String,Array} Full path to the image to be open, can also be an array containing full images paths.
		* @param title {String,Array} The title to be displayed with the picture, can also be an array containing all the titles.
		* @param description {String,Array} The description to be displayed with the picture, can also be an array containing all the descriptions.
		*/
		$.prettyPhoto2.open = function(gallery_images,gallery_titles,gallery_descriptions) {
			// To fix the bug with IE select boxes
			if($.browser.msie && $.browser.version == 6){
				$('select').css('visibility','hidden');
			};
			
			if(settings2.hideflash) $('object,embed').css('visibility','hidden'); // Hide the flash
			
			// Convert everything to an array in the case it's a single item
			images = $.makeArray(gallery_images);
			titles = $.makeArray(gallery_titles);
			descriptions = $.makeArray(gallery_descriptions);

			image_set = ($(images).size() > 0) ?  true : false; // Find out if it's a set

			// Hide the next/previous links if on first or last images.
			_checkPosition2($(images).size());

			$('.pp2_loaderIcon').show(); // Do I need to explain?

			// Fade the content in
			$pp2_overlay.show().fadeTo(settings2.animationSpeed,settings2.opacity);

			// Display the current position
			$pp2_pic_holder.find('.currentTextHolder2').text((setPosition2+1) + settings2.counter_separator_label + $(images).size());

			// Set the description
			if(descriptions[setPosition2]){
				$pp2_pic_holder.find('.pp2_description').show().html(unescape(descriptions[setPosition2]));
			}else{
				$pp2_pic_holder.find('.pp2_description').hide().text('');
			};

			// Set the title
			if(titles[setPosition2] && settings2.showTitle){
				hasTitle = true;
				$ppt2.html(unescape(titles[setPosition2]));
			}else{
				hasTitle = false;
			};
			
			// Get the dimensions
			movie_width = ( parseFloat(grab_param2('width',images[setPosition2])) ) ? grab_param2('width',images[setPosition2]) : settings2.default_width.toString();
			movie_height = ( parseFloat(grab_param2('height',images[setPosition2])) ) ? grab_param2('height',images[setPosition2]) : settings2.default_height.toString();
			
			// If the size is % based, calculate according to window dimensions
			if(movie_width.indexOf('%') != -1 || movie_height.indexOf('%') != -1){
				movie_height = parseFloat(($(window).height() * parseFloat(movie_height) / 100) - 100);
				movie_width = parseFloat(($(window).width() * parseFloat(movie_width) / 100) - 100);
				percentBased2 = true;
			}
			
			imgPreloader2 = "";

			// Inject the proper content
			switch(_getFileType2(images[setPosition2])){
				case 'image':
					// Set the new image
					imgPreloader2 = new Image();

					// Preload the neighbour images
					nextImage = new Image();
					if(image_set && setPosition2 > $(images).size()) nextImage.src = images[setPosition2 + 1];
					prevImage = new Image();
					if(image_set && images[setPosition2 - 1]) prevImage.src = images[setPosition2 - 1];

					$pp2_pic_holder.find('#pp2_full_res')[0].innerHTML = settings2.image_markup;
					$pp2_pic_holder.find('#fullResImage2').attr('src',images[setPosition2]);

					imgPreloader2.onload = function(){
						// Fit item to viewport
						correctSizes2 = _fitToViewport2(imgPreloader2.width,imgPreloader2.height);

						_showContent2();
					};

					imgPreloader2.onerror = function(){
						alert('Image cannot be loaded. Make sure the path is correct and image exist.');
						$.prettyPhoto2.close();
					};
					
					imgPreloader2.src = images[setPosition2];
				break;
				
				case 'youtube':
					correctSizes2 = _fitToViewport2(movie_width,movie_height); // Fit item to viewport

					movie = 'http://www.youtube.com/v/'+grab_param2('v',images[setPosition2]);
					if(settings2.autoplay) movie += "&autoplay=1";
					
					toInject = settings2.flash_markup.replace(/{width}/g,correctSizes2['width']).replace(/{height}/g,correctSizes2['height']).replace(/{wmode}/g,settings2.wmode).replace(/{path}/g,movie);
				break;
				
				case 'vimeo':
					correctSizes2 = _fitToViewport2(movie_width,movie_height); // Fit item to viewport
					
					movie_id = images[setPosition2];
					movie = 'http://vimeo.com/moogaloop.swf?clip_id='+ movie_id.replace('http://vimeo.com/','');
					if(settings2.autoplay) movie += "&autoplay=1";
				
					toInject = settings2.flash_markup.replace(/{width}/g,correctSizes2['width']).replace(/{height}/g,correctSizes2['height']).replace(/{wmode}/g,settings2.wmode).replace(/{path}/g,movie);
				break;
				
				case 'quicktime':
					correctSizes2 = _fitToViewport2(movie_width,movie_height); // Fit item to viewport
					correctSizes2['height']+=15; correctSizes2['contentHeight']+=15; correctSizes2['containerHeight']+=15; // Add space for the control bar
				
					toInject = settings2.quicktime_markup.replace(/{width}/g,correctSizes2['width']).replace(/{height}/g,correctSizes2['height']).replace(/{wmode}/g,settings2.wmode).replace(/{path}/g,images[setPosition2]).replace(/{autoplay}/g,settings2.autoplay);
				break;
				
				case 'flash':
					correctSizes2 = _fitToViewport2(movie_width,movie_height); // Fit item to viewport
					
					flash_vars = images[setPosition2];
					flash_vars = flash_vars.substring(images[setPosition2].indexOf('flashvars') + 10,images[setPosition2].length);

					filename = images[setPosition2];
					filename = filename.substring(0,filename.indexOf('?'));
					
					toInject =  settings2.flash_markup.replace(/{width}/g,correctSizes2['width']).replace(/{height}/g,correctSizes2['height']).replace(/{wmode}/g,settings2.wmode).replace(/{path}/g,filename+'?'+flash_vars);
				break;
				
				case 'iframe':
					correctSizes2 = _fitToViewport2(movie_width,movie_height); // Fit item to viewport
				
					frame_url = images[setPosition2];
					frame_url = frame_url.substr(0,frame_url.indexOf('iframe')-1);
				
					toInject = settings2.iframe_markup.replace(/{width}/g,correctSizes2['width']).replace(/{height}/g,correctSizes2['height']).replace(/{path}/g,frame_url);
				break;
				
				case 'inline':
					// to get the item height clone it, apply default width, wrap it in the prettyPhoto2 containers , then delete
					myClone = $(images[setPosition2]).clone().css({'width':settings2.default_width}).wrapInner('<div id="pp2_full_res"><div class="pp2_inline clearfix"></div></div>').appendTo($('body'));
					correctSizes2 = _fitToViewport2($(myClone).width(),$(myClone).height());
					$(myClone).remove();
					toInject = settings2.inline_markup.replace(/{content}/g,$(images[setPosition2]).html());
				break;
			};

			if(!imgPreloader2){
  
				//$pp2_pic_holder.find('#pp2_full_res')[0].innerHTML = toInject;
				$pp2_pic_holder.find('#pp2_full_res').append($(images[setPosition2]).html())
				$(images[setPosition2]).html('');

        // move elements back when you're finished
        settings2.callback = function()
        {
          $(images[setPosition2]).append( $pp2_pic_holder.find('#pp2_full_res').html() ); 
          $pp2_pic_holder.find('#pp2_full_res').html('');
        }
				
				// Show content
				_showContent2();
			};

		};
		
		/**
		* Change page in the prettyPhoto2 modal box
		* @param direction {String} Direction of the paging, previous or next.
		*/
		$.prettyPhoto2.changePage = function(direction){
			if(direction == 'previous') {
				setPosition2--;
				if (setPosition2 < 0){
					setPosition2 = 0;
					return;
				};
			}else{
				if($('.pp2_arrow_next').is('.disabled')) return;
				setPosition2++;
			};

			// Allow the resizing of the images
			if(!doresize) doresize = true;

			_showContent2(function(){$.prettyPhoto2.open(images,titles,descriptions)});
			$('a.pp2_expand,a.pp2_contract').fadeOut(settings2.animationSpeed);
		};
		
		/**
		* Closes the prettyPhoto2 modal box.
		*/
		$.prettyPhoto2.close = function(){
			$pp2_pic_holder.find('object,embed').css('visibility','hidden');
			
			$('div.pp2_pic_holder,div.ppt2,.pp2_fade').fadeOut(settings2.animationSpeed);
			
			$pp2_overlay.fadeOut(settings2.animationSpeed, function(){
				$pp2_pic_holder.attr('style','').find('div:not(.pp2_hoverContainer)').attr('style',''); // Reset the width and everything that has been set.
				_centerOverlay2(); // Center it
			
				// To fix the bug with IE select boxes
				if($.browser.msie && $.browser.version == 6){
					$('select').css('visibility','visible');
				};
				
				// Show the flash
				if(settings2.hideflash) $('object,embed').css('visibility','visible');
				
				setPosition2 = 0;
				settings2.callback();
			});
			doresize = true;
		};
	
		/**
		* Set the proper sizes on the containers and animate the content in.
		*/
		_showContent2 = function(){
			$('.pp2_loaderIcon').hide();

			// Calculate the opened top position of the pic holder
			projectedTop = scrollPos2['scrollTop'] + ((windowHeight/2) - (correctSizes2['containerHeight']/2));
			if(projectedTop < 0) projectedTop = 0 + $ppt2.height();

			// Resize the content holder
			$pp2_pic_holder.find('.pp2_content').animate({'height':correctSizes2['contentHeight']},settings2.animationSpeed);
			
			// Resize picture the holder
			$pp2_pic_holder.animate({
				'top': projectedTop,
				'left': (windowWidth/2) - (correctSizes2['containerWidth']/2),
				'width': correctSizes2['containerWidth']
			},settings2.animationSpeed,function(){
				$pp2_pic_holder.find('.pp2_hoverContainer,#fullResImage2').height(correctSizes2['height']).width(correctSizes2['width']);

				// Fade the new image
				$pp2_pic_holder.find('.pp2_fade').fadeIn(settings2.animationSpeed);

				// Show the nav
				if(image_set && _getFileType2(images[setPosition2])=="image") { $pp2_pic_holder.find('.pp2_hoverContainer').show(); }else{ $pp2_pic_holder.find('.pp2_hoverContainer').hide(); }

				// Show the title
				if(settings2.showTitle && hasTitle){
					$ppt2.css({
						'top' : $pp2_pic_holder.offset().top - 25,
						'left' : $pp2_pic_holder.offset().left + 20,
						'display' : 'none'
					});

					$ppt2.fadeIn(settings2.animationSpeed);
				};
			
				// Fade the resizing link if the image is resized
				if(correctSizes2['resized']) $('a.pp2_expand,a.pp2_contract').fadeIn(settings2.animationSpeed);

				// Callback!
				settings2.changepicturecallback();
			});
		};
		
		/**
		* Hide the content...DUH!
		*/
		function _showContent2(callback){
			// Fade out the current picture
			$pp2_pic_holder.find('#pp2_full_res object,#pp2_full_res embed').css('visibility','hidden');
			$pp2_pic_holder.find('.pp2_fade').fadeOut(settings2.animationSpeed,function(){
				$('.pp2_loaderIcon').show();
				
				if(callback) callback();
			});
			
			// Hide the title
			$ppt2.fadeOut(settings2.animationSpeed);
		}
	
		/**
		* Check the item position in the gallery array, hide or show the navigation links
		* @param setCount {integer} The total number of items in the set
		*/
		function _checkPosition2(setCount){
			// If at the end, hide the next link
			if(setPosition2 == setCount-1) {
				$pp2_pic_holder.find('a.pp2_next').css('visibility','hidden');
				$pp2_pic_holder.find('a.pp2_arrow_next').addClass('disabled').unbind('click');
			}else{ 
				$pp2_pic_holder.find('a.pp2_next').css('visibility','visible');
				$pp2_pic_holder.find('a.pp2_arrow_next.disabled').removeClass('disabled').bind('click',function(){
					$.prettyPhoto2.changePage('next');
					return false;
				});
			};
		
			// If at the beginning, hide the previous link
			if(setPosition2 == 0) {
				$pp2_pic_holder.find('a.pp2_previous').css('visibility','hidden');
				$pp2_pic_holder.find('a.pp2_arrow_previous').addClass('disabled').unbind('click');
			}else{
				$pp2_pic_holder.find('a.pp2_previous').css('visibility','visible');
				$pp2_pic_holder.find('a.pp2_arrow_previous.disabled').removeClass('disabled').bind('click',function(){
					$.prettyPhoto2.changePage('previous');
					return false;
				});
			};
			
			// Hide the bottom nav if it's not a set.
			if(setCount > 1) {
				$('.pp2_nav').show();
			}else{
				$('.pp2_nav').hide();
			}
		};
	
		/**
		* Resize the item dimensions if it's bigger than the viewport
		* @param width {integer} Width of the item to be opened
		* @param height {integer} Height of the item to be opened
		* @return An array containin the "fitted" dimensions
		*/
		function _fitToViewport2(width,height){
			hasBeenResized = false;

			_getDimensions2(width,height);
			
			// Define them in case there's no resize needed
			imageWidth = width;
			imageHeight = height;

			if( ((pp2_containerWidth > windowWidth) || (pp2_containerHeight > windowHeight)) && doresize && settings2.allowresize && !percentBased2) {
				hasBeenResized = true;
				notFitting = true;
			
				while (notFitting){
					if((pp2_containerWidth > windowWidth)){
						imageWidth = (windowWidth - 200);
						imageHeight = (height/width) * imageWidth;
					}else if((pp2_containerHeight > windowHeight)){
						imageHeight = (windowHeight - 200);
						imageWidth = (width/height) * imageHeight;
					}else{
						notFitting = false;
					};

					pp2_containerHeight = imageHeight;
					pp2_containerWidth = imageWidth;
				};
			
				_getDimensions2(imageWidth,imageHeight);
			};

			return {
				width:Math.floor(imageWidth),
				height:Math.floor(imageHeight),
				containerHeight:Math.floor(pp2_containerHeight),
				containerWidth:Math.floor(pp2_containerWidth) + 40,
				contentHeight:Math.floor(pp2_contentHeight),
				contentWidth:Math.floor(pp2_contentWidth),
				resized:hasBeenResized
			};
		};
		
		/**
		* Get the containers dimensions according to the item size
		* @param width {integer} Width of the item to be opened
		* @param height {integer} Height of the item to be opened
		*/
		function _getDimensions2(width,height){
			width = parseFloat(width);
			height = parseFloat(height);
			
			// Get the details height, to do so, I need to clone it since it's invisible
			$pp2_details = $pp2_pic_holder.find('.pp2_details');
			$pp2_details.width(width);
			detailsHeight = parseFloat($pp2_details.css('marginTop')) + parseFloat($pp2_details.css('marginBottom'));
			$pp2_details = $pp2_details.clone().appendTo($('body')).css({
				'position':'absolute',
				'top':-10000
			});
			detailsHeight += $pp2_details.height();
			detailsHeight = (detailsHeight <= 34) ? 36 : detailsHeight; // Min-height for the details
			if($.browser.msie && $.browser.version==7) detailsHeight+=8;
			$pp2_details.remove();
			
			// Get the container size, to resize the holder to the right dimensions
			pp2_contentHeight = height + detailsHeight;
			pp2_contentWidth = width;
			pp2_containerHeight = pp2_contentHeight + $ppt2.height() + $pp2_pic_holder.find('.pp2_top').height() + $pp2_pic_holder.find('.pp2_bottom').height();
			pp2_containerWidth = width;
		}
	
		function _getFileType2(itemSrc){
			if (itemSrc.match(/youtube\.com\/watch/i)) {
				return 'youtube';
			}else if (itemSrc.match(/vimeo\.com/i)) {
				return 'vimeo';
			}else if(itemSrc.indexOf('.mov') != -1){ 
				return 'quicktime';
			}else if(itemSrc.indexOf('.swf') != -1){
				return 'flash';
			}else if(itemSrc.indexOf('iframe') != -1){
				return 'iframe'
			}else if(itemSrc.substr(0,1) == '#'){
				return 'inline';
			}else{
				return 'image';
			};
		};
	
		function _centerOverlay2(){
			if(doresize) {
				titleHeight = $ppt2.height();
				contentHeight = $pp2_pic_holder.height();
				contentwidth = $pp2_pic_holder.width();
				
				projectedTop = (windowHeight/2) + scrollPos2['scrollTop'] - ((contentHeight+titleHeight)/2);
				
				$pp2_pic_holder.css({
					'top': projectedTop,
					'left': (windowWidth/2) + scrollPos2['scrollLeft'] - (contentwidth/2)
				});
				
				$ppt2.css({
					'top' : projectedTop - titleHeight,
					'left': (windowWidth/2) + scrollPos2['scrollLeft'] - (contentwidth/2) + 20
				});
			};
		};
	
		function _getScroll2(){
			if (self.pageYOffset) {
				return {scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset};
			} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
				return {scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft};
			} else if (document.body) {// all other Explorers
				return {scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft};
			};
		};
	
		function _resizeOverlay2() {
			windowHeight = $(window).height();
			windowWidth = $(window).width();
			
			$pp2_overlay.css({
				'height':$(document).height()
			});
		};
	
		function _buildOverlay2(){
			// Inject the markup
			$('body').append(settings2.markup);
			
			// Set my global selectors
			$pp2_pic_holder = $('.pp2_pic_holder');
			$ppt2 = $('.ppt2');
			$pp2_overlay = $('div.pp2_overlay');
			
			$pp2_pic_holder.attr('class','pp2_pic_holder ' + settings2.theme); // Set the proper theme
			
			$pp2_overlay
				.css({
					'opacity':0,
					'height':$(document).height()
					})
				.bind('click',function(){
					if(!settings2.modal)
					$.prettyPhoto2.close();
				});

			$('a.pp2_close').bind('click',function(){ $.prettyPhoto2.close(); return false; });

			$('a.pp2_expand').bind('click',function(){
				$this = $(this); // Fix scoping
				
				// Expand the image
				if($this.hasClass('pp2_expand')){
					$this.removeClass('pp2_expand').addClass('pp2_contract');
					doresize = false;
				}else{
					$this.removeClass('pp2_contract').addClass('pp2_expand');
					doresize = true;
				};
			
				_showContent2(function(){ $.prettyPhoto2.open(images,titles,descriptions) });
				
				$pp2_pic_holder.find('.pp2_fade').fadeOut(settings2.animationSpeed);
		
				return false;
			});
		
			$pp2_pic_holder.find('.pp2_previous, .pp2_arrow_previous').bind('click',function(){
				$.prettyPhoto2.changePage('previous');
				return false;
			});
		
			$pp2_pic_holder.find('.pp2_next, .pp2_arrow_next').bind('click',function(){
				$.prettyPhoto2.changePage('next');
				return false;
			});
		};
		
		_centerOverlay2(); // Center it
	};
	
	function grab_param2(name,url){
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( url );
	  if( results == null )
	    return "";
	  else
	    return results[1];
	}
})(jQuery);
