function xhtmlFlash( swf, width, height ) 
{	
  document.writeln('<object'); 
  document.writeln('classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"');
  document.writeln('width="' + width + '"');
  document.writeln('height="' + height + '">');
  document.writeln('<param name="movie" value="' + swf + '">');
  document.writeln('<param name="menu" value="false">');
  document.writeln('<param name="WMODE" value="transparent">');
  document.writeln('<embed ');
  document.writeln('pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" '); 
  document.writeln('width="' + width + '" ');
  document.writeln('height="' + height + '" ');
  document.writeln('menu="false" ');
  document.writeln('wmode="transparent" ');
  document.writeln('src="' + swf + '">');
  document.writeln('</embed>');
  document.writeln('</object>');
}

function externaliseLinks() { 
	if (!document.getElementsByTagName) 
	{	
		return;
	}

	var anchors = document.getElementsByTagName("a"); 
	for ( var i=0; i<anchors.length; i++ ) 
	{ 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		{
			anchor.target = "_blank"; 
		}
	} 
} 

window.onload = externaliseLinks;


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.getElementById) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document.getElementById(changeImages.arguments[i]).src = changeImages.arguments[i+1];
		}
	}
}

function showNode(nodeID) {
	switchImages('pointNode' + nodeID, 'images/arrow_on.gif', 'images/arrow.gif');
	switchHide('trNode' + nodeID);
	switchStyle('tdNode' + nodeID);
}

function switchStyle(arg) {
	document.getElementById(arg).className = (document.getElementById(arg).className == 'blueheader') ? 'greycopy' : 'blueheader';
}

function switchHide(arg) {
	document.getElementById(arg).style.display = (document.getElementById(arg).style.display == 'none') ? '' : 'none';
}


function switchImages(obj, switch1, switch2) {
	document.getElementById(obj).src = (document.getElementById(obj).src.indexOf(switch1) != -1) ? switch2 : switch1;
}

function preloadImages()
{
	for (var i=0; i<preloadImages.arguments.length; i++)
	{
		newImg = newImage(preloadImages.arguments[i]);
	}
}

preloadImages('../images/more-o.gif');

function highlightLink(dest) {
	var obj = document.getElementById('dest' + dest);
	var objLink = document.getElementById('destLabel' + dest);
	
	if (obj.className != 'selected') {
		obj.className = 'selected';
	}
	else {
		obj.className = '';
	}

	if (objLink.className != 'selected') {
		objLink.className = 'selected';
	}
	else {
		objLink.className = '';
	}
	
}

function restoreLink(dest) {
	var obj = document.getElementById('dest' + dest);
	var objLink = document.getElementById('destLabel' + dest);

	obj.className = '';
	objLink.className = '';
}




function showHide() {
	for ( var x = 0; x < showHide.arguments.length ; x+=2 )
	{
		document.getElementById(showHide.arguments[x]).style.display = showHide.arguments[x+1];
	}
}

var currentProduction = 0;

function showProduction(intShift) {
	var objTitle = document.getElementById('productionTitle');
	var objImage = document.getElementById('productionImage');
	
	currentProduction += intShift;
	
	if (currentProduction < 0) {
		currentProduction = productions.length-1;
	}
	
	if (currentProduction > productions.length-1) {
		currentProduction = 0;
	}
	
	
	var img = productions[currentProduction][2];
	var imgAlt = productions[currentProduction][3];
	var productionTitle = productions[currentProduction][1];
	var productionID = productions[currentProduction][0];
	
	if (img != null) {
		objImage.innerHTML = '<a href="index.aspx?id=123&productionID=' + productions[currentProduction][0] + '"><img src="' + img + '" alt="' + imgAlt + '"/></a>';
	}
	else {
		objImage.innerHTML = "";
	}
	
	
	objTitle.innerHTML = '<a href="index.aspx?id=123&productionID=' + productions[currentProduction][0] + '">' + productions[currentProduction][1] + '</a>';
}

function detectFlash() {
	var contentVersion = 6;
	var FlashCanPlay;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	
	if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
			if (isNaN(parseInt(words[i])))
			continue;
			var PluginVersion = words[i]; 
	    }
	
		var FlashCanPlay = PluginVersion >= contentVersion;
	
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	&& (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & contentVersion)))\n');
		document.write('</SCR' + 'IPT\> \n');
	}
	
	return eval(FlashCanPlay);
}
