// *********************************************** //
// Photos for sale                                 //
// *********************************************** //
// Author: rachel@dollypower.com                   //
// ----------------------------------------------- //
// This code removes the "photos-for-sale" class,  //
// if the galleries aren't for sale.               //
// ----------------------------------------------- //

 jQuery(document).ready(function(){
	
	// Add the gallery name as a class to the body
	var galleryName = jQuery("div.ngg-galleryoverview").attr("id");
	jQuery('body').addClass(galleryName);
	
	// Add a class of "photos-for-sale" to all ablum pages by id
		// London = page-id-15
		// Manchester = page-id-31
		// Brighton = page-id-42
		// All = page-id-155
		// Photobooth = page-id-1191
		
	// jQuery('body.page-id-15, body.page-id-31, body.page-id-42, body.page-id-155, body.page-id-1191').addClass('photos-for-sale');
	
	jQuery('body.page-id-1191').addClass('photos-for-sale');
	
	// Remove class for galleries that are NOT for sale
	// jQuery('body.ngg-gallery-47-31').removeClass('photos-for-sale');
	
 });

// *********************************************** //
// "Add to cart" PayPal buttons on photo galleries //
// *********************************************** //
// This code is in the file /js/thickbox.js, which //
// is which by the gallery plugin. It here for     //
// reference and back-up.                          //

// Only apply these buttons on photobooth pages 
// which now have a class of "photos-for-sale"

//if(jQuery('body').hasClass('photos-for-sale')){

	// Find the caption on photobooth page
	// and add the <p> for the photo id reference
	//jQuery("body.photos-for-sale div#TB_caption")
		//.prepend("<p class='photoID'><strong>Ref:</strong> <span></span></p>");
	
	// Get the photo source to form the ID
	//var photoURL = jQuery("body.photos-for-sale img#TB_Image").attr("src");

	// Spilt the source URL by forward slashes
	//var photoURLArray = photoURL.split('/');
	
	// Use the 5th and 6th parts to create the ID
	//var photoID = (photoURLArray[5]) + ("/") + (photoURLArray[6]);
	//jQuery("p.photoID span").text(photoID);				   
						   
	// Make the "Add to cart" button by using 
	// the PayPal code and inserting the photo ID
	//var button = "<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'><input type='hidden' name='cmd' value='_cart'><input type='hidden' name='business' value='info@guiltypleasures.co.uk'><input type='hidden' name='lc' value='GB'><input type='hidden' name='item_name' value='Photo'><input type='hidden' name='item_number' value='" + photoID + "'><input type='hidden' name='amount' value='6.38'><input type='hidden' name='currency_code' value='GBP'><input type='hidden' name='button_subtype' value='products'><input type='hidden' name='no_note' value='0'><input type='hidden' name='cn' value='Add special instructions to the seller'><input type='hidden' name='no_shipping' value='2'><input type='hidden' name='rm' value='1'><input type='hidden' name='return' value='http://www.guiltypleasures.co.uk/photobooth/thanks'><input type='hidden' name='cancel_return' value='http://www.guiltypleasures.co.uk/photobooth/problem'><input type='hidden' name='shipping' value='0.00'><input type='hidden' name='add' value='1'><input type='hidden' name='bn' value='PP-ShopCartBF:btn_cart_LG.gif:NonHosted'><input type='image' src='https://www.paypal.com/en_GB/i/btn/btn_cart_SM.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online.'><img alt='' border='0' src='https://www.paypal.com/en_GB/i/scr/pixel.gif' width='1' height='1'></form>";
	
	// Insert button in also caption, after reference.
	//jQuery("body.photos-for-sale div#TB_caption p.photoID")
		//.append(button);
	//}

