$=function(id) {
 var element;
 return (element=document.getElementById(id)) ? element : false;
}

Array.prototype.indexOf = function(e) {
  var i = this.length;
  for (i; i > -1 && e != this[i]; i--);
  return i;
}

var Ajax = {

  enabled: function() {
    var source = false;
     try {source = new XMLHttpRequest();} catch(e) {
    	try {	source = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {
    		try { source=new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {
    			source = false;
    			}
    		}
    	} 

    this.enabled = function() {
      return !!source;
    }

    return !!source;
  },

 request: function(url, callback) {
   this.url=url;
   this.callback=callback;

   if(!this.enabled()) {
    this.callback('error');
    return false;
    }

     try {this.source = new XMLHttpRequest();} catch(e) {
    	try {	this.source = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {
    		try { source=new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {
    			this.source = false;
    			}
    		}
    	} 

   var ajaxContext=this;
   
   this.source.onreadystatechange=function() {ajaxContext.onReadyState.call(ajaxContext)};
   this.source.open("GET", this.url, true);
   this.source.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   this.source.send(null);
   }
};

Ajax.onReadyState=function() {
 if(this.source.readyState != 4) return;
 if(this.source.status == 200) {
   this.callback(this.source.responseText);
   }
 else this.callback('error');
}

Ajax.upload = function(form, callback) {
  r = 'f' + Math.floor(Math.random() * 99999);
  d = document.createElement('div');
  d.setAttribute('id', r);
  c = callback;
  d.innerHTML = "<iframe width=0 height=0 style='visibility:hidden' name="+r+" onLoad='c(this.contentWindow.document.body.innerHTML, r);this.contentWindow.document.body.innerHTML=null;'></iframe>";
  document.body.appendChild(d);
  form.setAttribute('target', r);
  if (!/ajax_posted/.test(form.action)) {
    form.action += 'ajax_posted';
  }
}