//**Start Encode**

// Pic page
sNextPicTitle="Next photo";
sPrevPicTitle="Previous photo";

// Thumb page
sNextPageTitle="Next photo page";
sPrevPageTitle="Previous photo page";
sGotoPage="Click for page ";

// Control panel
sStartBtnTitle="Start page of this album";
sThumbBtnTitle="Photo Index";
sSlideShowBtnTitle="Slide show";
sFullScreenBtnTitle="Full screen";
sCloseFullBtnTitle="Close full screen";
sRepeatBtnTitle="Repeat";
sBgSoundBtnTitle="Background sound";
sAboutBtnTitle="About this photo album";

function BindToolTips()
{
	if(document.all.STARTBTN)
		document.all.STARTBTN.title=sStartBtnTitle;
	if(document.all.THUMBPAGEBTN)
		document.all.THUMBPAGEBTN.title=sThumbBtnTitle;
	if(document.all.SLIDESHOWBTN)
		document.all.SLIDESHOWBTN.title=sSlideShowBtnTitle;
	if(document.all.FULLSCREEN)
		document.all.FULLSCREEN.title=sFullScreenBtnTitle;
	if(document.all.CLOSEFULL)
		document.all.CLOSEFULL.title=sCloseFullBtnTitle;
	if(document.all.REPEATBTN)
		document.all.REPEATBTN.title=sRepeatBtnTitle;
	if(document.all.BGSOUNDBTN)
		document.all.BGSOUNDBTN.title=sBgSoundBtnTitle;
	if(document.all.ABOUTBTN)
		document.all.ABOUTBTN.title=sAboutBtnTitle;
	
	
	if (document.all.PREVPIC)
		document.all.PREVPIC.title=sPrevPicTitle;
	if (document.all.NEXTPIC)
		document.all.NEXTPIC.title=sNextPicTitle;
	if (document.all.PREVPICPAGE)
		document.all.PREVPICPAGE.title=sPrevPageTitle;
	if (document.all.NEXTPICPAGE)
		document.all.NEXTPICPAGE.title=sNextPageTitle;
}

//////////////////////////////////////////////////////////////////////////////////////
// Parameter  API
// in order to use the '#' as parameter passing option as well.
// This will enable parameter passing in HTMLHelp based systems.

URLparameters = "";
Myparams = -1;

// Now we initialise some settings
// This part must always be called before anything else
function InitParameters() 
{
	if ((navigator.appName!='Netscape')&&(navigator.appVersion<4))
	{
		// Older browsers
		URLparameters=document.location;
		if (URLparameters.indexOf('?')>-1)
		{
			URLparameters=URLparameters.substring(URLparameters.indexOf('?')+1,URLparameters.length);
		}
		
		// VV: handle passing parameters using the '#' tag after the URL.
		if (URLparameters.indexOf('#')>-1)
		{
			URLparameters=URLparameters.substring(URLparameters.indexOf('#')+1,URLparameters.length);
		}
	}
	else
	{
		// Netscape or version 4 browsers
		
		URLparameters=document.location.search;
		URLparameters="&"+URLparameters.substring(1,URLparameters.length);
		
		// VV: handle passing parameters using the '#' tag after the URL.
		URLparametersHash=document.location.hash;
		URLparameters+=(URLparameters!="&"?"&":"")+URLparametersHash.substring(1,URLparametersHash.length);
	}
	
	while (URLparameters.indexOf('%20')>0)
	{
		pos2=URLparameters.indexOf('%20',0);
		tmp=URLparameters.substring(0,pos2)+' '+URLparameters.substring(pos2+3,URLparameters.length);
		URLparameters=tmp;
	}
	
	pos = -1;		
	tmp = "";
	text=URLparameters;
	if (text!='') 
	{
		text=text+'&';
		URLparameters=URLparameters+'&';
		Myparams=0;
		while (text.length>0) 
		{
			pos=text.indexOf('&',0);
			text=text.substring(pos+1);
			Myparams++;
		}
	}
}

function GetParameter(checkOn)
{
	for (cnt=0; cnt<Myparams;)
	{
		pos   =-2;
		tempw = "";
		text  =URLparameters;
		
		for (i=0; i<=cnt;)
		{
			pos2= pos+2;
			pos= text.indexOf('&',pos2);
			tempw=text.substring(pos,pos2-1);
			i++;
		}
		text=tempw;
		pos=text.indexOf('=',0);
		if (pos!=-1)
		{
			tempw=text.substring(pos,0);
		}
		tempw=tempw.toLowerCase();
		if (tempw==checkOn.toLowerCase())
		{
			pos = -2;
			tempv = "";
			text = URLparameters;
			for (i=0; i<=cnt;)
			{
				pos2=pos+2;
				pos=text.indexOf('&',pos2);
				tempv=text.substring(pos,pos2-1);
				i++;
			}
			text=tempv;
			pos2=text.indexOf('=',0)+1;
			if (pos2!=-1)
			{
				tempv=text.substring(pos2);
				tempv=tempv.toLowerCase();
			} 
			else
			{ 
				tempv='' 
			}
			pos=-2;
			text=tempv; 
			if (text.indexOf('%20')>0)
			{
				pos=text.indexOf('%20',0);
				tmp=text.substring(0,pos2-4)+' '+text.substring(pos2-1,text.length);
				text=tempv;
			}
			return tempv;
		}
		cnt++;
	}
	return '';
}

