// Slideshow Functions
function jSlideshow(collection,delay) {

	// Setup Utility Variables
	this.images = $(collection);
	this.delay = (!delay || isNaN(delay)) ? 3000 : delay;

	// Create reference for THIS instance
	var me = this;

	// Ensure there are IMAGES in the COLLECTION
	if(this.images.length < 2) return false;

	// Slide In & Out
	this.slide = function(){

		// Get CURRENT Frame
		var jC = me.images.filter(':visible');

		// Get NEXT or FIRST Frame
		var jN = (!jC.next().length) ? me.images.filter(':first') : jC.next(); 

		// Next or First?
		jC.add(jN).fadeToggle(1000,function(){
			if($(this).is(':hidden')){
				$(this).children('div').hide();
			}else{
				$(this).children('div').show('slide',{direction:'left',duration:2000});
			}
		});

	}

	// Initialize 
	this.timer = setInterval(this.slide,this.delay);

	// Activate first CAPTION
	this.images.filter(':first').children('div').show('slide',{direction:'left',duration:2000});

}

// Go!
$(window).load(function(){

	// Load Slideshow for [page-header]
	pH = new jSlideshow('.global-header-show > ul > li',5000);

});
