
//----------------------------------------
//DEFINES
//----------------------------------------
var ROOT_NODE_ID 				= "ROOT_NODE";   	// the invisible root node at 0,0
var USER_NODE_ID 				= "USER_NODE";   	// the sphere+camera
var UNSIGNED_ID  				= "UNSIGNED_ID"; 	// someone didn't have an id.. for example the dummy load node.

var NODE_TYPE_GEO				= "GeoNode";  		// node without a type
var NODE_TYPE_ROOT 				= "GeoRoot";  		// the root node... invisible at 0,0.  everything else is it's child
var NODE_TYPE_USER 				= "GeoUser";  		// camera + sphere
var NODE_TYPE_IMAGE             = "GeoImage";       // plane (can be billboard)
var NODE_TYPE_TEXT              = "GeoText";        // text node

var NODE_STATE_NORMAL			= 0;
var NODE_STATE_HOVER 			= 1;
var NODE_STATE_DOWN 			= 2;

var VIDEO_STATE_UNINITIALIZED	= 0;
var VIDEO_STATE_STOPPED 		= 1;
var VIDEO_STATE_PAUSED 			= 2;
var VIDEO_STATE_PLAYING 		= 3;
var VIDEO_STATE_SEEKING 		= 4;
var VIDEO_STATE_BUFFERING 		= 5;
var VIDEO_STATE_STALLED 		= 6;
var VIDEO_STATE_LOADED 			= 7;
var VIDEO_STATE_LOAD_FAILED     = 8;

var VIDEO_EVENT_START           = "VIDEO_START";
var VIDEO_EVENT_FINISHED        = "VIDEO_FINISHED";
var VIDEO_EVENT_ERROR_FAILED    = "VIDEO_ERROR_FAILED";
var VIDEO_EVENT_ERROR_NOT_FOUND = "VIDEO_ERROR_NOT_FOUND";
var VIDEO_EVENT_PAUSE           = "VIDEO_PAUSE";
var VIDEO_EVENT_PLAY            = "VIDEO_PLAY";
var VIDEO_EVENT_CLOSE           = "VIDEO_CLOSE";


var DefaultRange 	= 50;
var DefaultPoiRange = 50;
var DefaultLimit 	= 50;
	
//var g_imSceneNodes = new Array();
var g_imDebug = true;	

var g_imPlayerArray = new Array();
var g_imPlayerInstanceCount = 0;
var g_imPlayerPath = '';

function getPlayer(playerId)
{
	return g_imPlayerArray[playerId];
}

function getFlashMovie(movieName)
{
	//var isIE = navigator.appName.indexOf("Microsoft") != -1;
	//return (isIE) ? window[movieName] : document[movieName];
	return document.getElementById(movieName);
	//return $("#" + movieName)[0];
}

function SceneNode(nodeId,nodeType,xmlData)// xmldata is a string
{
	this.nodeId = nodeId;
	//this.xmlData= new XML(xmlData);
	this.type = nodeType;
	
	//this.getLongitude = function getLongitude()
	//{
	//	return getPlayer().getLongitude(this.nodeId);
	//}
	
}

	
function sceneNode_onLoad(playerId,nodeId,script,nodeType,xmlData)
{
	
	player = getPlayer(playerId);
	augment = player;
	
	player.debugTrace("sceneNode_onLoad(): nodeID=" + nodeId);
	
	node = new SceneNode(nodeId,nodeType,xmlData);
	//g_imSceneNodes[nodeId] = node;

	try
	{
		eval(script);
	}
	catch(e)
	{
		if( g_imDebug )
		{
			alert("sceneNode_onLoad error parsing: " + e);
		}
	}
	
	player.onNodeLoad(nodeId);

}


function sceneNode_onMouseOut(playerId,nodeId,script)
{
	player = getPlayer(playerId);
	augment = player;
	
	player.debugTrace("sceneNode_onMouseOut(): nodeID=" + nodeId);
	
	//node = g_imSceneNodes[nodeId];

	try
	{
		eval(script);
	}
	catch(e)
	{
		if( g_imDebug )
		{
			alert("sceneNode_onMouseOut error parsing: " + e);
		}
	}
	
	player.onNodeMouseOut(nodeId);
	
}