///////////////////////////////////////////////////////////
// Check if this file is inside a compiled HTMLHelp file (CHM)
function InsideCHM()
{
	var thisDoc=document.URL.toLowerCase();
	return (thisDoc.indexOf(".chm::") != -1 || thisDoc.indexOf(".its::") != -1)
}

// Initialize the Parameter API
InitParameters();
document.title=strAlbumPageTitle;

var nAboutLastPic = 1;
var nStartLastPic = 1;

function About_OnBodyLoaded()
{
	BindToolTips();
	
	if(bShowTitleBar)
	{
		if (document.all.TitleBar)
			document.all.TitleBar.innerText=strAlbumPageTitle;
	}
	
	nAboutLastPic = GetParameter("pic");
	if (nAboutLastPic == null || nAboutLastPic == "")
		nAboutLastPic = 1;
}

function About_OnThumbnailsClicked()
{
	document.location="fspa_thumb.htm#pic=" + nAboutLastPic;
}

function About_OnSlideShowClicked()
{
	document.location="fspa_slide.htm#pic=" + nAboutLastPic + "&doslideshow=true";
}

function About_OnStartClicked()
{
	document.location="fspa_start.htm#pic=" + nAboutLastPic;
}

oStartImage = new Image;
oStartImage.onload=Start_OnImageCached;

function Start_OnImageCached()
{
	var nPicHeight=300;
	var nPicWidth=400;
	
	if(oStartImage.height<=nPicHeight && oStartImage.width<=nPicWidth)
	{
		nPicHeight=oStartImage.height;
		nPicWidth=oStartImage.width;
	}
	else
	{
			fRatio=nPicHeight/nPicWidth;
			fImgRatio=oStartImage.height/oStartImage.width;
			if(fImgRatio > fRatio)
			{
				nPicWidth=nPicHeight/fImgRatio;
			}
			else
			{
				nPicHeight=nPicWidth*fImgRatio;
			}
	}
	
	with (document.all.StartImage)
	{
		src = oStartImage.src;
		width=nPicWidth;
		height=nPicHeight;
	}
}

function Start_OnBodyLoaded()
{
	BindToolTips();
	
	if(bShowTitleBar)
	{
		if (document.all.TitleBar)
			document.all.TitleBar.innerText=strAlbumPageTitle;
	}
	
	nStartLastPic = GetParameter("pic");
	if (nStartLastPic == null || nStartLastPic == "")
		nStartLastPic = 1;
		
	if (document.all.StartImage)
	{
		// First load it in a dummy image object
		oStartImage.src = strStartImage;
	}
}

function Start_OnThumbnailsClicked()
{
	document.location="fspa_thumb.htm#pic=" + nStartLastPic;
}

function Start_OnSlideShowClicked()
{
	document.location="fspa_slide.htm#pic=" + nStartLastPic + "&doslideshow=true";
}

function Start_OnAboutClicked()
{
	document.location="fspa_about.htm#pic=" + nStartLastPic;
}

////////////////////////////////////////////////////////////////////
var nThumbCurrentPage = 1;
var nThumbLastPic=1;
var bThumbDoSlideShow = false;
var bThumbPageLoaded = false;

// Image object needed to test the orientation of an loading image.
oThumbTestingImage=new Array(12);
oThumbTestingImage[0]=new Image;
oThumbTestingImage[0].onload=onImageCached0;
oThumbTestingImage[1]=new Image;
oThumbTestingImage[1].onload=onImageCached1;
oThumbTestingImage[2]=new Image;
oThumbTestingImage[2].onload=onImageCached2;
oThumbTestingImage[3]=new Image;
oThumbTestingImage[3].onload=onImageCached3;
oThumbTestingImage[4]=new Image;
oThumbTestingImage[4].onload=onImageCached4;
oThumbTestingImage[5]=new Image;
oThumbTestingImage[5].onload=onImageCached5;
oThumbTestingImage[6]=new Image;
oThumbTestingImage[6].onload=onImageCached6;
oThumbTestingImage[7]=new Image;
oThumbTestingImage[7].onload=onImageCached7;
oThumbTestingImage[8]=new Image;
oThumbTestingImage[8].onload=onImageCached8;
oThumbTestingImage[9]=new Image;
oThumbTestingImage[9].onload=onImageCached9;
oThumbTestingImage[10]=new Image;
oThumbTestingImage[10].onload=onImageCached10;
oThumbTestingImage[11]=new Image;
oThumbTestingImage[11].onload=onImageCached11;

