$(document).ready(function(){

	var active = false;
	
	$('p.newsimage').hide();
	
	$('a.newsimage').click(function(){
		$(this).parent().next('p.newsimage').toggle();
		var newHtml = ($(this).html() == 'Show image') ? 'Hide image' : 'Show image';
		$(this).html(newHtml);
		return false;
	});

	$('#thumbs a').click(function(){
		id = $(this).attr('id').substr(3);
		if(active) {
			$('#img'+active).children().toggle();
			$('#img'+active).removeClass('active');	
		}
		if(id != active) {
			if($(this).children("img.big").length>0) {
				$(this).children().toggle();
				$(this).addClass('active');
			} else {
				$(this).append(big[id]);
				$(this).children("img.small").hide();
				$(this).addClass('active');
			}
			active = id;
		} else {
			$(this).removeClass('active');
			active = false;
		}
		return false;
	});
	
	$('#bigimage').click(function(){
		$('#bigimage').html('');
	});

});
