/* ------------------------------------------------------------------------
class: prettyphoto
use: lightbox clone for jquery
author: stephane caron (http://www.no-margin-for-errors.com)
version: 3.0.1
------------------------------------------------------------------------- */
(function($) {
$.prettyphoto = {version: '3.0'};
$.fn.prettyphoto = function(pp_settings) {
pp_settings = jquery.extend({
animation_speed: 'fast', /* fast/slow/normal */
slideshow: false, /* false or interval time in ms */
autoplay_slideshow: false, /* true/false */
opacity: 0.80, /* value between 0 and 1 */
show_title: false, /* true/false */
allow_resize: true, /* resize the photos bigger than viewport. true/false */
default_width: 500,
default_height: 344,
counter_separator_label: '/', /* the separator for the gallery counter 1 "of" 2 */
theme: 'dark_square', /* 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 prettyphoto */
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 */
overlay_gallery: true, /* if set to true, a gallery will overlay the fullscreen image on mouse over */
keyboard_shortcuts: true, /* set to false if you open forms inside prettyphoto */
changepicturecallback: function(){}, /* called everytime an item is shown/changed */
callback: function(){}, /* called when prettyphoto is closed */
markup: '
',
custom_markup: ''
}, pp_settings);
// global variables accessible only by prettyphoto
var matchedobjects = this, percentbased = false, correctsizes, pp_open,
// prettyphoto container specific
pp_contentheight, pp_contentwidth, pp_containerheight, pp_containerwidth,
// window size
windowheight = $(window).height(), windowwidth = $(window).width(),
// global elements
pp_slideshow;
doresize = true, scroll_pos = _get_scroll();
// window/keyboard events
$(window).unbind('resize').resize(function(){ _center_overlay(); _resize_overlay(); });
if(pp_settings.keyboard_shortcuts) {
$(document).unbind('keydown').keydown(function(e){
if(typeof $pp_pic_holder != 'undefined'){
if($pp_pic_holder.is(':visible')){
switch(e.keycode){
case 37:
$.prettyphoto.changepage('previous');
break;
case 39:
$.prettyphoto.changepage('next');
break;
case 27:
if(!settings.modal)
$.prettyphoto.close();
break;
};
return false;
};
};
});
}
/**
* initialize prettyphoto.
*/
$.prettyphoto.initialize = function() {
settings = pp_settings;
if($.browser.msie && parseint($.browser.version) == 6) settings.theme = "light_square"; // fallback to a supported theme for ie6
_buildoverlay(this); // build the overlay {this} being the caller
if(settings.allow_resize)
$(window).scroll(function(){ _center_overlay(); });
_center_overlay();
set_position = jquery.inarray($(this).attr('href'), pp_images); // define where in the array the clicked item is positionned
$.prettyphoto.open();
return false;
}
/**
* opens the prettyphoto 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.
*/
$.prettyphoto.open = function(event) {
if(typeof settings == "undefined"){ // means it's an api call, need to manually get the settings and set the variables
settings = pp_settings;
if($.browser.msie && $.browser.version == 6) settings.theme = "light_square"; // fallback to a supported theme for ie6
_buildoverlay(event.target); // build the overlay {this} being the caller
pp_images = $.makearray(arguments[0]);
pp_titles = (arguments[1]) ? $.makearray(arguments[1]) : $.makearray("");
pp_descriptions = (arguments[2]) ? $.makearray(arguments[2]) : $.makearray("");
isset = (pp_images.length > 1) ? true : false;
set_position = 0;
}
if($.browser.msie && $.browser.version == 6) $('select').css('visibility','hidden'); // to fix the bug with ie select boxes
if(settings.hideflash) $('object,embed').css('visibility','hidden'); // hide the flash
_checkposition($(pp_images).size()); // hide the next/previous links if on first or last images.
$('.pp_loadericon').show();
// fade the content in
if($ppt.is(':hidden')) $ppt.css('opacity',0).show();
$pp_overlay.show().fadeto(settings.animation_speed,settings.opacity);
// display the current position
$pp_pic_holder.find('.currenttextholder').text((set_position+1) + settings.counter_separator_label + $(pp_images).size());
// set the description
$pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position]));
// set the title
(settings.show_title && pp_titles[set_position] != "" && typeof pp_titles[set_position] != "undefined") ? $ppt.html(unescape(pp_titles[set_position])) : $ppt.html(' ');
// get the dimensions
movie_width = ( parsefloat(grab_param('width',pp_images[set_position])) ) ? grab_param('width',pp_images[set_position]) : settings.default_width.tostring();
movie_height = ( parsefloat(grab_param('height',pp_images[set_position])) ) ? grab_param('height',pp_images[set_position]) : settings.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) - 150);
movie_width = parsefloat(($(window).width() * parsefloat(movie_width) / 100) - 150);
percentbased = true;
}else{
percentbased = false;
}
// fade the holder
$pp_pic_holder.fadein(function(){
imgpreloader = "";
// inject the proper content
switch(_getfiletype(pp_images[set_position])){
case 'image':
imgpreloader = new image();
// preload the neighbour images
nextimage = new image();
if(isset && set_position > $(pp_images).size()) nextimage.src = pp_images[set_position + 1];
previmage = new image();
if(isset && pp_images[set_position - 1]) previmage.src = pp_images[set_position - 1];
$pp_pic_holder.find('#pp_full_res')[0].innerhtml = settings.image_markup;
$pp_pic_holder.find('#fullresimage').attr('src',pp_images[set_position]);
imgpreloader.onload = function(){
// fit item to viewport
correctsizes = _fittoviewport(imgpreloader.width,imgpreloader.height);
_showcontent();
};
imgpreloader.onerror = function(){
alert('image cannot be loaded. make sure the path is correct and image exist.');
$.prettyphoto.close();
};
imgpreloader.src = pp_images[set_position];
break;
case 'youtube':
correctsizes = _fittoviewport(movie_width,movie_height); // fit item to viewport
movie = 'http://www.youtube.com/v/'+grab_param('v',pp_images[set_position]);
if(settings.autoplay) movie += "&autoplay=1";
toinject = settings.flash_markup.replace(/{width}/g,correctsizes['width']).replace(/{height}/g,correctsizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);
break;
case 'vimeo':
correctsizes = _fittoviewport(movie_width,movie_height); // fit item to viewport
movie_id = pp_images[set_position];
var regexp = /http:\/\/(www\.)?vimeo.com\/(\d+)/;
var match = movie_id.match(regexp);
movie = 'http://player.vimeo.com/video/'+ match[2] +'?title=0&byline=0&portrait=0';
if(settings.autoplay) movie += "&autoplay=1;";
vimeo_width = correctsizes['width'] + '/embed/?moog_width='+ correctsizes['width'];
toinject = settings.iframe_markup.replace(/{width}/g,vimeo_width).replace(/{height}/g,correctsizes['height']).replace(/{path}/g,movie);
break;
case 'quicktime':
correctsizes = _fittoviewport(movie_width,movie_height); // fit item to viewport
correctsizes['height']+=15; correctsizes['contentheight']+=15; correctsizes['containerheight']+=15; // add space for the control bar
toinject = settings.quicktime_markup.replace(/{width}/g,correctsizes['width']).replace(/{height}/g,correctsizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,pp_images[set_position]).replace(/{autoplay}/g,settings.autoplay);
break;
case 'flash':
correctsizes = _fittoviewport(movie_width,movie_height); // fit item to viewport
flash_vars = pp_images[set_position];
flash_vars = flash_vars.substring(pp_images[set_position].indexof('flashvars') + 10,pp_images[set_position].length);
filename = pp_images[set_position];
filename = filename.substring(0,filename.indexof('?'));
toinject = settings.flash_markup.replace(/{width}/g,correctsizes['width']).replace(/{height}/g,correctsizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars);
break;
case 'iframe':
correctsizes = _fittoviewport(movie_width,movie_height); // fit item to viewport
frame_url = pp_images[set_position];
frame_url = frame_url.substr(0,frame_url.indexof('iframe')-1);
toinject = settings.iframe_markup.replace(/{width}/g,correctsizes['width']).replace(/{height}/g,correctsizes['height']).replace(/{path}/g,frame_url);
break;
case 'custom':
correctsizes = _fittoviewport(movie_width,movie_height); // fit item to viewport
toinject = settings.custom_markup;
break;
case 'inline':
// to get the item height clone it, apply default width, wrap it in the prettyphoto containers , then delete
myclone = $(pp_images[set_position]).clone().css({'width':settings.default_width}).wrapinner('
').appendto($('body'));
correctsizes = _fittoviewport($(myclone).width(),$(myclone).height());
$(myclone).remove();
toinject = settings.inline_markup.replace(/{content}/g,$(pp_images[set_position]).html());
break;
};
if(!imgpreloader){
$pp_pic_holder.find('#pp_full_res')[0].innerhtml = toinject;
// show content
_showcontent();
};
});
return false;
};
/**
* change page in the prettyphoto modal box
* @param direction {string} direction of the paging, previous or next.
*/
$.prettyphoto.changepage = function(direction){
currentgallerypage = 0;
if(direction == 'previous') {
set_position--;
if (set_position < 0){
set_position = 0;
return;
};
}else if(direction == 'next'){
set_position++;
if(set_position > $(pp_images).size()-1) {
set_position = 0;
}
}else{
set_position=direction;
};
if(!doresize) doresize = true; // allow the resizing of the images
$('.pp_contract').removeclass('pp_contract').addclass('pp_expand');
_hidecontent(function(){ $.prettyphoto.open(); });
};
/**
* change gallery page in the prettyphoto modal box
* @param direction {string} direction of the paging, previous or next.
*/
$.prettyphoto.changegallerypage = function(direction){
if(direction=='next'){
currentgallerypage ++;
if(currentgallerypage > totalpage){
currentgallerypage = 0;
};
}else if(direction=='previous'){
currentgallerypage --;
if(currentgallerypage < 0){
currentgallerypage = totalpage;
};
}else{
currentgallerypage = direction;
};
// slide the pages, if we're on the last page, find out how many items we need to slide. to make sure we don't have an empty space.
itemstoslide = (currentgallerypage == totalpage) ? pp_images.length - ((totalpage) * itemsperpage) : itemsperpage;
$pp_pic_holder.find('.pp_gallery li').each(function(i){
$(this).animate({
'left': (i * itemwidth) - ((itemstoslide * itemwidth) * currentgallerypage)
});
});
};
/**
* start the slideshow...
*/
$.prettyphoto.startslideshow = function(){
if(typeof pp_slideshow == 'undefined'){
$pp_pic_holder.find('.pp_play').unbind('click').removeclass('pp_play').addclass('pp_pause').click(function(){
$.prettyphoto.stopslideshow();
return false;
});
pp_slideshow = setinterval($.prettyphoto.startslideshow,settings.slideshow);
}else{
$.prettyphoto.changepage('next');
};
}
/**
* stop the slideshow...
*/
$.prettyphoto.stopslideshow = function(){
$pp_pic_holder.find('.pp_pause').unbind('click').removeclass('pp_pause').addclass('pp_play').click(function(){
$.prettyphoto.startslideshow();
return false;
});
clearinterval(pp_slideshow);
pp_slideshow=undefined;
}
/**
* closes prettyphoto.
*/
$.prettyphoto.close = function(){
clearinterval(pp_slideshow);
$pp_pic_holder.stop().find('object,embed').css('visibility','hidden');
$('div.pp_pic_holder,div.ppt,.pp_fade').fadeout(settings.animation_speed,function(){ $(this).remove(); });
$pp_overlay.fadeout(settings.animation_speed, function(){
if($.browser.msie && $.browser.version == 6) $('select').css('visibility','visible'); // to fix the bug with ie select boxes
if(settings.hideflash) $('object,embed').css('visibility','visible'); // show the flash
$(this).remove(); // no more need for the prettyphoto markup
//$(window).unbind('scroll');
settings.callback();
doresize = true;
pp_open = false;
delete settings;
});
};
/**
* set the proper sizes on the containers and animate the content in.
*/
_showcontent = function(){
$('.pp_loadericon').hide();
$ppt.fadeto(settings.animation_speed,1);
// calculate the opened top position of the pic holder
projectedtop = scroll_pos['scrolltop'] + ((windowheight/2) - (correctsizes['containerheight']/2));
if(projectedtop < 0) projectedtop = 0;
// resize the content holder
$pp_pic_holder.find('.pp_content').animate({'height':correctsizes['contentheight']},settings.animation_speed);
// resize picture the holder
$pp_pic_holder.animate({
'top': projectedtop,
'left': (windowwidth/2) - (correctsizes['containerwidth']/2),
'width': correctsizes['containerwidth']
},settings.animation_speed,function(){
$pp_pic_holder.find('.pp_hovercontainer,#fullresimage').height(correctsizes['height']).width(correctsizes['width']);
$pp_pic_holder.find('.pp_fade').fadein(settings.animation_speed); // fade the new content
// show the nav
if(isset && _getfiletype(pp_images[set_position])=="image") { $pp_pic_holder.find('.pp_hovercontainer').show(); }else{ $pp_pic_holder.find('.pp_hovercontainer').hide(); }
if(correctsizes['resized']) $('a.pp_expand,a.pp_contract').fadein(settings.animation_speed); // fade the resizing link if the image is resized
if(settings.autoplay_slideshow && !pp_slideshow && !pp_open) $.prettyphoto.startslideshow();
settings.changepicturecallback(); // callback!
pp_open = true;
});
_insert_gallery();
};
/**
* hide the content...duh!
*/
function _hidecontent(callback){
// fade out the current picture
$pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden');
$pp_pic_holder.find('.pp_fade').fadeout(settings.animation_speed,function(){
$('.pp_loadericon').show();
callback();
});
};
/**
* 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 _checkposition(setcount){
// if at the end, hide the next link
if(set_position == setcount-1) {
$pp_pic_holder.find('a.pp_next').css('visibility','hidden');
$pp_pic_holder.find('a.pp_next').addclass('disabled').unbind('click');
}else{
$pp_pic_holder.find('a.pp_next').css('visibility','visible');
$pp_pic_holder.find('a.pp_next.disabled').removeclass('disabled').bind('click',function(){
$.prettyphoto.changepage('next');
return false;
});
};
// if at the beginning, hide the previous link
if(set_position == 0) {
$pp_pic_holder
.find('a.pp_previous')
.css('visibility','hidden')
.addclass('disabled')
.unbind('click');
}else{
$pp_pic_holder.find('a.pp_previous.disabled')
.css('visibility','visible')
.removeclass('disabled')
.bind('click',function(){
$.prettyphoto.changepage('previous');
return false;
});
};
(setcount > 1) ? $('.pp_nav').show() : $('.pp_nav').hide(); // hide the bottom nav if it's not a set.
};
/**
* 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 _fittoviewport(width,height){
resized = false;
_getdimensions(width,height);
// define them in case there's no resize needed
imagewidth = width, imageheight = height;
if( ((pp_containerwidth > windowwidth) || (pp_containerheight > windowheight)) && doresize && settings.allow_resize && !percentbased) {
resized = true, fitting = false;
while (!fitting){
if((pp_containerwidth > windowwidth)){
imagewidth = (windowwidth - 200);
imageheight = (height/width) * imagewidth;
}else if((pp_containerheight > windowheight)){
imageheight = (windowheight - 200);
imagewidth = (width/height) * imageheight;
}else{
fitting = true;
};
pp_containerheight = imageheight, pp_containerwidth = imagewidth;
};
_getdimensions(imagewidth,imageheight);
};
return {
width:math.floor(imagewidth),
height:math.floor(imageheight),
containerheight:math.floor(pp_containerheight),
containerwidth:math.floor(pp_containerwidth) + 40, // 40 behind the side padding
contentheight:math.floor(pp_contentheight),
contentwidth:math.floor(pp_contentwidth),
resized:resized
};
};
/**
* 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 _getdimensions(width,height){
width = parsefloat(width);
height = parsefloat(height);
// get the details height, to do so, i need to clone it since it's invisible
$pp_details = $pp_pic_holder.find('.pp_details');
$pp_details.width(width);
detailsheight = parsefloat($pp_details.css('margintop')) + parsefloat($pp_details.css('marginbottom'));
$pp_details = $pp_details.clone().appendto($('body')).css({
'position':'absolute',
'top':-10000
});
detailsheight += $pp_details.height();
detailsheight = (detailsheight <= 34) ? 36 : detailsheight; // min-height for the details
if($.browser.msie && $.browser.version==7) detailsheight+=8;
$pp_details.remove();
// get the container size, to resize the holder to the right dimensions
pp_contentheight = height + detailsheight;
pp_contentwidth = width;
pp_containerheight = pp_contentheight + $ppt.height() + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height();
pp_containerwidth = width;
}
function _getfiletype(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.indexof('custom') != -1){
return 'custom';
}else if(itemsrc.substr(0,1) == '#'){
return 'inline';
}else{
return 'image';
};
};
function _center_overlay(){
if(doresize && typeof $pp_pic_holder != 'undefined') {
scroll_pos = _get_scroll();
titleheight = $ppt.height(), contentheight = $pp_pic_holder.height(), contentwidth = $pp_pic_holder.width();
projectedtop = (windowheight/2) + scroll_pos['scrolltop'] - (contentheight/2);
$pp_pic_holder.css({
'top': projectedtop,
'left': (windowwidth/2) + scroll_pos['scrollleft'] - (contentwidth/2)
});
};
};
function _get_scroll(){
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 _resize_overlay() {
windowheight = $(window).height(), windowwidth = $(window).width();
if(typeof $pp_overlay != "undefined") $pp_overlay.height($(document).height());
};
function _insert_gallery(){
if(isset && settings.overlay_gallery && _getfiletype(pp_images[set_position])=="image") {
itemwidth = 52+5; // 52 beign the thumb width, 5 being the right margin.
navwidth = (settings.theme == "facebook") ? 58 : 38; // define the arrow width depending on the theme
itemsperpage = math.floor((correctsizes['containerwidth'] - 100 - navwidth) / itemwidth);
itemsperpage = (itemsperpage < pp_images.length) ? itemsperpage : pp_images.length;
totalpage = math.ceil(pp_images.length / itemsperpage) - 1;
// hide the nav in the case there's no need for links
if(totalpage == 0){
navwidth = 0; // no nav means no width!
$pp_pic_holder.find('.pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous').hide();
}else{
$pp_pic_holder.find('.pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous').show();
};
gallerywidth = itemsperpage * itemwidth + navwidth;
// set the proper width to the gallery items
$pp_pic_holder.find('.pp_gallery')
.width(gallerywidth)
.css('margin-left',-(gallerywidth/2));
$pp_pic_holder
.find('.pp_gallery ul')
.width(itemsperpage * itemwidth)
.find('li.selected')
.removeclass('selected');
gotopage = (math.floor(set_position/itemsperpage) <= totalpage) ? math.floor(set_position/itemsperpage) : totalpage;
if(itemsperpage) {
$pp_pic_holder.find('.pp_gallery').hide().show().removeclass('disabled');
}else{
$pp_pic_holder.find('.pp_gallery').hide().addclass('disabled');
}
$.prettyphoto.changegallerypage(gotopage);
$pp_pic_holder
.find('.pp_gallery ul li:eq('+set_position+')')
.addclass('selected');
}else{
$pp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave');
$pp_pic_holder.find('.pp_gallery').hide();
}
}
function _buildoverlay(caller){
// find out if the picture is part of a set
therel = $(caller).attr('data-rel');
galleryregexp = /\[(?:.*)\]/;
isset = (galleryregexp.exec(therel)) ? true : false;
// put the srcs, titles, alts into an array.
pp_images = (isset) ? jquery.map(matchedobjects, function(n, i){ if($(n).attr('data-rel').indexof(therel) != -1) return $(n).attr('href'); }) : $.makearray($(caller).attr('href'));
pp_titles = (isset) ? jquery.map(matchedobjects, function(n, i){ if($(n).attr('data-rel').indexof(therel) != -1) return ($(n).find('img').attr('alt')) ? $(n).find('img').attr('alt') : ""; }) : $.makearray($(caller).find('img').attr('alt'));
pp_descriptions = (isset) ? jquery.map(matchedobjects, function(n, i){ if($(n).attr('data-rel').indexof(therel) != -1) return ($(n).attr('title')) ? $(n).attr('title') : ""; }) : $.makearray($(caller).attr('title'));
$('body').append(settings.markup); // inject the markup
$pp_pic_holder = $('.pp_pic_holder') , $ppt = $('.ppt'), $pp_overlay = $('div.pp_overlay'); // set my global selectors
// inject the inline gallery!
if(isset && settings.overlay_gallery) {
currentgallerypage = 0;
toinject = "";
for (var i=0; i < pp_images.length; i++) {
var regex = new regexp("(.*?)\.(jpg|jpeg|png|gif)$");
var results = regex.exec( pp_images[i] );
if(!results){
classname = 'default';
}else{
classname = '';
}
toinject += "
";
};
toinject = settings.gallery_markup.replace(/{gallery}/g,toinject);
$pp_pic_holder.find('#pp_full_res').after(toinject);
$pp_pic_holder.find('.pp_gallery .pp_arrow_next').click(function(){
$.prettyphoto.changegallerypage('next');
$.prettyphoto.stopslideshow();
return false;
});
$pp_pic_holder.find('.pp_gallery .pp_arrow_previous').click(function(){
$.prettyphoto.changegallerypage('previous');
$.prettyphoto.stopslideshow();
return false;
});
$pp_pic_holder.find('.pp_content').hover(
function(){
$pp_pic_holder.find('.pp_gallery:not(.disabled)').fadein();
},
function(){
$pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeout();
});
itemwidth = 52+5; // 52 beign the thumb width, 5 being the right margin.
$pp_pic_holder.find('.pp_gallery ul li').each(function(i){
$(this).css({
'position':'absolute',
'left': i * itemwidth
});
$(this).find('a').unbind('click').click(function(){
$.prettyphoto.changepage(i);
$.prettyphoto.stopslideshow();
return false;
});
});
};
// inject the play/pause if it's a slideshow
if(settings.slideshow){
$pp_pic_holder.find('.pp_nav').prepend('play')
$pp_pic_holder.find('.pp_nav .pp_play').click(function(){
$.prettyphoto.startslideshow();
return false;
});
}
$pp_pic_holder.attr('class','pp_pic_holder ' + settings.theme); // set the proper theme
$pp_overlay
.css({
'opacity':0,
'height':$(document).height(),
'width':$(document).width()
})
.bind('click',function(){
if(!settings.modal) $.prettyphoto.close();
});
$('a.pp_close').bind('click',function(){ $.prettyphoto.close(); return false; });
$('a.pp_expand').bind('click',function(e){
// expand the image
if($(this).hasclass('pp_expand')){
$(this).removeclass('pp_expand').addclass('pp_contract');
doresize = false;
}else{
$(this).removeclass('pp_contract').addclass('pp_expand');
doresize = true;
};
_hidecontent(function(){ $.prettyphoto.open(); });
return false;
});
$pp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click',function(){
$.prettyphoto.changepage('previous');
$.prettyphoto.stopslideshow();
return false;
});
$pp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click',function(){
$.prettyphoto.changepage('next');
$.prettyphoto.stopslideshow();
return false;
});
_center_overlay(); // center it
};
return this.unbind('click').click($.prettyphoto.initialize); // return the jquery object for chaining. the unbind method is used to avoid click conflict when the plugin is called more than once
};
function grab_param(name,url){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexs = "[\\?&]"+name+"=([^]*)";
var regex = new regexp( regexs );
var results = regex.exec( url );
return ( results == null ) ? "" : results[1];
}
})(jquery);