if(navigator.userAgent.toLowerCase().indexOf("safari")>=0){
	window.location = "index.swf";
}
//Constants
var flashPath = "index.swf";


//Code to embed the flash file
var flash = '<div id="container">';
flash += '<object id="fdlFlashObj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%">';
flash += '<param name="movie" value="@movie" />';
flash += '<param name="quality" value="high" />';
//flash += '<param name="wmode" value="transparent">';
flash += '<param name=flashvars value="@flashvars" />';
flash += '<embed src="@movie" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%" flashvars="@flashvars"></embed>';
flash += '</object>';
flash += '</div>';

//Hide non flash content
document.write("<style>body {visibility:hidden;background: none;}</style>");

//Flash detection script
var MM_contentVersion = 7;
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 MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_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('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}


function setFlash(){

	var bodyEl;
	var embedCode;
	var flashVars
	bodyEl = document.getElementsByTagName("body")[0];
	
	if(MM_FlashCanPlay){
		flashVars = escape(location.search);
		
		embedCode = flash.replace(/@flashvars/g, flashVars);
		embedCode = embedCode.replace(/@movie/g, flashPath);
		
		bodyEl.innerHTML = embedCode;

		}
		else{
			var noFlashCode = '<IMG SRC="no_flash.gif" alt="To view this web site you need the latest version of Flash Player Please download the plug-in if it is not yet installed vain your computer." WIDTH="355" HEIGHT="200" BORDER=0 usemap="#noplugMap">';
			noFlashCode += '<map name="noplugMap" id="noplugMap">';
			noFlashCode += '<area shape="rect" coords="129,149,218,180" href="http://www.macromedia.com/go/getflashplayer" target="_blank" alt="Download Flash">';
    		noFlashCode += '<area shape="rect" coords="43,119,96,134" href="http://www.macromedia.com/go/getflashplayer" target="_blank" alt="Download Flash">';
			noFlashCode += '</map>';
			bodyEl.innerHTML = noFlashCode;
			bodyEl.style.backgroundColor = "#E6E9E0";
		}
		
		
	bodyEl.style.visibility = "visible";

}

function getInnerText(e){

	 var strText = "";
	 var node;
	 for(var i=0; i<e.childNodes.length; i++ )
	 {node = e.childNodes[i];
	  switch(node.nodeType)
	  {
	   case 1: // elements
		strText += getInnerText(node);
		break;
	   case 3: // text
		strText += node.nodeValue;
		break;
	   default: // comments etc
		break;
	  }
	 }
	
	//Strip leading and trailing spaces.
    //var regEx = /^[ \t\r\n]+|[ \t\r\n]+$/g;
	var regEx = /[\r\n\t]+|[ ]{2}/g;
	strText = strText.replace(regEx, " ");
	
	var regEx = /[ ]+/g;
	strText = strText.replace(regEx, " ");
	
	//Force upper case if neccessary
	if(forceUpperCase)strText = strText.toUpperCase();
	return strText;
}

/*
	Finds elements on page that match a given CSS selector rule. Some
	complicated rules are not compatible.
	Based on Simon Willison's excellent "getElementsBySelector" function.
	Original code (with comments and description):
	http://simon.incutio.com/archive/2003/03/25/getElementsBySelector
*/
function getElementsBySelector(selector)
{
	var tokens = selector.split(' ');
	var currentContext = new Array(document);
	for(var i=0;i<tokens.length;i++)
	{
		token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');
		if(token.indexOf('#') > -1)
		{
			var bits = token.split('#');
			var tagName = bits[0];
			var id = bits[1];
			var element = document.getElementById(id);
			if(tagName && element.nodeName.toLowerCase() != tagName)
				return new Array();
			currentContext = new Array(element);
			continue;
		}

		if(token.indexOf('.') > -1)
		{
			var bits = token.split('.');
			var tagName = bits[0];
			var className = bits[1];
			if(!tagName)
				tagName = '*';

			var found = new Array;
			var foundCount = 0;
			for(var h=0;h<currentContext.length;h++)
			{
				var elements;
				if(tagName == '*')
					elements = currentContext[h].all ? currentContext[h].all : currentContext[h].getElementsByTagName('*');
				else
					elements = currentContext[h].getElementsByTagName(tagName);

				for(var j=0;j<elements.length;j++)
					found[foundCount++] = elements[j];
			}

			currentContext = new Array;
			var currentContextIndex = 0;
			for(var k=0;k<found.length;k++)
			{
				if(found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b')))
					currentContext[currentContextIndex++] = found[k];
			}

			continue;
	    }

		if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/))
		{
			var tagName = RegExp.$1;
			var attrName = RegExp.$2;
			var attrOperator = RegExp.$3;
			var attrValue = RegExp.$4;
			if(!tagName)
				tagName = '*';

			var found = new Array;
			var foundCount = 0;
			for(var h=0;h<currentContext.length;h++)
			{
				var elements;
	        	if(tagName == '*')
					elements = currentContext[h].all ? currentContext[h].all : currentContext[h].getElementsByTagName('*');
				else
					elements = currentContext[h].getElementsByTagName(tagName);

				for(var j=0;j<elements.length;j++)
					found[foundCount++] = elements[j];
			}

			currentContext = new Array;
			var currentContextIndex = 0;
			var checkFunction;
			switch(attrOperator)
			{
				case '=':
					checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
					break;
				case '~':
					checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
					break;
				case '|':
					checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
					break;
				case '^':
					checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
					break;
				case '$':
					checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
					break;
				case '*':
					checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
					break;
				default :
					checkFunction = function(e) { return e.getAttribute(attrName); };
			}

			currentContext = new Array;
			var currentContextIndex = 0;
			for(var k=0;k<found.length;k++)
			{
				if(checkFunction(found[k]))
					currentContext[currentContextIndex++] = found[k];
			}

			continue;
		}

		tagName = token;
		var found = new Array;
		var foundCount = 0;
			for(var h=0;h<currentContext.length;h++)
			{
				//alert(currentContext[h]);
				if(currentContext[h]){
					var elements = currentContext[h].getElementsByTagName(tagName);
					for(var j=0;j<elements.length; j++)
						found[foundCount++] = elements[j];
				}
			}

		currentContext = found;
	}

	return currentContext;
}



/* @constructor */
function EventUtils() {
	throw 'RuntimeException: EventUtils is a static utility class ' +
		' and may not be instantiated';
}

/**
 *	@access static
 *	@param HTMLElement target
 *	@param string type
 *	@param Function callback
 *	@param boolean captures
 */
EventUtils.addEventListener = function (target,type,callback,captures) {
	if (target.addEventListener) {
			// EOMB
		target.addEventListener(type,callback,captures);
	} else if (target.attachEvent) {
		// IE
		target.attachEvent('on'+type,callback,captures);
	} else {
		// IE 5 Mac and some others
		target['on'+type] = callback;
	}
}

EventUtils.removeEventListener = function (target,type,callback,captures) {
	if (target.removeEventListener) {
			// EOMB
		target.removeEventListener(type,callback,captures);
	} else if (target.detachEvent) {
		// IE
		target.detachEvent('on'+type,callback);
	} else {
		// IE 5 Mac and some others
		target['on'+type] = null;
	}
}

EventUtils.addEventListener(window,'load',setFlash);
