/**
 * Javascript functions
 * 2011 (c) Badabing
 */

$(function() {
	/**
	 * Rotates with available images
	 * @param type type of rotation
	 */
	function rotateImage(type) {
		type = type || 'left';
		var $image = $("#actual-image");
		var maxIndex = images.length - 1;
		for (i in images) {
			var imagePath = images[i];
			if ($image.attr('src') == imagePath) {
				if (type == 'left') {
					i--;
					if (i < 0) {
						i = maxIndex;
					}
				} else {
					i++;
					if (i > maxIndex) {
						i = 0;
					}
				}
				$image.attr('src', images[i]);
				break;
			}
		}
	}
	
	$("#reference-detail > a.left-arrow").live("click", function() {
		rotateImage('left');
	});
		
	$("#reference-detail div.wrapper-image > img").live("click", function() {
		rotateImage('right');
	});
	
	$("#reference-detail > a.right-arrow").live("click", function() {
		rotateImage('right');
	});
})



