var current_id = 1;

$(document).ready(function () {
	$("#block1").mouseover(event_over);
	$("#block1").mouseout(event_out);
	$("#block1").click(event_click);
	$("#block2").mouseover(event_over);
	$("#block2").mouseout(event_out);
	$("#block2").click(event_click);
	$("#block3").mouseover(event_over);
	$("#block3").mouseout(event_out);
	$("#block3").click(event_click);
	
	function getImage(id, isOver) {
		var index = (id - 1) * 2;
		if (isOver)
			index++;
		
		return "../images/events/" + event_images[index];
	}
	function show_image(id, isOver) {
		$("#block" + id + "_image").attr('src', getImage(id, isOver));
	}
	
	function event_over() {
		var event_id = $(this).attr('id');
		var id = event_id.substr(event_id.length - 1);
		show_image(id, true);
	}
	function event_out() {
		var event_id = $(this).attr('id');
		var id = event_id.substr(event_id.length - 1);
		if (id != current_id)
			show_image(id, false);
		
	}
	function event_click() {
		var event_id = $(this).attr('id');
		var id = event_id.substr(event_id.length - 1);
		if (id != current_id) {
			show_image(current_id, false);
			animate_blocks(current_id, id);
			current_id = id;
		}
	}
	function animate_blocks(id1, id2) {
		var label1 = "#block" + id1 + "_display";
		var label2 = "#block" + id2 + "_display";
		$(label1).hide();
		$(label2).show();
	}
});