function Thumb_OnBodyLoaded()
{
	BindToolTips();
	
	if(bShowTitleBar)
	{
		if (document.all.TitleBar)
			document.all.TitleBar.innerText=strAlbumPageTitle;
	}
	
	nThumbLastPic = GetParameter("pic");
	if (nThumbLastPic == null || nThumbLastPic == "")
		nThumbLastPic = 1;
	
	nThumbCurrentPage = Math.floor((nThumbLastPic-1) / 12) + 1;
	
	ShowThumbs();
}

function Thumb_ImageNotFound(oThisImg)
{
	oThisImg.height=75;
	oThisImg.width=100;
	
	oThisImg.src = "fspa_images/transp100x75.gif";
}

// User clicked on a thumbnail and show that picture!
function ClickThumb(ThumbnailNum)
{
	nPicNum = nThumbCurrentPage * 12 + ThumbnailNum - 11;
	document.location="fspa_slide.htm#pic=" + nPicNum + "&doslideshow=" + bThumbDoSlideShow;
}

// The image is first loaded in the TestingImage. When loaded (using OnLoad event),
// the dimensions of the image is tested for portret or landscape.
// Then the photo is relayed to the image object on screen with the correct image aspect.
function RelayImage(i)
{
	var nThumbHeight=75;
	if (oThumbTestingImage[i].height > oThumbTestingImage[i].width)
		nThumbWidth=Math.floor(oThumbTestingImage[i].width * (75/oThumbTestingImage[i].height));
	else
		nThumbWidth=Math.floor(Math.min(oThumbTestingImage[i].width, 100));
	
	with (document.images["THUMB" + i])
	{
		src = oThumbTestingImage[i].src;
		width = nThumbWidth;
		height = nThumbHeight;
	}
}

function onImageCached0()
{
	RelayImage(0);
}
function onImageCached1()
{
	RelayImage(1);
}
function onImageCached2()
{
	RelayImage(2);
}
function onImageCached3()
{
	RelayImage(3);
}
function onImageCached4()
{
	RelayImage(4);
}
function onImageCached5()
{
	RelayImage(5);
}
function onImageCached6()
{
	RelayImage(6);
}
function onImageCached7()
{
	RelayImage(7);
}
function onImageCached8()
{
	RelayImage(8);
}
function onImageCached9()
{
	RelayImage(9);
}
function onImageCached10()
{
	RelayImage(10);
}
function onImageCached11()
{
	RelayImage(11);
}

///////////////////////////////////////////////////////////
// Display a page of 12 thumbnails of the available photos
// and below the available page numbers.
function ShowThumbs()
{
	sThumbSrc = "";
	sThumbCaption = "";
	
	for (i=0; i < 12; i++)
	{
		nThumbLastPic = nThumbCurrentPage * 12 + i - 12;
		ThumbName = "THUMB" + i;
		if (nThumbLastPic < aPhotos.length/2)
		{
			sThumbSrc = aPhotos[nThumbLastPic*2];
			//sThumbCaption = aPhotos[nThumbLastPic*2+1];
			nParametersIndex = parseInt(aPhotos[nThumbLastPic*2+1]);
			sThumbCaption = aPhotosParameters[nParametersIndex];
			if(sThumbCaption==" ")
				sThumbCaption="";
				
			sDisplay="";
		}
		else
		{
			// Empty thumbnail
			sThumbSrc = "fspa_images/transp100x75.gif";
			sThumbCaption = "";
			sDisplay="none";
		}
		
		// First cache the image to find the dimensions.
		oThumbTestingImage[i].src=sThumbSrc;
		
		with(document.images[ThumbName])
		{
			title=sThumbCaption;
			style.display=sDisplay;
		}
	}
	
	// Show the page numbers below the thumbs
	sPagesHTML = "&nbsp;";
	nNumPages = aPhotos.length / 24 + 1;	// aPhotos.length / 12 / 2 + 1
	nPageStart = 1;
	nPageEnd = 1;
	
	// Set start and end pagenumber to be shown.
	if (nNumPages <= 9)
	{
		nPageStart = 1;
		nPageEnd = nNumPages;
	}
	else
	{
		nPageStart = Math.max(1, nThumbCurrentPage - 6);
		nPageEnd = Math.min(nNumPages, nThumbCurrentPage + 7);
	}
	
	if (nPageStart != 1)
		sPagesHTML += "...";
	
	if (nNumPages > 1)
	{
		// Display the numbers of pages with thumbs
		for (i=nPageStart; i < nPageEnd; i++)
		{
			if (i == nThumbCurrentPage)
				sPagesHTML += "<font color='#FFFFFF'>" + (i<10?"&nbsp;":"") + i + "</font>&nbsp;";
			else
				sPagesHTML += (i<10?"&nbsp;":"") + "<a href='javascript:nThumbCurrentPage=" + i + ";ShowThumbs();' style='color: #00FF00' title='" + sGotoPage + i + "'>" + i + "</a>&nbsp;";
		}
	}
	else
		sPagesHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	
	if (nPageEnd != nNumPages)
		sPagesHTML += "...";
	
	document.all.PAGEINDEX.innerHTML = sPagesHTML;
	
	document.images["PREVPICPAGE"].style.display = ((nThumbCurrentPage == 1) ? "none" : "");
	document.images["NEXTPICPAGE"].style.display = ((nThumbCurrentPage * 12 >= aPhotos.length/2) ? "none" : "");
}

