// JavaScript Code for Nykris-designed Websites
// (c) 2004 Nykris Digital Design Ltd.
// Engineer: Graham Bartram

// Global Settings



// Browser ID Utilities

var gAgent = window.navigator.userAgent;
var gAgentVers = parseInt(gAgent.charAt(gAgent.indexOf("/")+1),10);

function is_explorer()
{
	return gAgent.indexOf("MSIE") > 0;
}
	
function is_macnetscape()
{
	if (gAgent.indexOf("Mac") <= 0)
		return false;
	else
		return !(gAgent.indexOf("MSIE") > 0);
}
	
function is_macie4()
{
	var msoffset = gAgent.indexOf("MSIE");
	if ((gAgent.indexOf("Mac") > 0) && (msoffset > 0))
	{
		gAgentVers = parseInt(msoffset+1,10);
		if (gAgentVers < 5)
			return true;
		else
			return false;
	}
	else
		return false;
}

function is_pcnetscape()
{
	if (gAgent.indexOf("Mac") > 0)
		return false;
	else
		return !(gAgent.indexOf("MSIE") > 0);
}
	
function is_aol()
{
	return gAgent.indexOf("AOL") > 0;
}


// Flash and Image Utilities

// Check whether Flash is installed on the user's computer return one of four possible values
// which tell other routines what to do when asked to insert a Flash movie:
// "img" - write out <IMG> tag instead
// "swf" - write out <EMBED> tag and use a Flash movie
// "mov" - write out <EMBED> tag and use a QuickTime movie (QT4 onwards plays Flash)
// "none" - do nothing, <NOSCRIPT> will handle the image in Netscape 2

var gImageHandling = "";

function check_flash()
{	
	gImageHandling = "none";
		
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
	{
		// Navigator and Explorer ver 5 onwards
		if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		{
			var desc = navigator.plugins["Shockwave Flash"].description;
			var vers = parseInt(desc.charAt(16));
			if (vers >= 6) gImageHandling = "swf";
		}
	}
			
	if (gImageHandling == "none" && navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	   && (navigator.userAgent.indexOf("Windows")>=0 || navigator.userAgent.indexOf("Win32")>=0))
	{
	   	// Explorer on a 32-bit PC
		document.write('<scr' + 'ipt language=VBSc' + 'ript\> \n');
		document.write('dim Obj\n');
		document.write('gImageHandling = "gif"\n');
		document.write('on error resume next \n');
		document.write('Set Obj = CreateObject("ShockwaveFlash.ShockwaveFlash.6")\n');
		document.write('if IsObject(Obj) = True then gImageHandling = "swf" \n');
		document.write('Set Obj = Null \n');
		document.write('</scr' + 'ipt\> \n');
	}
		
	if (gImageHandling == "none" && !(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
	{
		// Anything else, other than Navigator ver 2 which will use <NOSCRIPT>
		gImageHandling = "gif";
	}
	
	//	document.write('<p>gImageHandling = ' + gImageHandling + '</p>');
}




// Insert a Flash movie or fallback GIF into the current page depending upon the setting
// of the gImageHandling variable.

function insert_flash(name, width, height, bgCol)
{
	if (gImageHandling == "")
	{
		// The variable has not been set so do a check.
		check_flash();
	}
		
	if (gImageHandling.indexOf("none") != -1)
	{
	}
	else if (gImageHandling.indexOf("swf") != -1)
	{
		document.write('<embed src="' + name + '.swf"');
		document.write(' swLiveConnect=false width=' + width + ' height=' + height);
		document.write(' loop=false quality=high scale=noborder bgcolor=' + bgCol);
		document.write(' type="application/x-shockwave-flash"\>');
		document.write('</embed\>');
		document.write('<noembed\><img src="' + name + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\></noembed\>');
	
	}
	else if (gImageHandling.indexOf("mov") != -1)
	{
		document.write('<embed src="' + name + '.mov"');
		document.write(' autoplay="true" controller="false" width="' + width + '" height="' + height + '"');
		document.write(' loop=false bgcolor=' + bgCol);
		document.write(' type="video/quicktime"\>');
		document.write('</embed\>');
		document.write('<noembed\><img src="' + name + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\></noembed\>');
	}
	else
	{
		document.write('<img src="' + name + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\>');
	} 
	
}




// Insert a random GIF image into the current page depending upon the setting of the
// gImageHandling variable.

function insert_random_image(imgType,imgPath,imgWidth,imgHeight,imgHspace,imgVspace,numImages)
{
	var imgNum,imgNumStr="";
	
	if (gImageHandling == "")
	{
		// The variable has not been set so do a check.
		check_flash();
	}
		
	if (gImageHandling.indexOf("none") == -1)
	{
		imgNum = (Math.floor((new Date()).getTime()/10)%numImages) + 1;
		imgNumStr = (new Number(imgNum)).toString();
		if (imgNum < 10) imgNumStr = '0' + imgNumStr;
		document.write('<img src="' + imgPath + imgNumStr + '.' + imgType + '" width=' + imgWidth + ' height=' + imgHeight + ' vspace=' + imgVspace + ' hspace=' + imgHspace + '\>');
	}

}



// Insert a random GIF image into the current page along with the appropriate URL and ALT tags. The
// individual URLs and ALT tags are separated in the string by the '|' character.

function insert_random_image_plus(imgType,imgPath,imgWidth,imgHeight,imgHspace,imgVspace,numImages,urls,alts)
{
	var imgNum,imgNumStr="";
	var altTag = "";
	var url = "";
	
	if (gImageHandling == "")
	{
		// The variable has not been set so do a check.
		check_flash();
	}
		
	if (gImageHandling.indexOf("none") == -1)
	{
		var urlArray = mySplit(urls,'|');
		var altArray = mySplit(alts,'|');
		
		imgNum = (Math.floor((new Date()).getTime()/10)%numImages) + 1;
		url = urlArray[imgNum-1];
		altTag = altArray[imgNum-1];
		imgNumStr = (new Number(imgNum)).toString();
		if (imgNum < 10) imgNumStr = '0' + imgNumStr;
		document.write('<a href="' + url + '"\><img src="' + imgPath + imgNumStr + '.' + imgType + '" width=' + imgWidth + ' height=' + imgHeight + ' vspace=' + imgVspace + ' hspace=' + imgHspace + ' alt="' + altTag + '" border=0\></a\>');
	}

}




// Java 1.0 doesn't support a split method, so define one here

function mySplit (stringtoSplit, separator)
{
	var splitIndex = 0 ;
	var splitArray = new Array () ;

	while ((stringtoSplit.length > 0) && (separator.length > 0))
	{
		var i = stringtoSplit.indexOf (separator) ;
		if ((!i) && (separator != stringtoSplit.substring (0, separator.length)))
			break ;
		if (i == -1)
		{
			splitArray [splitIndex++] = stringtoSplit ;
			break ;
		}
		splitArray [splitIndex++] = stringtoSplit.substring (0,i) ;

		stringtoSplit = stringtoSplit.substring (i+separator.length, stringtoSplit.length) ;
	}

	splitArray.length = splitIndex; 
	return splitArray ;
}


