var i = 0;

function SetSlide( caller )
{
	var current;
	if( i%2 == 1 )
	{
		current = '#mainImage .fade_even';
	}
	else
	{
		current = '#mainImage .fade_odd';
	}
	
	if( jQuery(current+' img').attr('src') != jQuery(caller).parent().attr('href') )
	{
		jQuery('#gallery .image').removeClass('selected');
		jQuery(caller).parent().parent().addClass('selected');

		jQuery(current+' img').attr('src',jQuery(caller).parent().attr('href'));
		jQuery(current+' img').attr('alt',jQuery(caller).attr('alt'));
                var wholeTitle = jQuery(caller).parent().attr('title');
                var title = wholeTitle.substring(0, wholeTitle.indexOf("."));
                var subtitle = wholeTitle.substring(wholeTitle.indexOf(".")+1);
		jQuery(current+' .caption').html('<h1 style=\"color: #' + jQuery(caller).parent().attr('class') + ';\">'+title+'</h1>');
                jQuery(current+' .caption h1').after('<h3 style=\"color: #' + jQuery(caller).parent().attr('class') + ';\">'+subtitle+'</h3>');

		jQuery(current).fadeTo(0,0);
		jQuery(current).css('z-index',i+++2);
		jQuery(current).fadeTo(500,1);
	}
}
function NextPage()
{
	jQuery('#galleryWindow').animate({scrollLeft: '+=218px'},500);
}
function PreviousPage()
{
	jQuery('#galleryWindow').animate({scrollLeft: '-=218px'},500);
}

/*jQuery.noConflict();*/
/*jQuery(document).ready( function(){
jQuery('#gallery .image a').click(function(e) {
    e.preventDefault();
});
	jQuery('#galleryScroller').css('width',(jQuery('#gallery .image img').size()*218)+'px')
	jQuery('#arrow_l').click( function(){PreviousPage();} );
	jQuery('#arrow_r').click( function(){NextPage();} );
	jQuery('#gallery .image img').click( function(){SetSlide( this );} );
});*/