function sceneNode_onMouseOver(playerId,nodeId,script)
{
	player = getPlayer(playerId);
	augment = player;
	
	player.debugTrace("sceneNode_onMouseOver(): nodeID=" + nodeId);
	
	//node = g_imSceneNodes[nodeId];

	try
	{
		eval(script);
	}
	catch(e)
	{
		if( g_imDebug )
		{
			alert("sceneNode_onMouseOver error parsing: " + e);
		}
	}
	
	player.onNodeMouseOver(nodeId);

}

function sceneNode_onClick(playerId,nodeId,script)
{
		
	player = getPlayer(playerId);
	augment = player;



	player.debugTrace("sceneNode_onClick(): nodeID=" + nodeId);
	
	//node = g_imSceneNodes[nodeId];

	try
	{
		eval(script);
	}
	catch(e)
	{
		if( g_imDebug )
		{
			alert("sceneNode_onClick error parsing: " + e);
		}
	}

	player.onNodeMouseClick(nodeId);
	
}


function button_onClick(playerId,buttonId, script) {

    player = getPlayer(playerId);
    augment = player;

    //alert("button_onClick(): TEST");

    player.debugTrace("button_onClick(): buttonID=" + buttonId);

    //node = g_imSceneNodes[nodeId];

    try {
        eval(script);
    }
    catch (e) {
        if (g_imDebug) {
            alert("sceneNode_onClick error parsing: " + e);
        }
    }
}


function Flash_Alert(txt) 
{
    alert(txt);
}

//----------------------------------------
// PLAYER INITIALIZATION SUPPORT
//----------------------------------------
function imSetPlayerPath(url){
	g_imPlayerPath = url;
}

