/*********************************************************************************************************************************/
/* 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"]').val('Search');
	$('#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 *****************************************************************/
	
	$('#page-oring-sizes').jScrollPane({scrollbarWidth:17,scrollbarMargin:0,showArrows:true});

}); //close document.ready

/*********************************************************************************************************************************/
/* DOCUMENT READY FUNCTIONS ******************************************************************************************************/
/*********************************************************************************************************************************/
if($('#internal').length >0){Cufon.replace('#page-title');}
/* SLIDESHOW function start *********************************************************/
function slideSwitch() {
	var selector = "#slideshow .display span";
	var $active = $(selector+'.active');
	
	if ( $active.length == 0 ) $active = $(selector+':first');
	
	var $next = $active.next('span').length ? $active.next() : $(selector+':first');	
	var item_active = $active.attr('id'); item_active = item_active.replace(/photo-/,'');
	var item_next = $next.attr('id'); item_next = item_next.replace(/photo-/,'');
	
	$active.addClass('last-active');
			$('#slideshow .'+item_next).addClass('active');
			$('#slideshow .'+item_active).removeClass('active');
	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 500, function() {
			 $active.removeClass('active last-active');
	});
	
}
/* SLIDESHOW function end ***********************************************************/