// initialize variables:
var scriptLoc = "http://www.harmanmusicgroup.com/cgi-bin/stats.pl";
var first = 0;

// ------------------------------------------------------------------
// Gather JS variables and add them to scriptLoc:
// -------------------------------------------------------------------

// Is javascript enabled?
  addVar('javascript', "true");

// Did the visitor come from a link on another page?
  if (document.referrer) {
  	equ = /=/g;
  	que = /\?/g;
 	ampersand = /\&/g;
  	referrer = document.referrer.replace(equ, "<equals>");
  	referrer = referrer.replace(que, "<que>");
  	referrer = referrer.replace(ampersand, "<amp>");
  	addVar('referrer', referrer);}

// Log the URL of the current page
  addVar('document_location', window.location);

// Are cookies enabled?
  document.cookie = "test=pass";
  if (document.cookie) {cookies = "true";}
  else {cookies = "false";}
  addVar('cookies', cookies);

// Screen resolution & color depth
  screenWidth=screen.width
  screenHeight=screen.height
  screenColors=screen.colorDepth
  resolution = (screenWidth +"x"+ screenHeight);
  addVar('resolution', resolution);
  addVar('colors', screenColors);

// Language and Country
  var type=navigator.appName
  if (type=="Netscape") {var lang = navigator.language} 
  else {var lang = navigator.userLanguage}
  var lang = lang.substr()
  addVar('language', lang);

// Get the visitor's operating system using the checkOS function
// For some reason, Netscape won't let you use the variable directly in the addVar() function,
// so I have to go through each option.  Weird.
  if(navigator.userAgent.indexOf('IRIX') != -1) { addVar("os", "Irix"); }
  else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('98') != -1)) { addVar("os", "Windows98");}
  else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) { addVar("os", "Windows95"); }
  else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('Me') != -1)) { addVar("os", "WindowsME");}
  else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('2000') != -1)) {addVar("os", "Windows2000");}
  else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('NT') != -1)) { addVar("os", "WindowsNT");}
  else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('CE') != -1)) { addVar("os", "WindowsCE");}
  else if(navigator.userAgent.indexOf('Win') != -1)  { addVar("os", "Windows3.1"); }
  else if(navigator.userAgent.indexOf('Unix') != -1)  { addVar("os", "Unix"); }
  else if(navigator.userAgent.indexOf('Linux') != -1)  { addVar("os", "Linux"); }
  else if(navigator.userAgent.indexOf('Mac') != -1) { addVar("os", "Macintosh"); }
  else { addVar("os", "other"); }

// Get the browser name.  Once again, Netscape doesn't like this, so it
// is abbreviated.
//  if (document.all) {var version=/MSIE \d+.\d+/}
//  if (!document.all) {var browser = (navigator.appName+" "+navigator.userAgent);}
//  else {var browser = (navigator.appName +" "+ navigator.appVersion.match(version));}
  addVar('browser', navigator.appName);

// print a line in the html document which points to the cgi script and includes all JS variables:
document.writeln('<img src="' +scriptLoc+ '" border=0 width=1 height=1>');

// function to add collected variables to the script URL:
function addVar (name, value) {
	if (first == 1) {
		scriptLoc = (scriptLoc+"&"+name+"="+value);
	} else {
		scriptLoc = (scriptLoc+"?"+name+"="+value);
		first = 1;
	}
}
