function _WExecuteFunction(mExecFunc){
	eval(mExecFunc);
}
function MakeArray(size){
	this.length = size;
	for(i=0;i<=size;i++)
		this[i] = null;
	return this;

}
function ObjProp(strid,strtype,strobjdesc,strwidth,strheight,strtop,strleft,strzindex,strborder,strsourcepath,strnewwidth,strnewheight,strlight,strdark,strlinkhref,strbackgroundcolor,strmarquebehavior,strmarquedirection,strmarqueloop,strmarquescrolldelay,strmarquescrollamount,strtextfont,strtextsize,strtext1,strtextwithcode,strtextbold,strtextitalic,strtextunderline,strtextcolor,strnewtop,strnewleft,strphotobordername,strfilterglow,strfilterglowcolor,strfilterglowstrength,strfiltershadow,strfiltershadowcolor,strfiltershadowdir,strfiltershadowmov,strfilteralpha,strfilteralphaopacity,strtemplateobjid,strdecorsize,strsourcename,strdestname,strpictquality,strspinobj,strspinobjspeed,strphotosizename,strtextalign,strmarquelooptype,strlinktype,strnewtextcolor,strbgcolorctrl,strlayoutctrl,strbgimgctrl){
	this.id = strid;
	this.type = strtype;
	this.objdesc = strobjdesc;
	this.width = strwidth;
	this.height = strheight;
	this.top = strtop;
	this.left = strleft;
	this.zindex = strzindex;
	this.border = strborder;
	this.sourcepath = strsourcepath;
	this.newwidth = strnewwidth;
	this.newheight = strnewheight;
	this.bordercolorlight = strlight;
	this.bordercolordark = strdark;
	this.linkhref = strlinkhref;
	this.backgroundcolor = strbackgroundcolor;
	this.marquebehavior = strmarquebehavior;
	this.marquedirection = strmarquedirection;
	this.marqueloop = strmarqueloop;
	this.marquescrolldelay = strmarquescrolldelay;
	this.marquescrollamount = strmarquescrollamount;
	this.textfont = strtextfont;
	this.textsize = strtextsize;
	this.text1 = strtext1;
	this.textwithcode = strtextwithcode;
	this.textbold = strtextbold;
	this.textitalic = strtextitalic;
	this.textunderline = strtextunderline;
	this.textcolor = strtextcolor;
	this.newtop = strnewtop;
	this.newleft = strnewleft;
	this.photobordername = strphotobordername;
	this.filterglow = strfilterglow;
	this.filterglowcolor = strfilterglowcolor;
	this.filterglowstrength = strfilterglowstrength;
	this.filtershadow = strfiltershadow;
	this.filtershadowcolor = strfiltershadowcolor;
	this.filtershadowdir = strfiltershadowdir;
	this.filtershadowmov = strfiltershadowmov;
	this.filteralpha = strfilteralpha;
	this.filteralphaopacity = strfilteralphaopacity;
	this.templateobjid = strtemplateobjid;
	this.decorsize = strdecorsize;
	this.sourcename = strsourcename;
	this.destname = strdestname;
	this.pictquality = strpictquality;
	this.spinobj = strspinobj;
	this.spinobjspeed = strspinobjspeed;
	this.photosizename = strphotosizename;
	this.textalign = strtextalign;
	this.marquelooptype = strmarquelooptype;
	this.linktype = strlinktype;
	this.newtextcolor = strnewtextcolor;
	this.bgcolorctrl = strbgcolorctrl;
	this.layoutctrl = strlayoutctrl;
	this.bgimgctrl = strbgimgctrl;
}
function PageProp(strtitle,strbackgroundimage,stralink,strlink,strvlink,strtextcolor,strbgcolor,strmusicname,strmusicplayoption,strphotoborder,strphotoborderw,strbackgroundimagepath,strnewbgimage,strnewbgimagepath,strmusicnamepath,strnewbgcolor,strtemplatetype){
	this.title = strtitle;
	this.backgroundimage = strbackgroundimage;
	this.alink = stralink;
	this.link = strlink;
	this.vlink = strvlink;
	this.textcolor = strtextcolor;
	this.bgcolor = strbgcolor;
	this.musicname = strmusicname;
	this.musicplayoption = strmusicplayoption;
	this.photoborder = strphotoborder;
	this.photoborderw = strphotoborderw;
	this.backgroundimagepath = strbackgroundimagepath;
	this.newbgimage = strnewbgimage;
	this.newbgimagepath = strnewbgimagepath;
	this.musicnamepath = strmusicnamepath;
	this.newbgcolor = strnewbgcolor;
	this.templatetype = strtemplatetype;
}
function LinksProp(strtype,strwidth,strheight,strtop,strleft,strlayer,strpath,strlink,strfont,strfontsize,strsource,strtemplateobjid,strdisplay,strdescription){
	this.type = strtype;
	this.width = strwidth;
	this.height = strheight;
	this.top = strtop;
	this.left = strleft;
	this.layer = strlayer;
	this.path = strpath;
	this.link = strlink;
	this.font = strfont;
	this.fontsize = strfontsize;
	this.source = strsource;
	this.templateobjid = strtemplateobjid;
	this.display = strdisplay;
	this.description = strdescription;
}
function PictCtrlProp(strorderid,strpath,strsource,strheight,strwidth,strsoundpath,strsound,strduration,strtransno,strdurationinf,strtitle,strdate,strcaption,struserdefine1,struserdefine2,stralbumtitle,strplaystatus){
	this.orderid = strorderid;
	this.path = strpath;
	this.source = strsource;
	this.height = strheight;
	this.width = strwidth;
	this.soundpath = strsoundpath;
	this.sound = strsound;
	this.duration = strduration;
	this.transno = strtransno;
	this.durationinf = strdurationinf;
	this.title = strtitle;
	this.date = strdate;
	this.caption = strcaption;
	this.userdefine1 = struserdefine1;
	this.userdefine2 = struserdefine2;
	this.albumtitle = stralbumtitle;
	this.playstatus = strplaystatus;
}
function SlideShowProp(strloop,strplaceholdercolorcheck,strfitplaceholder,strplaystatus){
	this.loop = strloop;
	this.placeholdercolorcheck = strplaceholdercolorcheck;
	this.fitplaceholder = strfitplaceholder;
	this.playstatus = strplaystatus;
}
function ButtonsProp(strid,strdstate,strhstate,strnstate,strsstate,stractivestate){
	this.id = strid;
	this.dstate = strdstate;
	this.hstate = strhstate;
	this.nstate = strnstate;
	this.sstate = strsstate;
	this.activestate = stractivestate;
}
function ConvertLFtoBR(mstring){
	var tempstring=""; var newstring="";
	for(varb=0;varb<=mstring.length;varb++){
		tempstring = mstring.charAt(varb);
		if(tempstring.charCodeAt(0) == 13){ 
		}
		else{
			if(tempstring.charCodeAt(0) == 10){
				newstring = newstring + "<br>";
			}
			else
				newstring = newstring + tempstring;
		}
	}
	return newstring;
}
function ConvertBlank(mstring){
	var tempstring=""; var newstring="";
	for(vara=0;vara<=mstring.length;vara++){
		tempstring = mstring.charAt(vara);
		if(tempstring == " "){
			newstring = newstring + "&nbsp;";
		}
		else{
			if(tempstring == "<"){
				newstring = newstring + "&#60;";
			}
			else{
				newstring = newstring + tempstring;
			}
		}
	}
	return newstring;
}
function ArrowClick(mdirection){
	if(navigator.appName != "Microsoft Internet Explorer"){
		NSArrowClick(mdirection);
		return;
	}
	if(PictCtrlArray[0].orderid == "-1" ){ // not pictures in the array, just ignore
		return;
	}
	if(PageArray[0].templatetype == "slideshow" ){
		if(SlideShowArray[0].playstatus == "play")
			return;
	}
	var thumbnailW = 50; var thumbnailH = 50; 
	mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray");

	if(mdirection == "down" || mdirection == "right"){
		PictCtrlFirstObj = PictCtrlFirstObj + PictCtrlObjShow;
		if(PictCtrlFirstObj >= PictCtrlArray.length)
			PictCtrlFirstObj = PictCtrlFirstObj - PictCtrlObjShow;
		else
			ResetPictList();
	}
	if(mdirection == "up" || mdirection == "left"){
		PictCtrlFirstObj = PictCtrlFirstObj - PictCtrlObjShow;
		if(PictCtrlFirstObj < 0)
			PictCtrlFirstObj = PictCtrlFirstObj + PictCtrlObjShow;
		else
			ResetPictList();
	}
	//RefreshButtons();
	RefreshPicturesctrl();
}
function ResetPictList(){
	if(navigator.appName != "Microsoft Internet Explorer"){
		NSResetPictList();
		return;
	}
	var thumbnailW = 50; var thumbnailH = 50; UpdatePict = 0;
	mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray");
	for(mvar=0; mvar < PictCtrlObjShow; mvar++){
		if((PictCtrlFirstObj+mvar) < PictCtrlArray.length){
			newwidth = parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width); newheight = parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height);
			if(newwidth > thumbnailW || newheight > thumbnailH){
				if(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width) > parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height)){
					newheight = parseFloat(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height)/(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width)/thumbnailW));
					if(newheight < 1)
						newheight = 1;
					else
						newheight = parseInt(newheight + 0.5);
					newwidth = thumbnailW;
				}
				else{
					newwidth = parseFloat(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width)/(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height)/thumbnailH));
					if(newwidth < 1)
						newwidth = 1;
					else
						newwidth = parseInt(newwidth + 0.5);
					newheight = thumbnailH;
				}
			}
			eval("Obj" + mObjInArray + "TableIC" + (mvar)).borderColorLight = "ffffff";
			eval("Obj" + mObjInArray + "TableIC" + (mvar)).borderColorDark = "ababab";
			eval("Obj" + mObjInArray + "TableIC" + (mvar)).style.visibility = "hidden";
			eval("Obj" + mObjInArray + "ImageCtrl" + (mvar)).width = newwidth;
			eval("Obj" + mObjInArray + "ImageCtrl" + (mvar)).height = newheight;
			eval("Obj" + mObjInArray + "ImageCtrl" + (mvar)).src =  PictCtrlArray[(PictCtrlFirstObj+mvar)].path + "Tn"+PictCtrlArray[(PictCtrlFirstObj+mvar)].source;
			eval("Obj" + mObjInArray + "TableIC" + (mvar)).style.visibility = "visible";
		}
		else{
			if(mvar < PictCtrlArray.length)
				eval("Obj" + mObjInArray + "TableIC" + (mvar)).style.visibility = "hidden";
		}
		if((PictCtrlFirstObj+mvar) == PictCtrlFocusObj){
			eval("Obj" + mObjInArray + "TableIC" + mvar).borderColorLight = "a0ffff";
			eval("Obj" + mObjInArray + "TableIC" + mvar).borderColorDark = "009a9a";
		}
	}
}
function Picturesctrlclick(PictureID,mfunction){
	if(navigator.appName != "Microsoft Internet Explorer"){
		NSPicturesctrlclick(PictureID,mfunction);
		return;
	}
	if(PageArray[0].musicname != "" && PageArray[0].musicname != "no sound" && mfunction == "init"){
		document.MediaPlayer.FileName = PageArray[0].musicnamepath + PageArray[0].musicname;
	}
	if(PictCtrlArray[0].orderid == "-1"){ 
		return;
	}
	var oldPictCtrlFocusObj = PictCtrlFocusObj; var	msquarelayout = 0; var ssplaying = 0;
	if(mfunction == "ss"){
		if(SlideShowArray[0].playstatus == "play")
			ssplaying = 1;
		else{
			ssplaying = 0;
		}
	}
	else
		if(PageArray[0].templatetype == "slideshow")
			SlideShowArray[0].playstatus = "stop";

	// update the picture list
	mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray");
	oldPictCtrlFirstObj = PictCtrlFirstObj;
	if((mfunction == "next" || mfunction == "previous"  || mfunction == "ss") && PictCtrlFocusObj < PictCtrlArray.length ){
		for(mfirst=0; mfirst<PictCtrlArray.length; mfirst+=PictCtrlObjShow){
			if(PictCtrlFocusObj >= mfirst)
				PictCtrlFirstObj = mfirst;
		}
	}
	if(PictureID != -1 ){
		PictCtrlFocusObj = PictureID+PictCtrlFirstObj;
	}
	if(mfunction == "next" || (ssplaying == 1)){
		PictureID = (PictCtrlFocusObj - PictCtrlFirstObj)+1;
		PictCtrlFocusObj = PictCtrlFocusObj + 1;
		if(PictCtrlFocusObj >= PictCtrlArray.length){
			PictureID = PictureID - 1;
			PictCtrlFocusObj = PictCtrlFocusObj - 1;
			if(mfunction == "ss"){
				PictureID = 0;
				PictCtrlFocusObj = 0;
				PictCtrlFirstObj = 0;
			}
		}
		else{
			if(PictureID >= PictCtrlObjShow){
				if(ObjArray[mObjInArray].layoutctrl == "square" || ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "horizontal"){
					PictCtrlFirstObj = PictCtrlFirstObj + PictCtrlObjShow;
					if(PictCtrlFirstObj >= PictCtrlArray.length)
						PictCtrlFirstObj = PictCtrlFirstObj - PictCtrlObjShow;
				}
				PictureID = 0;
			}
		}
	}
	if(mfunction == "previous"){
		PictureID = (PictCtrlFocusObj - PictCtrlFirstObj)-1;
		PictCtrlFocusObj = PictCtrlFocusObj - 1;
		if(PictCtrlFocusObj < 0){
			PictureID = PictureID + 1;
			PictCtrlFocusObj = PictCtrlFocusObj + 1;
		}
		else{
			if(PictureID < 0){
				if(ObjArray[mObjInArray].layoutctrl == "square" || ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "horizontal"){
					//ArrowClick("up");
					PictCtrlFirstObj = PictCtrlFirstObj - PictCtrlObjShow;
					if(PictCtrlFirstObj < 0)
						PictCtrlFirstObj = PictCtrlFirstObj + PictCtrlObjShow;
				}
				PictureID = PictCtrlObjShow-1;
			}
		}
	}

	// show or hide placeholder control
	mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray"); // need this here otherwise the text is not working
	msquarelayout = 0;
	if(ObjArray[mObjInArray].layoutctrl == "square"){
		if(mfunction != "init")
			eval("Obj" + mObjInArray).style.display = "none";
		else
			eval("Obj" + mObjInArray).style.display = "";
		msquarelayout = 1;
	}
	mObjInArray = FindCtrlID("type","Placeholderctrl","ObjArray");
	if(msquarelayout){
		if(mfunction != "init")
			eval("Obj" + mObjInArray).style.display = "";
		else
			eval("Obj" + mObjInArray).style.display = "none";
	}

	// set the placeholder here
	mObjInArray = FindCtrlID("type","Placeholderctrl","ObjArray");
	imgsizeW = parseInt(ObjArray[mObjInArray].newwidth);
	imgsizeH = parseInt(ObjArray[mObjInArray].newheight);
	if(SlideShowArray[0].fitplaceholder == "false"){
		if(parseInt(PictCtrlArray[PictCtrlFocusObj].width) > imgsizeW){
			newheight = parseFloat(parseInt(PictCtrlArray[PictCtrlFocusObj].height)/(parseInt(PictCtrlArray[PictCtrlFocusObj].width)/imgsizeW));
			if(newheight < 1)
				newheight = 1;
			else
				newheight = parseInt(newheight + 0.5);
			newwidth = imgsizeW;
		}
		else{
			newwidth = parseInt(PictCtrlArray[PictCtrlFocusObj].width);
			newheight = parseInt(PictCtrlArray[PictCtrlFocusObj].height);
		}
		if(newheight > imgsizeH){
			newwidth = parseFloat(newwidth/(newheight/imgsizeH));
			if(newwidth < 1)
				newwidth = 1;
			else
				newwidth = parseInt(newwidth + 0.5);
			newheight = imgsizeH;
		}
		else{
			//nothing
		}
	}
	else{
		newheight = parseFloat(parseInt(PictCtrlArray[PictCtrlFocusObj].height)/(parseInt(PictCtrlArray[PictCtrlFocusObj].width)/imgsizeW));
		if(newheight < 1)
			newheight = 1;
		else
			newheight = parseInt(newheight + 0.5);
		newwidth = imgsizeW;
		if(newheight > imgsizeH){
			newwidth = parseFloat(newwidth/(newheight/imgsizeH));
			if(newwidth < 1)
				newwidth = 1;
			else
				newwidth = parseInt(newwidth + 0.5);
			newheight = imgsizeH;
		}
	}
	// set the new picture transition if slide show
	if(ssplaying == 1 && parseInt(PictCtrlArray[PictCtrlFocusObj].transno) != 77){
		var meffect;
		meffect="revealtrans() ";
		eval("Obj" + mObjInArray ).style.filter=meffect;
		if(eval("Obj" + mObjInArray ).filters.item(0).status == 2){
			eval("Obj" + mObjInArray ).filters.item(0).stop();
		}
		eval("Obj" + mObjInArray ).filters.item(0).transition=parseInt(PictCtrlArray[PictCtrlFocusObj].transno);
		eval("Obj" + mObjInArray ).filters.item(0).duration=3; 
		eval("Obj" + mObjInArray ).filters.item(0).apply();
	}
	// set the new picture
	if(mfunction != "ss" || ssplaying == 1){
		eval("Obj" + mObjInArray + "Image").style.display = "none";
		window.clearInterval(IntervalIDLoad);
		mwaitforimage = "waitforimage(" + mObjInArray + ")";
		IntervalIDLoad = window.setInterval(mwaitforimage,300);
		///eval("Obj" + mObjInArray + "Image").src = "Transparent.gif";
		eval("Obj" + mObjInArray + "Image").width = newwidth;
		eval("Obj" + mObjInArray + "Image").height = newheight;
		eval("Obj" + mObjInArray + "Image").src = PictCtrlArray[PictCtrlFocusObj].path + PictCtrlArray[PictCtrlFocusObj].source;
	}
	// if a slide show, play the transition
	if(ssplaying == 1){
		if(parseInt(PictCtrlArray[PictCtrlFocusObj].transno) != 77)
			eval("Obj" + mObjInArray).filters.item(0).play();
		window.clearInterval(IntervalID);
	}

	// update the picture control
	if(PictCtrlFirstObj != oldPictCtrlFirstObj)
		ResetPictList(); 
	else{
		if(mfunction != "ss" || ssplaying == 1){ // if a slide show, it must be playing for the old thumbnail to be updated
			// take out the hightlight of the old picture
			mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray");
			if(oldPictCtrlFocusObj - PictCtrlFirstObj >= 0 && oldPictCtrlFocusObj - PictCtrlFirstObj < PictCtrlObjShow ){
				eval("Obj" + mObjInArray + "TableIC" + (oldPictCtrlFocusObj - PictCtrlFirstObj)).borderColorLight = "ffffff";
				eval("Obj" + mObjInArray + "TableIC" + (oldPictCtrlFocusObj - PictCtrlFirstObj)).borderColorDark = "ababab";
			}
		}
	}

	// hightlight the new image
	if(mfunction != "ss" || ssplaying == 1){ // if a slide show, it must be playing for the new thumbnail to be updated
		eval("Obj" + mObjInArray + "TableIC" + PictureID).borderColorLight = "a0ffff";
		eval("Obj" + mObjInArray + "TableIC" + PictureID).borderColorDark = "009a9a";
//		eval("Obj" + mObjInArray + "ImageCtrl" + PictureID).src = PictCtrlArray[PictCtrlFocusObj].path + "Tn"+PictCtrlArray[PictCtrlFocusObj].source;
	}

	// update the text fields
	if(PageArray[0].templatetype == "album"){
		if(mfunction != "init")
			PlaySound('play');
	}

	UpdateTextfields();

	RefreshButtonsctrl();
	RefreshPicturesctrl();
}
function UpdateTextfields(){
	// update the text fields
	if(PageArray[0].templatetype == "album"){
		var mexit = 0;
		for(i=0; i<ObjArray.length && mexit != 1;i++){
			if(ObjArray[i] != null){
				if(ObjArray[i].templateobjid == "title")
					midtitle = i;
				if(ObjArray[i].templateobjid == "date")
					middate = i;
				if(ObjArray[i].templateobjid == "caption")
					midcaption = i;
				if(ObjArray[i].templateobjid == "userdefine1")
					miduserdefine1 = i;
				if(ObjArray[i].templateobjid == "userdefine2")
					miduserdefine2 = i;
				if(ObjArray[i].templateobjid == "albumtitle")
					midalbumtitle = i;
			}
		}
		if(FindCtrlID("templateobjid","title","ObjArray") != -1)
			eval("Obj" + midtitle + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].title;
		if(FindCtrlID("templateobjid","date","ObjArray") != -1)
			eval("Obj" + middate + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].date;
		if(FindCtrlID("templateobjid","caption","ObjArray") != -1)
			eval("Obj" + midcaption + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].caption;
		if(FindCtrlID("templateobjid","userdefine1","ObjArray") != -1)
			eval("Obj" + miduserdefine1 + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].userdefine1;
		if(FindCtrlID("templateobjid","userdefine2","ObjArray") != -1)
			eval("Obj" + miduserdefine2 + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].userdefine2;
		if(FindCtrlID("templateobjid","albumtitle","ObjArray") != -1)
			eval("Obj" + midalbumtitle + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].albumtitle;
	}
	if(PageArray[0].templatetype == "slideshow" ){
		var mexit = 0;
		for(i=0; i<ObjArray.length && mexit != 1;i++){
			if(ObjArray[i] != null){
				if(ObjArray[i].templateobjid == "title")
					midtitle = i;
				if(ObjArray[i].templateobjid == "date")
					middate = i;
				if(ObjArray[i].templateobjid == "albumtitle")
					midalbumtitle = i;
			}
		}
		if(FindCtrlID("templateobjid","title","ObjArray") != -1)
			eval("Obj" + midtitle + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].title;
		if(FindCtrlID("templateobjid","date","ObjArray") != -1)
			eval("Obj" + middate + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].date;
		if(FindCtrlID("templateobjid","albumtitle","ObjArray") != -1)
			eval("Obj" + midalbumtitle + "textwithcode").innerHTML = PictCtrlArray[PictCtrlFocusObj].albumtitle;
	}
}

