/*********************************************************************************************************************************/
/* DOCUMENT READY CALLS **********************************************************************************************************/
/*********************************************************************************************************************************/

$(document).ready(function(){
	
	/* EXTERNAL LINKS start ***********************************************************/
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	/* EXTERNAL LINKS end *************************************************************/
	
	$('html').addClass('js');

	/*SEARCH start ********************************************************************/
	$('#search input[type="text"]').focus(function(){ if(this.value=='Search') { $(this).val('');} });
	$('#search input[type="text"]').blur(function(){ if(this.value =='') { $(this).val('Search');} });
	/*SEARCH end **********************************************************************/
		
	/* SLIDESHOW start ***************************************************************/
	var slideshow = setInterval( "slideSwitch()", 5000 );
	/* SLIDESHOW end *****************************************************************/
	
	$('#content .c').jScrollPane({showArrows:true,scrollbarWidth : 18});
	
}); //close document.ready

/*********************************************************************************************************************************/
/* DOCUMENT READY FUNCTIONS ******************************************************************************************************/
/*********************************************************************************************************************************/

/* SLIDESHOW function start *********************************************************/
function slideSwitch(direction) {
	var $active = $('#slideshow span.active');

	if ( $active.length == 0 ) $active = $('#slideshow span:first');	
	
	if(direction == 'Next' || direction == null){ var $next = $active.next('span').length ? $active.next() : $('#slideshow span:first'); }
	else if(direction == 'Previous') { var $next = $active.prev('span').length ? $active.prev() : $('#slideshow span:last'); }	

	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1500, function() {
			 $active.removeClass('active last-active');
	});
	
}
/* SLIDESHOW function end ***********************************************************/
