/*****************************************************************************
* Include this file to analyze the results of Exent's ActiveX compunent.
* The functions that you should use are "compareSWHWdependency" and "checkClientVersion"
*
* V 5.0.4.0
******** Do not change the content of this file *************
         -------------------------------------
******************************************************************************/


/******************************************************************************
Function compareSWHWdependency 
Input:	
	strDB:	Components requirements from the database
	strPC:	The installed components (from the ActiveX)
	iParam1:	For future use
	strParam2:	For future use

Return Value:
	arrComponents2D - two dimensional Array [component][required data]
	[][0]:	Name
	[][1]:  Status
				0:	Unknown
				1: Detected < Min
				2:	Min <= Detected < Recommended
				3: Recommended <= Detected
	[][2]:	Minimum requirements(from the database)
	[][3]:	Recommended requirements(from the database)
	[][4]:	Detected (from ActiveX)
	[][5]:  strExtraData1 - some extra data
	[][6]:  strExtraData2 - some extra data
******************************************************************************/
function compareSWHWdependency(strDB, strPC, iParam1, strParam2)
{
	var iDependencyArrayCount = 0;
	var Component;
	var iStart;
	var iEnd;
	var strTemp;
	var arrComponents2D = new Array();  
	var arrDBComponents = strDB.split(";");   // new array DBString[]
	var strDetectedOS = "";

	// support old client 4.1.3.0. Replace the ; delimiter in the DisplayAdapter with ,
	iStart = strPC.search("DisplayAdapter");
	if(iStart != -1 )
	{
		iEnd = strPC.indexOf("]", iStart);
		if(iEnd > iStart)
		{
			strTemp = strPC.substring(iStart, iEnd);
			strTemp = strTemp.replace(";",":");
			strTemp = strTemp.replace(";",":");
			strPC = strPC.substring(0,iStart) + strTemp + strPC.substring(iEnd,strPC.length);
		}
	}

	var arrPCComponents = strPC.split(";");   // new array PCString[]

   AddMissingComponentsToPcArray( arrDBComponents, arrPCComponents );

	for (var i=0; i<arrPCComponents.length; i++)
	{// loop over the arrPCComponents first
		Component = updateComponentInfo(arrPCComponents[i], arrDBComponents, strDetectedOS);	
		if(Component.bValid == true)
		{
			arrComponents2D[iDependencyArrayCount] = 
				new Array(Component.strName, Component.iStatus, Component.strMinimum, Component.strRecommended, Component.strDetected, Component.strExtraData1, Component.strExtraData2);
			iDependencyArrayCount++;

			if(Component.strName == "OS")
			{
				strDetectedOS = Component.strDetected;
			}
		}
		else if( Component.strName=="DisplayAdapter" && strDetectedOS=="" && i<arrPCComponents.length-1)
		{	// could be invalid needs the strDetectedOS. Push to the end
			arrPCComponents[arrPCComponents.length] = arrPCComponents[i];
		}
	}

	return arrComponents2D;
}

/******************************************************************************
Function checkClientVersion
	Checks if the client check of the ActiveX was successful
Input:	
	strVersionCheck:	The string that the version check returned

Return Value:
	1:	the client is OK
	0:	the client is not OK
******************************************************************************/
function checkClientVersion( strVersionCheck )
{
	var strErrorId = strVersionCheck.substring(strVersionCheck.indexOf('<ErrorId>')+9 ,strVersionCheck.indexOf('</ErrorId>'));
	var strClientVersion = strVersionCheck.substring(strVersionCheck.indexOf('<Information>')+13, strVersionCheck.indexOf('</Information>'));
	var iClientInstalled = 1;

	if(strErrorId != "0")
	{
		iClientInstalled = 0;
	}
	
	return iClientInstalled;
}