function PlaySound(maction){
	if(navigator.appName != "Microsoft Internet Explorer"){
		return;
	}
	if(maction == "stop"){
		document.MediaPlayer.Stop();
		if(navigator.appName == "Microsoft Internet Explorer")
			document.MediaPlayer.FileName = "";
		else
			document.MediaPlayer.src = "";
	}
	else{
		if((PageArray[0].templatetype == "album" || SlideShowArray[0].playstatus != "stop") && maction == "play"){
			if((PictCtrlArray[PictCtrlFocusObj].sound != "" && PictCtrlArray[PictCtrlFocusObj].sound != "no sound") ){
				if(navigator.appName == "Microsoft Internet Explorer"){
					if(PageArray[0].musicname != PictCtrlArray[PictCtrlFocusObj].sound ){
						document.MediaPlayer.FileName = "";
						document.MediaPlayer.FileName = PictCtrlArray[PictCtrlFocusObj].soundpath + PictCtrlArray[PictCtrlFocusObj].sound;
						if(PictCtrlArray[PictCtrlFocusObj].playstatus == "once")
							document.MediaPlayer.PlayCount = 1;
						else
							document.MediaPlayer.PlayCount = 0;
						if(document.MediaPlayer.FileName != "" )
							document.MediaPlayer.Play();
					}
				}
			}
			else{
				if(PageArray[0].musicname != "" && PageArray[0].musicname != "no sound" ){
					if(navigator.appName == "Microsoft Internet Explorer"){
						if(document.MediaPlayer.FileName.substr(document.MediaPlayer.FileName.lastIndexOf("\\")+1) != PageArray[0].musicname && document.MediaPlayer.FileName.substr(document.MediaPlayer.FileName.lastIndexOf("/")+1) != PageArray[0].musicname){
							document.MediaPlayer.FileName = "";
							document.MediaPlayer.FileName = PageArray[0].musicnamepath + PageArray[0].musicname;
							if(PageArray[0].musicplayoption == "once")
								document.MediaPlayer.PlayCount = 1;
							else
								document.MediaPlayer.PlayCount = 0;
							if(document.MediaPlayer.FileName != "")
								document.MediaPlayer.Play();
						}
						else{
							if(PageArray[0].musicplayoption == "once")
								document.MediaPlayer.PlayCount = 1;
							else
								document.MediaPlayer.PlayCount = 0;
							if(document.MediaPlayer.FileName != "" )
								document.MediaPlayer.Play();
						}

					}
				}
				else{
					document.MediaPlayer.PlayCount = 1;
					document.MediaPlayer.Stop();
				}
			}
		}
	}
}
function Buttonctrlclick(mfunction){
	if(navigator.appName != "Microsoft Internet Explorer"){
		NSButtonctrlclick(mfunction);
		return;
	}

	if(PictCtrlArray[0].orderid == "-1"){ // slide show or album has no valid pictures
		return;
	}
	mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray");
	mButtonsctrl = FindCtrlID("type","Buttonsctrl","ObjArray");
	if(mfunction == "home"){
		if(ObjArray[mObjInArray].layoutctrl == "square"){
			eval("Obj" + mObjInArray).style.display = "";
			mObjInArray=-1; mexit = 0;
			for(vari=0; vari<ObjArray.length && mexit != 1;vari++){
				if(ObjArray[vari] != null){
					if(ObjArray[vari].type == "Placeholderctrl"){
						mObjInArray = vari;
						mexit = 1;
					}
				}
			}
			eval("Obj" + mObjInArray).style.display = "none";
		}
		else{
			if(PictCtrlFocusObj != 0){
				PictCtrlFocusObj = 0;
				Picturesctrlclick(0,'previous');
			}
			else{
				PictCtrlFirstObj = 0;
			}
			ResetPictList(); 
		}
	}
	if(mfunction == "play"){
		if(SlideShowArray[0].playstatus != "play"){
			for(mfirst=0; mfirst<PictCtrlArray.length; mfirst+=PictCtrlObjShow){
				if(PictCtrlFocusObj >= mfirst)
					PictCtrlFirstObj = mfirst;
			}
			ResetPictList();
			SlideShowArray[0].playstatus = "play";
			window.clearInterval(IntervalIDLoad);
			window.clearInterval(IntervalID);
			PlaySound('play');
			mtime = parseInt(PictCtrlArray[PictCtrlFocusObj].duration);
			if(PictCtrlArray[PictCtrlFocusObj].durationinf != "true"){
				IntervalID = window.setTimeout("Picturesctrlclick(-1,'ss')",(mtime*1050));

			}
			//RefreshButtons();
			RefreshButtonsctrl();
		}
	}
	if(mfunction == "stop"){
		if(SlideShowArray[0].playstatus != "stop"){
			SlideShowArray[0].playstatus = "stop";
			//RefreshButtons();
			RefreshButtonsctrl();
			IntervalID = window.setTimeout("",0);
			window.clearInterval(IntervalIDLoad);
			window.clearInterval(IntervalID);
			PlaySound("stop");
		}
	}
	if(mfunction == "previous"){
		if(PageArray[0].templatetype == "slideshow"){
			if(SlideShowArray[0].playstatus == "stop"){
				window.clearInterval(IntervalIDLoad);
				window.clearInterval(IntervalID);
				Picturesctrlclick(-1,'previous');
			}
		}
		else{
			if(PictCtrlFocusObj != 0)
				Picturesctrlclick(-1,'previous');
		}
	}
	if(mfunction == "next"){
		if(PageArray[0].templatetype == "slideshow"){
			if(SlideShowArray[0].playstatus == "play" && PictCtrlArray[PictCtrlFocusObj].durationinf == "true"){
				window.clearInterval(IntervalIDLoad);
				window.clearInterval(IntervalID);
				Picturesctrlclick(-1,'ss');
			}
			else{
				if(SlideShowArray[0].playstatus == "stop"){
					Picturesctrlclick(-1,'next');
				}
			}
		}
		else{
			if(PictCtrlFocusObj != PictCtrlArray.length-1)
				Picturesctrlclick(-1,'next');
		}
	}		
}
function RefreshPicturesctrl(){
	mObjInArray = FindCtrlID("type","Picturesctrl","ObjArray");
	if(PictCtrlFirstObj == 0){
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			SetButtons("Obj" + mObjInArray + "ImageArrowLeft" ,"d");
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			SetButtons("Obj" + mObjInArray + "ImageArrowUp" ,"d");
	}
	else{
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			SetButtons("Obj" + mObjInArray + "ImageArrowLeft" ,"n");
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			SetButtons("Obj" + mObjInArray + "ImageArrowUp" ,"n");
	}
	if(PictCtrlFirstObj+PictCtrlObjShow >= PictCtrlArray.length){
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			SetButtons("Obj" + mObjInArray + "ImageArrowRight" ,"d");
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			SetButtons("Obj" + mObjInArray + "ImageArrowDown" ,"d");
	}
	else{
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			SetButtons("Obj" + mObjInArray + "ImageArrowRight" ,"n");
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			SetButtons("Obj" + mObjInArray + "ImageArrowDown" ,"n");
	}
}
function RefreshButtonsctrl(){
	// find the control ID number
	mObjInArray = FindCtrlID("type","Buttonsctrl","ObjArray");
	if(PageArray[0].templatetype == "slideshow"){
		if(SlideShowArray[0].playstatus == "stop"){
			SetButtons("Obj" + mObjInArray + "ImageCtrl1" ,"n");
			SetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"n");
			SetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"d");
			SetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"n");
		}
		if(SlideShowArray[0].playstatus == "play"){
			SetButtons("Obj" + mObjInArray + "ImageCtrl1" ,"d");
			SetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"s");
			SetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"n");
			SetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"d");
		}
		if(PictCtrlArray[PictCtrlFocusObj].durationinf == "true")
			SetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"n");
	}
	if(PictCtrlFocusObj == 0){
		if(PageArray[0].templatetype != "slideshow")
			SetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"d");
		else
			SetButtons("Obj" + mObjInArray + "ImageCtrl1" ,"d");
	}
	else{
		if(PageArray[0].templatetype != "slideshow")
				SetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"n");
	}
	if(PictCtrlFocusObj == PictCtrlArray.length - 1){
		if(PageArray[0].templatetype == "slideshow"){
			if(PictCtrlArray[PictCtrlFocusObj].durationinf == "true")
				SetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"n");
			else
				SetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"d");
		}
		else
			SetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"d");
	}
	else{
		if(PageArray[0].templatetype != "slideshow")
			SetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"n");
	}
}
function SetButtons(mID,mstate){
	if(navigator.appName != "Microsoft Internet Explorer"){
		NSSetButtons(mID,mstate);
		return;
	}

	mObjnum = FindCtrlID("id",mID,"ButtonsArray");
	if(mstate == "d"){
		eval(ButtonsArray[mObjnum].id).src = ButtonsArray[mObjnum].dstate;
		ButtonsArray[mObjnum].activestate = mstate; 
	}
	else{
		if(mstate == "s"){
			eval(ButtonsArray[mObjnum].id).src = ButtonsArray[mObjnum].sstate;
			ButtonsArray[mObjnum].activestate = mstate; 
		}
		else{
			if(mstate == "n"){
				eval(ButtonsArray[mObjnum].id).src = ButtonsArray[mObjnum].nstate;
				ButtonsArray[mObjnum].activestate = mstate; 
			}
		}
	}
}
function FindCtrlID(mfield,mid,marray){
	if(navigator.appName != "Microsoft Internet Explorer"){
		NSFindCtrlID(mfield,mid,marray);
		return;
	}
	var mObjInArray=-1; var mexit = 0;
	for(i=0; i< eval(marray+".length") && mexit != 1;i++){
		if(eval(marray+"[i]") != null){
			if(eval(marray + "[i]." + mfield) == mid){
				mObjInArray = i;
				mexit = 1;
			}
		}
	}
	return mObjInArray;
}
function waitforimage(mObjInArray){
	var temp;
	temp = eval("Obj" + mObjInArray + "Image").readyState;
	if (temp == 'complete'){
		window.clearInterval(IntervalIDLoad);
		eval("Obj" + mObjInArray + "Image").style.display = "";
		IntervalID2 = window.setTimeout("",0);
		window.clearInterval(IntervalID2);
		IntervalID2 = window.setTimeout("PlaySound('play')",0);
		if(PageArray[0].templatetype == "slideshow"){
			if(SlideShowArray[0].playstatus == "play"){
				// make sure the picture is finish loaded before going to the next picture
				window.clearInterval(IntervalID);
				mtime = parseInt(PictCtrlArray[PictCtrlFocusObj].duration);
				if(PictCtrlArray[PictCtrlFocusObj].durationinf != "true"){
					if(PictCtrlFocusObj == PictCtrlArray.length-1){
						if(SlideShowArray[0].loop != "false"){
							if(parseInt(PictCtrlArray[PictCtrlFocusObj].transno) != 77)
								IntervalID = window.setTimeout("Picturesctrlclick(-1,'ss')",(mtime+3) *1050);
							else
								IntervalID = window.setTimeout("Picturesctrlclick(-1,'ss')",(mtime) *1050);
						}
					}
					else{
						if(parseInt(PictCtrlArray[PictCtrlFocusObj].transno) != 77)
							IntervalID = window.setTimeout("Picturesctrlclick(-1,'ss')",(mtime+3) *1050);
						else
							IntervalID = window.setTimeout("Picturesctrlclick(-1,'ss')",(mtime) *1050);
					}
				}
			}
		}
	}
}


