/*********************************************************************************************************************************/
/* DOCUMENT READY CALLS **********************************************************************************************************/
/*********************************************************************************************************************************/

$(document).ready(function(){
	
	/* EXTERNAL LINKS start ***********************************************************/
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	/* EXTERNAL LINKS end *************************************************************/
	
	$('html').addClass('js');

	/* SLIDESHOW start ***************************************************************/
	$("#slideshow p:first").addClass('active');
	var slideshow = setInterval( "slideSwitch('#slideshow p',500,'Next')", 3500 );
	/* SLIDESHOW end *****************************************************************/

}); //close document.ready

/*********************************************************************************************************************************/
/* DOCUMENT READY FUNCTIONS ******************************************************************************************************/
/*********************************************************************************************************************************/
if($('#internal').length){Cufon.replace('#page-title');}

/* SLIDESHOW function start *********************************************************/
function slideSwitch(selector,opacity_speed,direction) {
	var $active = $(selector+'.active');

	if ( $active.length == 0 ) $active = $(selector+':first');	
	
	if(direction == 'Next' || direction == null){ var $next = $active.next().length ? $active.next() : $(selector+':first'); }
	else if(direction == 'Previous') { var $next = $active.prev().length ? $active.prev() : $(selector+':last'); }	

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, opacity_speed, function() {
			 $active.removeClass('active last-active');
	});
	
}
/* SLIDESHOW function end ***********************************************************/