// Show next page of thumbnails
function NextPage()
{
	nThumbCurrentPage++;
	ShowThumbs();
}

// Show previous page of thumbnails
function PrevPage()
{
	nThumbCurrentPage--;
	ShowThumbs();
}

function Thumb_OnStartClicked()
{
	document.location="fspa_start.htm#pic=" + nThumbLastPic;
}

function Thumb_OnSlideShowClicked()
{
	bThumbDoSlideShow = true;
	ClickThumb(0);
}

function Thumb_OnAboutClicked()
{
	document.location="fspa_about.htm#pic="+((nThumbCurrentPage-1)*12+1);
}

////////////////////////////////////////////////////////////
nCurrentPic = 1;
bSlideShow = false;
nSlideShowTimerID = 0;
bRepeat=false;
bPlayBgsound=true;
nIntervalTime=0;

oTestingImage = new Image;
oTestingImage.onload=Pic_OnImageCached;

function OnRepeatClicked(obj_img)
{
	if(bRepeat)
	{
		bRepeat=false;
		obj_img.src="fspa_images/repeatoff.ico";
	}
	else
	{
		bRepeat=true;
		obj_img.src="fspa_images/repeaton.ico";
	}
}

function OnBgsoundControl(obj_bgsound, obj_img)
{
	if(bPlayBgsound)
	{
		bPlayBgsound = false;
		obj_bgsound.src="";
		obj_img.src="fspa_images/bgsoundoff.ico";
	}
	else
	{
		bPlayBgsound = true;
		obj_bgsound.src=strMusicFile;
		obj_img.src="fspa_images/bgsoundon.ico";
	}
}

// Show the designated picture when the page is loaded.
function Pic_OnBodyLoaded()
{
	BindToolTips();
	
	if(bShowTitleBar)
	{
		if (document.all.TitleBar)
			document.all.TitleBar.innerText=strAlbumPageTitle;
	}
	
	if (document.all.bg_sound)
		document.all.bg_sound.src = strMusicFile;
		
	sSlideShow = GetParameter("doslideshow");
	if (sSlideShow == null || sSlideShow == "")
		bSlideShow = false;
	sSlideShow=sSlideShow.toLowerCase();
	if (sSlideShow=="true")
		bSlideShow=true;
	
	if (bSlideShow)
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_running.gif";
	
	nPicNum = GetParameter("pic");
	if (nPicNum == null || nPicNum == "")
		nPicNum = 1;
	ShowPic(nPicNum);
}

function Pic_OnBodyClicked()
{
	// Turn off the slideshow if clicked anywhere
	//if (bSlideShow)
	//	StopSlideShowTimer();
}

function Pic_OnStartClicked()
{
	document.location="fspa_start.htm#pic=" + nCurrentPic;
}

function Pic_OnThumbnailsClicked()
{
	document.location="fspa_thumb.htm#pic=" + nCurrentPic;
}

function Pic_OnSlideShowClicked()
{
	window.event.cancelBubble=true; // Stop bubbling the event to a parent.
	
	if (bSlideShow)
	{
		StopSlideShowTimer();
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_over.gif";
	}
	else
	{
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_running.gif";
		bSlideShow = true;
		NextPic();						// this will show the nextpic AND start a new timer
	}
}

function Pic_OnSlideShowMouse(sNewImage)
{
	window.event.cancelBubble=true;
	if (!bSlideShow)
		document.all.SLIDESHOWBTN.src=sNewImage;
}

function Pic_OnFullClicked()
{
	//var thisDoc=document.URL.toLowerCase();
	//window.open(thisDoc, 'big', 'toolbar=no,directories=no,status=no,location=no,resizable=no,scrollbars=no,menubar=no,fullscreen=yes');
	
	var address;
	
	if(bSlideShow)
		address = "fspa_full.htm#pic=" + nCurrentPic + "&doslideshow=true";
	else
		address = "fspa_full.htm#pic=" + nCurrentPic + "&doslideshow=false";
	
	//close music before opening the full page
	if(bPlayBgsound)
	{
		if(document.all.bg_sound)
			document.all.bg_sound.src = "";
	}
	
	//window.open(address, 'big', 'fullscreen=yes');
	window.open(address, 'big', 'toolbar=no,directories=no,status=no,location=no,resizable=no,scrollbars=no,menubar=no,fullscreen=yes');
}