/************************************************************************
structComponentData
	a component struct.
bValid:		Indicates whether the data that is stored in this struct is valid or not
strName:	The name of the component
iStatus:	The overall status of the component 
			0:	Unknown
			1:	Detected < Min
			2:	Min <= Detected < Recommended
			3:	Recommended <= Detected
strMinimum:	The minimum version for this component from the AoD database
strRecommended:	The ewcommended version for this component from the AoD database
strDetected:	The installed version of this component on the end-user's computer
strExtraData1:  Extra data
strExtraData2:  Extra data
************************************************************************/
function structComponentData(bValid, strName, iStatus, strMinimum, 
						strRecommended, strDetected, strExtraData1, strExtraData2)
{
	this.bValid = bValid;
	this.strName = strName;
	this.iStatus = iStatus;
	this.strMinimum = strMinimum;
	this.strRecommended = strRecommended;
	this.strDetected = strDetected;
	this.strExtraData1 = strExtraData1;
	this.strExtraData2 = strExtraData2;
}

function ComponentDataToString( Component )
{
	var str;

	str = "bValid = " + Component.bValid + "\n";
	str += "strName = " + Component.strName + "\n";
	str += "iStatus = " + Component.iStatus + "\n";
	str += "strMinimum = " + Component.strMinimum + "\n";
	str += "strRecommended = " + Component.strRecommended + "\n";
	str += "strDetected = " + Component.strDetected + "\n";
	str += "strExtraData1 = " + Component.strExtraData1 + "\n";
	str += "strExtraData2 = " + Component.strExtraData2 + "\n";

	return str;
}

/************************************************************************
updateComponentInfo
	returns a component with all its info
Input:	
	strPCinfo:	a string conteing the name of the component and its detected version.
				the strin is in the following format "name=version"
	arrDBComponents:	an array of all the components requests in the AoD DB	
	strDetectedOS:	The detected OS dependency
Return Value:
	structComponentData
************************************************************************/
function updateComponentInfo(strPCinfo, arrDBComponents, strDetectedOS)
{
	var Component = new structComponentData(false, "", 0, "", "", "", "");

	Component = GetBasicComponentInfo(strPCinfo, arrDBComponents);
	if(Component.bValid != true)
	{
		return Component;
	}
	Component.bValid = false;

   // ignore SoundCard, Joystick, and Mouse
   if(   Component.strName=="SoundCard"   || 
         Component.strName=="Joystick"    ||
         Component.strName=="Mouse"       ||
         Component.strName=="DirectPlay"  ||
         Component.strName=="DirectXMedia"||
         Component.strName=="Indeo Audio"       )
   {
      Component.bValid = false;
      return Component;
   }

	if(Component.strName=="OS")
	{
		checkOSDependency(Component);
		return Component;
	}

	if(Component.strName=="DisplayAdapter")
	{
		if(strDetectedOS == "")
		{
			return Component;
		}
		Component = checkDisplayAdapterDependency(Component, strDetectedOS);
		return Component;
	}

	// if we do not have database info about this component this component is not needed
	if(Component.strMinimum=="" && Component.strRecommended=="")
	{	// no request for this component in the database
		Component.bValid = false;
		return Component;
	}

	Component = SetComponentVersions(Component);
	if(Component.bValid != true)
	{
		return Component;
	}
	Component.bValid = false;

	Component = SetComponentStatus(Component);
	return Component;
}

/************************************************************************
SetComponentStatus
	Calculates the status of the component
Input:	
	Component: raw component
Return Value:
	structComponentData
************************************************************************/
function SetComponentStatus(Component_)
{
	var Component = Component_; 
	var iDepth = 0;
   var iCompareType = 0;

	if( Component.strName=="Indeo Video" ||  Component.strName=="Indeo Audio" )
	{
		iDepth = 2;
      iCompareType = 1;
	}
		
	// calculatet the status
	if(Component.strDetected == "" )
	{	// unknown
		Component.iStatus = 0;
	}
	else if(compareVersions(Component.strDetected,Component.strMinimum, iDepth, iCompareType) == 2) 
	{ // Detected < Min
		Component.iStatus = 1;
	}
	else if(compareVersions(Component.strDetected,Component.strRecommended, iDepth, iCompareType) == 2)
	{ // Min <= Detected < Recommended
		Component.iStatus = 2;
	}
	else
	{ // Recommended <= Detected
		Component.iStatus = 3;
	}

	Component.bValid = true;
	return Component;
}


