﻿var currentID = 0;

function changeGalleyImg(imgPath,imgID){
	
	if(imgID == "next"){
	
		if(currentID == galleyMax - 1){
			currentID = 0;
		}else{
			currentID++;
		}
		
		imgID = currentID;
	
	}else if(imgID == "prev"){
	
		if(currentID == 0){
			currentID = galleyMax;
		}else{
			currentID--;
		}
		
		imgID = currentID;
		
	}else{
		currentID = imgID;
	}
	
	document.getElementById("g_image").src = imgPath + imgList[imgID][0];
	document.getElementById("g_imgConti").style.visibility = "hidden";
	chgImg = window.setInterval(showStatus,1,imgPath,imgID);
	
}

function showStatus(imgPath, imgID){
	
	if(imgID == null){ imgID = currentID; }
	
	if(document.getElementById("g_image").complete == true){
		document.getElementById("g_canvas").style.visibility = "visible";
		document.getElementById("g_imgConti").style.visibility = "visible";
		document.getElementById("g_imgConti").style.width = imgList[imgID][1] + 2;
		document.getElementById("nextBtn").style.left = imgList[imgID][1] - 24;
		document.getElementById("g_buConti").innerHTML = buList[imgID];
		window.clearInterval(chgImg);
	}

}

function hideCanvas(){
	document.getElementById("g_canvas").style.visibility = "hidden";
	document.getElementById("g_imgConti").style.visibility = "hidden";
}