function FullPageClose()
{
	//play music after closing the full page
	if(bPlayBgsound)
	{
		if(document.all.bg_sound)
			document.all.bg_sound.src = strMusicFile;
	}
}

function Pic_OnAboutClicked()
{
	document.location="fspa_about.htm#pic=" + nCurrentPic;
}

function StartSlideShowTimer()
{
	bSlideShow = true;
	
	nSlideShowTimerID = setTimeout("NextPic()", nIntervalTime);
}

function StopSlideShowTimer()
{
	if (bSlideShow)
	{
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow.gif";
		bSlideShow = false;
		clearTimeout(nSlideShowTimerID);
	}
}

function Pic_OnLastPicShown()
{
	Pic_OnThumbnailsClicked();
}

function Pic_OnImageCached()
{
	var nPicHeight=300;
	var nPicWidth=400;
	
	if(oTestingImage.height<=nPicHeight && oTestingImage.width<=nPicWidth)
	{
		nPicHeight=oTestingImage.height;
		nPicWidth=oTestingImage.width;
	}
	else
	{
			fRatio=nPicHeight/nPicWidth;
			fImgRatio=oTestingImage.height/oTestingImage.width;
			if(fImgRatio > fRatio)
			{
				nPicWidth=nPicHeight/fImgRatio;
			}
			else
			{
				nPicHeight=nPicWidth*fImgRatio;
			}
	}
	
	with (document.all.PIC)
	{
		src = oTestingImage.src;
		width=nPicWidth;
		height=nPicHeight;
	}
}