/************************************************************************
SetComponentVersions
	Gets raw component data, and returns a components with formated version. 
Input:	
	Component: raw component
Return Value:
	structComponentData
************************************************************************/
function SetComponentVersions(Component_)
{
	var Component = Component_;

	// remove unnecessary characters from the versions
	Component.strMinimum = cleanVersionString(Component.strMinimum);
	Component.strRecommended = cleanVersionString(Component.strRecommended);
	Component.strDetected = cleanVersionString(Component.strDetected);

	// Set the BD versions. Fix porbelms in the DB
	if(Component.strMinimum!="" && Component.strRecommended=="")
	{	// We have min version and we do not have recommended version
		Component.strRecommended = Component.strMinimum;
	}
	else if(Component.strRecommended!="" && Component.strMinimum=="")
	{	// We have recommended version and we do not have min version
		Component.strMinimum = Component.strRecommended;
	}
	else if(compareVersions(Component.strRecommended, Component.strMinimum, 0, 0) != 1)
	{	// the recommended version is not bigger than the min version
		Component.strRecommended = Component.strMinimum;
	}

	Component.bValid = true;
	return Component;
}

/************************************************************************
GetBasicComponentInfo
	return the raw data that we know atout a cpmponent. That is:
		Name.
		Detected installed version.
		Minimum version deom AoD database.
		Recommended version from AoD Database.
Input:	
	strPCInfo: information that we get from the End-User's PC
	arrDBComponents: array of components as appear in AoD database
Return Value:
	structComponentData
************************************************************************/
function GetBasicComponentInfo(strPCInfo, arrDBComponents)
{
	var Component = new structComponentData(false, "", 0, "", "", "", "");

	Component.strName = getOnlyName(strPCInfo);
	Component.strDetected = getVersion(strPCInfo);
	Component.strMinimum = getVersionFromComponentsArray(Component.strName,arrDBComponents);
	if(Component.strMinimum == "" )
	{	// if cannot find the real name try with the "Min" extension 
		Component.strMinimum = getVersionFromComponentsArray(Component.strName + "Min",arrDBComponents);
	}
	Component.strRecommended = getVersionFromComponentsArray(Component.strName + "Rec",arrDBComponents);

	Component.bValid = true;
	return Component;
}

/************************************************************************
checkOSDependency
	Sets the OS dependency. This implementation handles only one demand 
	([[a.b.c.d.e]], and not [[a.b.c.d.e]1*]).
Input:	
	Component_:	Raw component 
Return Value:
	structComponentData
************************************************************************/
function checkOSDependency(Component_)
{
	var Component = Component_;
	var	strRequest = Component.strMinimum;
	var strMinVersion;
	var strMaxVersion;

	// Clean the detected version
	Component.strDetected = cleanVersionString(Component.strDetected);
	Component.strMinimum = FormatOSRequest(strRequest);

	// make sure that the strMinimum and strRecommended are the same
	Component.strRecommended = Component.strMinimum;

	if(Component.strMinimum == "")
	{ // no valid request => OK
		Component.iStatus = 3;
		Component.bValid = true;	
		return Component;
	}
	

	if(IsOSInRange(Component.strMinimum,Component.strDetected) == false )
	{	// detected in not in the range => not OK
		Component.iStatus = 1;
		Component.bValid = true;	
		return Component;
	}

	// OK
	Component.iStatus = 3;
	Component.bValid = true;	
	return Component;
}

