var SelectedImage = '';
var SelectedImageOff = '';

function showItem(file, type, caption, imageID, imageOff, imageOn, container) {
	if (SelectedImage != '')
	{
		var img = document.getElementById(SelectedImage);
		img.src = SelectedImageOff;
	}
	SelectedImage = imageID;
	SelectedImageOff = imageOff;
	MouseOverThumb(imageID, imageOn);
	switch(type) {
		case "video":     playVideo(file, caption, container); break;
		case "wallpaper": showWallpaper(file, caption, container); break;
		case "image":
		case "photo":     showPhoto(file, caption, container); break;
		case "audio":     playAudio(file, caption, container); break;
	}
}

function MouseOverThumb(imageID, imageOn)
{
	var img = document.getElementById(imageID);
	img.src = imageOn;	
}

function MouseOutThumb(imageID, imageOff)
{
	if (SelectedImage == imageID)
	{
	}
	else
	{
		var img = document.getElementById(imageID);

		img.src = imageOff;
	}
}

function playVideo(videoFile, caption, container) {
	var flash = new FlashObject("/ATV2008/videos/player_buf2.swf?movieFile=" + videoFile, "ATV", "270", "250", "8", "#000000");
	flash.addParam("WMode", "transparent");
	flash.addParam("Quality", "High");
	flash.addParam("scale", "noborder");
	flash.addParam("allowscriptaccess", "always");
	
	flash.write(container);
	var captionDiv = document.getElementById('captionDiv');
	captionDiv.innerHTML = '<BR>' + caption;
}
function showWallpaper(wallpaperFile, caption, container) {
	var playerDiv = document.getElementById(container);
	var captionDiv = document.getElementById('captionDiv');

	var objHTML = 
		//'<img src="' + wallpaperFile + '" border="0" width="270" height="202" />' +
		'<img src="' + wallpaperFile + '" style="border-right: #e56936 5px solid;border-top: #e56936 5px solid;border-left: #e56936 5px solid;border-bottom: #e56936 5px solid;" width="270" height="202" />'
	var objCaption = caption +'<BR><BR>PC users: Right click the image on the left and select "Set as Wallpaper/Background" from the options.<BR><BR>' +
		'Mac users: Click and hold on the image, then select "Save this link as..." from the options.';
		
	playerDiv.innerHTML = objHTML;
	captionDiv.innerHTML = objCaption;
}
function showPhoto(photoFile, caption, container) {
	var playerDiv = document.getElementById(container);
	var captionDiv = document.getElementById('captionDiv');

	//var objHTML = '<img src="' + photoFile + '" border="0" width="264" height="171" />';
	var objHTML = '<a href="javascript:OpenLargeWindow(\'' + photoFile + '\');" border=0><img src="' + photoFile + '" style="border-right: #e56936 5px solid;border-top: #e56936 5px solid;border-left: #e56936 5px solid;border-bottom: #e56936 5px solid;" width="267" height="200" /></a><BR>'
	
	var objCaption = caption + '<BR><BR>Click on Image to Increase Size';
	playerDiv.innerHTML = objHTML;
	captionDiv.innerHTML =  objCaption;
}

function OpenLargeWindow(photoFile)
{
	window.open(photoFile, "LARGEPHOTO", "width=800,height=600,status=no,toolbar=no,menubar=no,location=no");
}

function playAudio(audioFile, caption, container) {
	var flash = new FlashObject(audioFile, "ATV", "264", "250", "7", "#000000");
	//flash.addParam("WMode", "transparent");
	flash.addParam("Quality", "High");
	
	flash.write(container);
}