
$(document).ready(function(){	
	$("#images-nav a").click(function () {
		$("#images-nav img").css("border","1px solid #FFFFFF");
		id = $(this).attr('rel');
		$(this).children("img").css("border", "1px solid #FF0000");
		$("#images img").hide();
		$("#images p").hide();
		$("#prod_img_" + id).show();
		$("#prod_description_" + id).show();
    });
});

function change() {
	speed = 600;
	galleries = $('.image_viewer');
	jQuery.each(galleries, function(i, val) {
		images = $(val).find('.image');
		image_count = $(images).size();
		for(j=0;j<image_count;j++) {
			if ($(images[j]).hasClass('active')) {
				old = j;
				$(images[j]).fadeOut(speed);
				$(images[j]).removeClass('active');
 
				old = old+1;
				if(old == image_count) {
					$(images[0]).addClass('active');
				} else {
					$(images[old]).addClass('active');
				}
				break;
			}
		}
		setTimeout('fadeIn()', speed);
    });
}
 
function fadeIn() {
	$('.image_viewer .image.active').fadeIn(speed);
}