function setPreviewImage(imageID, orderPhoto) {
	var photoGalleryPreviewImage = window.document.getElementById("photoGalleryPreviewImage");
	if(photoGalleryPreviewImage) {
		photoGalleryPreviewImage.style.background = "url('../app/cmsFile.php?disposition=i&imageSize=730&ID=" + imageID + "') center no-repeat";
	}
	
	var photoGalleryOrderNumber = DOM.gI("photoGalleryOrderNumber");
	if(photoGalleryOrderNumber) {
		photoGalleryOrderNumber.innerHTML = orderPhoto;
	}
}

var doScrollCycle = false;
var photoGalleryScrollTimeout = null;
function photoGalleryThumScroll(scrollDirection) {
	var photoGalleryThumbScroller = window.document.getElementById("photoGalleryThumbScroller");
	if(photoGalleryThumbScroller) {
		doScrollCycle = true;
		photoGalleryScrollCycle(scrollDirection);
	}
}

function photoGalleryScrollCycle(scrollDirection) {
	if(doScrollCycle == true) {
		window.clearTimeout(photoGalleryScrollTimeout);
		var photoGalleryThumbScroller = window.document.getElementById("photoGalleryThumbScroller");
		if(photoGalleryThumbScroller) {
			if(scrollDirection == "R") {
				photoGalleryThumbScroller.scrollLeft = photoGalleryThumbScroller.scrollLeft + 1;
			} else {
				photoGalleryThumbScroller.scrollLeft = photoGalleryThumbScroller.scrollLeft - 1;
			}
			
			if(scrollDirection == "R") {
				photoGalleryScrollTimeout = window.setTimeout("photoGalleryScrollCycle('R')", 20);
			} else {
				photoGalleryScrollTimeout = window.setTimeout("photoGalleryScrollCycle('L')", 20);
			}
		}
	}
}

function photoGalleryStopScrollCycle() {
	doScrollCycle = false;
}

var lastPhotoGalleryRowZIndex = 10;
var photoGalleryActiveRowIndex = 1;

function photoGalleryRow(arrowDirection) {
	if(arrowDirection == "prew" && photoGalleryActiveRowIndex != 1) {
		photoGalleryShowRow(photoGalleryActiveRowIndex - 1);
	}
	
	if(arrowDirection == "next" && photoGalleryActiveRowIndex != photoGalleryRowCount) {
		photoGalleryShowRow(photoGalleryActiveRowIndex + 1);
	}
}

function photoGalleryShowRow(rowID)	{
	if(rowID == photoGalleryActiveRowIndex) {
		return true;
	}
	
	lastPhotoGalleryRowZIndex = lastPhotoGalleryRowZIndex + 1;
	
	DOM.gI("photoGalleryRowIcon_" + photoGalleryActiveRowIndex).src = "images/photoGallery/photoGalleryRowIcon.gif";
	DOM.gI("photoGalleryRowIcon_" + rowID).src = "images/photoGallery/photoGalleryRowIconActive.gif";
	if(DOM.gI("photoGalleryRowIconBottom_" + photoGalleryActiveRowIndex)) {
		DOM.gI("photoGalleryRowIconBottom_" + photoGalleryActiveRowIndex).src = "images/photoGallery/photoGalleryRowIcon.gif";
		DOM.gI("photoGalleryRowIconBottom_" + rowID).src = "images/photoGallery/photoGalleryRowIconActive.gif";
	}
	DOM.gI("photoGalleryRow_" + rowID).style.display = "block";
	DOM.gI("photoGalleryRow_" + rowID).style.zIndex = lastPhotoGalleryRowZIndex;
	if(DOM.gI("photoGalleryRowBottom_" + rowID)) {
		DOM.gI("photoGalleryRowBottom_" + rowID).style.display = "block";
		DOM.gI("photoGalleryRowBottom_" + rowID).style.zIndex = lastPhotoGalleryRowZIndex;
	}
	photoGalerySetOpacity(rowID, 1);
	window.setTimeout(function (){photoGalleryShowRowFading(rowID, 4);}, 23);
	
	photoGalleryActiveRowIndex = rowID;
}

function photoGalleryShowRowFading(rowID, opacity) {
	photoGalerySetOpacity(rowID, opacity);
	opacity = opacity + 4;
	if(opacity <= 100) {
		window.setTimeout(function (){photoGalleryShowRowFading(rowID, opacity);}, 23);
	}
}

function photoGalerySetOpacity(rowID, opacity) {
	var thisElement = DOM.gI("photoGalleryRow_" + rowID);
	var thisElementBottom = DOM.gI("photoGalleryRowBottom_" + rowID);
	
	thisElement.style.filter = "alpha(opacity:" + opacity + ",style=0)";
	thisElement.style.KHTMLOpacity = opacity/100;
	thisElement.style.MozOpacity = opacity/100;
	thisElement.style.opacity = opacity/100;
	
	if(thisElementBottom) {
		thisElementBottom.style.filter = "alpha(opacity:" + opacity + ",style=0)";
		thisElementBottom.style.KHTMLOpacity = opacity/100;
		thisElementBottom.style.MozOpacity = opacity/100;
		thisElementBottom.style.opacity = opacity/100;
	}
}
