g_current_image = 0;
function show_image(num) {
	// animation: opacity 0 -> 1
	function show() {
		$("#big_img").style.backgroundPosition = "0px 15px";
		$("#big_img").style.backgroundImage = "url("+ images_array[g_current_image].src +")";
		window.setTimeout(
			function() {
				Animation.add(
					{
						"obj": 	$("#big_img"),
						"prop": "opacity",
						"begin": "0",
						"end": "1",
						"time": 3000,
						"points": 60,
						"func": {
							"value": 1,
							"func": move
						}
					}
				);
			},
			200
		);
	}

	// animation: backgroundPositionX
	function move() {
		window.setTimeout(
			function() {
				Animation.add(
					{
						"obj": $("#big_img"),
						"prop": "backgroundPosition",
						"begin": "0px 15px",
						"end": "-42px 15px",
						"time": 4000,
						"points": 50,
						"func":  {
							"value": "-42px 15px",
							"func":	function() {
											window.setTimeout(
												function() {
													Animation.remove();
													choose_image();
												}
											),
											200
										}
						}
					}
				)
			},
			200
		);
	}
	g_current_image = num;
	Animation.add(
		{
			"obj": 	$("#big_img"),
			"prop": "opacity",
			"begin": "1",
			"end": "0",
			"time": 1000,
			"points": 20,
			"func": {
				"value": 0,
				"func": show
			}
		}
	)
}

function choose_image( ) {
	next_image = g_current_image + 1 >= images_array.length ? 0 : g_current_image + 1;
	show_image(next_image);
}
