jQuery.ping = function(url, params) {
  querystring = '';

  switch (true) {
    case (params instanceof Array):
      querystring = params.join('&');
      break;
    case ((params instanceof Object) && !(params instanceof String)):
      var temp_array = new Array();
      for (var k in params) {
        temp_array.push(k + '=' + params[k]);
      }
      querystring = temp_array.join('&');
      break;
    default: // It's a string.
      querystring = params;
  }
  //alert(url + '?' + querystring);
  var img = new Image();
  img.src = url + '?' + querystring;
}


// when document is ready
jQuery(document).ready(function(){
		// find all links
	jQuery('a').click(function() {
		// only work with absolute links (no relative links) 
		// i.e. links that begin with http
		if (jQuery(this).attr('href').substr(0,4) == 'http') {
			// IP address and href
			//alert("You are leaving the page to go to "+jQuery(this).attr('href'));
			// record this click
			// Call with a string.
      		$.ping('http://readingberkspa.com/linktrack.ashx', 'to='+jQuery(this).attr('href'));
      		}
      		
		});	
});