

$( function(){
	
	
	/* link to pdf on home page */
	
	$( ".testimonial p" ).click( function(){
		
		window.open( $( this ).find( 'a' ).attr( 'href' ) );
		return false;
	} );
	
	/* XHTML 1.0 Strict doesn't like the target */
	$( ".testimonial a" ).click( function(){
		
		window.open( $( this ).attr( 'href' ) );
		return false;
	} );
	
	/* enable fancy box */
	
	$( "a.grouped_elements" ).lightBox({fixedNavigation:true});

	
	$( ".images_container a" ).append( "<img src='images/hover.png' class='hover_image' width='135' height='100' />" );
	$( ".press_item a.grouped_elements" ).append( "<img src='images/hover_large.png' class='hover_image' width='284' height='194'/>" );
	
	$( ".press_link" ).click( function(){
		$( this ).parent( ".press_item" ).find( ".grouped_elements" ).trigger( 'click' );
		return false;
	});
	
	$( ".gobacktohome" ).hover( 
		function(){
			$( this ).find( ":first" ).hide();
			$( this ) .find( ":last" ).show();
		},
		function(){
			$( this ) .find( ":first" ).show();
			$( this ) .find( ":last" ).hide();
		}
	)
	
	/* image gallery */
	current = 0;
	$( ".gallery_object:first" ).show();
	$( ".caption" ).html( $( ".gallery_object" ).eq( current ).find( "p" ).text() );
	if( $( ".gallery_object" ).size() > 0 ){
		$( ".next " ).show();		
		$( ".prev" ).hide();
	}
	
	$( ".gallery_object p" ).hide();
	 
	$( ".next" ).click( function(){
		$( ".gallery_object" ).eq( current ).hide();		
		current = current + 1;
		if( current > 0 ){
			$( ".prev" ).show();					
		}
		
		if( current == $( ".gallery_object" ).size() - 1 ){
			$( ".next" ).hide();	
		}else{
			$( ".next" ).show();				
		}
		
		$( ".gallery_object" ).eq( current ).show();		
		$( ".caption" ).html( $( ".gallery_object" ).eq( current ).find( "p" ).text() );
		//console.log( $( ".gallery_object" ).eq( current ).find( "p" ).text() );
	} );
	
	$( ".prev" ).click( function(){
		$( ".gallery_object" ).eq( current ).hide();		
		current = current - 1;
		if( current < 1 ){
			$( ".prev" ).hide();					
		}
		
		if( current == $( ".gallery_object" ).size() ){
			$( ".next" ).hide();	
		}else{
			$( ".next" ).show();				
		}
		
		$( ".gallery_object" ).eq( current ).show();		
		$( ".caption" ).html( $( ".gallery_object" ).eq( current ).find( "p" ).text() );
	} );
	
	$( ".homepagelink" ).hover( 
		function(){
			$( this ).attr( "src", "/images/assets/arrow_orange.png" );
		}, function(){
			$( this ).attr( "src", "/images/assets/arrow.png" );
		} );
	
	
} );
