var container = new Array();

function setIndex(p_strValue, array_index) {
	if(container[array_index]["p_strIndex"] != p_strValue) {//make new gallery visible
	 container[array_index]["p_strIndex"] = p_strValue;
	 document.getElementById("divimagebox_" + container[array_index]["p_strIndex"]).style.display = 'block';
  }										

  if(container[array_index]["oldIndex"] != '' && container[array_index]["oldIndex"] != p_strValue) {
	 document.getElementById("divimagebox_" + container[array_index]["oldIndex"]).style.display = 'none';
  }
  container[array_index]["oldIndex"] = p_strValue;										
}

function changeImage(p_strAction, array_index) {
	
  switch(p_strAction) {
	 case "next" : {
	 
		if(container[array_index]["maxCount"] > (container[array_index]["actPos"] + 1)) {
		  if(container[array_index]["intStatus"] == 0)
			 document.getElementById("imagebox_" + container[array_index]["p_strIndex"]).src = container[array_index]["arrayImages"][container[array_index]["actPos"] + 1];
		  else
			 document.getElementById("imagebox_" + container[array_index]["p_strIndex"]).src = container[array_index]["arrayImagesZoomPart"][container[array_index]["actPos"]  + 1];

		  document.getElementById("imagebox_" + container[array_index]["p_strIndex"]).alt = container[array_index]["arrayAltTexts"][container[array_index]["actPos"] + 1];
		  if(document.getElementById("imageboxcaption_" + container[array_index]["p_strIndex"]))
			 document.getElementById("imageboxcaption_" + container[array_index]["p_strIndex"]).innerHTML = container[array_index]["arrayCaptionTexts"][container[array_index]["actPos"] + 1];
		  document.getElementById("imageboxcount_" + container[array_index]["p_strIndex"]).innerHTML = (container[array_index]["actPos"] + 2) + '/' + container[array_index]["maxCount"];        
		  container[array_index]["actPos"]++;
		  if(container[array_index]["actPos"] == container[array_index]["maxCount"] - 1) {
			 document.getElementById("nextImage_" + container[array_index]["p_strIndex"]).src = container[array_index]["srcTransImage"];
		  } else {
			 document.getElementById("nextImage_" + container[array_index]["p_strIndex"]).src = container[array_index]["srcNextImage"];
		  }
		  document.getElementById("prevImage_" + container[array_index]["p_strIndex"]).src = container[array_index]["srcPrevImage"];
		}
		break;
	 } case "previous" : {
	 	
		if(container[array_index]["actPos"] > 0) {
		  if(container[array_index]["intStatus"] == 0)
			 document.getElementById("imagebox_" + container[array_index]["p_strIndex"]).src = container[array_index]["arrayImages"][container[array_index]["actPos"] - 1];
		  else
			 document.getElementById("imagebox_" + container[array_index]["p_strIndex"]).src = container[array_index]["arrayImagesZoomPart"][container[array_index]["actPos"] - 1];

		  document.getElementById("imagebox_" + container[array_index]["p_strIndex"]).alt = container[array_index]["arrayAltTexts"][container[array_index]["actPos"] - 1];
		  if(document.getElementById("imageboxcaption_" + container[array_index]["p_strIndex"]))
			 document.getElementById("imageboxcaption_" + container[array_index]["p_strIndex"]).innerHTML = container[array_index]["arrayCaptionTexts"][container[array_index]["actPos"] - 1];        
		  document.getElementById("imageboxcount_" + container[array_index]["p_strIndex"]).innerHTML = (container[array_index]["actPos"]) + '/' + container[array_index]["maxCount"];                
		  container[array_index]["actPos"]--;
		  if(container[array_index]["actPos"] == 0) {
			 document.getElementById("prevImage_" + container[array_index]["p_strIndex"]).src = container[array_index]["srcTransImage"];
		  } else {
			 document.getElementById("prevImage_" + container[array_index]["p_strIndex"]).src = container[array_index]["srcPrevImage"];
		  }
		  document.getElementById("nextImage_" + container[array_index]["p_strIndex"]).src = container[array_index]["srcNextImage"];
		}    
		break;
	 }
	 default : break;
  }
}

function zoomImage(p_strIndex, array_index) {
  if(container[array_index]["intStatus"] == 0) {
	 document.getElementById("imagebox_" + p_strIndex).src = container[array_index]["arrayImagesZoomPart"][container[array_index]["actPos"]];
	 document.getElementById("zoomicon_" + p_strIndex).src = container[array_index]["arrayZoomIcon"][1];
	 document.getElementById("zoomicon_" + p_strIndex).alt = altTextzoomOut;
	 document.getElementById("divimagebox_" + p_strIndex).className = container[array_index]["arrayZoomClass"][1];
	 container[array_index]["intStatus"] = 1;
  } else {
	 document.getElementById("imagebox_" + p_strIndex).src = container[array_index]["arrayImages"][container[array_index]["actPos"]];
	 document.getElementById("zoomicon_" + p_strIndex).src = container[array_index]["arrayZoomIcon"][0];
	 document.getElementById("zoomicon_" + p_strIndex).alt = altTextzoomIn;
	 document.getElementById("divimagebox_" + p_strIndex).className = container[array_index]["arrayZoomClass"][0];
	 container[array_index]["intStatus"] = 0;
  }
}

function jumpTo(array_index) {
	var count = document.getElementById("jump_"+array_index).value;
	if(container[array_index]["maxCount"] <= count) {
	 count = container[array_index]["maxCount"];
	 document.getElementById("nextImage_"+array_index).src = container[array_index]["srcTransImage"];
	} else {
	 document.getElementById("nextImage_"+array_index).src = container[array_index]["srcNextImage"];
	}
	
	if(count <=  1) {
	 count = 1;
	 document.getElementById("prevImage_"+array_index).src = container[array_index]["srcTransImage"];
	} else {
	 document.getElementById("prevImage_"+array_index).src = container[array_index]["srcPrevImage"];
	}

	if(container[array_index]["intStatus"] == 0)
		document.getElementById("imagebox_"+array_index).src = container[array_index]["arrayImages"][count - 1];
	else
		document.getElementById("imagebox_"+array_index).src = container[array_index]["arrayImagesZoomPart"][count - 1];
		
		
	//document.getElementById("imagebox_"+array_index).src = container[array_index]["arrayImagesZoomPart"][count - 1];
	document.getElementById("imageboxcount_"+array_index).innerHTML = count + "/" + container[array_index]["maxCount"];

	container[array_index]["actPos"] = count - 1;
}
