/**
 * The function js_gallery_previous() shows previous gallery-collection image.
 */
function js_gallery_previous()
{
	if (current_image > 0)
	{
		current_image = current_image-1;
		var img_canvas = document.getElementById('js_gllery_canvas');
		img_canvas.src = grange_gallery_big_img_array[current_image];
		js_gallery_caption();
		
	}	
} 

/**
 * The function js_gallery_next() shows next gallery-collection image.
 */
function js_gallery_next()
{
	if (current_image < grange_gallery_big_img_array.length-1)
	{
		current_image++;
		var img_canvas = document.getElementById('js_gllery_canvas');
		img_canvas.src = grange_gallery_big_img_array[current_image];
		js_gallery_caption();
	}	
} 

/**
 * The function js_gallery_load_by_address(img_way) shows the image which loading by address img_way
 */
function js_gallery_load_by_address(img_way)
{
	var img_canvas = document.getElementById('js_gllery_canvas');
	img_canvas.src = img_way;

	//Search image number in main array by it value
    	var searching_number = 0; 
	while(grange_gallery_big_img_array[searching_number] != img_way)
	{
		searching_number++;
	}
	current_image = searching_number;
	js_gallery_caption();

}

/**
 * The function js_gallery_load_by_index(img_index) shows the image from gallery-collection by it index
 */
function js_gallery_load_by_index(img_index)
{
	current_image = img_index-1;
	var img_canvas = document.getElementById('js_gllery_canvas');
	img_canvas.src = grange_gallery_big_img_array[current_image];
	js_gallery_caption();
}


/**
 * The function js_gallery_caption() generates and prints caption under the current image
 */
function js_gallery_caption()
{
	var  gallery_control_caption = document.getElementById('js_gallery_control_caption');
	gallery_control_caption.innerHTML = (current_image+1)+"/"+grange_gallery_big_img_array.length;
}