
function resolver ()
{
  document.write ( getButtonCode () );
}

function getButtonCode ()
{
  // Global variables (declared without "var"):
  msg = '[<i>none</i>]';
  srch = 0;
  url = '[no URL]';

  reslt = '';

// Referrer Analysis functionality:
  if (document.referrer)
  {
	var ref = document.referrer;
	var pcs = ref.split('/');
	url = pcs[2];

	if ( url.indexOf('\.ares\.') > -1 ) {
	  msg = 'ares web site' ;
	  srch = -1;
	}
	else if ( url.indexOf('ares\.') > -1 ) {
	  msg = 'ares web site' ;
	  srch = -1;
	}
	else 

	if ( url.indexOf('\.google\.') > -1 ) {
	  msg = 'Google' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.yahoo\.') > -1 ) {
	  msg = 'Yahoo!' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.bing\.') > -1 ) {
	  msg = 'Bing' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.ask\.') > -1 ) {
	  msg = 'Ask' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.live\.') > -1 ) {
	  msg = 'Windws Live' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.mywebsearch\.') > -1 ) {
	  msg = 'MyWebSearch' ;
	  srch = 1;
	}
	else if ( url.indexOf('search\.aol\.') > -1 ) {
	  msg = 'Aol' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.altavista\.') > -1 ) {
	  msg = 'Altavista' ;
	  srch = 1;
	}
	else if ( url.indexOf('search\.msn\.') > -1 ) {
	  msg = 'MSN Search' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.virgilio\.it') > -1 ) {
	  msg = 'Virgilio.it' ;
	  srch = 1;
	}
	else if ( url.indexOf('infospace\.') > -1 ) {
	  msg = 'InfoSpace' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.avantfind\.') > -1 ) {
	  msg = 'AvantFind' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.dogpile\.') > -1 ) {
	  msg = 'DogPile' ;
	  srch = 1;
	}
	else if ( url.indexOf('onet\.pl') > -1 ) {
	  msg = 'Onet.pl' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.tiscali\.') > -1 ) {
	  msg = 'Tiscali' ;
	  srch = 1;
	}
	else if ( url.indexOf('search\.netscape\.') > -1 ) {
	  msg = 'Netscape' ;
	  srch = 1;
	}
	else if ( url.indexOf('yandex\.') > -1 ) {
	  msg = 'Yandex' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.search\.com') > -1 ) {
	  msg = 'Search.com' ;
	  srch = 1;
	}
	else if ( url.indexOf('sogou\.') > -1 ) {
	  msg = 'SoGou' ;
	  srch = 1;
	}
	else if ( url.indexOf('baidu\.') > -1 ) {
	  msg = 'Baidu' ;
	  srch = 1;
	}
	else if ( url.indexOf('seznam\.') > -1 ) {
	  msg = 'Seznam' ;
	  srch = 1;
	}
	else if ( url.indexOf('ixquick\.') > -1 ) {
	  msg = 'ix quick' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.webcrawler\.') > -1 ) {
	  msg = 'WebCrawler' ;
	  srch = 1;
	}
	else if ( url.indexOf('lycos\.') > -1 ) {
	  msg = 'Lycos' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.soso\.') > -1 ) {
	  msg = 'SoSo' ;
	  srch = 1;
	}
	else if ( url.indexOf('goodsearch\.') > -1 ) {
	  msg = 'GoodSearch' ;
	  srch = 1;
	}
	else if ( url.indexOf('clusty\.') > -1 ) {
	  msg = 'Clusty' ;
	  srch = 1;
	}
	else if ( url.indexOf('earthlink\.') > -1 ) {
	  msg = 'Earth Link' ;
	  srch = 1;
	}
	else if ( url.indexOf('hotbot\.') > -1 ) {
	  msg = 'Hotbot' ;
	  srch = 1;
	}
	else if ( url.indexOf('arianna\.libero\.it') > -1 ) {
	  msg = 'Arianna' ;
	  srch = 1;
	}
	else if ( url.indexOf('Interia\.pl') > -1 ) {
	  msg = 'Interia.pl' ;
	  srch = 1;
	}
	else if ( url.indexOf('centrum\.cz') > -1 ) {
	  msg = 'Centrum.cz' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.alltheweb\.com') > -1 ) {
	  msg = 'AllTheWeb' ;
	  srch = 1;
	}
	else if ( url.indexOf('excite\.') > -1 ) {
	  msg = 'Excite' ;
	  srch = 1;
	}
	else if ( url.indexOf('searchalot\.') > -1 ) {
	  msg = 'Searchalot' ;
	  srch = 1;
	}
	else if ( url.indexOf('eniro\.se') > -1 ) {
	  msg = 'Eniro Svrge' ;
	  srch = 1;
	}
	else if ( url.indexOf('stumbleupon\.') > -1 ) {
	  msg = 'Stumbleupon' ;
	  srch = 1;
	}
	else if ( url.indexOf('bluewin\.ch') > -1 ) {
	  msg = 'bluewin.ch' ;
	  srch = 1;
	}
	else if ( url.indexOf('\.mysearch\.') > -1 ) {
	  msg = 'MySearch' ;
	  srch = 1;
	}
	else if ( url.indexOf('copernic\.') > -1 ) {
	  msg = 'Copernic' ;
	  srch = 1;
	}
	else if ( url.indexOf('toile\.') > -1 ) {
	  msg = 'Toile du Qc' ;
	  srch = 1;
	}
	else if ( url.indexOf('sapo\.') > -1 ) {
	  msg = 'Sapo' ;
	  srch = 1;
	}
	else if ( url.indexOf('alexa\.') > -1 ) {
	  msg = 'Alexa' ;
	  srch = 1;
	}
	else if ( url.indexOf('sify\.') > -1 ) {
	  msg = 'Sify' ;
	  srch = 1;
	}
	else if ( ( url.indexOf('\.att\.net' ) > -1 ) &&
	          ( url.indexOf('page=search') > -1 ) ) {
	  msg = 'AT&T Search' ;
	  srch = 1;
	}
	else {
	  msg = '[<i>other</i>]';
	  srch = 0;
	}
  }

// NOW CREATE THE APPROPRIATE BUTTON:

  // Write the beginning of the <div class="contentleft"> contents:
  reslt += '<p>';

  // Write first part of the anchor:
  reslt += '<a href="downloads/' ;

  if ( srch > 0 )	// Search engine
  { // -- use alternate:
	reslt += 'Ares_Installer.exe' ;
  }

  else if ( srch < 0 )	// ares web site
  { // -- use default:
	reslt += 'Ares_Setup.exe' ;
  }

  else			// neither, incl. no referrer
  { // -- use default:
	reslt += 'Ares_Setup.exe' ;
  }

  // Write the rest of that anchor:
  reslt += '" id="ares-download-btn">' ;

  // Now write the rest of <p> contents:
  reslt += '<img alt="Ares Download" title="Ares Download" ' ;
  reslt += 'name="Ares-Download" src="images/ares-download-btn.png" ' ;
  reslt += '/></a></p>' ;

  return reslt;
}