//----------------------------------------
// Proxy Object
//----------------------------------------
function imPlayer(element, callback){

	this.parent = element;
	this.id = 'imp_inst_' + g_imPlayerInstanceCount++;	
	this.parent.innerHTML = InsertPlayerString(this.id, element.style.width,element.style.height);
	this.isLoaded = false;
	
	g_imPlayerArray[this.id] = this;


	///////////////////////////////////////////////////
	// Core player functionality
	///////////////////////////////////////////////////
		
	this.loadVideo = function(url){
		getFlashMovie(this.id).loadVideo(url);
			
	}

	this.loadStill = function(url, heading){
		getFlashMovie(this.id).loadStill(url, heading);
	}


	this.width = function(width) {
	    this.parent.style.width = width + 'px';
	    getFlashMovie(this.id).style.width = this.parent.style.width;
	}

	this.height = function(height) {
	    this.parent.style.height = height + 'px';
	    getFlashMovie(this.id).style.height = this.parent.style.height;
	}

	this.debugTrace = function(strTrace) {
	    getFlashMovie(this.id).debugTrace(strTrace);
	}
	
	//this.getMediaUrl = function(){
	//	return getFlashMovie(this.id).getMediaUrl();
	//}

	this.getMediaDuration = function() {
	    return getFlashMovie(this.id).getMediaTime();
	}

	this.getMediaTime = function(){
		return getFlashMovie(this.id).getMediaTime();
    }
    
	this.setMediaTime = function(time){
		getFlashMovie(this.id).setMediaTime(time);
	}

	//this.getMediaState = function(){
	//	return getFlashMovie(this.id).getMediaState();
	//}

	this.pauseVideo = function(){
		getFlashMovie(this.id).pauseVideo();
	}

	this.playVideo = function(){
		getFlashMovie(this.id).playVideo();
	}

	this.togglePlayPause = function(){
		getFlashMovie(this.id).togglePlayPause();
	}

	this.loadData = function(url, resetView) {
	    getFlashMovie(this.id).loadData(url, resetView);
	}

	this.setData = function(xml, resetView) {
	    getFlashMovie(this.id).setData(xml, resetView);
	}

	this.setUserConfigData = function(key,value){
		getFlashMovie(this.id).setUserConfigData(key,value);
	}

	this.getUserConfigData = function(key){
		return getFlashMovie(this.id).getUserConfigData(key);
	}

	this.getVersion = function(key){
		return getFlashMovie(this.id).getVersion();
	}

	this.resize = function(){
		getFlashMovie(this.id).style.width = this.parent.style.width;
		getFlashMovie(this.id).style.height = this.parent.style.height;
    }

    this.getFov = function() {
        return getFlashMovie(this.id).getFov();
    }

    this.setFov = function(fov) {
        getFlashMovie(this.id).setFov(key);
    }


    this.getGuiElementVisible = function(name) {
        return getFlashMovie(this.id).getGuiElementVisible(name);
    }

    this.setGuiElementVisible = function(name, visible) {
        getFlashMovie(this.id).setGuiElementVisible(name, visible);
    }

    this.getGuiElementEnabled = function(name) {
        return getFlashMovie(this.id).getGuiElementEnabled(name);
    }

    this.setGuiElementEnabled = function(name, enabled) {
        getFlashMovie(this.id).setGuiElementEnabled(name, enabled);
    }

    this.makeURL = function(urlId,path) {
        return getFlashMovie(this.id).makeURL(urlId, path);
    }
	
	// Core player events.
	this.onLoad = function(){
		if ( callback ){
			callback();
		}
	}
	
	this.onViewHeadingChange = function(heading,pitch){
	}

	this.onVideoStateChange = function(newState) {
	    //alert("onVideoStateChange(): newState: " + newState);
	}
	
    ///////////////////////////////////////////////////
	// Augumentation Functionality
	///////////////////////////////////////////////////


	this.getRequestParameter = function(requestId, parameterName) {
	    return getFlashMovie(this.id).getRequestParameter(requestId, parameterName);
	}

	this.setRequestParameter = function(requestId ,parameterName, newValue) {
	    getFlashMovie(this.id).setRequestParameter(requestId, parameterName, newValue);
	}
	
	this.getCustomerKey = function() {
	    return getFlashMovie(this.id).getCustomerKey();
	}

	this.setCustomerKey = function(key) {
	    getFlashMovie(this.id).setCustomerKey(key);
	}

	this.setStillHeading = function(heading){
		getFlashMovie(this.id).setStillHeading(heading);
	}

	this.getStillHeading = function(){
		return getFlashMovie(this.id).getStillHeading();
	}	

	this.queryLocation = function(longitude,latitude,altitude,imageTypes,resetView){
	    getFlashMovie(this.id).queryLocation(longitude, latitude, altitude, imageTypes, resetView);
	}

	this.clearScene = function() {
	    getFlashMovie(this.id).clearScene();
	}

	this.getRelativeLocation = function(longitude, latitude, altitude, x, y, z){
	    return getFlashMovie(this.id).getRelativeLocation(longitude, latitude, altitude, x, y, z);
	}

	// Augment Events
	this.onLocationChange = function(longitude, latitude, altitude, travelHeading){
	}

	this.onNodeLoad = function(nodeId){
	}
	
	this.onNodeMouseOver = function(nodeId){
		//alert("over: " + nodeId);
	}

	this.onNodeMouseClick = function(nodeId){		
		//alert("click: " + nodeId);
	}

	this.onNodeMouseOut = function(nodeId){
		//alert("out: " + nodeId);
	}

	///////////////////////////////////////////////////
	// Augumentation.node Functionality
	///////////////////////////////////////////////////
	
	this.setImageNodeTexture = function(nodeId,state,url){
		getFlashMovie(this.id).setImageNodeTexture(nodeId,state,url);
	}		
	
	this.getImageNodeTextureUrl = function(nodeId,state){
		return getFlashMovie(this.id).getImageNodeTextureUrl(nodeId,state);
	}		
	
	this.removeGeoNode = function(nodeId){
		getFlashMovie(this.id).removeGeoNode(nodeId);
	}		

	this.setLocation = function(nodeId,longitude,latitude,altitude){
		getFlashMovie(this.id).setLocation(nodeId,longitude,latitude,altitude);
	}		

	this.getLocation = function(nodeId){
		return getFlashMovie(this.id).getLocation(nodeId);
    }

    this.setRotations = function(nodeId, yaw, pitch, roll) {
        getFlashMovie(this.id).setRotations(nodeId, yaw, pitch, roll);
    }

    this.getRotations = function(nodeId) {
        return getFlashMovie(this.id).getRotations(nodeId);
    }
		
	this.getLongitude = function(nodeId){
		return getFlashMovie(this.id).getLongitude(nodeId);
	}	
	
	this.getLatitude = function(nodeId){
		return getFlashMovie(this.id).getLatitude(nodeId);
	}	
	
	this.getAltitude = function(nodeId){
		return getFlashMovie(this.id).getAltitude(nodeId);
	}
	
	this.getYaw = function(nodeId){
		return getFlashMovie(this.id).getYaw(nodeId);
	}	
	
	this.setYaw = function(nodeId,newYaw){
		getFlashMovie(this.id).setYaw(nodeId,newYaw);
	}	

	this.getPitch = function(nodeId){
		return getFlashMovie(this.id).getPitch(nodeId);
	}	
	
	this.setPitch = function(nodeId,newPitch){
		getFlashMovie(this.id).setPitch(nodeId,newPitch);
	}

	this.getRoll = function(nodeId){
		return getFlashMovie(this.id).getRoll(nodeId);
	}
	
	this.setRoll = function(nodeId,newRoll){
		getFlashMovie(this.id).setRoll(nodeId,newRoll);
	}	
	
	this.getVisibility = function(nodeId){
		return getFlashMovie(this.id).getVisibility(nodeId);
	}	
	
	this.setVisibility = function(nodeId,visible){
		getFlashMovie(this.id).setVisibility(nodeId,visible);
    }

    this.getTextNodeText = function(nodeId) {
        return getFlashMovie(this.id).getTextNodeText(nodeId);
    }

    this.setTextNodeText = function(nodeId, newText) {
        getFlashMovie(this.id).setTextNodeText(nodeId, newText);
    }

    this.getStillProperty = function(nodeId, stillId, propertyName) {
        return getFlashMovie(this.id).getStillProperty(nodeId, stillId, propertyName);
    }

    this.getVideoProperty = function(nodeId, videoId, propertyName) {
        return getFlashMovie(this.id).getVideoProperty(nodeId, videoId, propertyName);
    }



    

}