/************************************************************************
checkDisplayAdapterDependency
	sets the display adapter dependency
Input:	
	Component_:	Raw component 
	strDetectedOS:	The detected OS dependency
Return Value:
	structComponentData
************************************************************************/
function checkDisplayAdapterDependency( Component_, strDetectedOS )
{
	var Component = Component_;
	var strTemp;
	var arrDetected;
	var CardName;
	var bRes;

	strTemp = Component.strDetected;

	// remove brackets
	strTemp = strTemp.substr(1, strTemp.length-2);

	arrDetected = strTemp.split(":");
	CardName = arrDetected[0].toUpperCase();

	switch(arrDetected[1])
	{
		case "4098": // ATI
			if(CardName.search("RADEON") != -1)
			{
				return Get_RADEON_DisplayAdapterComponent(Component.strName, "RADEON", arrDetected[2], arrDetected[1], strDetectedOS);
			}
		break;

		case "4318": // NVIDIA
			if(CardName.search("GEFORCE") != -1)
			{
				return Get_NVIDIA_DisplayAdapterComponent(Component.strName, "NVIDIA GeForce", arrDetected[2], arrDetected[1], strDetectedOS);
			}

			if(CardName.search("RIVATNT") != -1 || CardName.search("RIVA TNT") != -1)
			{
				return Get_NVIDIA_DisplayAdapterComponent(Component.strName, "NVIDIA RIVA TNT", arrDetected[2], arrDetected[1], strDetectedOS);
			}

			if(CardName.search("VANTA") != -1)
			{
				return Get_NVIDIA_DisplayAdapterComponent(Component.strName, "NVIDIA Vanta", arrDetected[2], arrDetected[1], strDetectedOS);
			}
		break;
	}

	// we do not support the detected card
	Component.bValid = false;
	return Component;
}

/************************************************************************
Get_NVIDIA_DisplayAdapterComponent
	Return a structComponentData with NVIDIA data in it.
	The data in the component is as follows:
		bValid - true if everything is OK
		strName - holds the strComponentName
		iStatus - can be 2 (Detected < Recommended) or 3 (Recommended <= Detected)
		strMinimum - empty
		strRecommended - 45.23 (This is the driver version for all the NVIDIA cards that we support,
								NVIDIA GeForce, NVIDIA RIVA TNT, and NVIDIA Vanta. Last check date May 19 2003)
		strDetected - The version is take from the minor version of the strDetectedVertion version. E.g. if
					  strDetectedVertion is 6.14.01.4345 this variable will be 43.45
		strExtraData1 - holds strCardName
		strExtraData2 - holds the strVendorId
Input:	
	strComponentName: The name of the component
	strCardName:	The name of the card
	strDetectedVertion:	The dected version
	strVendorId: The vendor ID
	strDetectedOS:	The detected OS dependency
Return Value:
	structComponentData
************************************************************************/
function Get_NVIDIA_DisplayAdapterComponent( strComponentName, strCardName, strDetectedVertion, strVendorId, strDetectedOS )
{
	var Component = new structComponentData(false, "", 0, "", "", "", "");
	var arrTemp;
	var strTemp;

	Component.bValid = true;
	Component.strName = strComponentName;
	Component.strMinimum = "";
	Component.strRecommended = "61.76";
	Component.strExtraData1 = strCardName;
	Component.strExtraData2 = strVendorId;

	Component.strRecommended = cleanVersionString( Component.strRecommended);

	arrTemp = strDetectedVertion.split(".");
	strTemp = arrTemp[arrTemp.length-1]; // the minor version

	if(strTemp.length < 3 )
	{	// a new type of version. we do not handle it.
		Component.bValid = false;
		return Component;
	}

	Component.strDetected = strTemp.substring(0,strTemp.length-2);
	Component.strDetected += ".";
	Component.strDetected += strTemp.substring(strTemp.length-2, strTemp.length);
	Component.strDetected = cleanVersionString(Component.strDetected);
	
	if(compareVersions( Component.strDetected, Component.strRecommended, 0, 0 ) == 2 )
	{
		Component.iStatus = 2;
	}
	else
	{
		Component.iStatus = 3;
	}
	
	return Component;
}