//
//-------- netscape support starts here --------------------------------------------------------------------------------------------
//
function dumpout(FirstL,SecondL,writeout,newx,newy) {
 	document.layers[FirstL].document.layers[SecondL].left=newx;
 	document.layers[FirstL].document.layers[SecondL].top=newy;
	document.layers[FirstL].document.layers[SecondL].document.open();
	document.layers[FirstL].document.layers[SecondL].document.write(writeout);
	document.layers[FirstL].document.layers[SecondL].document.close();
}

function outputImgList(objNum, destImg, sourceImg,objIndex,widthImg,heightImg,widthTbl,heightTbl,outputString){
	var holderSize=' width='+widthTbl+' height='+heightTbl+' '
	if (document.images) {
		var emptyout='<table ><tr><td align=center valign=center></td></tr></table>'
		if (document.layers) {	
			//document.layers['Obj' + objNum].document.images[destImg].src = (eval(sourceImg).path + eval(sourceImg).source); 
		}
		else 
			document.images[destImg].src;
	}
	if (sourceImg == 0){
		document.layers['Obj'+objNum+'ImageCtrl'+objIndex+'b'].document.open();
		document.layers['Obj'+objNum+'ImageCtrl'+objIndex+'b'].document.writeln(emptyout);
		document.layers['Obj'+objNum+'ImageCtrl'+objIndex+'b'].document.close();
	}
	else{
		newx=document.layers['Obj'+objNum].document.images['Obj'+objNum+'ImageCtrl'+objIndex].x-2; // -2 because the border is 2 width
		newy=document.layers['Obj'+objNum].document.images['Obj'+objNum+'ImageCtrl'+objIndex].y-2; // -2 because the border is 2 height
		dumpout('Obj'+objNum,'Obj'+objNum+'ImageCtrl'+objIndex+'b', outputString,newx,newy) 
	}
}
function hidelayer(objnum){
    	document.layers[objnum].visibility='hidden';
}
 