function player_onLoad(playerId){
	g_imPlayerArray[playerId].isLoaded = true;
	g_imPlayerArray[playerId].resize();
	g_imPlayerArray[playerId].onLoad();	
}

function player_onVideoStateChange(playerId, newState) {
    g_imPlayerArray[playerId].onVideoStateChange(newState);
}

function player_onViewHeadingChange(playerId,heading,pitch){
	g_imPlayerArray[playerId].onViewHeadingChange(heading,pitch);
}

function augment_onLocationChange(playerId,longitude,latitude,altitude,travelHeading){
	g_imPlayerArray[playerId].onLocationChange(longitude,latitude,altitude,travelHeading);
}






//----------------------------------------
// Player Embed Support
//----------------------------------------
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;


function AC_GenerateobjString(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		str += '>';
  		for (var i in params)
  			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '</object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    return str;
}

function AC_FL_RunContentString(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  return AC_GenerateobjString(ret.objAttrs, ret.params, ret.embedAttrs);
}

function InsertPlayerString(id, width, height){
	
	var Id = id;

	var hasProductInstall = DetectFlashVer(6, 0, 65);
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	var Result = "";
	//var Result = "<script language='javascript'>";
		
	// Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
	if ( hasProductInstall && !hasRequestedVersion ) {
		// MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
		// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
		// DO NOT MODIFY THE FOLLOWING FOUR LINES
		// Location visited after installation is complete if installation is required
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
	   	document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		var MMdoctitle = document.title;
		
		Result += AC_FL_RunContentString(
					"src", g_imPlayerPath + "playerProductInstall",
					"base", g_imPlayerPath,
					"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
					"width", width,
					"height", height,
					"align", "middle",
					"id", Id,
					"name", Id,
					"quality", "high",
					"allowFullScreen","true",
					"menu","true",			
					"bgcolor", "#000000",
					"allowScriptAccess","always",
					"wmode","transparent",
					"type", "application/x-shockwave-flash",
					"pluginspage", "http://www.adobe.com/go/getflashplayer"
					);

	} else if (hasRequestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed
		Result += AC_FL_RunContentString(
						"src", g_imPlayerPath + "IMPlayer",
						"base", g_imPlayerPath,
						"width", width,
						"height", height,
						"align", "middle",
						"id", Id,
						"name", Id,
						"quality", "high",
						"allowFullScreen","true",
						"menu","true",				
						"bgcolor", "#000000",
						"flashvars","config=config.xml&playerid=" + Id,
						"allowScriptAccess","always",
						"wmode","transparent",
						"type", "application/x-shockwave-flash",
						"pluginspage", "http://www.adobe.com/go/getflashplayer"
						);
	
	} else {  // flash is too old or we can't detect the plugin
		Result = 'Alternate HTML content should be placed here. ' +
					'This content requires the Adobe Flash Player. ' +
					'<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
	}
	
	//Result += "</script>";

	Result += "<noscript>" +
				"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' " +
				"id='" + Id + "' width='" + width + "' height='" + height + "' align='center' " +
				"codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>" +
				"<param name='movie' value='" + g_imPlayerPath + "IMPlayer.swf'/>" +
				"<param name='quality' value='high'/>" +
				"<param name='bgcolor' value='#000000'/>" +
				"<param name='wmode' value='transparent'/>" +
				"<param name='allowScriptAccess' value='always'/>" +
				"<embed src='" + g_imPlayerPath + "IMPlayer.swf' quality='high' bgcolor='#000000' " +
				"width='" + width + "' height='" + height + "' name='" + Id + "' align='middle' " +
				"play='true' " +
				"loop='false' " +
				"quality='high'	 " +			
				"allowScriptAccess='always' " +					
				"allowFullScreen='true' " +
				"menu='true' " +			
				"type='application/x-shockwave-flash' " +
				"pluginspage='http://www.adobe.com/go/getflashplayer'>" +
				"base='" + g_imPlayerPath + "' " +
				"</embed>" +
				"</object>" +
				"</noscript>";

	return Result;
}