// Show a specific picture and caption
function ShowPic(nPicNum)
{
	var el;
	divElements = document.all.tags("img");
	for(var index = 0; index < divElements.length; index++) 
	{
		el = divElements[index];
		objectName = el.getAttribute("name", false);
		if(objectName == "PIC")
		{
			break;
		}
	}
	
	nPicNum = Math.min(Math.max(nPicNum, 1), aPhotos.length/2);
	nParametersIndex = parseInt(aPhotos[(nPicNum-1)*2 + 1]);
	
	nFilterType = aPhotosParameters[nParametersIndex + 1];
	
	nIntervalTime = nSlideShowTime;
	
	if(nFilterType==1)
	{
		el.style.filter = "revealTrans()";
		el.filters.revealTrans.transition = aPhotosParameters[nParametersIndex + 2];
		el.filters.revealTrans.apply();
		el.filters.revealTrans.play(aPhotosParameters[nParametersIndex + 3]);
		
		nIntervalTime = nIntervalTime + aPhotosParameters[nParametersIndex + 3]*1000;
	}
	
	else if(nFilterType==2)
	{
		el.style.filter = "blendTrans()";
		el.filters.blendTrans.duration = aPhotosParameters[nParametersIndex + 2];
		el.filters.blendTrans.apply();
  	el.filters.blendTrans.play();
  	
  	nIntervalTime = nIntervalTime + aPhotosParameters[nParametersIndex + 2]*1000;
	}
	
	else if(nFilterType==3)
	{
		el.style.filter = "light()";
		
		//el.filters.light.clear();
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nRed = aPhotosParameters[nParametersIndex + 3];
		nGreen = aPhotosParameters[nParametersIndex + 4];
		nBlue = aPhotosParameters[nParametersIndex + 5];
		
		el.filters.light.addAmbient(nRed,nGreen,nBlue,nStrength);
		//el.filters.light.addAmbient(255,255,200,100);
	}
	
	else if(nFilterType==4)
	{
		el.style.filter = "light()";
		
		//el.filters.light.clear();
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nX1 = aPhotosParameters[nParametersIndex + 3];
		nY1 = aPhotosParameters[nParametersIndex + 4];
		nX2 = aPhotosParameters[nParametersIndex + 5];
		nY2 = aPhotosParameters[nParametersIndex + 6];
		nZ1 = aPhotosParameters[nParametersIndex + 7];
		nSpread = aPhotosParameters[nParametersIndex + 8];
		nRed = aPhotosParameters[nParametersIndex + 9];
		nGreen = aPhotosParameters[nParametersIndex + 10];
		nBlue = aPhotosParameters[nParametersIndex + 11];
		
		el.filters.light.addCone(nX1, nY1, nZ1, nX2, nY2, nRed, nGreen, nBlue, nStrength, nSpread);
	}
	
	else if(nFilterType==5)
	{
		el.style.filter = "alpha()";
		
		nOpacity = aPhotosParameters[nParametersIndex + 2];
		nStyle = aPhotosParameters[nParametersIndex + 3];
		nStartX = aPhotosParameters[nParametersIndex + 4];
		nStartY = aPhotosParameters[nParametersIndex + 5];
		nFinishX = aPhotosParameters[nParametersIndex + 6];
		nFinishY = aPhotosParameters[nParametersIndex + 7];
		nFinishOpacity = aPhotosParameters[nParametersIndex + 8];
	
		el.filters.alpha.opacity = nOpacity;
		el.filters.alpha.style = nStyle;
		el.filters.alpha.startX = nStartX;
		el.filters.alpha.startY = nStartY;
		el.filters.alpha.finishX = nFinishX;
		el.filters.alpha.finishY = nFinishY;
		el.filters.alpha.finishOpacity = nFinishOpacity;
	}
	
	else if(nFilterType==6)
	{
		el.style.filter = "blur()";
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nDirection = aPhotosParameters[nParametersIndex + 3];
	
		el.filters.blur.strength = nStrength;
		el.filters.blur.direction = nDirection;
	}
	
	else if(nFilterType==7)
	{
		el.style.filter = "wave()";
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nFreq = aPhotosParameters[nParametersIndex + 3];
		nPhase = aPhotosParameters[nParametersIndex + 4];
		nLightStrength = aPhotosParameters[nParametersIndex + 5];
		
		el.filters.wave.add=0;
		el.filters.wave.strength = nStrength;
		el.filters.wave.freq = nFreq;
		el.filters.wave.phase = nPhase;
		el.filters.wave.lightstrength = nLightStrength;
	}
		
	else if(nFilterType==8)
	{
		el.style.filter = "flipH";
	}
	
	else if(nFilterType==9)
	{
		el.style.filter = "flipV";
	}
	
	else if(nFilterType==10)
	{
		el.style.filter = "invert";
	}
	
	else if(nFilterType==11)
	{
		el.style.filter = "gray";
	}
	
	else if(nFilterType==12)
	{
		el.style.filter = "xray";
	}
	
	else
	{
		el.style.filter = "";
	}
	
	// First load it in a dummy image object.
	oTestingImage.src = aPhotos[(nPicNum-1)*2];
	sDummyVar = oTestingImage.src;	// Simulate a "NOP"
	sDummyVar = oTestingImage.src;	// Simulate a "NOP"
	
	if(document.all.PICLABEL)
	{
		//document.all.PICLABEL.innerText = aPhotos[(nPicNum-1)*2 + 1];
		document.all.PICLABEL.innerText = aPhotosParameters[nParametersIndex];
		document.all.PICLABEL.style.display = "";
	}
	
	// Hide an arrow if at the first or last picture
	document.all.PREVPIC.style.display = ((nPicNum == 1) ? "none" : "");
	document.all.NEXTPIC.style.display = ((nPicNum == aPhotos.length/2) ? "none" : "");
	
	nCurrentPic=nPicNum;
}

function Pic_RepeatPlay()
{
	nPicNum = 1;
	ShowPic(nPicNum);
}

// Pic_OnPhotoLoaded is fired when the photo is fully loaded in the image object
// We need this for giving the user enough viewing time for the slideshow.
function Pic_OnPhotoLoaded()
{
	window.event.cancelBubble=true;
	if (bSlideShow && window.event.srcElement.src.toLowerCase().indexOf("fspa_images/transp400x300.gif") == -1)
	{
		// The loaded photo is NOT the tranparent background picture, so
		// we can start the slideshow timer.
		// alert("Loaded image - " + window.event.srcElement.src);
		StartSlideShowTimer();
		
		// Stop the timer if at the last photo
		if (nCurrentPic >= aPhotos.length/2)
		{
			if(bRepeat)
			{
				clearTimeout(nSlideShowTimerID);
				nSlideShowTimerID = setTimeout("Pic_RepeatPlay()", nIntervalTime);
			}
			else
			{
				StopSlideShowTimer();
				
				// Wait a while and then move to the index!
				nSlideShowTimerID = setTimeout("Pic_OnLastPicShown()", nIntervalTime);
			}
		}
	}
}

function Pic_ImageNotFound(oThisImg)
{
	oThisImg.height=300;
	oThisImg.width=400;
	
	oThisImg.src = "fspa_images/transp400x300.gif";
}

// Goto Previous picture
function PrevPic()
{
	nCurrentPic--;
	ShowPic(nCurrentPic);
}

// Goto Next picture
function NextPic()
{
	nCurrentPic++;
	ShowPic(nCurrentPic);
}

/////////////////////////////////////////////////////////////////////////
//Full Screen
oFullScreenImage = new Image;
oFullScreenImage.onload=Full_OnImageCached;