function showlayer(objnum){
 	document.layers[objnum].visibility='visible';
}

function outputImgMain(objNum, destImg, sourceImg,widthImg,heightImg,widthTbl,heightTbl,outputString){
	//table generation
	var borsource1= PageArray[0].photoborder;
	var borsource2 = borsource1.substring(0, borsource1.length-5)+'2'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	var borsource3 = borsource1.substring(0, borsource1.length-5)+'3'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	var borsource4 = borsource1.substring(0, borsource1.length-5)+'4'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	var borsource5 = borsource1.substring(0, borsource1.length-5)+'5'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	var borsource6 = borsource1.substring(0, borsource1.length-5)+'6'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	var borsource7 = borsource1.substring(0, borsource1.length-5)+'7'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	var borsource8 = borsource1.substring(0, borsource1.length-5)+'8'+ borsource1.substring(borsource1.length-4, borsource1.length)      ;
	tmpmObjInArray = NSFindCtrlID("type","Placeholderctrl","ObjArray");
	var holderSize=' width='+(widthTbl+4)+' height='+(heightTbl+4)+' '
	var mlayout = NSFindCtrlID("type","Picturesctrl","ObjArray");
	var output="";
	if(ObjArray[mlayout].layoutctrl == "square")
		output='<table bgcolor='+ObjArray[tmpmObjInArray].bgcolorctrl +' cellpadding=0 cellspacing=0 '+holderSize+'><tr><td align=center valign=center><img  onMouseDown="Buttonctrlclick(&quot;home&quot;);" '+ ' name=Obj3Image id=Obj3Image src=' +eval(sourceImg).source +' height='+heightImg+' width='+widthImg+' ></td></tr></table>'
	else
		output='<table bgcolor='+ObjArray[tmpmObjInArray].bgcolorctrl +' cellpadding=0 cellspacing=0 '+holderSize+'><tr><td align=center valign=center><img name=Obj3Image id=Obj3Image src=' +eval(sourceImg).source +' height='+heightImg+' width='+widthImg+' ></td></tr></table>'
	var boutput='<table bgcolor=000000 border=0 id=Obj'+objNum+'DesignBorder  cellspacing=0 cellpadding=0><tr><td ><img id=Obj'+objNum+'db1 src='+borsource1+'></td><td id=Obj'+objNum+'db2 background='+borsource2+'>&nbsp;</td><td ><img id=Obj'+objNum+'db3 src='+borsource3+' ></td></tr><tr><td id=Obj'+objNum+'db8 background='+borsource8+' >&nbsp;</td><td>'+output+'</td><td id=Obj'+objNum+'db4 background='+borsource4+'>&nbsp;</td></tr><tr><td ><img id=Obj'+objNum+'db7 src='+borsource7+'></td><td id=Obj'+objNum+'db6 background='+borsource6+' >&nbsp;</td><td ><img id=Obj'+objNum+'db5 src='+borsource5+' ></td></tr></table>'
	var emptyout='<table '+holderSize+'  ><tr><td align=center valign=center></td></tr></table>'
	if (document.images) {
		if (document.layers) {		
			//	document.layers['Obj' + objNum].document.images[destImg].src = (eval(sourceImg).path + eval(sourceImg).source); 
		}
		else 
			document.images[destImg].src;
	}
	if(sourceImg == 0){
		document.layers['Obj'+objNum].document.open();
		document.layers['Obj'+objNum].document.writeln(emptyout);
		document.layers['Obj'+objNum].document.close();
	}
	else{
		newx=document.layers['Obj'+objNum].document.images['Obj'+objNum+'Image'].x-2;
		newy=document.layers['Obj'+objNum].document.images['Obj'+objNum+'Image'].y-2;
		dumpout('Obj'+objNum,'Obj'+objNum+'Imageb', output,newx,newy) 
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//output the titles and stuff for the slideshow
	if(PageArray[0].templatetype == "slideshow" ){
		// find the control ID number 
		var mexit = 0;
		for(i=0; i<ObjArray.length && mexit != 1;i++){
			if(ObjArray[i] != null){
				if(ObjArray[i].templateobjid == "title")
					midtitle = i;
				if(ObjArray[i].templateobjid == "date")
					middate = i;
				if(ObjArray[i].templateobjid == "albumtitle")
					midalbumtitle = i;
			}
		}
		if(NSFindCtrlID("templateobjid","title","ObjArray") != -1){
			
			document.layers['Obj' + midtitle ].document.open();
				document.layers['Obj' + midtitle].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[midtitle].textalign +'  class='+'Obj' + midtitle + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].title+'</td></tr></table>' );				
			document.layers['Obj' + midtitle ].document.close();
		}
		if(NSFindCtrlID("templateobjid","date","ObjArray") != -1){
			document.layers['Obj' + middate ].document.open();
				document.layers['Obj' + middate ].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[middate].textalign +'  class='+'Obj' + middate + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].date+'</td></tr></table>' );				
			document.layers['Obj' + middate].document.close();
		}

		if(NSFindCtrlID("templateobjid","albumtitle","ObjArray") != -1){
			document.layers['Obj' + midalbumtitle ].document.open();
				document.layers['Obj' + midalbumtitle ].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[midalbumtitle].textalign +'  class='+'Obj' + midalbumtitle + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].albumtitle +'</td></tr></table>' );				
			document.layers['Obj' + midalbumtitle  ].document.close();
		}
	}	 
	//output titles for the album
	if(PageArray[0].templatetype == "album"){
		// find the control ID number 
		var mexit = 0;
		for(i=0; i<ObjArray.length && mexit != 1;i++){
			if(ObjArray[i] != null){
				if(ObjArray[i].templateobjid == "title")
					midtitle = i;
				if(ObjArray[i].templateobjid == "date")
					middate = i;
				if(ObjArray[i].templateobjid == "caption")
					midcaption = i;
				if(ObjArray[i].templateobjid == "userdefine1")
					miduserdefine1 = i;
				if(ObjArray[i].templateobjid == "userdefine2")
					miduserdefine2 = i;
				if(ObjArray[i].templateobjid == "albumtitle")
					midalbumtitle = i;
			}
		}
		if(NSFindCtrlID("templateobjid","title","ObjArray") != -1){
			document.layers['Obj' + midtitle ].document.open();
				document.layers['Obj' + midtitle].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[midtitle].textalign +'  class='+'Obj' + midtitle + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].title+'</td></tr></table>' );				
			document.layers['Obj' + midtitle ].document.close();
			}
		if(NSFindCtrlID("templateobjid","date","ObjArray") != -1){
			document.layers['Obj' + middate ].document.open();
				document.layers['Obj' + middate].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[middate].textalign +'  class='+'Obj' + middate + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].date +'</td></tr></table>' );				
			document.layers['Obj' + middate ].document.close();
			}
		if(NSFindCtrlID("templateobjid","caption","ObjArray") != -1){
			document.layers['Obj' + midcaption ].document.open();
				document.layers['Obj' + midcaption].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[midcaption].textalign +'  class='+'Obj' + midcaption + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].caption +'</td></tr></table>' );				
			document.layers['Obj' + midcaption ].document.close();
			}
		if(NSFindCtrlID("templateobjid","userdefine1","ObjArray") != -1){
			document.layers['Obj' + miduserdefine1 ].document.open();
				document.layers['Obj' + miduserdefine1 ].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[miduserdefine1].textalign +'  class='+'Obj' + miduserdefine1 + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].userdefine1 +'</td></tr></table>' );				
			document.layers['Obj' + miduserdefine1].document.close();
			}
		if(NSFindCtrlID("templateobjid","userdefine2","ObjArray") != -1){
			document.layers['Obj' + miduserdefine2 ].document.open();
				document.layers['Obj' + miduserdefine2 ].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[miduserdefine2].textalign +'  class='+'Obj' + miduserdefine2 + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].userdefine2 +'</td></tr></table>' );				
			document.layers['Obj' + miduserdefine2 ].document.close();
			}
		if(NSFindCtrlID("templateobjid","albumtitle","ObjArray") != -1){
			document.layers['Obj' + midalbumtitle ].document.open();
				document.layers['Obj' + midalbumtitle].document.writeln('<table cellspacing=0 cellpadding=0><tr><td align=' +ObjArray[midalbumtitle].textalign +'  class='+'Obj' + midalbumtitle + 'style' + '>' + PictCtrlArray[PictCtrlFocusObj].albumtitle +'</td></tr></table>' );				
			document.layers['Obj' + midalbumtitle ].document.close();			
			}
	}
}
function NSplaySlide()	{
	if (SlideShowArray[0].playstatus == "play"){
		//display the new images
		//update big pic
		// repeat sequence
		var delay=parseInt(PictCtrlArray[PictCtrlFocusObj].duration);
		if(parseInt(PictCtrlArray[PictCtrlFocusObj].transno) != 77){
			delay=delay+3;
		}
		setTimeout('NSplaySlide2()', delay*1050);
	}	
}	

