$(document).ready(function(){
	$('#right-gallery a img').hover(
	function(){
		$(this).addClass('over');
												
	},function(){
		$(this).removeClass('over');
												
	});
				
	$("a.thumb").click(function() {
		var atag = $(this);
		$("#large-img").fadeOut(500, function() {
				$(this).attr({						 
					src: atag.attr('href'),
					name: atag.find("img").attr("name")});
						
				if (this.complete) $(this).fadeIn(500);
						
				  });
		changeCaption($(this).attr("title"));
	})
	$("img#prev").click(function() {
			f_slideshow(-1);
		 }).mouseover(function() {
			$(this).attr({ src : '/images/prev_over.gif'})
		 }).mouseout(function() {
			$(this).attr({ src : '/images/prev.gif'})
	 	 });
	$("img#next").click(function() {
			f_slideshow(1);
		 }).mouseover(function() {
			$(this).attr({ src : '/images/next_over.gif'})
		 }).mouseout(function() {
			$(this).attr({ src : '/images/next.gif'})
		 });
	
});

curImage = '';

function f_slideshow( n ) {
	var numImages = $('#right-gallery img').length;
	largeImg = $('#large-img');
	

	curImage = parseInt(largeImg.attr('name'));
	curImage = curImage + n;

	if (curImage > numImages)
		{ curImage = 1 ; }
	if (curImage == 0)
		{ curImage = numImages ; }		
		largeImg.fadeOut(500, function() {
			var newSrc = $('#right-gallery img:eq('+(curImage-1)+')').parent().attr('href');
			var target = $('#right-gallery img:eq('+(curImage-1)+')').parent();
			largeImg.attr({'name': String(curImage), 'src': newSrc});
			if (this.complete) $(this).fadeIn(500);
			changeCaption(target.attr("title"));
		});
		
}

function changeAtt(v){
$("#large-img").attr("name", v);
}

function changeCaption(v){
$("#caption").html(v);
	if (v == '') {
		$("#caption").fadeOut(500);
	}
	else $("#caption").fadeIn(500);
}

						   

	
				
	