// Show the designated picture when the page is loaded.
function Full_OnBodyLoaded()
{
	BindToolTips();
	
	if (document.all.bg_sound)
		document.all.bg_sound.src = strMusicFile;
	
	sSlideShow = GetParameter("doslideshow");
	if (sSlideShow == null || sSlideShow == "")
		bSlideShow = false;
	sSlideShow=sSlideShow.toLowerCase();
	if (sSlideShow=="true")
		bSlideShow=true;
	
	if (bSlideShow)
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_running.gif";
	
	nPicNum = GetParameter("pic");
	if (nPicNum == null || nPicNum == "")
		nPicNum = 1;
	
	Full_ShowPic(nPicNum);
}

function Full_OnSlideShowClicked()
{
	window.event.cancelBubble=true; // Stop bubbling the event to a parent.
	
	if (bSlideShow)
	{
		StopSlideShowTimer();
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_over.gif";
	}
	else
	{
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_running.gif";
		bSlideShow = true;
		Full_NextPic();						// this will show the nextpic AND start a new timer
	}
}

function Full_OnSlideShowMouse(sNewImage)
{
	window.event.cancelBubble=true;
	if (!bSlideShow)
		document.all.SLIDESHOWBTN.src=sNewImage;
}

function Full_OnCloseClicked()
{
	if (parent.opener) 
 		parent.opener.FullPageClose();
	window.close();
}

function Full_StartSlideShowTimer()
{
	bSlideShow = true;
	
	nSlideShowTimerID = setTimeout("Full_NextPic()", nIntervalTime);
}

function Full_StopSlideShowTimer()
{
	if (bSlideShow)
	{
		document.all.SLIDESHOWBTN.src="fspa_images/slideshow_over.gif";
		bSlideShow = false;
		clearTimeout(nSlideShowTimerID);
	}
}

function Full_OnImageCached()
{
	var nPicHeight=screen.height;
	var nPicWidth=screen.width;
	
	if(oFullScreenImage.height<=nPicHeight && oFullScreenImage.width<=nPicWidth)
	{
		nPicHeight=oFullScreenImage.height;
		nPicWidth=oFullScreenImage.width;
	}
	else
	{
			fRatio=nPicHeight/nPicWidth;
			fImgRatio=oFullScreenImage.height/oFullScreenImage.width;
			if(fImgRatio > fRatio)
			{
				nPicWidth=nPicHeight/fImgRatio;
			}
			else
			{
				nPicHeight=nPicWidth*fImgRatio;
			}
	}
	
	with (document.all.PIC)
	{
		width=nPicWidth;
		height=nPicHeight;
		src = oFullScreenImage.src;
	}
}

