// Wait until the document is ready.
// This is not necessarily when the page is finished loading!
$( document ).ready( function( ){

	/**********************************
	 * Top Page Navigation
	 **********************************/
	$( '#s200-topnav > li > a' ).click( function( evt ){
		$.scrollTo( '#s200-' + evt.target.name, 500 );
	});
	
	$( '.s200-backtotop' ).click(function(evt){
		$.scrollTo( 'top', 500 );
	});
	
	/**********************************
	 * Feeling Selector
	 **********************************/
	 $('#feeling').change( function( ){
		$('.s200-feeling').fadeOut( );
		
		switch( $( this ).val( ) )
		{
			case 'sassy':
				$('#img-sassy').fadeIn( );
				$('#img-sassy-txt').fadeIn( );
				break;
				
			case 'crabby':
				$('#img-crabby').fadeIn( );
				$('#img-crabby-txt').fadeIn( );
				break;
				
			case 'kinky':
				$('#img-kinky').fadeIn( );
				$('#img-kinky-txt').fadeIn( );
				break;
				
			default:
				//
		}
	});
	 
	/**********************************
	 * show 'about us' information
	 **********************************/
	function showBio ( ele )
	{
		// Make sure the requested bio isn't already
		// displayed.
		if ( $( ele + '-bio' ).is( ':hidden' ) )
		{
			// Hide the bio that is displayed.
			// ( This actually hides all bios )
			$( ".s200-bio" ).slideUp( 'fast' );
			
			// Display requested bio
			$( ele + '-bio').fadeIn( 'slow' );
		}
	}
	
	// Set onClick event listener for each stylist link.
	$(".biolink").click(function(evt){
		// Trigger function to display the corresponding bio when 
		// a link is clicked.
		showBio ( evt.target.hash );
	});
	
	/**********************************
	 * News Carousel
	 **********************************/
	var $paneTarget = $( '#press' );
	
	$( '#next-button' ).click( function( evt ) {
		$paneTarget.stop( ).scrollTo( '+=722px', 800 );
	});
	
	$( '#previous-button' ).click( function( evt ) {
		$paneTarget.stop( ).scrollTo( '-=722px', 800 );
	});
	
	/**********************************
	 * Flickr Stream Mod
	 **********************************/
	// open flickr in a new window
	$('#flickr_badge_wrapper a').attr('target', '_blank');
	
	/**********************************
	 * Anchor Handling
	 **********************************/
															 
		switch( location.hash )
		{
			case '#ashleydootson':
			case '#amymann':
			case '#jamyporter':
			case '#efrainvilla':
			case '#connietrent':
			case '#teresa':
				showBio( location.hash );
				break;
			case '#aboutus':
			case '#bookappt':
			case '#werefamous':
			case '#welookgood':
				//$.scrollTo( '#s200-' + location.hash.slice(1), 500 );
				break;
			default:
				//
		}

});
