﻿	
	imageCount = strintCounter;

	var width = 300;
	function startSlideShow()
	{
	if (imageCount > 0)
	    {
	    updateImage();
		}
		timerID = setTimeout("runThread();", 4000);
	}	
	
	function stopSlideShow()
	{
		clearTimeout(timerID);
	}

	function updateImage()
	{
	if (imageCount > 0)
	    {
		    document.getElementById('ImgComments').innerHTML  = imageComments[counter].toString() ;
		    document.getElementById('ImageFile').src = images[counter].toString();
	    }
		document.getElementById('ImageFile').alt = imageName[counter].toString();
		document.getElementById('ImageFile').title = imageName[counter].toString();
		
				 	
		var currentPage = Math.ceil((counter + 1)/PageSize);
		if(page!=currentPage)ChangePaggng(currentPage,PageSize);
		
		var strPage="Page" + currentPage;
		document.getElementById(strPage).className='currentPage';
		
		PreviewImage(document.getElementById('img_thumb_' + counter));
	}

	function runThread()
	{
		showNext();
		timerID = setTimeout("runThread();", 15000);
	}

	function showNext()
	{
		counter++;
		if (counter >= imageCount) counter = 0;
		if (imageCount > 0)
	    {
		updateImage();
		}
	}

	function showCurrent(intIndex){
		counter=intIndex;
		if (counter >= imageCount) counter = 0;
		if (imageCount > 0)
	    {
		updateImage();
		}
	}
	
	function showPrevious()
	{
		counter--;
		if (counter < 0) counter = imageCount - 1;	
		if (imageCount > 0)
	    {					
		updateImage();
		}
	}

	function toggleSlideShow()
	{
		slideShow = !slideShow;
		if (!slideShow){
		document.getElementById("ctl00_ContentPlaceHolder1_Ctrl_photo_album1_imgPlay").src=  'App_Themes/' + LangSettingsKey + '/images/play.gif';
		document.getElementById("ctl00_ContentPlaceHolder1_Ctrl_photo_album1_imgPlay").title = getwordKeyPlay;
		stopSlideShow();  }
		else {
		document.getElementById("ctl00_ContentPlaceHolder1_Ctrl_photo_album1_imgPlay").src=  'App_Themes/' + LangSettingsKey + '/images/pause.gif';
		document.getElementById("ctl00_ContentPlaceHolder1_Ctrl_photo_album1_imgPlay").title = getwordKeyPause;
		startSlideShow();
		}
	}
	function ChangePaggng(intPage,intPageSize){
			var strPage="Page" + (page==0?1:page);
			document.getElementById(strPage).className = document.getElementById(strPage).oldClassName;
			
			page=intPage;PageSize=intPageSize;
			var tnailstart = parseInt(intPage -1 )* (intPageSize);
			if (tnailstart < 0)tnailstart = 0;
			var tnailend = intPageSize + tnailstart;
			if(tnailend >= imageCount)	tnailend = imageCount;
			var str="";
			   for(intIndex = tnailstart; intIndex <= tnailend -1 ; intIndex++){			 
				str=str + "<img id='img_thumb_" + intIndex + "' alt='" + imageName[intIndex].toString() + "' title='" + imageName[intIndex].toString() + "' onclick='showCurrent(" + intIndex + ");PreviewImage(this);' src='" + imagesThumb[intIndex].toString() + "' width='50' height='50' />";
				}
			document.getElementById("thumb").innerHTML=str;
			showCurrent(tnailstart);		
	}
	
	function PreviewImage(obj){
		var arrImage=document.getElementById("thumb").getElementsByTagName("img");
		for (i=0; i <= arrImage.length -1; i++){
			ResetImage(arrImage[i]);
		}
		if (imageCount > 0)
	    {
		obj.className="imgOver";
		
		}
	}
	
	function ResetImage(obj){
	obj.className=obj.oldClassName;
	}
		
	var scrollingTimerID = 0;
