

//Function that tests if THBVersionCheck is available
function IsInstalledTHBVersionCheck()
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom.THBVersionCheck.50");
		return true;
	}
	catch(ex)
	{
		try
		{
			showAbsolute('idWarningTHBVersionCheck'); 
		}
		catch(ex)
		{	
			alert('THBVersionCheck is not installed!');
		}
		return false;
	}
}

function THBVersionCheckLog()
{
    if(IsInstalledTHBVersionCheck())
    {
        try
        {
		    var ie; 
		    ie = new ActiveXObject("THBCom.THBVersionCheck.50");
		    return ie.LogCOMVersion();
		}
		catch(ex)
		{	
			alert('THBVersionCheck is not installed!');
		}
		return "";
	}
	else return "THBVersionCheck is not installed!";
}

//Function that tests if THBImageEdit is available
function IsInstalledTHBImageEdit()
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom.THBImageEdit.50");
		return true;
	}
	catch(ex)
	{
		try
		{
			showAbsolute('idWarningTHBImageEdit');
		}
		catch(ex)
		{	
			alert('THBImageEdit is not installed!');
		}
		return false;
	}
}

//Function that tests if THBView is available
function IsInstalledTHBView()
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom.THBView.50");
		return true;
	}
	catch(ex)
	{
		try
		{
			showAbsolute('idWarningTHBImage'); 
		}
		catch(ex)
		{	
			alert('THBImage is not installed!');
		}
		return false;
	}
}

//Function that tests if THBGeoImage is available
function IsInstalledTHBGeoImage()
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom.THBGeoImageFactory.50");
		return true;
	}
	catch(ex)
	{
		try
		{
			showAbsolute('idWarningTHBGeoImage'); 
		}
		catch(ex)
		{	
			alert('THBGeoImage is not installed!');
		}
		return false;
	}
}

//Function that tests if THBGeoVector is available
function IsInstalledTHBGeoVector()
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom.THBGeoVectorFactory.50");
		return true;
	}
	catch(ex)
	{
		try
		{
			showAbsolute('idWarningTHBGeoVector'); 
		}
		catch(ex)
		{	
			alert('THBGeoVector is not installed!');
		}
		return false;
	}
}


//Function that tests if THBVectorAnalysis is available
function IsInstalledTHBVectorAnalysis()
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom.THBVectorAnalysisFactory.50");
		return true;
	}
	catch(ex)
	{
		try
		{
			showAbsolute('idWarningTHBVectorAnalysis'); 
		}
		catch(ex)
		{	
			alert('THBVectorAnalysis is not installed!');
		}
		return false;
	}
}


//Function that tests for installed THB objects
function IsInstalled(name)
{
	try 
	{ 
		var ie; 
		ie = new ActiveXObject("THBCom." + name + ".50");
		ie = null;
		return true;
	}
	catch(ex)
	{
		return false;
	}
}
function IsInstalledText(name)
{
    if(!IsInstalled(name)) return name + ' is not installed!<br/>';
    else return '';
}
function CompareVersion()
{
    if(!IsInstalled('THBVersionCheck')) return "";
    
    // THBImage prior to 5.0.3.2 does not have the version property
    var result = "";	
	try 
	{ 
		var vc, compare; 
        var yourversion = "5.0.3.1";
        var strRecommendedTHBImageVersionMin = "5.0.4.2";
		vc = new ActiveXObject("THBCom.THBVersionCheck.50");
		try
        {
            yourversion = vc.Version;
	    }
	    catch(ex)
	    {
	    }
		
		result += "Your THBImage version is '" + yourversion + "'<br/>";
		result += "The recommended version is '" + strRecommendedTHBImageVersionMin + "'!<br/>";
		result += "<br/>";
		compare = vc.CompareVersion(yourversion, strRecommendedTHBImageVersionMin);
		if(compare == 0) result += "<FONT COLOR='#00FF00'>Version OK! THBImage is installed on this machine, there is no need to run the setup!</FONT><br/>";
		else if(compare == -1) result += "<FONT COLOR='#FF0000'>Version too old! Please run the setup!</FONT><br/>";
		else result += "<FONT COLOR='#00FF00'>Version newer than required OK! THBImage is installed on this machine, there is no need to run the setup again!</FONT><br/>";
	}
	catch(ex)
	{
		alert('Error checking version using THBVersionCheck!');
	}
	return result;
}
function THBImageInstallationStatus()
{
    var str;
    str = "";
    str += IsInstalledText('THBVersionCheck');
    str += IsInstalledText('THBUtilsFactory');
    str += IsInstalledText('THBImageEdit');
    str += IsInstalledText('THBView');
    str += IsInstalledText('THBTwain');
    //str += IsInstalledText('THBExif');
    str += IsInstalledText('THBGeoImageFactory');
    str += IsInstalledText('THBGeoVectorFactory');
    if(str == '') str += CompareVersion();
    return str;
}


