$(document).ready(function() {
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		show_title: true,
		allow_resize: true,
		keyboard_shortcuts: true,
		theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
		social_tools: false,
		callback: clearHash()
	});
	
	
///////////////// SLIDE SHOW /////////////////////	
	if($('#featured').length)
	{
		if(! $('#featured img.active').length)
	 	{
	 		$('#featured img:first').addClass('active');
	 	}
		
		setInterval( "slideSwitch();", 5000 );
	}
	
	
		
});

///////////////// SLIDE SHOW SWITCH /////////////////////
function slideSwitch() {	
 	 
	var active = $('#featured img.active');//,
		//indicator_active = $('#slide_show_indicators span.active');
	
	// use this to pull the images in the order they appear in the markup
	var next =  active.next().length ? active.next()
	    : $('#featured img:first');
	    
	    
	/*var next_indicator =  indicator_active.next().length ? indicator_active.next()
	    : $('#slide_show_indicators span:first');*/
	    
	        
	active.addClass('last-active');
	/*indicator_active.addClass('last-active');*/
	
	next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			active.removeClass('active last-active');
			/*next_indicator.addClass('active');
			indicator_active.removeClass('active last-active');*/
	});
}



function clearHash () { 
    if ("pushState" in history)
        history.pushState("", document.title, window.location.pathname);
    else
        window.location.hash = "";
}