/************************************************************************
Get_RADEON_DisplayAdapterComponent
	Return a structComponentData with NVIDIA data in it.
	The data in the component is as follows:
		bValid - true if everything is OK
		strName - holds the strComponentName
		iStatus - can be 2 (Detected < Recommended) or 3 (Recommended <= Detected)
		strMinimum - empty
		strRecommended - 6.14.10.6396 for win XP/win 2K. 4.14.01.9113 for win ME/win 98
		strDetected - The detected version
		strExtraData1 - holds strCardName
		strExtraData2 - holds the strVendorId
Input:	
	strComponentName: The name of the component
	strCardName:	The name of the card
	strDetectedVertion:	The dected version
	strVendorId: The vendor ID
	strDetectedOS:	The detected OS dependency
Return Value:
	structComponentData
************************************************************************/
function Get_RADEON_DisplayAdapterComponent( strComponentName, strCardName, strDetectedVertion, strVendorId, strDetectedOS )
{
	var Component = new structComponentData(false, "", 0, "", "", "", "");
	var arrTemp;
	var strTemp;

	Component.bValid = true;
	Component.strName = strComponentName;
	Component.strMinimum = "";
	Component.strDetected = strDetectedVertion;
	Component.strExtraData1 = strCardName;
	Component.strExtraData2 = strVendorId;

	if(compareVersions( 2, strDetectedOS, 0, 0) == 2 )
	{  // XP
		Component.strRecommended = "6.14.10.6458";
	}
	else
	{ // 9X
		Component.strRecommended = "4.14.01.9138";
	}

	Component.strRecommended = cleanVersionString( Component.strRecommended);
	Component.strDetected = cleanVersionString( Component.strDetected);
	
	if(compareVersions( Component.strDetected, Component.strRecommended, 0, 0 ) == 2 )
	{
		Component.iStatus = 2;
	}
	else
	{
		Component.iStatus = 3;
	}
	
	return Component;
}

/************************************************************************
FormatOSRequest
	returns a formated OS request. Handles only one the fist request. 
	[[a.b.c.d.e]1*] -> a.b.c.d.e
Input:	
	strDBReqest:	The OD request as appear in AoD database
Return Value:
	strFormatedRequest
************************************************************************/
function FormatOSRequest(strDBReqest)
{
	var strFormatedRequest;
	var iStartIndex;
	var iEndIndex;
	var arrTest;

	// read the version request. This request must be in the strMinimum field
	iStartIndex = strDBReqest.indexOf("[", 1);
	iEndIndex = strDBReqest.indexOf("]", iStartIndex+1);
	
	if(iStartIndex+1 >= iEndIndex)
	{ // invalid request
		return "";
	}

	strFormatedRequest = strDBReqest.substr(iStartIndex+1,iEndIndex-iStartIndex-1);

	arrTest = strFormatedRequest.split(".");
	if(arrTest.length != 5)
	{ // invalid request	
		strFormatedRequest = "";
	}

	return strFormatedRequest;
}

/************************************************************************
IsOSInRange
	Checks if strOS, is in strRange.
Input:	
	strRange:	a string in the foemat of a.b.c.d.e
	strOs:	a string of the detected OS version
Return Value:
	true on success 
************************************************************************/
function IsOSInRange(strRange, strOS)
{
	var arrRange;
	var strTemp;

	arrRange = strRange.split(".");
	if(arrRange.length != 5)
	{	// invalid format
		return false;
	}
	
	strTemp = "" + arrRange[0] + "." + arrRange[1] + "." + arrRange[2];
	if(compareVersions(strOS,strTemp, 0, 0) == 2 )
	{	//strOS < strTemp
		return false;
	}

	if(arrRange[3] == "-1")
	{
		arrRange[3] = 9999;
	}
	if(arrRange[4] == "-1")
	{
		arrRange[4] = 9999;
	}

	strTemp = "" + arrRange[0] + "." + arrRange[3] + "." + arrRange[4];
	if(compareVersions(strOS,strTemp, 0, 0) == 1 )
	{	//strOS > strTemp
		return false;
	}

	return true;
}

