$(document).ready(function() {		
	// Setup for Cycle Plugin
    $('#hp-slideshow').cycle({ 
		timeout: 3000, 
		before: onBefore
	}); 
 

	function onBefore(curr,next,opts) {

		// Centers the slide img 
		
		// Height = Max image height plus any border width
		// Width = Max image width plus any border width
		// In this example I have a 1px border so I add 2 to my total width and height below
		
		var $slide = $(next);
		var w = $slide.outerWidth();
		var h = $slide.outerHeight();
		$slide.css({
			marginTop: (191 - h) / 2,
			marginLeft: (381 - w) / 2
		});
		
		
		// Centers the DIV vertically!!!! 	
		var divHeight = 191;
		var theImageHeight = $slide.outerHeight();
		var newTopMargin = (divHeight - theImageHeight) / 2;
		if(theImageHeight > 191){
			$('#hp-slideshow').css({
				marginTop: newTopMargin
			});
		}
	};
	
}); // END
