function showTooltip(tooltip) {
	tooltip = $(tooltip);
	tooltip.setStyle({zIndex: -1});
	tooltip.show();
	tooltip.setStyle({top: "-"+(tooltip.offsetHeight)+"px"});
	tooltip.setStyle({zIndex: 100});
}

function toggle_bgcolor( x, on, off ){
	if ( x.style ) {
		x.style.backgroundColor = (on == x.style.backgroundColor)?
		off : on;
	}
}

function recordGoogleAnalytics() {
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));  

}

function trackGoogleAnalytics() {
	try { 
		var pageTracker = _gat._getTracker("UA-6451094-1"); 
		pageTracker._trackPageview(); 
	} 
	catch(err) {}
}

function redirectifNoFlash() {

	var flash = getFlashVersion().split(',');
	var flash_version = flash.shift();
	flash.shift();
	var	flash_version_min = flash.shift();
	if(flash_version < 9 || (flash_version == 9 && flash_version_min < 115)) {  window.location="http://zoom.animare.org/browser"; } 

}

function changeClass(d,c) {
	if(d.length < 1) { return; }
	document.getElementById(d).className = c;
}
function hideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function showContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}
function toggleContent(d) {
	if(d.length < 1) { return; }
	if (document.getElementById(d).style.display == "none") {
		document.getElementById(d).style.display = "block";
	} 
	else {
		document.getElementById(d).style.display = "none";
	}

}

function resize(which, max) {
	var elem = document.getElementById(which);
	if (elem == undefined || elem == null) return false;
	if (max == undefined) max = 100;
	if (elem.width > elem.height) {
		if (elem.width > max) elem.width = max;
	} 
	else {
		if (elem.height > max) elem.height = max;
	}
}

function fireEvent(obj,evt){

	var fireOnThis = obj;
	if( document.createEvent ) {
		var evObj = document.createEvent('MouseEvents');
		evObj.initEvent( evt, true, false );
		fireOnThis.dispatchEvent(evObj);
	} 
	else if( document.createEventObject ) {
		fireOnThis.fireEvent('on'+evt);
	}
}

function getFlashVersion(){ 
	// ie 
	try { 
		try { 
			// avoid fp6 minor version lookup issues 
			// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
			try { axo.AllowScriptAccess = 'always'; } 
			catch(e) { return '6,0,0'; } 
		} 
		catch(e) {} 
		return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
		// other browsers 
	} 
	catch(e) { 
		try { 
			if(navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin){ 
				return (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
			} 
		} 
		catch(e) {} 
	} 
	return '0,0,0'; 
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
		|| this.searchVersion(navigator.appVersion)
		|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
		},
		searchString: function (data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
				}
				else if (dataProp)
				return data[i].identity;
			}
			},
			searchVersion: function (dataString) {
				var index = dataString.indexOf(this.versionSearchString);
				if (index == -1) return;
				return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
				},
				dataBrowser: [
				{ 	
					string: navigator.userAgent,
					subString: "OmniWeb",
					versionSearch: "OmniWeb/",
					identity: "OmniWeb" },
					{
						string: navigator.vendor,
						subString: "Apple",
						identity: "Safari"
						},
						{
							prop: window.opera,
							identity: "Opera"
							},
							{
								string: navigator.vendor,
								subString: "iCab",
								identity: "iCab"
								},
								{
									string: navigator.vendor,
									subString: "KDE",
									identity: "Konqueror"
									},
									{
										string: navigator.userAgent,
										subString: "Firefox",
										identity: "Firefox"
										},
										{
											string: navigator.vendor,
											subString: "Camino",
											identity: "Camino"
											},
											{		// for newer Netscapes (6+)
												string: navigator.userAgent,
												subString: "Netscape",
												identity: "Netscape"
												},
												{
													string: navigator.userAgent,
													subString: "MSIE",
													identity: "Explorer",
													versionSearch: "MSIE"
													},
													{
														string: navigator.userAgent,
														subString: "Gecko",
														identity: "Mozilla",
														versionSearch: "rv"
														},
														{ 		// for older Netscapes (4-)
															string: navigator.userAgent,
															subString: "Mozilla",
															identity: "Netscape",
															versionSearch: "Mozilla"
														}
														],
														dataOS : [
														{
															string: navigator.platform,
															subString: "Win",
															identity: "Windows"
															},
															{
																string: navigator.platform,
																subString: "Mac",
																identity: "Mac"
																},
																{
																	string: navigator.platform,
																	subString: "Linux",
																	identity: "Linux"
																	} ]

																};




																var currentPosition = 0; 
																var currentVolume = 0; 
																var endPosition = 0;
																var player = null;
																function playerReady(thePlayer) {
																	player = window.document[thePlayer.id];
																	endPosition = player.getConfig().stop;
																	//alert (thePlayer.id)
																	addListeners();
																	//alert(endPosition);
																}


																function addListeners() {
																	if (player) { 
																		player.addModelListener("TIME", "positionListener");
																		//player.addViewListener("VOLUME", "volumeListener");
																	} 
																	else {
																		setTimeout("addListeners()",100);
																	}
																}


																function positionListener(obj) { 
																	currentPosition = obj.position; 

																	if (currentPosition >= endPosition) { player.sendEvent('STOP'); }
																	var tmp = document.getElementById("posId");
																	if (tmp) { tmp.innerHTML = "position: " + currentPosition; }
																}


																function volumeListener(obj) { 
																	currentVolume = obj.percentage; 
																	var tmp = document.getElementById("volId");
																	if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
																}





/* Jeroen */

var currentPlayer;
var currentPosition =   0;
var currentItem     =   0;
var previousItem    =  -1;
var beginCTime       =  0;
var endCTime         =  0;
var beginATime       =  0;
var endATime         =  0;

function sendEvent(swf, typ, prm)
{
	thisMovie(swf).sendEvent(typ, prm);
};

function thisMovie(swf) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[swf];
		} else {
			return document[swf];
		}
	};

	function getUpdate(typ, pr1, pr2, pid)
	{
		currentPlayer = pid;

		if(typ == 'time')
		{
			currentPosition = pr1-1;

			// look for a new caption
			/*
			if(eval(currentPosition) > endCTime || eval(currentPosition)< beginCTime)
			{
			// clear current caption
			cA = document.getElementById('captions');
			cA.innerHTML = '';
			cA1 = document.getElementById('captions1');
			cA1.innerHTML = '';

for( i = 0; i < Captions.length; i++)
{

if(eval(Captions[i]['begin']) ==  eval(currentPosition))
{
// display caption
c = document.getElementById('captions');
c.innerHTML = Captions[i]['caption'];
beginCTime = Captions[i]['begin'];
endCTime   = Captions[i]['end'];
break;
}

}
}
*/

if(eval(currentPosition) > endATime || eval(currentPosition) < beginATime)
{


	// clear current caption
	cB = document.getElementById('annotations');
	cB.innerHTML = '';
	cB1 = document.getElementById('annotations1');
	cB1.innerHTML = '';

	localAnnotations = Annotations[eval(pid)];

	//alert(localAnnotations.length + " -- " + pid)
	for( i = 0; i < localAnnotations.length; i++)
	{
		// cB.innerHTML = "popopopopo" + 
		if(eval(localAnnotations[i]['begin']) ==  eval(currentPosition))
		{
			// display caption
			//alert(localAnnotations[i]['begin'] + "time"+currentPosition);
			c = document.getElementById('annotations');
			c.innerHTML = localAnnotations[i]['caption'];
			beginATime = localAnnotations[i]['begin'];
			endATime   = localAnnotations[i]['end'];
			break;
		}
	}


}

}


};