/************************************************************************
getVersionFromComponentsArray
Input:	
	strName:		A component name to search for
	arrComponents:	An array of strings in the format of "Name=Version"

Return Value:
	strVersion:	The version of the component
************************************************************************/
function getVersionFromComponentsArray( strName, arrComponents)
{
	var iIndex;
	var strCurrentName = "";
	var strCurrentVersion = "";

	for(iIndex=0; iIndex<arrComponents.length; iIndex++)
	{
		strCurrentName = getOnlyName(arrComponents[iIndex]);
		strCurrentVersion = getVersion(arrComponents[iIndex]);
		
		if(strCurrentName==strName )
		{
			return strCurrentVersion;
		}
	}

	return "";
}

/************************************************************************
getIndexOfComponentInComponentsArray
Input:	
	strName:		A component name to search for
	arrComponents:	An array of strings in the format of "Name=Version"

Return Value:
	the index of the component. -1 If the componnet was not found
************************************************************************/
function getIndexOfComponentInComponentsArray( strName, arrComponents)
{
	var iIndex;
	var strCurrentName = "";
	var strCurrentVersion = "";

	for(iIndex=0; iIndex<arrComponents.length; iIndex++)
	{
		strCurrentName = getOnlyName(arrComponents[iIndex]);
		
		if(strCurrentName==strName )
		{
			return iIndex;
		}
	}

	return -1;
}


/************************************************************************
cleanVersionString
Input:	
	strVer:		A string with version

Return Value:
	A string without all the unnecessary characters  ("ab.4.3.5drf" -> "4.3.5")
************************************************************************/
function cleanVersionString(strVer)
{
	var strClean = "";
	var iIndex;
	var chCurrent;
	var iStatus = 0; //0: Before Start, 1: Number Found, 2: Dot Found
	strVer = "" + strVer;
	
	for(iIndex=0;iIndex<strVer.length;iIndex++ )
	{
		chCurrent = strVer.charAt(iIndex);
		if(iStatus==1 && chCurrent=='.')
		{	// if the '.' is not after a number treat it as a letter
			iStatus = 2;
			strClean += chCurrent;
		}
		else if(chCurrent<='9' && chCurrent>='0')
		{  // number
			iStatus = 1;
			strClean += chCurrent;
		}
		else if(iStatus!=0) // letter after the start
		{
			break;
		}
	}
	
	if(iStatus == 2)
	{	// remove last '.'
		strClean= strClean.slice(0,strClean.length-1);
	}

	return strClean;
}

/************************************************************************
AlignSubVerLen
   Adds 0 to the end of strVer1 so its size will fit sreVer2.
   E.g 
      strVer1 = 5
      sreVer2 = 231
      return string = 500

************************************************************************/
function AlignSubVerLen( strVer1, sreVer2 )
{
   var strRet = strVer1;
   while(strRet.length < sreVer2.length)
   {
      strRet = strRet + "0";
   }

   return strRet;
}

