//	blog images loading

var imgArray = new Array();
var functionsArray = new Array();

function loadRotationImgBox(imgArr, idImgBox, link_text) {
	if(typeof(imgArray) == "undefined")  {
		var mainImgBox = document.getElementById(idImgBox);
		if (imgArr.length > 1) {
			var imgBox = createRotationBox(mainImgBox);
			for (i=0;i<imgArr.length;i++){
	 			addImgToBox(imgArr[i],imgBox,i>0,link_text);
	 		}
		}
		else addImgToBox(imgArr[0],mainImgBox,false,link_text);
	 }
	 else imgArray.push({imageBox:idImgBox,imagesSrc:imgArr,lastImageLink:link_text});
}

function loadAllRotationImgBoxes(){
	var imgBox;
	for (i=0;i<imgArray.length;i++) {
		if (imgArray[i].imagesSrc.length > 1) imgBox = createRotationBox(document.getElementById(imgArray[i].imageBox));
		else imgBox=document.getElementById(imgArray[i].imageBox);
		for (j=0;j<imgArray[i].imagesSrc.length;j++){
			if (j<imgArray[i].imagesSrc.length-1) addImgToBox(imgArray[i].imagesSrc[j],imgBox,j>0);
			else addImgToBox(imgArray[i].imagesSrc[j],imgBox,j>0,imgArray[i].lastImageLink);
		}
	}
	if(typeof(functionsArray) !== "undefined")  
		for (var i=0; i < functionsArray.length; i++) functionsArray[i].call();
}

function addImgToBox(img,imgBox,hidden,link) {
	if (imgBox) {
		var imgObj = document.createElement("img");;
	 	imgObj.src = img;
	 	imgObj.alt = "sample";
	 	if (hidden) imgObj.className = "hidden";
	 	if ((link)&&(img.indexOf("slideshow_end") > -1)){
	 		imgObj.style.cursor = "pointer";
	 		imgObj.onclick = function(){window.open(link);}
	 	}
	 	imgBox.appendChild(imgObj);
	}
}

function createRotationBox(mainImgBox) {
	if (mainImgBox) {
		var imgBox = document.createElement("div");
		imgBox.className = "hp-ImageRotation";
		imgBox.onmouseover = function() {ImageManager(this, "hp-ImageButtonLeft", "hp-ImageButtonRight", true);}
		mainImgBox.appendChild(imgBox);
		var imgNav = document.createElement("a");
		imgNav.href = "#";
		imgNav.className ="hp-ImageButtonLeft";
		imgNav.innerHTML = "Rotation Button";
		imgBox.appendChild(imgNav);
		var imgNav = document.createElement("a");
		imgNav.href = "#";
		imgNav.className ="hp-ImageButtonRight";
		imgNav.innerHTML = "Rotation Button";
		imgBox.appendChild(imgNav);
		return imgBox;
	}
}

var loaded_images = 0;

function checkLoadedNumber() {
	loaded_images += 1;
	if (loaded_images == loaded_needs) pushSlideshow();
}