function fnEnlargeImg(nCategoryID) {	
	if (currentPicNumber != -1)
		fnShowGalleryFullImg(pics[currentPicNumber].FullImg,pics[currentPicNumber].ImgID, nCategoryID);
}

function fnNextImg() {	
	var nextPicNumber = currentPicNumber + 1;
	if (pics != null) {
		if (nextPicNumber < pics.length) {
			fnShowPic(nextPicNumber);
		}
		else if (sNextPage.length > 0) {
			window.location = sNextPage;
		}
	}
}

function fnPrevImg() {	
	var prevPicNumber = currentPicNumber - 1;
	if (pics != null) {
		if (prevPicNumber > -1) {
			fnShowPic(prevPicNumber);
		}
		else if (sPrevPage.length > 0) {
			window.location = sPrevPage;
		}
	}		
}

function fnShowPic(num) {		
	//alert(num);
	if (pics!=null && num<pics.length && num>-1) {		
		currentPicNumber = num;
		fnThumbClicked(pics[num].MainImgSummary,pics[num].MainImgTitle,pics[num].MainImg,pics[num].FullImg);
	}
}

function fnShowPicByID(ID) {
	var num = -1;
	for (var i=0; i<pics.length; i++) {
		if (pics[i].ImgID == ID) {
			num = i;
			break;
		}
	}
	if (num != -1) {
		fnShowPic(num);
	}
	currentPicNumber = num;
}

function fnThumbClicked(sSummary,sTitle,sSrc,sFullSrc) {
	if (sSrc != null && sSrc != '') {
		fnSetMainImg(sSrc);
		fnSetMainImgSummary(sTitle,sSummary);
		fnSetMainImgTitle(sTitle,sSummary);		
	}
}

function fnSetMainImg(sSrc) {
	var imgMain = document.getElementById("imgMain");
	var oTransContainer = document.getElementById("BigImageTD");
	if (imgMain != null) {	
		if (oTransContainer.filters && oTransContainer.filters.length > 0)
			oTransContainer.filters[0].Apply();
		
		imgMain.src = sSrc;
		if (oTransContainer.filters && oTransContainer.filters.length > 0)
			oTransContainer.filters[0].Play();
	}
}

function fnSetMainImgTitle(sTitle,sSummary) {
	var imgMainTitle = document.getElementById("imgMainTitle");
	var imgGalleryTextContainer = document.getElementById("imgMainTitle");
	var imgMain = document.getElementById("imgMain");
	if (imgMain != null)
		imgMain.alt = sTitle;
	
	if (imgMainTitle != null)
		imgMainTitle.innerHTML = sTitle;
		
	if (sTitle+sSummary == "")
		 imgGalleryTextContainer.style.display = "none";		
	else
		imgGalleryTextContainer.style.display = "block";
}

function fnSetMainImgSummary(sTitle,sSummary) {
	var imgMainSummary = document.getElementById("imgMainSummary");
	if (imgMainSummary != null) {
		imgMainSummary.innerHTML = sSummary;
	}
	
	if (sTitle+sSummary == "")
		 imgGalleryTextContainer.style.display = "none";
	else
		imgGalleryTextContainer.style.display = "block";
}