function NSplaySlide2()	{
	window.clearInterval(IntervalID);
	if (SlideShowArray[0].playstatus == "play"){
		//display the new images
		//update big pic
		NSPicturesctrlclick(PictCtrlFocusObj % PictCtrlObjShow,'ss');
		// repeat sequence
		var delay=parseInt(PictCtrlArray[PictCtrlFocusObj].duration);
		if(parseInt(PictCtrlArray[PictCtrlFocusObj].transno) != 77){
				delay=delay+3;
		}
		if(PictCtrlArray[PictCtrlFocusObj].durationinf != "true")
			IntervalID = window.setTimeout('NSplaySlide2()', delay*1050);
	}	
}

function NSResetPicList(mPictureID,mfunction){
	var thumbnailW = 50; var thumbnailH = 50; UpdatePict = 0;
	var tblW = 58; var tblH = 58; 
	mObjInArray = NSFindCtrlID("type","Picturesctrl","ObjArray");
	var outputString='';
	for(mvar=0; mvar < PictCtrlObjShow; mvar++){
		if((parseInt(PictCtrlFirstObj)+mvar) < PictCtrlArray.length){
			// calculate the width and height for the thumbnail
			newwidth = parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width); newheight = parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height);
			if(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width) > parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height)){
				newheight = parseFloat(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height)/(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width)/thumbnailW));
				if(newheight < 1)
					newheight = 1;
				else
					newheight = parseInt(newheight + 0.5);
				newwidth = thumbnailW;
			}
			else{
				newwidth = parseFloat(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].width)/(parseInt(PictCtrlArray[(PictCtrlFirstObj+mvar)].height)/thumbnailH));
				if(newwidth < 1)
					newwidth = 1;
				else
					newwidth = parseInt(newwidth + 0.5);
				newheight = thumbnailH;
			}
			sourceImg="PictCtrlArray[" + (PictCtrlFirstObj + mvar)  + "]";
			//display changes to the thumbnail array
			if((PictCtrlFirstObj+mvar) == PictCtrlFocusObj){
				borcolour="00ffff";
			}
			else
				borcolour="ffffff";
			outputString = '<table border=2  borderColor='+borcolour+' cellpadding=0 cellspacing=0  bgcolor=000000 height='+tblW+' width='+tblW+'><tr><td  align=center valign=center><img   src='+ eval(sourceImg).source+' height='+newheight+' width='+newwidth+' onMouseDown=NSPicturesctrlclick('+ mvar +',0)></td></tr></table> '
			if(mPictureID != null && mfunction != "init"){
				if((PictCtrlFirstObj+mvar) == PictCtrlFocusObj || mPictureID == mvar){
					outputImgList(mObjInArray, ("Obj" + mObjInArray + "ImageCtrl" + (mvar)),"PictCtrlArray[" + (PictCtrlFirstObj + mvar)  + "]",mvar,newwidth,newheight,tblW,tblH,outputString);				
				}
			}
			else
				outputImgList(mObjInArray, ("Obj" + mObjInArray + "ImageCtrl" + (mvar)),"PictCtrlArray[" + (PictCtrlFirstObj + mvar)  + "]",mvar,newwidth,newheight,tblW,tblH,outputString);				
		}
		else{
			if( mvar < PictCtrlArray.length){
				if(mPictureID == null || mfunction == "init"){
					outputString = "&nbsp;";
					outputImgList(mObjInArray, ("Obj" + mObjInArray + "ImageCtrl" + (mvar)),"PictCtrlArray[" + (PictCtrlFirstObj + mvar)  + "]",mvar,newwidth,newheight,tblW,tblH,outputString);			
				}
			}
		}
	}	
}

