// browser detection

var isMac;
var NS4;
var IEmac;
var IE4plus;
var IE4;
var IE5;
var IE6;
var ver4;
var NS6;
var IE5plus;
var IEMajor;

detectBrowser();

function detectBrowser()
{
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	NS4 = (document.layers) ? true : false;
	IEmac = ((document.all)&&(isMac)) ? true : false;
	IE4plus = (document.all) ? true : false;
	IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
	ver4 = (NS4 || IE4plus) ? true : false;
	NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
	IE5plus = IE5 || IE6;
	IEMajor = 0;
	if (IE4plus)
	{
		var start = navigator.appVersion.indexOf("MSIE");
		var end = navigator.appVersion.indexOf(".",start);
		IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
		IE5plus = (IEMajor>=5) ? true : false;
	}
}

// flash detection
var requiredVersion = 6;
var flashAvailable = false;
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(" ");
	console.log(navigator.plugins["Shockwave Flash"].description);
	for (var i = 0; i < words.length; ++i)
	{
		if (isNaN(parseInt(words[i])))
			continue;
		var pluginVersion = words[i]; 
	}
	parts = pluginVersion.split(".");
	majorVersion = parts[0];
	flashAvailable = majorVersion >= requiredVersion;
}
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('flashAvailable=( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & requiredVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

function pageLoaded()
{
	try
	{
		if (setDrawing)
		{
			eval('setDrawing()');
		}
	}
	catch(e)
	{
	}
}


function getElementPosition(elementID)
{
	point = new Object();
	element = getElement(elementID);
	if (!element)
		return;
	var x=0,y=0;
	while (element!=null){
		x+=element.offsetLeft;
		y+=element.offsetTop;
		element=element.offsetParent;
	}
	return {x:x,y:y};
}

function getElement(elementID)
{
	if (document.getElementById)
		return document.getElementById(elementID);
	else if (document.all)
		return document.all[elementID];
	else if (document.layers)
		return document.elementID;
	else
		return false;
}

