var purephoto = (function(){
	
  //BEGIN global AJAX POST handler
  var fnAJAXPost = function(url,params,callback,callbackError) {
    $.ajax({
       type: "POST",
       url: url,
       cache: false,
       dataType : 'html',
       data: (params),
       success: function(msg){
          callback(msg);
       },
       error : function(msg) {
           alert('an error has occured. Please try again');
           callbackError();
       }
     });
  };
  //END global AJAX Get handling	
	
  var fnLeftMenu = function(evt) {
     var
       $obj = $(evt.target),
       $ul = $obj.closest('ul'),
       index = $ul.children('li').index($obj) 
      ;

      if(index < 0) return;

      switch(index) {
       case 0 : location='/'; break;
       case 2 : location='/organize'; break;
       case 3 : location='/learn'; break;
       case 4 : location='/share'; break;
       case 5 : location='/print'; break;
       case 6 : location='/sell'; break;
      }

   };
   
  var fnSubmitContactForm = function () {
    var params = {
        fname          : $('#firstName').val(),
        lname          : $('#lastName').val(),
        email          : $('#email').val(),
        phone          : $('#phone').val(),
        reason_contact : $('#reason').val(),
        questions      : $('#comments').val()
    };

    //cheesy validation
    if(params.fname.length < 1 || params.lname.length < 1
        || params.email.length < 1 || params.questions.length < 1) {
        alert('First Name, Last Name, Email address and Comments are required.');
        return;
    }

    var callback = function(data) {
      setTimeout("$('#subitSignupLoader').html('Thank you. We will get back to you as soon as possible.');", 2000);
    };

    var callbackError = function(data) {
      $('#submitContactUs').show();
      $('#subitSignupLoader').hide();
    };

    $('#submitContactUs').hide();
    $('#subitSignupLoader').show();
    fnAJAXPost('/sendmail.php',params, callback, callbackError);
  };   


  var fnFooterLinks = function(evt) {
     var
       $obj = $(evt.target),
       $span = $obj.closest('span'),
       index = $span.children('a').index($obj)
      ;  	

      if(index < 0 ) { return; }
      switch(index) {
        case 2 : window.open('/terms.html','help','top=75,left=20,width=800,height=700,toolbar=0,location=0,status=0,menubar=0,scrollbars=1'); break;
        case 3 : window.open('/privacy.html','help','top=75,left=20,width=800,height=700,toolbar=0,location=0,status=0,menubar=0,scrollbars=1'); break;
        default : break;
      }
  };
  
  
  var fnSubmitSellForm = function () {
    var params = {
        fname          : $('#firstName').val(),
        lname          : $('#lastName').val(),
        email          : $('#email').val(),
        phone          : $('#phone').val(),
        site           : $('#siteurl').val(),
        bio            : $('#biotext').val()
    };

    //cheesy validation
    if(params.fname.length < 1 || params.lname.length < 1
        || params.email.length < 1 || params.phone.length < 1 
        || params.site.length < 1 || params.bio.length < 1) {
        alert('All form fields are required.');
        return;
    }

    var callback = function(data) {
      $('div.sell_form').fadeOut('fast', function() {
      	  $('div.sell_form_thankyou').fadeIn('fast');
      });
    };

    var callbackError = function(data) {
      $('#submitSell').show();
      $('#submitSellLoader').hide();
    };

    $('#submitSell').hide();
    $('#submitSellLoader').show();
    
    fnAJAXPost('/sendmail_sell.php',params, callback, callbackError);
  }; 
  
    

  var fnInit= function init() {

    $('div.leftmenu').click(fnLeftMenu);
    $('div.contactbtn').click(fnSubmitContactForm);
    $('span.links').click(fnFooterLinks);
    $('span.logolink').click(function() {
      location = '/'; 
    });
    $('span.join').click(function() {
      location = 'https://members.purephoto.com/app/secure/login'; 
    });
    $('span.login').click(function() {
      location = 'https://members.purephoto.com/app/secure/login'; 
    });   
    $('#submitSell').click(fnSubmitSellForm); 
    $('#toolTipLayer span.closebox').click(function() {
    	$('#toolTipLayer').fadeOut();
    });
  };

  return { C : fnInit };

}() );

