var isActiveX;
function checkIsActiveXBrowser()
{
	if (typeof isActiveX != 'undefined') return isActiveX;
	/// Please note: This should be done early when loading the page or else some javascript methods like
	/// document.write may make the test fail for some strange reasons. This is a known bug in IE
	if (window.ActiveXObject)
	{
		isActiveX = true;
	}
	else
	{
		isActiveX = false;
	}
	return isActiveX;
}

function buildMyVRObject()
{
	var myVRobjHtml;
	var postSysInfoStr = '';
	if (typeof myVRpostSystemInfoURL != 'undefined')
	{
		postSysInfoStr = '<param name="postSystemInfo" value="'+ myVRpostSystemInfoURL +'" /> ';
	}
	if (checkIsActiveXBrowser())
	{
			myVRobjHtml = '' +
			'<object name="myVR" id="myVR" '+
			'        classid="CLSID:6A023CCB-BFAA-46EE-800B-26897ED01771" '+
			'        codebase="' + myVRcodeBase + '" '+
			'        width="'+ myVRlauncerWidth + '" height="' + myVRlauncerHeight +'"> '+
			'        <!-- Parameter tags go here !--> '+
			'        <param name="configURL" value="'+ myVRlauncherConfig +'" /> ' + 
			'       ' + postSysInfoStr +
			'                <iframe src="'+ myVRlauncherAltUrl +'" '+
			'                        width="'+ myVRlauncerWidth + '" height="' + myVRlauncerHeight + '" ' + myVRaltParams + '> '+
			'                </iframe> '+
			'</object>';
	}
	else
	{
		myVRobjHtml = '' +
			'<object name="myVR" id="myVR" '+
			'        type="application/x-vnd.myvr-3dmapview" '+
			'        codebase="' + myVRcodeBase + '" '+
			'        width="'+ myVRlauncerWidth + '" height="' + myVRlauncerHeight +'"> '+
			'        <!-- Parameter tags go here !--> '+
			'        <param name="configURL" value="'+ myVRlauncherConfig +'" /> ' + 
			'       ' + postSysInfoStr +
			'                <iframe src="'+ myVRlauncherAltUrl +'" '+
			'                        width="'+ myVRlauncerWidth + '" height="' + myVRlauncerHeight + '" ' + myVRaltParams + '> '+
			'                </iframe> '+
			'</object>';
	}
	return myVRobjHtml;
}

function initMYVR()
{
	if (document.getElementById("myVR")!=null)
	{
		document.getElementById("myVR").focus();
	}
}

function MyVRMapViewInstalled()
{
	if (checkIsActiveXBrowser())
	{
		var isInstalled;
		try
		{
			var isInstalledTest = new ActiveXObject("myVR 3D Framework {6A023CCB-BFAA-46EE-800B-26897ED01771}");
			isInstalled = true;
		}
		catch (err)
		{
			isInstalled = false;
		}
		return isInstalled;
	}
	else
	{
		if (navigator.plugins)
		{
			navigator.plugins.refresh();
			for (i=0; i < navigator.plugins.length; i++) 
			{
				if( (navigator.plugins[i] != null) && (navigator.plugins[i].name != null) && (navigator.plugins[i].name == "myVR 3D Framework") )
				{
					return true;
				}
			}
		}
		else
		{
			// The above should work on most non-ie browser. The navigator.plugin array has been defined since Navigator 3
			// If not, we just assume the plugin is installed.
			return true;
		}
		return false;
	}
}

if (typeof myVRdelayLoad == 'undefined' || !myVRdelayLoad)
{
	document.write(buildMyVRObject());
}

