
// Inicializálás
var MediaSrc = new Array();
var FileLines = new Array();
var ShTime;
var ActPos = 0;
var MaxMedia = 0;
var i;
var preLoad = new Array();

function InitMedia() {
	try {
		// Média leíró betöltése
		//var file = "<?php echo $albumfiles; ?>";

		// A sorainak feldolgozása
		MaxMedia = 0;
		ActPos = 0;
		FileLines = file.split(";");
		for(i = 0; i < FileLines.length; i++) MediaSrc[MaxMedia++] = FileLines[i];

		if(MaxMedia > 0) {
			// A cache feltöltése
			for(i = 0; i < MaxMedia; i++)
				if(((MediaSrc[i].toUpperCase()+"$").indexOf(".GIF$") != -1) ||
					((MediaSrc[i].toUpperCase()+"$").indexOf(".JPG$") != -1) ||
					((MediaSrc[i].toUpperCase()+"$").indexOf(".PNG$") != -1)) {
				preLoad[i] = new Image();
				preLoad[i].src = MediaSrc[i];
			}

			// Start slideshow
			runSlideShow();
		}
	} catch(Exception) { }
}

function runSlideShow() {
	if(((MediaSrc[ActPos].toUpperCase()+"$").indexOf(".GIF$") != -1) ||
			((MediaSrc[ActPos].toUpperCase()+"$").indexOf(".JPG$") != -1) ||
			((MediaSrc[ActPos].toUpperCase()+"$").indexOf(".PNG$") != -1)) {
		if (document.images.Picture) {
			// Show pictures in IE
			document.images.Picture.style.filter="blendTrans(duration=2)";
			document.images.Picture.style.filter="blendTrans(duration=4)";
			document.images.Picture.filters.blendTrans.Apply();
			document.images.Picture.src = MediaSrc[ActPos];
			document.images.Picture.filters.blendTrans.Play();
		} else {
			// Show pictures in Mozilla
			upStr = "<img src="+MediaSrc[ActPos]+" style='height:96px;width:128px'>";
			document.getElementById('photoalbum').innerHTML=upStr;
		}
	} else {
		// Show video
		upStr  = "<OBJECT id='Movie' style='position:absolute;top:0px;right:0px;height:96px;width:128px' ";
		upStr += "codeBase='http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,0701' ";
		upStr += "CLASSID='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' STANDBY='Wait...' TYPE='application/x-oleobject'>";
		upStr += "<PARAM NAME=FileName VALUE='"+MediaSrc[ActPos]+"'><PARAM NAME=ShowControls VALUE=0>";
		upStr += "<PARAM NAME=ShowStatusBar VALUE=0><PARAM NAME=ShowDisplay VALUE=0><PARAM NAME=AnimationAtStart VALUE=1>";
		upStr += "<PARAM NAME=TransparentAtStart VALUE=1><PARAM NAME=AutoStart VALUE=1>";
		upStr += "<PARAM NAME=AllowChangeDisplaySize VALUE=1></OBJECT>";
		
		document.getElementById('photoalbum').innerHTML=upStr;
	}

	ActPos = (ActPos + 1) % MaxMedia;
	if(MaxMedia > 1) ShTime = setTimeout('runSlideShow()', 5000);
}