//-------------------------------------------------------------------------------------
//Adobe AC_OETags.js included for simplicity
//-------------------------------------------------------------------------------------
//Flash Player Version Detection - Rev 1.6
//Detect Client Browser type
//Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

//JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

//When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

     	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
if (src.indexOf('?') != -1)
 return src.replace(/\?/, ext+'?'); 
else
 return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
 var str = '';
 if (isIE && isWin && !isOpera)
 {
		str += '<object ';
		for (var i in objAttrs)
			str += i + '="' + objAttrs[i] + '" ';
		str += '>';
		for (var i in params)
			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		str += '</object>';
 } else {
		str += '<embed ';
		for (var i in embedAttrs)
			str += i + '="' + embedAttrs[i] + '" ';
		str += '> </embed>';
 }

 document.write(str);
}

function AC_FL_RunContent(){
var ret = 
 AC_GetArgs
 (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
  , "application/x-shockwave-flash"
 );
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i=0; i < args.length; i=i+2){
 var currArg = args[i].toLowerCase();    

 switch (currArg){	
   case "classid":
     break;
   case "pluginspage":
     ret.embedAttrs[args[i]] = args[i+1];
     break;
   case "src":
   case "movie":	
     args[i+1] = AC_AddExtension(args[i+1], ext);
     ret.embedAttrs["src"] = args[i+1];
     ret.params[srcParamName] = args[i+1];
     break;
   case "onafterupdate":
   case "onbeforeupdate":
   case "onblur":
   case "oncellchange":
   case "onclick":
   case "ondblClick":
   case "ondrag":
   case "ondragend":
   case "ondragenter":
   case "ondragleave":
   case "ondragover":
   case "ondrop":
   case "onfinish":
   case "onfocus":
   case "onhelp":
   case "onmousedown":
   case "onmouseup":
   case "onmouseover":
   case "onmousemove":
   case "onmouseout":
   case "onkeypress":
   case "onkeydown":
   case "onkeyup":
   case "onload":
   case "onlosecapture":
   case "onpropertychange":
   case "onreadystatechange":
   case "onrowsdelete":
   case "onrowenter":
   case "onrowexit":
   case "onrowsinserted":
   case "onstart":
   case "onscroll":
   case "onbeforeeditfocus":
   case "onactivate":
   case "onbeforedeactivate":
   case "ondeactivate":
   case "type":
   case "codebase":
     ret.objAttrs[args[i]] = args[i+1];
     break;
   case "id":
   case "width":
   case "height":
   case "align":
   case "vspace": 
   case "hspace":
   case "class":
   case "title":
   case "accesskey":
   case "name":
   case "tabindex":
     ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
     break;
   default:
     ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
 }
}
ret.objAttrs["classid"] = classid;
if (mimeType) ret.embedAttrs["type"] = mimeType;
return ret;
}


