/* 
 vimAjax v1.0 - simple ajax framework 
 (C)2008 Adam Sobocinski (logic@anubisdev.com) www.vim.pl
 Dual licensed under the MIT and GPL licenses.
*/

function vimAjax() {
  this.req = null
  this.url = null 
  this.data = ""
  this.loading = function(){}
  this.loaded = function(){}
  this.interactive = function(){}
  this.success = function(r){}
  this.error = function(){}
  
  this.init = function(){
    try {
      this.req = new XMLHttpRequest()
    } catch(e1) {
      try {
        this.req = new ActiveXObject('Msxml2.XMLHTTP')
      } catch(e2) {
        try {
          this.req = new ActiveXObject('Microsoft.XMLHTTP')
        } catch(e3) {
          this.req = false
        }
      }
    }   

    var obj = this
    this.req.onreadystatechange = function(){
       switch(obj.req.readyState)
       {
       		case 1: obj.loading(); break
					case 2: obj.loaded(); break
					case 3: obj.interactive(); break
					case 4: if(obj.req.status == 200) obj.success(obj.req.responseText) 
                  else obj.error(obj.req.status) 
       }
    }
   }     
 
  this.handleparams = function(args){
   	for (var p in args){
       if (p == 'data'){
          if(typeof args[p]=="object") this.data = args[p].join("&") 
          else this.data = args[p]
       }
       else this[p] = args[p]
    } 
  }
  
  this.get = function(args){
    this.init()
    this.handleparams(args)   
	  this.req.open('GET', this.url+"?"+this.data, true)
    this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2006 00:00:00 GMT")
		this.req.send(null) 
	}
	
  this.post = function(args){
    this.init()
    this.handleparams(args)   
    this.req.open('POST', this.url, true)
		this.req.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
		this.req.setRequestHeader("Content-length", this.data.length)
		this.req.setRequestHeader("Connection", "close")
		this.req.send(this.data)
	}
	
  $id = function(o){return (typeof o=="string")?document.getElementById(o):o}
	
 	return this
}

function ShowInfo(id) 
{
var x = new vimAjax();
x.get({
    url: "getinfo.php?id="+id,
    success: function(t) { $id("info").innerHTML = t  }
 })
}

$$ = new vimAjax();
