// -- This is a modified version of the original script
// -- from CodeLifter.com, in order to fit in SPGM

// SlideShow with Captions and Cross-Fade
// (C) 2002 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header.

// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

var tss;
var jss = 1;
var iss = 1;

var preLoad = new Array();
var arrCaptions = new Array();
var arrWidth = new Array();
var arrHeight = new Array();

function runSlideShow() {

	if ( document.getElementById('picture') ) {
		if (document.all && !window.opera){
			document.getElementById('picture').style.filter="blendTrans(duration=2)";
			document.getElementById('picture').style.filter="blendTrans(duration=CrossFadeDuration)";
			document.getElementById('picture').filters.blendTrans.Apply();
		}
		document.getElementById('picture').setAttribute('width', arrWidth[jss]);
		document.getElementById('picture').setAttribute('height', arrHeight[jss]);
		document.getElementById('picture').src = preLoad[jss].src;
		if (document.all && !window.opera){
			document.getElementById('picture').filters.blendTrans.Play();
		}
		if ( document.getElementById('picture-caption') ) {
			document.getElementById('picture-caption').innerHTML = arrCaptions[jss];
		}
	}

	jss = jss + 1;
	if (jss > (iss - 1)) jss=1;
	tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

function addPicture(pictureURL, caption, width, height) {
	preLoad[iss] = new Image();
	preLoad[iss].src = pictureURL;
	arrCaptions[iss] = caption;
	arrWidth[iss] = width;
	arrHeight[iss] = height;
	iss = iss + 1;
}

function popupPicture(pictureURL, width, height, justPicture) {
	if (justPicture) {
		//var frame = document.open('', '', 'width='+width+',height='+height+',scrollbars=0,location=0,menubar=0,resizable=1');
		var frame = document.open('PhotoGallery', 'PhotoGallery', 'width='+width+',height='+height+',scrollbars=0,location=0,menubar=0,resizable=0,status=0');
		frame.document.write(
				'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n'
			+	'<HTML>\n'
			+	'<HEAD>\n'
			+	'<TITLE>Photo Gallery</TITLE>\n'
			+	'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n'
			+	'</HEAD>\n'
			+	'<BODY bgcolor="#000000" leftmargin="0" topmargin="00" marginwidth="0" marginheight="0">\n'
			+	'<IMG SRC="'+pictureURL+'" ALT="Photo Gallery">\n'
			+	'</BODY>\n'
			+	'</HTML>\n'
		/*
			'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '
			+'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'
			+'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
			+'  <head>\n'
			//+'    <title>SPGM: '+pictureURL+'</title>'
			+'    <title>Photo Gallery</title>'
			+'    <style type="text/css">body {margin: 0px}</style>\n'
			+'    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\n'
			+'  </head>\n'
			+'  <body>\n'
			+'    <div style="margin: 0px;">\n'
			//+'      <img src="'+pictureURL+'" alt="'+pictureURL+'" />\n'
			+'      <img src="'+pictureURL+'" alt="Photo Gallery" />\n'
			+'    </div>\n'
			+'  </body>\n'
			+'</html>'
		*/
		);
		frame.document.close();
		frame.focus();
		return true;
	} else {
		//document.open(pictureURL, '', 'width='+width+',height='+height+',scrollbars=1,location=0,menubar=0,resizable=1');
		//document.open(pictureURL, 'PhotoGallery', 'width='+width+',height='+height+',scrollbars=0,location=0,menubar=0,resizable=0,status=0');
		document.open(pictureURL, 'PhotoGallery', 'width='+width+',height='+height+',scrollbars=0,location=0,menubar=0,resizable=0,status=0');
		document.close();
		//alert(pictureURL);
	}
}

function popupVideo(vidURL, vidwidth, vidheight, vidshadow, vidtype) {

	var x = new String;x = '';

	//The Object & Embed Tag for the Video Clip

	// Real Player
	if ( vidtype == 'real' ) {
		x = x + '<table class="'+vidshadow+'">'+"\n";
		x = x + '  <tr>'+"\n";
		x = x + '    <td>'+"\n";
		x = x + '      <object id="RVOC" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height="'+vidheight+'" width="'+vidwidth+'">'+"\n";
		x = x + '        <param name="controls" value="ImageWindow" />'+"\n";
		x = x + '        <param name="nologo" value="true" />'+"\n";
		x = x + '        <param name="console" value="video" />'+"\n";
		x = x + '        <param name="autostart" value="true" />'+"\n";
		x = x + '        <embed type="audio/x-pn-realaudio-plugin" console="video" controls="ImageWindow" height="'+vidheight+'" width="'+vidwidth+'" nologo="true" autostart="true">'+"\n";
		x = x + '        </embed>'+"\n";
		x = x + '      </object>'+"\n";
		x = x + '    </td>'+"\n";
		x = x + '  </tr>'+"\n";
		x = x + '  <tr>'+"\n";
		x = x + '    <td>'+"\n";
		x = x + '      <object id="RVOCX" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+vidwidth+'" height="30">'+"\n";
		x = x + '        <param name="controls" value="ControlPanel" />'+"\n";
		x = x + '        <param name="console" value="video" />'+"\n";
		x = x + '        <param name="autostart" value="true" />'+"\n";
		x = x + '        <param name="src" value="'+vidURL+'" />'+"\n";
		x = x + '        <embed src="'+vidURL+'" type="audio/x-pn-realaudio-plugin" console="video" controls="ControlPanel" width="'+vidwidth+'" height="30" autostart="true" nojava="true">'+"\n";
		x = x + '        </embed>'+"\n";
		x = x + '      </object>'+"\n";
		x = x + '    </td>'+"\n";
		x = x + '  </tr>'+"\n";
		x = x + '</table>'+"\n";
	}
	// Windows Media Player
	if ( (vidtype == 'asf') || (vidtype == 'riff') ) {
		x = x + '<object id="MediaPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows® Media Player components..." type="application/x-oleobject" width="'+vidwidth+'" height="'+(vidheight+64)+'">'+"\n";
		x = x + '  <param name="url" value="'+vidURL+'" />'+"\n";
		x = x + '  <param name="AutoStart" value="true" />'+"\n";
		x = x + '  <param name="EnableTracker" value="false" />'+"\n";
		x = x + '  <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+vidURL+'" width="'+vidwidth+'" height="'+(vidheight+44)+'" autostart="1" showcontrols="1">'+"\n";
		x = x + '  </embed> '+"\n";
		x = x + '</object>'+"\n";
	}
	// Shockwave Player
	if ( vidtype == 'swf' ) {
		x = x + '<object id="Shockwave" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+vidwidth+'" height="'+vidheight+'">'+"\n";
		x = x + '  <param name="movie" value="'+vidURL+'" />'+"\n";
		x = x + '  <param name="quality" value="high" />'+"\n";
		x = x + '  <param name="bgcolor" value="#FFFFFF" />'+"\n";
		x = x + '  <embed type="application/x-shockwave-flash" src="'+vidURL+'" quality="high" bgcolor="#FFFFFF" width="'+vidwidth+'" height="'+vidheight+'" name="Shockwave" align="" pluginspage="http://www.macromedia.com/go/getflashplayer">'+"\n";
		x = x + '  </embed>'+"\n";
		x = x + '</object>'+"\n";
	}
	// Quicktime Player
	if ( vidtype == 'quicktime' ) {
		x = x + '<object id="QTPlayer" classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+vidwidth+'" height="'+(vidheight+15)+'" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'+"\n";
		x = x + '  <param name="src" value="'+vidURL+'" />'+"\n";
		x = x + '  <param name="autoplay" value="true" />'+"\n";
		x = x + '  <param name="controller" value="true" />'+"\n";
		x = x + '  <embed type="video/quicktime " src="'+vidURL+'" width="'+vidwidth+'" height="'+(vidheight+15)+'" autoplay="true" controller="true">'+"\n";
		x = x + '  </embed>'+"\n";
		x = x + '</object>'+"\n";
	}
	// Flash Video Player
	if ( vidtype == 'flv' ) {
		x = x + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="320" height="300" id="flvplayer" align="middle">';
		x = x + '<param name="allowScriptAccess" value="sameDomain" />';
		x = x + '<param name="movie" value="flvplayer.swf" />';
		x = x + '<param name="play" value="false" />';
		x = x + '<param name="quality" value="autolow" />';
		x = x + '<param name="wmode" value="transparent" />';
		x = x + '<param name="bgcolor" value="#000000" />';
		x = x + '<param name="FlashVars" value="flvsrc='+vidURL+'" />';
		x = x + '<embed src="flvplayer.swf" FlashVars="flvsrc='+vidURL+'" play="false" quality="autolow" wmode="transparent" bgcolor="#000000" width="320" height="300" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		x = x + '</object>';
	}

	var frame = document.open('VideoGallery', 'VideoGallery', 'width='+vidwidth+',height='+vidheight+',scrollbars=0,location=0,menubar=0,resizable=1,status=0');
	frame.document.write(x);
	frame.document.close();
	frame.focus();
	return true;

}