// Show a specific picture and caption
function Full_ShowPic(nPicNum)
{
	var el;
	divElements = document.all.tags("img");
	for(var index = 0; index < divElements.length; index++) 
	{
		el = divElements[index];
		objectName = el.getAttribute("name", false);
		if(objectName == "PIC")
		{
			break;
		}
	}
	
	nPicNum = Math.min(Math.max(nPicNum, 1), aPhotos.length/2);
	nParametersIndex = parseInt(aPhotos[(nPicNum-1)*2 + 1]);
	
	nFilterType = aPhotosParameters[nParametersIndex + 1];
	
	nIntervalTime = nSlideShowTime;
	
	if(nFilterType==1)
	{
		el.style.filter = "revealTrans()";
		el.filters.revealTrans.transition = aPhotosParameters[nParametersIndex + 2];
		el.filters.revealTrans.apply();
		el.filters.revealTrans.play(aPhotosParameters[nParametersIndex + 3]);
		
		nIntervalTime = nIntervalTime + aPhotosParameters[nParametersIndex + 3]*1000;
	}
	
	else if(nFilterType==2)
	{
		el.style.filter = "blendTrans()";
		el.filters.blendTrans.duration = aPhotosParameters[nParametersIndex + 2];
		el.filters.blendTrans.apply();
  	el.filters.blendTrans.play();
  	
  	nIntervalTime = nIntervalTime + aPhotosParameters[nParametersIndex + 2]*1000;
	}
	
	else if(nFilterType==3)
	{
		el.style.filter = "light()";
		
		//el.filters.light.clear();
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nRed = aPhotosParameters[nParametersIndex + 3];
		nGreen = aPhotosParameters[nParametersIndex + 4];
		nBlue = aPhotosParameters[nParametersIndex + 5];
		
		el.filters.light.addAmbient(nRed,nGreen,nBlue,nStrength);
		//el.filters.light.addAmbient(255,255,200,100);
	}
	
	else if(nFilterType==4)
	{
		el.style.filter = "light()";
		
		//el.filters.light.clear();
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nX1 = aPhotosParameters[nParametersIndex + 3];
		nY1 = aPhotosParameters[nParametersIndex + 4];
		nX2 = aPhotosParameters[nParametersIndex + 5];
		nY2 = aPhotosParameters[nParametersIndex + 6];
		nZ1 = aPhotosParameters[nParametersIndex + 7];
		nSpread = aPhotosParameters[nParametersIndex + 8];
		nRed = aPhotosParameters[nParametersIndex + 9];
		nGreen = aPhotosParameters[nParametersIndex + 10];
		nBlue = aPhotosParameters[nParametersIndex + 11];
		
		el.filters.light.addCone(nX1, nY1, nZ1, nX2, nY2, nRed, nGreen, nBlue, nStrength, nSpread);
	}
	
	else if(nFilterType==5)
	{
		el.style.filter = "alpha()";
		
		nOpacity = aPhotosParameters[nParametersIndex + 2];
		nStyle = aPhotosParameters[nParametersIndex + 3];
		nStartX = aPhotosParameters[nParametersIndex + 4];
		nStartY = aPhotosParameters[nParametersIndex + 5];
		nFinishX = aPhotosParameters[nParametersIndex + 6];
		nFinishY = aPhotosParameters[nParametersIndex + 7];
		nFinishOpacity = aPhotosParameters[nParametersIndex + 8];
	
		el.filters.alpha.opacity = nOpacity;
		el.filters.alpha.opacity = nStyle;
		el.filters.alpha.opacity = nStartX;
		el.filters.alpha.opacity = nStartY;
		el.filters.alpha.opacity = nFinishX;
		el.filters.alpha.opacity = nFinishY;
		el.filters.alpha.opacity = nFinishOpacity;
	}
	
	else if(nFilterType==6)
	{
		el.style.filter = "blur()";
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nDirection = aPhotosParameters[nParametersIndex + 3];
	
		el.filters.blur.strength = nStrength;
		el.filters.blur.direction = nDirection;
	}
	
	else if(nFilterType==7)
	{
		el.style.filter = "wave()";
		
		nStrength = aPhotosParameters[nParametersIndex + 2];
		nFreq = aPhotosParameters[nParametersIndex + 3];
		nPhase = aPhotosParameters[nParametersIndex + 4];
		nLightStrength = aPhotosParameters[nParametersIndex + 5];
		
		el.filters.wave.add=0;
		el.filters.wave.strength = nStrength;
		el.filters.wave.freq = nFreq;
		el.filters.wave.phase = nPhase;
		el.filters.wave.lightstrength = nLightStrength;
	}
	
	else if(nFilterType==8)
	{
		el.style.filter = "flipH";
	}
	
	else if(nFilterType==9)
	{
		el.style.filter = "flipV";
	}
	
	else if(nFilterType==10)
	{
		el.style.filter = "invert";
	}
	
	else if(nFilterType==11)
	{
		el.style.filter = "gray";
	}
	
	else if(nFilterType==12)
	{
		el.style.filter = "xray";
	}
	
	else
	{
		el.style.filter = "";
	}
	
	// First load it in a dummy image object.
	oFullScreenImage.src = aPhotos[(nPicNum-1)*2];
	sDummyVar = oFullScreenImage.src;	// Simulate a "NOP"
	sDummyVar = oFullScreenImage.src;	// Simulate a "NOP"
	
	// Hide an arrow if at the first or last picture
	document.all.PREVPIC.style.display = ((nPicNum == 1) ? "none" : "");
	document.all.NEXTPIC.style.display = ((nPicNum == aPhotos.length/2) ? "none" : "");
	
	nCurrentPic=nPicNum;
}

function Full_RepeatPlay()
{
	nPicNum = 1;
	Full_ShowPic(nPicNum);
}

// Full_OnPhotoLoaded is fired when the photo is fully loaded in the image object
// We need this for giving the user enough viewing time for the slideshow.
function Full_OnPhotoLoaded()
{
	window.event.cancelBubble=true;
	if (bSlideShow && window.event.srcElement.src.toLowerCase().indexOf("fspa_images/transp400x300.gif") == -1)
	{
		// The loaded photo is NOT the tranparent background picture, so
		// we can start the slideshow timer.
		
		Full_StartSlideShowTimer();
		
		// Stop the timer if at the last photo
		if (nCurrentPic >= aPhotos.length/2)
		{
			if(bRepeat)
			{
				clearTimeout(nSlideShowTimerID);
				nSlideShowTimerID = setTimeout("Full_RepeatPlay()", nIntervalTime);
			}
			else
				Full_StopSlideShowTimer();
		}
	}
}

function Full_ImageNotFound(oThisImg)
{
	oThisImg.src = "fspa_images/transp400x300.gif";
}

// Goto Previous picture
function Full_PrevPic()
{
	nCurrentPic--;
	Full_ShowPic(nCurrentPic);
}

// Goto Next picture
function Full_NextPic()
{
	nCurrentPic++;
	Full_ShowPic(nCurrentPic);
}
//-->