/************************************************************************
compareVersions
Input:	
	strVer1:		A string with version
	strVer2:		A string with version
   iDepth:     The number of components versions to check. 0 means all
   icompareType: 0 - Normal
                 1 - Align versions (input ver1=5.20.1, ver2=5.2.10 is converted to
                     ver1=5.20.10, ver2=5.20.10)

Return Value:
	0: strVer1 == strVer2
	1: strVer1 >  strVer2
	2: strVer1 <  strVer2
************************************************************************/
function compareVersions(strVer1, strVer2, iDepth, icompareType) 
{
	var iIndex;
   var iEnd;

	strVer1 = cleanVersionString(strVer1);
	strVer2 = cleanVersionString(strVer2);

	var arrVer1 = strVer1.split(".");
	var arrVer2 = strVer2.split(".");

   // set compare type
   if(icompareType==1)
   {
      iEnd = arrVer1.length;
      if( arrVer2.length < arrVer1.length)
      {
         iEnd = arrVer2.length;
      }

      for(iIndex=0;iIndex<iEnd;iIndex++)
      {
         if(arrVer1[iIndex].length < arrVer2[iIndex].length)
         {
            arrVer1[iIndex] = AlignSubVerLen(arrVer1[iIndex], arrVer2[iIndex]);
         }
         if(arrVer2[iIndex].length < arrVer1[iIndex].length)
         {
            arrVer2[iIndex] = AlignSubVerLen(arrVer2[iIndex], arrVer1[iIndex]);
         }        
      }
   }

	var iCurrent1;
	var iCurrent2;

   if(iDepth>0 && iDepth<arrVer1.length)
   {
      arrVer1 = arrVer1.slice(0,iDepth);
   }
   if(iDepth>0 && iDepth<arrVer2.length)
   {
      arrVer2 = arrVer2.slice(0,iDepth);
   }

	for(iIndex=0;iIndex<arrVer1.length;iIndex++)
	{
		if(arrVer2.length-1<iIndex)
		{
			return 1;
		}

		iCurrent1 = Number(arrVer1[iIndex]);
		iCurrent2 = Number(arrVer2[iIndex]);

		if(iCurrent1 > iCurrent2)
		{
			return 1;
		}

		if(iCurrent1 < iCurrent2)
		{
			return 2;
		}
	}

	if(arrVer1.length < arrVer2.length )
	{
		return 2;
	}

	return 0;
}

/************************************************************************
getOnlyName
Input:	
	strInput:	A string in the format of "Name=Version"

Return Value:
	strName:	The name in the input string
************************************************************************/
function getOnlyName(strInput) 
{
	strInput = "" + strInput;

	var strName = "";
	// check that the "=" sign is in the middle of the input string
	var iIndex = strInput.indexOf("=");

	if((iIndex < 1) || (iIndex>strInput.length-1) )
	{
		return strName;
	}

	strName = strInput.substring(0,iIndex);   
	return strName;
}

/************************************************************************
getVersion
Input:	
	strInput:	A string in the format of "Name=Version"

Return Value:
	strVersion:	The version in the input string
************************************************************************/
function getVersion(strInput)
{
	strInput = "" + strInput;
	var strVersion = "";
	// check that the "=" sign is in the middle of the input string
	var iIndex = strInput.indexOf("=");

	if((iIndex < 1) || (iIndex>strInput.length-1) )
	{
		return strVersion;
	}

	strVersion = strInput.substring(iIndex+1,strInput.length);   
	return strVersion;
}

/************************************************************************
AddMissingComponentsToPcArray
Input:	
   arrDBComponents [out]: Array of components from database
	arrPCComponents [in,out]:	Array of known PC components
Return Value:
	changes the input arrPCComponents parameter
************************************************************************/
function AddMissingComponentsToPcArray(arrDBComponents, arrPCComponents)
{
   var strTemp;
   var i;

   for(var iIndex=0; iIndex<arrDBComponents.length; iIndex++)
   {
      strCurrentName = getOnlyName(arrDBComponents[iIndex]);
      strTemp = strCurrentName;

      // Check unneeded components
      if( strCurrentName=="OS"         ||
         strCurrentName=="DirectPlay"  ||
         strCurrentName=="DirectXMedia"||
         strCurrentName=="Indeo Audio"    )
      {
         continue;
      }
      
      // remove Min and Req extensions
      if( strTemp.length >= 3 )
      {
         strTemp = strCurrentName.substr( strCurrentName.length - 3 );
      }
      if("Min"==strTemp || "Rec"==strTemp)
      {
         strCurrentName = strCurrentName.substr( 0, strCurrentName.length - 3 );
      }

      // Search for the componen in arrPCComponents
      i = getIndexOfComponentInComponentsArray(strCurrentName, arrPCComponents);
      if(i == -1 )
      {  // add the component
         arrPCComponents[arrPCComponents.length] = strCurrentName + "=";
      }
   }
}