function NSPicturesctrlclick(PictureID,mfunction){
	var oldPictCtrlFocusObj=PictCtrlFocusObj;
	if(mfunction == 'next' || mfunction == 'ss'){
		PictCtrlFocusObj++;
		mNextFirstObj = PictCtrlFirstObj+PictCtrlObjShow;
		//check if it goes beyond bounds
		if(PictCtrlFocusObj < PictCtrlArray.length){
			PictCtrlFirstObj = Math.floor(PictCtrlFocusObj/PictCtrlObjShow) * PictCtrlObjShow;
			if(mNextFirstObj == PictCtrlFocusObj){
				NSResetPicList();
			}		
		}
		else
		{
			if(mfunction == 'ss'){
				if (PictCtrlFocusObj >= PictCtrlArray.length -1  ){	
					PictCtrlFirstObj = 0;
					PictCtrlFocusObj = 0;
					PictureID = 0;
					NSResetPicList();
				}
			}
			else{
				//it goes beyond bounds ignore command
				PictCtrlFocusObj--;
			}
		}
	}
	//picture has been clicked, 
	if(mfunction == 'previous'){
		PictCtrlFocusObj--;
		mOldPictCtrlFirstObj = PictCtrlFirstObj;
		//check if it goes beyond bounds
		if(PictCtrlFocusObj >=0){
			if ( Math.floor(PictCtrlFocusObj/PictCtrlObjShow) == PictCtrlFirstObj) {
				//alert('the image is on the screen');
				//no need to do anything but display it			
			}
			else{				
				//alert('the image is not already on the visible list, increment the arrow and choose the next element');
				PictCtrlFirstObj = Math.floor(PictCtrlFocusObj/PictCtrlObjShow) * PictCtrlObjShow;
				if(mOldPictCtrlFirstObj > PictCtrlFocusObj)
					NSArrowClick('');				
			}
		}
		else{
			//it goes beyond bounds ignore command
			PictCtrlFocusObj++;
		}
	}
	if(mfunction == 'init' || mfunction == '0' || mfunction == ''){
		PictCtrlFocusObj=PictCtrlFirstObj+PictureID;
	}
	if(mfunction != 'ss'){
		if(PageArray[0].templatetype == "slideshow"){
			if(SlideShowArray[0].playstatus == "play"){
				document.MediaPlayer.Stop();
				SlideShowArray[0].playstatus = "stop";		
			}
		}
	}
	//bound checking low
	if(PictCtrlFirstObj < 0 ){
		PictCtrlFirstObj = 0;
	}
	//now check for titles and other stuff
	// find the control ID number of the picturectrl
	mObjInArray = NSFindCtrlID("type","Placeholderctrl","ObjArray");
	//displaying image
	//////// placeholderctrl ////////
	imgsizeW = parseInt(ObjArray[mObjInArray].newwidth);
	imgsizeH = parseInt(ObjArray[mObjInArray].newheight);
	if(SlideShowArray[0].fitplaceholder == "false"){
		// normal view(actual size). shrink to fit in the window if it's too large
		if(parseInt(PictCtrlArray[PictCtrlFocusObj].width) > imgsizeW){
			newheight = parseFloat(parseInt(PictCtrlArray[PictCtrlFocusObj].height)/(parseInt(PictCtrlArray[PictCtrlFocusObj].width)/imgsizeW));
			if(newheight < 1)
				newheight = 1;
			else
				newheight = parseInt(newheight + 0.5);
			newwidth = imgsizeW;
		}
		else{
			newwidth = parseInt(PictCtrlArray[PictCtrlFocusObj].width);
			newheight = parseInt(PictCtrlArray[PictCtrlFocusObj].height);
		}
		if(newheight > imgsizeH){
			newwidth = parseFloat(newwidth/(newheight/imgsizeH));
			if(newwidth < 1)
				newwidth = 1;
			else
				newwidth = parseInt(newwidth + 0.5);
			newheight = imgsizeH;
		}
	}
	else{
		// make the small picture "fit to placeholder". make the photo larger than the actual size if placeholder larger than picture
		newheight = parseFloat(parseInt(PictCtrlArray[PictCtrlFocusObj].height)/(parseInt(PictCtrlArray[PictCtrlFocusObj].width)/imgsizeW));
		if(newheight < 1)
			newheight = 1;
		else
			newheight = parseInt(newheight + 0.5);
		newwidth = imgsizeW;
		if(newheight > imgsizeH){
			newwidth = parseFloat(newwidth/(newheight/imgsizeH));
			if(newwidth < 1)
				newwidth = 1;
			else
				newwidth = parseInt(newwidth + 0.5);
			newheight = imgsizeH;
		}
	}
	// output the images and set the textfields if an album or slide show
	outputImgMain(mObjInArray, ("Obj" + mObjInArray + "Image"),("PictCtrlArray[" + PictCtrlFocusObj  + "]"),newwidth,newheight,imgsizeW,imgsizeH);		

	NSResetPicList(oldPictCtrlFocusObj % PictCtrlObjShow,mfunction);

	if(ObjArray[mObjInArray].layoutctrl == "square"&& (mfunction != 'init') ){
		mObjInArray = NSFindCtrlID("type","Picturesctrl","ObjArray");
		mPlacectrl = NSFindCtrlID("type","Placeholderctrl","ObjArray");
		showlayer('Obj'+mPlacectrl);
		hidelayer('Obj'+mObjInArray);
	}
	if(ObjArray[mObjInArray].layoutctrl == "square" && (mfunction == 'init')){
		mThmInArray = NSFindCtrlID("type","Picturesctrl","ObjArray");
		mPlacectrl = NSFindCtrlID("type","Placeholderctrl","ObjArray");
		hidelayer('Obj'+mPlacectrl);
		showlayer('Obj'+mThmInArray);
	}		
	// update the buttons here
	NSRefreshButtonsctrl();
	NSRefreshPicturesctrl();
}
function NSArrowClick(mdirection){
	if(PageArray[0].templatetype == "slideshow"){
		if(SlideShowArray[0].playstatus == "play"){ // only if slide show is stop, if playing then ignore
			return;
		}
	}
	var mObjInArray;	
	//find out where you're showing it
	mObjInArray = NSFindCtrlID("type","Picturesctrl","ObjArray");
	//START the user has altered the index, changed index appropriately
	if(mdirection == 'right'|| mdirection == "down" ){
		PictCtrlFirstObj = PictCtrlFirstObj + PictCtrlObjShow;			
		if((PictCtrlArray.length-PictCtrlFirstObj) >= 0)
			NSResetPicList();
	}	
	if(mdirection == 'left' || mdirection == "up" ){
		PictCtrlFirstObj = PictCtrlFirstObj - PictCtrlObjShow ;
		if(PictCtrlFirstObj >= 0)
			NSResetPicList();
	}
	if(mdirection == '' ){
		//do nothing but update the thumbnail
		NSResetPicList();
	}
	//END the user has altered the index, changed index appropriately
	//bound checking low
	if(PictCtrlFirstObj <= 0 ){
		PictCtrlFirstObj = 0;
	}
	//bound checking high
	if(PictCtrlFirstObj >= (PictCtrlArray.length)){
		PictCtrlFirstObj = (PictCtrlFirstObj - PictCtrlObjShow);
	}
	NSRefreshPicturesctrl();
}
function NSFindCtrlID(mfield,mid,marray){
	// find the control ID number
	var mObjInArray=-1; var mexit = 0;
	for(i=0; i< eval(marray+".length") && mexit != 1;i++){
		if(eval(marray+"[i]") != null){
			if(eval(marray + "[i]." + mfield) == mid){
				mObjInArray = i;
				mexit = 1;
			}
		}
	}
	return mObjInArray;
}
function NSButtonctrlclick(mfunction){
	mObjInArray = NSFindCtrlID("type","Picturesctrl","ObjArray");
	mButtonsctrl = NSFindCtrlID("type","Buttonsctrl","ObjArray");
	mPlacectrl = NSFindCtrlID("type","Placeholderctrl","ObjArray");
	if(mfunction == "home"){
		if(ObjArray[mObjInArray].layoutctrl == "square"){
				hidelayer('Obj'+mPlacectrl);
				showlayer('Obj'+mObjInArray);
		}
		else{
			if(PictCtrlFocusObj != 0){
				//reset the counter
				PictCtrlFocusObj =0;			
				PictCtrlFirstObj = 0;
				//display changes
				NSPicturesctrlclick(PictCtrlFocusObj % PictCtrlObjShow,'init');		
			}
			else{
				if(PictCtrlFirstObj != 0){
					PictCtrlFirstObj = 0;
					NSResetPicList();
				}
			}
		}
		NSRefreshButtonsctrl();
	}
	if(mfunction == 'next'){
		if(PageArray[0].templatetype == "slideshow"){
			if(SlideShowArray[0].playstatus == "play"){
				if(PictCtrlArray[PictCtrlFocusObj].durationinf == "true")
					NSplaySlide2();
			}
			else{ // slide show is stop
				if(PictCtrlFocusObj != PictCtrlArray.length-1)
					NSPicturesctrlclick(PictCtrlFocusObj % PictCtrlObjShow,'next');
			}
		}
		else{ // this is an album
			if(PictCtrlFocusObj != PictCtrlArray.length-1)
				NSPicturesctrlclick(PictCtrlFocusObj % PictCtrlObjShow,'next');
		}
	}	
	if(mfunction == "previous"){
		if(PageArray[0].templatetype == "slideshow"){
			if(SlideShowArray[0].playstatus == "stop"){ // only if slide show is stop, if playing then ignore
				if(PictCtrlFocusObj != 0){
					SlideShowArray[0].playstatus = "stop";
					NSPicturesctrlclick(PictCtrlFocusObj % PictCtrlObjShow,'previous');
				}
			}
		}
		else{ // this is an album
			if(PictCtrlFocusObj != 0){
				NSPicturesctrlclick(PictCtrlFocusObj % PictCtrlObjShow,'previous');
			}
		}
	}
	if(mfunction == "play"){
		//make sure it's not already running
		document.MediaPlayer.Play()
		if (SlideShowArray[0].playstatus != "play"){
			for(mfirst=0; mfirst<PictCtrlArray.length; mfirst+=PictCtrlObjShow){
				if(PictCtrlFocusObj >= mfirst)
					PictCtrlFirstObj = mfirst;
			}
			NSResetPicList();
			SlideShowArray[0].playstatus = "play";
			NSplaySlide();
		}
		NSRefreshButtonsctrl();
	}
	if(mfunction == "stop"){
			document.MediaPlayer.Stop()
			SlideShowArray[0].playstatus = "stop";		
			NSRefreshButtonsctrl();
	}
}

