// BarkleyREI Gallery 1.0 
$.fn.rei_gallery=function(container){
	//populate container with image object
	var init_display = $(this).parent().children("li").get(0);
	var the_img = '<img src="' + $(init_display).find("a").attr("href") + '" alt="' + $(init_display).find("a").attr("title") + '" title="' + $(init_display).find("a").attr("title") + '" />'
	$(container).prepend(the_img);
	$(init_display).addClass('active');	
	//on li click
	return this.click(function(){
		//source and target attributes
		var target = $(container + " img").attr("src");
		var source =  $(this).find("a").attr("href");
		var alt_text = $(this).find("a").attr("title");
		//active class
		$(this).siblings().removeClass('active');
		$(this).addClass('active');
		//swap images
		if (target != source) {
			$(container + " img").fadeOut(250, function() {$(container + " img").attr({src: source, title: alt_text, alt: alt_text}).fadeIn(250);});
		};
		return false;
	});
};
