////////////////////////////////////////////////////
//
// GALLERYPRETTY.JS
//
//	This page defines javascript for the gallery
//	pages when the prettyPhoto plugin is used.
//
// Created 15/07/2009 by Chris Jones
//
////////////////////////////////////////////////////

function initPageSpecific()
{
	// Target the items designated to a specific gallery
	jQ(".RDCMS_JSexpose a[href*='images/linked'][rel]").each(function()
	{
		jQ(this).attr('rel','prettyPhoto['+jQ(this).attr('rel')+']');
	});
	jQ(".RDCMS_JSexpose a[href*='flash/linked'][rel]").each(function()
	{
		jQ(this).attr('rel','prettyPhoto['+jQ(this).attr('rel')+']');
	});
	jQ(".RDCMS_JSexpose a[href*='vimeo'][rel]").each(function()
	{
		jQ(this).attr('rel','prettyPhoto['+jQ(this).attr('rel')+']');
	});
	
	// Target the remaining items into a generic gallery
	jQ(".RDCMS_JSexpose a[href*='images/linked']:not([rel])").attr('rel','prettyPhoto[RDCMS_gallery]');
	jQ(".RDCMS_JSexpose a[href*='flash/linked']:not([rel])").attr('rel','prettyPhoto[RDCMS_gallery]');
	jQ(".RDCMS_JSexpose a[href*='vimeo']:not([rel])").attr('rel','prettyPhoto[RDCMS_gallery]');


	// Use the prettyPhoto plugin on them
	jQ(".arandomclassthatwillneverexist").prettyPhoto(
	{
		animation_speed: 400,
		required_flash_version: 9,
		default_width: 720,
		default_height: 405,
		counter_separator_label:' of ',
		allow_resize:false,
		theme:'light_square',
		noflash_imagepath:'../images/noflash.jpg?width=640&height=400'
	});


	jQ(".RDCMS_JSexpose a[rel^='prettyPhoto']").bind('click', function()
	{
		var images = jQ(".RDCMS_JSexpose a[rel='" + jQ(this).attr('rel') + "']").map(function(){
			return jQ(this).attr('href');
		}).get();
		var titles = jQ(".RDCMS_JSexpose a[rel='" + jQ(this).attr('rel') + "']").map(function(){
			return jQ(this).children('img').attr('alt');
		}).get();
		var descriptions = jQ(".RDCMS_JSexpose a[rel='" + jQ(this).attr('rel') + "']").map(function(){
			return (jQ(this).siblings('div').length > 0 ? jQ(this).siblings('div').eq(0).html() : '');
		}).get();
		var index = jQ(".RDCMS_JSexpose a[rel='" + jQ(this).attr('rel') + "']").index(jQ(this));
		jQ.prettyPhoto.open(images,titles,descriptions,index);
		return false;
	});

}
