//
//      _______                          .__ .__   .__   .__                 
//      \      \    ____   __ __ _______ |__||  |  |  |  |__|  ____    ____  
//      /   |   \ _/ __ \ |  |  \\_  __ \|  ||  |  |  |  |  | /  _ \  /    \ 
//     /    |    \\  ___/ |  |  / |  | \/|  ||  |__|  |__|  |(  <_> )|   |  \
//     \____|__  / \___  >|____/  |__|   |__||____/|____/|__| \____/ |___|  /
//    =========\/======\/=================================================\/==
//  v0.01 06/JUL/2007 (C) Copyright 2007-2007 Scott D. Yelich SOME RIGHTS RESERVED
// .,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.-*~'`^`'~*-,._.,-*~'`^`'~*-,. 
//
//
//  LICENSE:  Creative Commons Attribution 3.0 License.
//  SEE:      http://creativecommons.org/licenses/by/3.0/
//


//  
//  AjaxCounter.js
//  

//  Mon Aug  6 22:15:34 EDT 2007, v0.01 sdy

//  requires Sajax.js

var AjaxCounter = function() {  

  var ajax = 0;
  var self = 0;

  this.handle = function ( text ) {
    while(text.charAt(text.length-1) == " " ) {  text = text.substring(0,text.length-1); }
    while(text.charAt(text.length-1) == "\n" ) {  text = text.substring(0,text.length-1); }
    var data = text.split(/\s|\n/); // \n is a new AJAX return coming in at the same time!
    var id = data[0];
    swdiv = document.getElementById(id);
    if (swdiv) {
      var count = data[1];
      swdiv.innerHTML = count;
      swdiv.style.background="#C0C0C0";
    }
  }

  this.hit = function(id) {
    ajax.request("http://www.neurillion.com/p/33/exec/counter_ajax_v2",self.handle,id);
    swdiv = document.getElementById(id);
    if (swdiv) {
      swdiv.style.background="#FF0000";
    }
  }

  this.init = function() {
    self  = this;  //  w00t
    ajax = new Sajax();
  }

  this.init();

}
