/////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Network Associates Corporation
// McAfee.com Free Scan Web page Java Script functions
/////////////////////////////////////////////////////////////////////////////////
// Author: Ramy Eldesoky
// Created: 10/14/2002
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
function GetIEVersion()
{
	var userAgent, ieLocation, retValue;
	var ieSignature;

	retValue = 0;
	ieSignature = "MSIE";
	
	userAgent  = navigator.userAgent;

	ieLocation = userAgent.search(ieSignature);
	
	if (ieLocation >= 0)
	{
		//check third party browsers signatures
		var userAgentTokens, sPostFix;
		
		userAgentTokens = userAgent.split(")");

		if (userAgentTokens.length > 0)
		{
			sPostFix= userAgentTokens[1];
		}
		
		if ( 0 == sPostFix.length )
		{// no third party browser signature
			ieLocation = ieLocation + ieSignature.length + 1; // skip the signature to read the version number
			
			userAgent = userAgent.substr(ieLocation);
			
			retValue = parseFloat(userAgent);
		}
	}

	return retValue;
}
/////////////////////////////////////////////////////////////////////////////////
// Check that browser is compatible
/////////////////////////////////////////////////////////////////////////////////
if (GetIEVersion() < 5)
{
	document.location.replace("NotIE5.htm");
}
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
function init()
{
	
	document.title = strPageTitle;

    idScanType[0].innerHTML = strDriveC;
    idScanType[1].innerHTML = strMyDocuments;
    idScanType[2].innerHTML = strWindowsFiles;

	idTitleInfectedFiles.innerHTML	= strTitleInfectedFiles;
	idTitleScanStatus.innerHTML		= strTitleScanStatus;
	idTitleScanLocation.innerHTML	= strTitleScanLocation;
	
	var sHostName = document.location.href.toLowerCase();
	
	idUpsellVSO.innerHTML = strUpsellVSO;
	idUpsellTitle.innerHTML = strUpsellTitle;
	idUpsellVSOBuy.innerHTML = strUpsellVSOBuy

	idFooter.style.display = "";

	txtFiles.innerHTML				= "<b>" + strLabelScannedFiles  + ":</b> 0";
	txtInfected.innerHTML			= "<b>" + strLabelInfectedFiles + ":</b> 0";
	txtInformation.innerHTML		= "<b>" + strLabelInformation   + ":</b> " + strInitialInformation;

	txtLog.innerHTML = InitTextLog();
	idContents.style.display		= "";
	
	gTimerID = 0;

	showAVInfoMessage (INFO_DISABLE_OTHER_AV ,false);
}
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
function trimFilePath( szFilePath, nMaxLength )
{
	var arPatternArray;
	var nMinLength = 6;	// Constant...
	
	if (szFilePath.length <= nMaxLength)
		return szFilePath;
	
	if( nMinLength >= nMaxLength )
		return szFilePath.substring( 0, 3 ) + "...";
	
	if( szFilePath.Length <= nMaxLength )
		return szFilePath;
	
	arPatternArray = szFilePath.split( "\\" );
	
	do
	{
		if( 1 == arPatternArray.length )
		{
			return arPatternArray[0].substring( 0, nMaxLength - 3 ) + "...";
		}
		else if( 2 == arPatternArray.length )
		{
			return arPatternArray[0] + "\\" + arPatternArray[1].substring( 0, nMaxLength - 4 - arPatternArray[0].length ) + "...";
		}

		arPatternArray = spliceArray( arPatternArray, (arPatternArray.length/2), 1, "..." ); // insert "..." instead of the middle folder
		
		if( arPatternArray.join( "\\" ).length > nMaxLength-3 ) // check the length of the Path
		{// still longer than needed
			arPatternArray = spliceArray( arPatternArray, (arPatternArray.length/2), 1, null );  // remove the inserted "..."
		}
		else
		{// 
			return arPatternArray.join( "\\" );
		}
		
	} while( true );
	
	return szRetFilePath;
}
/////////////////////////////////////////////////////////////////////////////////
// This is to support IE 5.0 browser
/////////////////////////////////////////////////////////////////////////////////
function spliceArray(myArray, start, count, replacement)
{
	var newArray = new Array();

	if (null == replacement)
		return newArray.concat (myArray.slice(0,start), myArray.slice(start+count));
	else
		return newArray.concat ( myArray.slice(0,start), replacement, myArray.slice(start+count) ) ;
}
