//---: Zoomify Javascript functions for swapping out the main image for Zoomify flash objects.
//---: Author: Andy Cummins
//---: Date: 06/08/2008

//***if zoomify available add links to swap the flash in.

function addZoomifyLinks(path, link)
{
	if (document.getElementById(link)) 
	{
		if(link == 'zoomifyLink'){
			var playerPath = 'zoomify/zoomifyDynamicViewer.swf';
			var objZoomLink = document.getElementById(link);
			objZoomLink.innerHTML +='<a id="zoomLink" href="#" title="Zoom this image">Zoom this image</a>';		
			document.getElementById('zoomLink').onclick=function(){swap4Zoomify(playerPath,path);return false;};
		}
		else if(link == 'videoLink'){
			var playerPath = 'videoPlayer/flvplayer.swf';
			var objVideoLink = document.getElementById(link);
			objVideoLink.innerHTML ='<a id="video" href="#" title="Watch video">Watch video</a>';	
			document.getElementById('video').onclick=function(){swap4Video(playerPath,path, 'videoContent', 320, 308);return false;};
		}
		else if(link == 'audioLink'){
			var playerPath = 'audioPlayer/JMAudio.swf';
			var objAudioLink = document.getElementById(link);
			objAudioLink.innerHTML ='<a id="audioDescription" href="#" title="Listen to audio">Listen to audio</a>';	
			document.getElementById('audioDescription').onclick=function(){swap4Audio(playerPath,path, 'audioContent', 377, 66);return false;};
		}
	}
}

//***replace main image with zoomify flash object

function swap4Zoomify(playerPath, assetPath)
{
	var flashvars = {zoomifyImagePath: assetPath};
	var params = {bgcolor: "#f3f3f3", allowFullScreen: "true"};
	swfobject.embedSWF(playerPath, "zoomifyContent", "450", "496", "6","",flashvars,params);
	//document.getElementById("zoomifyLink").style.display="none";
}

//add 3D image stuff
function add3DContent(path, width)
{
	
	$('a.threeDObject').click(function() {
	var third = (width/3)*2;
	$('#threeDcontent').html('<APPLET archive=3dViewer/ModelViewer.jar code=ModelViewer.class width='+width+' height=480>'+
	'<PARAM NAME="fname" VALUE="oca/3d/'+path+'">'+
	'<PARAM NAME="toolbar" VALUE="yes">'+
	'<PARAM NAME="number" VALUE="36">'+
	'<PARAM NAME="autorun" VALUE="yes">'+
	'<PARAM NAME="settings" VALUE="3dViewer/result.ser">'+
	'<PARAM NAME="waitingimage" VALUE="3dViewer/wait.gif">'+
	'<PARAM NAME="bar_height" VALUE="10">'+
	'<PARAM NAME="bar_width" VALUE="'+third+'">'+
	'<PARAM NAME="barcolor" VALUE="0066B3">'+
	'<PARAM NAME="bgcolor" VALUE="FFFFFF">'+
	'<PARAM NAME="ctrlImage" VALUE="3dViewer/control.gif">'+
	'<PARAM NAME="tbImage" VALUE="3dViewer/toolbar.gif">'+
	'<PARAM NAME="waitingImage" VALUE="3dViewer/wait.gif">'+
	'<PARAM NAME="home" VALUE="www.jewishmuseum.org">'+
	'</APPLET>');
	
	});

}

function swap4Video(playerPath, assetPath, container, height, width)
{
	var flashvars = {file: '../'+assetPath};
	var params = {bgcolor: "#f3f3f3", allowFullScreen: "true"};
	swfobject.embedSWF(playerPath, container, height, width, "6","",flashvars,params);
}

function swap4Audio(playerPath, assetPath, container, height, width)
{
	var flashvars = {file: '/onlinecollection/'+assetPath};
	var params = {bgcolor: "#f3f3f3", allowFullScreen: "true"};
	swfobject.embedSWF(playerPath, container, height, width, "6","",flashvars,params);
}