function showLayer(id) {
  try {
  var layer = "tooltip-"+id;
  var html = $('#'+layer).html();
  $('#toolTipLayer span.content').html(html);
  $('#toolTipLayer').fadeIn();
  }catch(err) {}
}

/*
 * Photozen JavaScript Library http://photozen.net
 * Copyright (c) 2010 Photozen Inc, All rights reserved
 *
 * slideshow -- embeds a rolling slideshow in any matched elements
*/

/*jslint laxbreak: true, browser: true,
   bitwise: true, eqeqeq: true, nomen: true,
   onevar: false, plusplus: false,
   regexp: true, undef: true,
*/

/*global pz $ Math console document setTimeout Showdown */
var pz = ( function(){

  // BEGIN public utility /fnGetClassOf/
  // Returns 'Object', 'Array', 'String', 'Number', 'Boolean', 'Undefined'
  var fnGetClassOf = function( arg_data ){
    if (undefined === arg_data ){ return "Undefined"; }
    if (null      === arg_data ){ return "Null"; }
    return {}.toString.call(arg_data).slice(8, -1);
  };
  // END public utility /fnGetClassOf/

  // BEGIN public utility /fnGetHashCopy/
  // Warning: this returns a shallow copy; values other than
  // strings or numbers will use references!
  var fnGetHashCopy = function( arg_hash ){
    var hash_copy = {}, key;
    for ( key in arg_hash ){
      // filter out extended properties
      if ( arg_hash.hasOwnProperty(key) ){
        hash_copy[key] = arg_hash[key];
      }
    }
    return hash_copy;
  };
  // BEGIN public utility /fnGetHashCopy/
  // get hash args - params from bookmark string split by a '|'
  var fnGetHashBArg = function(){
    var
      hash_b_arg = {},
      ary_b_args = location.hash.substring(1).split('|'),
      idx_arg, idx_pos, ary_key_val
      ;

    H_ARG:
    for( idx_arg = 0; idx_arg < ary_b_args.length; idx_arg++ ){
      ary_key_val = ary_b_args[idx_arg].split('=');

      switch ( ary_key_val.length ){
        case 1:
          hash_b_arg[decodeURIComponent(ary_key_val[0])] = true;
        break;
        case 2:
          hash_b_arg[decodeURIComponent(ary_key_val[0])]
            = decodeURIComponent(ary_key_val[1])
            ;
        break;
        default:
          continue H_ARG;
      }
    }
    return hash_b_arg;
  };

  var fnGetStrToday = function(){
    var
      obj_date   = new Date(),
      int_year   = obj_date.getYear() + 1900,
      int_month  = obj_date.getMonth() + 1,
      int_date   = obj_date.getDate(),
      str_year   = int_year + '',
      str_month  = int_month < 10 ? '0' + int_month + '' : int_month + '',
      str_date   = int_date  < 10 ? '0' + int_date  + '' : int_date  + '',
      str_today  = str_year + '-' + str_month + '-' + str_date
      ;
    return str_today;
  };

  // BEGIN fnPreloadImgs
  // revised to pass jslint tests from: 
  //   http://ajaxian.com/archives/preloading-images-with-jquery
  // See http://www.filamentgroup.com/lab/\
  //   update_automatically_preload_images_from_css_with_jquery/
  //   for alternate implementation
  // We store the image objects in a hash to (a) prevent multiple
  //   loads of the same image, and (b) prevent aggressive garbage collection
  //   from dumping object before it has a chance to load
  //
  var Hash_Obj_Img_Cache = {};

  var fnPreloadImgs = function(){
    var
      ary_imgs = [],   // new array for all the image urls
      idx_img  = 0,    // iterator for adding images
      ary_ss   = document.styleSheets, //array of stylesheets
      idx_ss,
      str_css, str_css_href,ary_url_bits, str_base_url,
      ary_ss_rules, idx_rule, ary_img_urls, idx_url,
      obj_img, str_url
      ;

    // Begin loop through each stylesheet
    for ( idx_ss = 0; idx_ss<ary_ss .length; idx_ss++){

      //create large string of all css rules in sheet
      str_css      = '';
      str_css_href = (ary_ss[idx_ss].href)
        ? ary_ss[idx_ss].href : 'window.location.href'
        ;

      // split href at / to make array
      ary_url_bits = str_css_href.split('/');

      // remove file path from base_url array
      ary_url_bits.pop();

      // create base url for the images in this sheet (css file's dir)
      str_base_url = ary_url_bits.join('/') + '';

      // tack on a / if needed
      if ( str_base_url !== '' ){ str_base_url += '/'; }

      // w3
      if ( document.styleSheets[idx_ss].cssRules ){
        ary_ss_rules = document.styleSheets[idx_ss].cssRules;
        for ( idx_rule = 0; idx_rule<ary_ss_rules.length; idx_rule++ ){
          str_css+= ary_ss_rules[idx_rule].cssText;
        }
      }
      else {
        str_css+= document.styleSheets[idx_ss].cssText;
      }

      //parse str_css for image urls and load them into the DOM
      //reg ex to get a string of between a "(" and a ".filename"
      ary_img_urls = str_css.match(/[^\(]+\.(gif|jpg|jpeg|png)/g);

      // Begin loop over all found image urls
      if ( ary_img_urls !== null
        && ary_img_urls.length > 0
      ){
        for ( idx_url = 0; idx_url < ary_img_urls.length; idx_url++ ){
          str_url = ary_img_urls[idx_url];

          if ( ! ( str_url.substr(0,1) === '/'
            || str_url.match('http://') )
          ){
            str_url = str_base_url + str_url;
          }

          if ( ! Hash_Obj_Img_Cache.hasOwnProperty(str_url) ){
            obj_img = new Image();
            obj_img.src = str_url;
            Hash_Obj_Img_Cache[str_url] = obj_img;
            // after the image load, we are cached, so we no longer
            // need the image object hanging around; but we keep the key
            // so we don't re-cache
            Hash_Obj_Img_Cache[str_url].onload
              = function(){ Hash_Obj_Img_Cache[this.src] = null; }
              ;
            // console.warn( 'preloaded %s', str_url );
          }
          else {
            // console.warn ('already cached %s', str_url );
          }
        }
      }
    }
    // End loop through each stylesheet
    return true;
  };
  // END fnPreloadImgs

  // BEGIN fnDecodeHTML
  // Decodes HTML entities in a browser-friendly way
  // See http://stackoverflow.com/questions/1912501/unescape-html-entities-in-javascript
  var fnDecodeHTML = function ( arg_str ){
    return $('<div/>').html(arg_str).text();
  };
  // END fnDecodeHTML

  // export methods
  return {
    decodeHTML     : fnDecodeHTML,
    getHashCopy    : fnGetHashCopy,
    getClassOf     : fnGetClassOf,
    getHashBArg    : fnGetHashBArg,
    getStrToday    : fnGetStrToday,
    preloadImgs    : fnPreloadImgs
    // fnLogEventReport : fnLogEventReport,
    // fnFancyButts     : fnFancyButts,
  };
}() );

pz.ss = {
	updater : false, // will contain the id of the interval timer
	
	markdown : function(t){ 
		t = t.replace(/\&amp\;/g, '&');
		if( typeof(Showdown) === 'object' ){
			t = t.replace( /\\n/g, "\n" );
			var converter = new Showdown.converter();
			return converter.makeHtml(t);
		} else {
			t = t.replace( /\\n/g, "<br/>");
			return '<p>' + t + '</p>';
		}
	},
	
	slideshows : [],
	
	// this handles the json data once it arrives,
	// we build the show object onto our original options object (which, you may recall, we returned),
	// and then we append the options object to the slideshows array
	load_slideshow : function( elt_id, show ){ 
		return function( data ){
			$(elt_id)
			.css( 'background-color', show.background_color )
			.css( 'overflow', 'hidden' )
			.html('');
			
			show.elt_id = elt_id;
			show.ar = data.ar;
			show.hc = data.hc;
			
			//console.log( 'Created new slideshow: ', show );
			
			show.current_slide = -1;
			show.last_slide_loaded = new Date().getTime() 
				- (show.transition_duration + show.slide_duration) * 1000;
			
			if( data.ar.length === 0 ){
				console.warn( 'Error: empty slideshow.' );
			}
			pz.ss.resized = true;
			
			show.ready = true;
			
			show.handleEvent( 'load' );
			
			pz.ss.slideshows.push( show );
		};
	},
	
	// simple error handling function that vomits everything it's passed to the console...
	// actually simply passing console.log as an error handler would work just as well :-)
	handle_error : function(){
		for( var i = 0; i < arguments.length; i++ ){
			//console.log( arguments[i] );
		}
	},
	
	// cache an image, return an object containing that image with a member ("ready") that will indicate when it's
	// ready to display
	cache_image : function( show, idx ){
		if( idx < 0 ){
			idx += show.ar.length;
		}
		if( idx >= 0 && idx < show.ar.length && show.ar[idx].img === undefined ){
			var p = show.ar[idx];
			p.img = new Image();
			p.url = show.server_url + "/app/img/1000/" + p.u + ".jpg?dts=" + p.dt;
			p.img.src = p.url;
			p.ready = false;
			p.img.onload = function(){ p.ready = true; };
		}
	},
	
	// sets a default value inside an array (hash) if the current value is undefined
	set_default : function( options_array, key, default_value ){
		if( options_array[key] === undefined ){
			options_array[key] = default_value;
		}
	},
	
	// attaches an array to nominated element(s) (div or whatever -- jQuery specification, e.g. 'div#foo')
	attach_slideshow : function( elt_id, url ){
		var 
			h = pz.ss,
			show = arguments.length > 2 ? arguments[2] : {} ;
			
		pz.ss.set_default( show, 'background_color', '#fff' ); // <-- CSS color spec
		pz.ss.set_default( show, 'slide_duration', 2 ); // <-- seconds
		pz.ss.set_default( show, 'transition_duration', 0.5 ); // <-- seconds
		pz.ss.set_default( show, 'transition', 'push_right_to_left' ); // | none | crossfade | push_left_to_right | grid
		pz.ss.set_default( show, 'scale', 'to_fill' ); // | to_fit | noscale
		pz.ss.set_default( show, 'autoplay', true ); // | false (paused)
		pz.ss.set_default( show, 'caption_class', '' );
		pz.ss.set_default( show, 'server_url', '' );
		pz.ss.set_default( show, 'v_align', 'center' ); // | top | bottom
		pz.ss.set_default( show, 'h_align', 'center' ); // | left | right
		pz.ss.set_default( show, 'first_slide', -1 ); // | -1 (random) | n >= 0
		if( show.caption_class !== '' ){
			show.caption_class = ' class="' + show.caption_class + '" ';
		}
		show.ready = false;
		
		if( typeof( url ) === 'string' ){
			//( 'attaching slideshow to ' + elt_id + ' from ' + show.server_url + url );
			$.ajax({
				url		: show.server_url + url,
				cache	: false,
				dataType: 'jsonp',
				jsonp	: 'jsonp_callback',
				type	: 'GET',
				success : h.load_slideshow( elt_id, show ),
				error : h.handle_error
			});
		} else if ( typeof( url ) === 'object' ) {
			//console.log( 
				//'attaching slideshow to ' + elt_id + ' using data', 
				//url 
			//);
			setTimeout( 
				function(){
					(h.load_slideshow( elt_id, show ))( url );
				}, 
				500
			);
		} else {
			//console.log( 
				//'error attaching slidehow to ' + elt_id + '(bad url)' 
			//);
		}
		
		pz.ss.init_slideshows();
			
		show.eventHandlers = [];
		
		show.addEventHandler = function( eventType, fnHandler ){
			show.eventHandlers.push({
				event : eventType,
				handler : fnHandler
			});
			return show;
		};
		
		show.handleEvent = function( eventType ){
			for( var idx in show.eventHandlers ){
				if( show.eventHandlers[idx].event === eventType ){
					show.eventHandlers[idx].handler();
				}
			}
			return show;
		};
		
		show.previous = function(){
			show.pause();
			pz.ss.load_slide( show, show.current_slide - 1 );
			return show;
		};
		
		show.next = function(){
			show.pause();
			pz.ss.load_slide( show, show.current_slide + 1 );
			return show;
		};
		
		show.update = function(){				
			var
				now = new Date().getTime();
			
			if( show.ready ){
				if( 
					show.autoplay 
					&& now > (show.slide_duration + show.transition_duration) * 1000 + show.last_slide_loaded 
				){
					pz.ss.next_slide( show );
				}
				if( pz.ss.resized ){
					show.handleEvent('beforeResize');
					if( show.current_slide >= 0 ){
						pz.ss.show_slide( show, show.current_slide );
					}
				}
				if( 
					pz.ss.resized
					|| show.transition === 'none' 
					|| now > show.transition_duration * 1000 + show.last_slide_loaded 
				){
					$(show.elt_id).each(function(){
						$(this).children('div.slide').each( function(idx){
							if( idx > 0 ){
								$(this).remove();
							}
						});
					});
				}
				if( pz.ss.resized ){
					show.handleEvent('afterResize');
				}
				if( show.pending_slide !== show.current_slide ){
					pz.ss.show_slide( show, show.pending_slide );
				}
			}
			show.handleEvent('update');
		};
		
		show.pause = function(){
			//console.log( 'paused slideshow attached to ' + show.elt_id );
			show.autoplay = false;
			show.handleEvent( 'pause' );
			return show;
		};
		
		show.play = function(){
			//( 'playing slideshow attached to ' + show.elt_id );
			pz.ss.load_slide( show, show.current_slide + 1 );
			show.autoplay = true;
			show.handleEvent( 'play' );
			return show;
		};
		
		show.toggle_play = function(){
			if( !show.autoplay ){
				show.play();
			} else {
				show.pause();
			}
			return show;
		};
		
		show.attachButton = function( buttonObj ){
			var
				elt_id = buttonObj.elt_id;
				
			switch( buttonObj.type ){
				case 'play':
					$( buttonObj.elt_id ).click( show.play );
					break;
				case 'pause':
					$( buttonObj.elt_id ).click( show.pause );
					break;
				case 'play_or_pause':
					var
						play_code = buttonObj.play_code,
						pause_code = buttonObj.pause_code,
						updatePlayOrPause = function(){
							if( show.autoplay ){
								$( elt_id ).html( pause_code );
							} else {
								$( elt_id ).html( play_code );
							}
						};
						
					$( elt_id ).click( show.toggle_play );
					show.addEventHandler(
						'pause',
						updatePlayOrPause
					);
					show.addEventHandler(
						'play',
						updatePlayOrPause
					);
					updatePlayOrPause();
					break;
				case 'next':
					$( buttonObj.elt_id ).click( show.next );
					break;
				case 'previous':
					$( buttonObj.elt_id ).click( show.previous );
					break;
				case 'progress':
					$( elt_id ).click( function( evt ){
						var 
							a = evt.target.innerHTML.split('#'),
							x = a.length > 2 ? x = parseInt(a[1], 10) : false;
						if( typeof( x ) === 'number' ){
							//( 'slide', x );
							show.pause();
							pz.ss.load_slide( show, x );
						}
					});
					show.addEventHandler(
						'load',
						function(){
							for( var i = 0; i < show.ar.length; i++ ){
								$( '<span><!--#' + i + '#--></span>' ).appendTo( $( elt_id ) ).addClass(
									i === show.current_slide 
									? buttonObj.item_current_class
									: buttonObj.item_class
								);
							}
						}
					).addEventHandler(
						'slideChanged',
						function(){
							$( elt_id + ' span' ).each( function(i){
								if( i === show.current_slide ){
									$(this).removeClass( 
										buttonObj.item_class 
									).addClass(
										buttonObj.item_current_class
									);
								} else {
									$(this).removeClass(
										buttonObj.item_current_class
									).addClass( 
										buttonObj.item_class 
									);
								}
							});
						}
					);
					break;
			}
			return show;
		};
		
		return show;
	},
	
	// simple-minded function for rotating images in 90¬∞ increments 
	// using the wonderful propietary CSS transforms
	// IE, Mozilla, Webkit, and Opera browsers should be supported
	image_rotation_css : function( angle ){
		var
			code = '';
			
		switch( angle ){
			case 90:
				code =	'filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);';
				code +=	'-webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -o-transform: rotate(90deg);';
				break;
			case 180:
				code =	'filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);';
				code +=	'-webkit-transform: rotate(180deg); -moz-transform: rotate(180deg); -o-transform: rotate(180deg);';
				break;
			case -90:
			case 270:
				code =	'filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);';
				code +=	'-webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); -o-transform: rotate(-90deg);';
				break;
			default:
				// do nothing (either it's 0 or some value not a multiple of 90 which we can't handle anyway)
		}
		
		return code;
	},
	
	// simple function to parse out special markup from pz gallery text fields
	render_text : function( t ){
		var
			heading = t.substr( 0, t.indexOf('%!%') ),
			body = t.substr( heading.length + 3 ),
			code = '';
		
		if( heading !== '' ){
			code += '<h1>' + heading + '</h1>';
		}
		
		if( body !== '' ){
			code += pz.ss.markdown(body);
		}
		
		return code;
	},
	
	load_slide : function( show, which_slide ){
		// force which_slide to a legal value
		if( which_slide < 0 ){
			which_slide += show.ar.length;
		}
		if( which_slide >= show.ar.length ){
			which_slide = 0;
		}
		
		// just in case we haven't cached the image (e.g. random access)
		pz.ss.cache_image( show, which_slide );
		
		show.pending_slide = which_slide;
	},
	
	next_slide : function( show ){
		if( show.current_slide === -1 ){
			pz.ss.load_slide( 
				show, 
				show.first_slide < 0 
					? Math.floor( Math.random() * show.ar.length ) 
					: show.first_slide
			);
		} else {
			pz.ss.load_slide( show, show.current_slide + 1 );
		}
	},
	
	show_slide : function( show, pending_slide ){
		// ready is set by the onload handler cache_image attaches to the .img
		if( 
			show.ar[pending_slide].ready !== undefined 
			&& show.ar[pending_slide].ready 
		){
			var 
				code, 
				x, y, w, h,
				scale,
				p = show.ar[pending_slide];
			
			$(show.elt_id).each( function(){
				var
					ow = $(this).width(),
					oh = $(this).height();
				p.d = (p.d + 360) % 360;
				if( p.d === 90 || p.d === 270 || p.d === -90 ){
					w = p.img.height;
					h = p.img.width;
				} else {
					w = p.img.width;
					h = p.img.height;
				}
				// implements our three scale options
				switch( show.scale ){
					case 'to_fit':
						scale = Math.min( ow / w, oh / h );
						break;
					case 'to_fill':
						scale = Math.max( ow / w, oh / h );
						break;
					default: // no_scale
						scale = 1;
				}
				// Note that we may need to tweak this on a per-browser basis
				w = Math.ceil( p.img.width * scale );
				h = Math.ceil( p.img.height * scale );
				switch( show.h_align ){
					case 'left':
						x = 0;
						break;
					case 'right':
						x = ow - w;
						break;
					default:
						x = Math.floor( ( ow - w ) * 0.5 );
				}
				switch( show.v_align ){
					case 'top':
						y = 0;
						break;
					case 'bottom':
						y = oh - h;
						break;
					default:
						y = Math.floor( ( oh - h ) * 0.5 );
				}
				
				/*
					Transitions
					
					In essence we set up an inline style for the incoming element and
					animations for the incoming and all outgoing elements. (Note that
					while there should only be one outgoing element, because this is
					all asynchronous, we make no assumptions.)
				*/
				var 
					new_style = '',
					existing_anim = {},
					new_anim = {},
					transition = show.resized ? 'none' : show.transition;
				switch( transition ){
					case 'push_right_to_left':
						new_style = 'left: ' + ow + 'px';
						existing_anim = new_anim = { left: '-=' + ow };
						break;
						
					case 'push_left_to_right':
						new_style = 'left: -' + ow + 'px';
						existing_anim = new_anim = { left: '+=' + ow };
						break;
						
					case 'push_top_to_bottom':
						new_style = 'top: -' + oh + 'px';
						existing_anim = new_anim = { top: '+=' + oh };
						break;
						
					case 'push_bottom_to_top':
						new_style = 'top: ' + oh + 'px';
						existing_anim = new_anim = { top: '-=' + oh };
						break;
						
					case 'crossfade':
						new_style = 'opacity: 0;';
						new_anim = { opacity: '+=1' };
						existing_anim = { opacity: '-=1' };
						break;
				}
				code = '<div class="slide" style="position: absolute; '
					+ 'width: ' + ow + 'px; height: ' + oh + 'px; overflow: hidden; ' + new_style + '">'
					+ '<div class="image" style="width: ' + ow + 'px; height: ' + oh + 'px;">'
					+ '<div style="position: absolute; left: ' + x + 'px; top: ' + y + 'px;">'
					+ '<img style="' + pz.ss.image_rotation_css( p.d ) 
					+ '" width="' + w + '" height="' + h + '" src="' + p.url + '" />'
					+ '</div></div>';
				if( show.caption_class !== '' ){
					code += '<div' + show.caption_class + '>' + pz.ss.render_text( p.t ) + '</div>';
				}
				code += '</div>';
				$(this).children( 'div.slide' ).animate( 
					existing_anim, 
					show.transition_duration * 1000, 
					'swing' 
				);
				$(code).animate( 
					new_anim, 
					show.transition_duration * 1000, 
					'swing' 
				).prependTo( $(this) );
			} );
			show.last_slide_loaded = new Date().getTime();
			if( show.current_side !== pending_slide ){
				show.current_slide = pending_slide;
				show.handleEvent( 'slideChanged' );
			}
			pz.ss.cache_image( show, pending_slide + 1 );
		}
	},
	
	// Updates each slideshow in the slideshows array
	update_slideshows : function () {	
		if( 
			pz.ss.doc_width !== $(document).width()
			|| pz.ss.doc_height !== $(document).height()
		){
			pz.ss.resized = true;
			pz.ss.doc_width = $(document).width();
			pz.ss.doc_height = $(document).height();
			//( 'resized' );
		}
	
		for( var i = 0; i < pz.ss.slideshows.length; i++ ){
			pz.ss.slideshows[i].update();
		}
		
		pz.ss.resized = false;
	},
	
	// Create an interval task that updates the slideshows
	init_slideshows : function (){
	
		pz.ss.doc_width = $(document).width();
		pz.ss.doc_height = $(document).height();
		pz.ss.resized = true;
		if( !pz.ss.updater ){
			pz.ss.updater = setInterval( pz.ss.update_slideshows, 100 );
		}
	}
};


$(document).ready( purephoto.C );


$(document).ready( function(){
try
{ 
      pz.ss.attach_slideshow(
               'div.inside_photos',
               '/app/json/gallery/1627/last',
               {
                       transition : 'crossfade',
                       slide_duration: 3,
                       transition_duration : 1,
                       scale: 'to_fill',
                       server_url : 'http://members.purephoto.com'
               }
       );

       pz.ss.attach_slideshow(
               'div.photos',
               '/app/json/gallery/1626/last',
               {
                       transition : 'crossfade',
                       slide_duration: 3,
                       transition_duration : 1,
                       scale: 'to_fill',
                       server_url : 'http://members.purephoto.com'
               }
       );
}catch(err) {}
});
