var clicktracking = new sack('index.php');

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmouseup = getMouseXY;

var thisdate = new Date();
var sec = Math.round(thisdate.getTime()/1000);

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0


// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
  // eliminate frenzy clicking
  var thisdate = new Date();
  var sec2 = Math.round(thisdate.getTime()/1000);
  if (sec2 == sec)
    return;
  else
    sec = sec2;  


  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  


  // window size
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }   
  
  clicktracking.setVar("ct", 1);
  clicktracking.setVar("x", tempX);
	clicktracking.setVar("y", tempY);
  clicktracking.setVar("w", myWidth);
	clicktracking.setVar("h", myHeight);
  clicktracking.setVar("url", document.location.href);

	clicktracking.method = 'GET';
	clicktracking.runAJAX();
//	clicktracking.runResponse();

  return true
}
