<!--
//Including this file on your page calls include/log.php which
//log visits to this page and the page that referred them,
//And logs clicks to all anchor tags
//
//Also in your html with javascript, you can call recordclick(string) 
//to write something to the log file which adds line feed, time, and indent.
//or call recordClick2(string) to add comment without space,line feed, or time.
//or call recordClick3(string) to add comment without time.
//
//It also prevents loging if someone views a cached page on their harddrive.

//record that this page was viewed.
var loc=''+window.location;
if (loc.indexOf('file')==-1){ //if it isn't someone running this page as a file on their computer.
  document.write('<img id="runphp" src="http://math.ucsd.edu/~cdeotte/include/log.php?');
  if (document.referrer){
    var reference=(''+document.referrer).replace(/&/g,'|');
    document.write('ref='+reference+'&');
  }
  loc=loc.replace(/&/g,'|');
  document.write('req='+loc+'&sid='+(new Date()).getTime()+'" width=0 height=0/>'); //use image to call log.php

//record which anchors are clicked.
var anchors=document.getElementsByTagName('a');
for (var i=0;i<anchors.length;i++)
  anchors[i].onmousedown=function(){recordClick(this.href);};

}; //end file check.

function recordClick(what){
  what=what.replace(/&/g,'|');
  what=what.replace(/#/g,'=');
  document.getElementById('runphp').src='http://math.ucsd.edu/~cdeotte/include/log.php?sid='+(new Date()).getTime()+'&rec='+what; //USE IMAGE
  //ajax('http://math.ucsd.edu/~cdeotte/include/log.php?rec='+what); //USE AJAX
};

function recordClick2(what){
  what=what.replace(/&/g,'|');
  document.getElementById('runphp').src='http://math.ucsd.edu/~cdeotte/include/log.php?sid='+(new Date()).getTime()+'&rec2='+what; //USE IMAGE
}

function recordClick3(what){
  what=what.replace(/&/g,'|');
  document.getElementById('runphp').src='http://math.ucsd.edu/~cdeotte/include/log.php?sid='+(new Date()).getTime()+'&rec3='+what; //USE IMAGE
}

function ajax(url){
//THis function isn't being used but could be in place of an image src change call.
var page_request = false
if (window.XMLHttpRequest) // if Firefox, Opera 8.0+, Safari
  page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
  try {page_request = new ActiveXObject("Msxml2.XMLHTTP")}  //IE 6.0+
  catch (e){
    try{page_request = new ActiveXObject("Microsoft.XMLHTTP")} //IE 5.5+
    catch (e){return false;};
  }
}
else return false //Ajax not supported.

var bustcache=(url.indexOf("?")!=-1)? "&sid="+new Date().getTime() : "?sid="+new Date().getTime();
//page_request.onreadystatechange=function(){};
page_request.open('GET', url+bustcache, true)
page_request.send(null)
}
-->
