function RefreshLinksWithReferrer()
{
	for ( nIndex = 0; nIndex < document.links.length; nIndex++)
	{
//		if (document.links(nIndex).name=="vreferrer")
//		{
		if ( (document.links[nIndex].href.indexOf("@")==-1) &&
		     (document.links[nIndex].href.indexOf(".exe")==-1) )
		{
			strAdjacent = document.location.search;

			if ( document.links[nIndex].search.length != 0 &&
				 strAdjacent != 0)
			{
				strAdjacent = "&"+ strAdjacent.substr(1, strAdjacent.length-1);
				document.links[nIndex].search += strAdjacent;
			}
			else
			{
				document.links[nIndex].search += document.location.search;
			}
		}
	};
}

var vrefs = new Array();

vrefs[0] = new Array("hellfire.exe", "adwords");
vrefs[1] = new Array("firestorm.exe","001", "003", "004", "005", "adwords");
vrefs[2] = new Array("firemagic.exe", "001", "003", "004", "005", "5stars", "aw","ukfire", "adwords", "dissoft");
vrefs[3] = new Array("earth3d.exe", "001","003","004", "adwords");
vrefs[4] = new Array("mars3d.exe", "001","003","004", "adwords");
vrefs[5] = new Array("moon3d.exe", "001","003","004","adwords");
vrefs[6] = new Array("saturn3d.exe", "001","003","004","adwords");
vrefs[7] = new Array("jupiter3d.exe", "001","003","004","adwords");
vrefs[8] = new Array("galaxy3d.exe", "001","003","004","adwords");

function IsValidVreferrer(strVref, strProduct)
{
	for ( nProduct = 0; nProduct < vrefs.length; nProduct++ )
	{
		if ( vrefs[nProduct][0] == strProduct )
		{
			for ( nVref = 1; nVref < vrefs[nProduct].length; nVref++)
			{
				if ( vrefs[nProduct][nVref] == strVref )
				{
					return true;
				}
			}
		}
	}
 
	return false;
}

function GetVreferrer()
{
	var strVRefID = "";
	var strVrefParam = "vreferrer=";
	var strParam = document.location.search.toLowerCase();
	var nBegin = strParam.indexOf(strVrefParam);
	

	if ( nBegin != -1 )
	{
		nBegin += strVrefParam.length;
		strVRefID = strParam.substring ( nBegin, strParam.length);
		
		var i = 0;
		while( (strVRefID.charAt(i) >= 'a' && strVRefID.charAt(i) <= 'z') ||
			(strVRefID.charAt(i) >= 'A' && strVRefID.charAt(i) <= 'Z') ||
			(strVRefID.charAt(i) >= '0' && strVRefID.charAt(i) <= '9') )
		{
			i++;
		}
		strVRefID = strVRefID.substring ( 0, i );
	}
	return strVRefID;
}

strURLBaseLinkStart = "<a href='http://www.fpsoftlab.com/";

function DownloadProduct(strFile)
{

	strVrefParam = "vreferrer=";
	strParam = document.location.search.toLowerCase();
	nBegin = strParam.indexOf(strVrefParam);
	
	if ( nBegin != -1 )
	{
		strVRefID = GetVreferrer();
		
		if ( (strVRefID != "") && IsValidVreferrer(strVRefID, strFile) )
		{
			document.write(strURLBaseLinkStart + strVRefID + "/" + strFile + "'>");
		}
		else
		{
			document.write(strURLBaseLinkStart + strFile + "'>");
		}
	}
	else
		document.write(strURLBaseLinkStart + strFile + "'>");
}