function NSRefreshButtonsctrl(){
	mObjInArray = NSFindCtrlID("type","Buttonsctrl","ObjArray");
	if(PageArray[0].templatetype == "slideshow"){
		if(SlideShowArray[0].playstatus == "stop"){
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl1" ,"n",mObjInArray);
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"n",mObjInArray);
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"d",mObjInArray);
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"n",mObjInArray);
		}
		if(SlideShowArray[0].playstatus == "play"){
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl1" ,"d",mObjInArray);
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"s",mObjInArray);
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"n",mObjInArray);
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"d",mObjInArray);
		}
		if(PictCtrlArray[PictCtrlFocusObj].durationinf == "true")
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"n",mObjInArray);
	}
	if(PictCtrlFocusObj == 0){
		if(PageArray[0].templatetype != "slideshow")
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"d",mObjInArray);
		else
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl1" ,"d",mObjInArray);
	}
	else{
		if(PageArray[0].templatetype != "slideshow")
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl2" ,"n",mObjInArray);
	}
	if(PictCtrlFocusObj == PictCtrlArray.length - 1){
		if(PageArray[0].templatetype == "slideshow"){
			if(PictCtrlArray[PictCtrlFocusObj].durationinf == "true")
				NSSetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"n",mObjInArray);
			else
				NSSetButtons("Obj" + mObjInArray + "ImageCtrl4" ,"d",mObjInArray);
		}
		else
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"d",mObjInArray);
	}
	else{
		if(PageArray[0].templatetype != "slideshow")
			NSSetButtons("Obj" + mObjInArray + "ImageCtrl3" ,"n",mObjInArray);
	}
}
function NSRefreshPicturesctrl(){
	mObjInArray = NSFindCtrlID("type","Picturesctrl","ObjArray");
	if(PictCtrlFirstObj == 0 ){
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowLeft" ,"d",mObjInArray);
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowUp" ,"d",mObjInArray);
	}
	else{
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowLeft" ,"n",mObjInArray);
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowUp" ,"n",mObjInArray);
	}
	if(PictCtrlFirstObj+PictCtrlObjShow >= PictCtrlArray.length){
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowRight" ,"d",mObjInArray);
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowDown" ,"d",mObjInArray);
	}
	else{
		if(ObjArray[mObjInArray].layoutctrl == "horizontal")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowRight" ,"n",mObjInArray);
		if(ObjArray[mObjInArray].layoutctrl == "vertical" || ObjArray[mObjInArray].layoutctrl == "square")
			NSSetButtons("Obj" + mObjInArray + "ImageArrowDown" ,"n",mObjInArray);
	}
}
function NSSetButtons(mID,mstate,mctrl){
	mObjnum = NSFindCtrlID("id",mID,"ButtonsArray");
	if(mstate == "d"){
		//eval(ButtonsArray[mObjnum].id).src = ButtonsArray[mObjnum].dstate;
		ButtonsArray[mObjnum].activestate = mstate; 
		document.layers['Obj'+mctrl].document.images[mID].src = ButtonsArray[mObjnum].dstate;
	}
	else{
		if(mstate == "s"){
			//eval(ButtonsArray[mObjnum].id).src = ButtonsArray[mObjnum].sstate;
			ButtonsArray[mObjnum].activestate = mstate; 
			document.layers['Obj'+mctrl].document.images[mID].src = ButtonsArray[mObjnum].sstate;
		}
		else{
			if(mstate == "n"){
				//eval(ButtonsArray[mObjnum].id).src = ButtonsArray[mObjnum].nstate;
				document.layers['Obj'+mctrl].document.images[mID].src = ButtonsArray[mObjnum].nstate;
				ButtonsArray[mObjnum].activestate = mstate; 
			}
		}
	}
}

