/*
Raxcido.com --> iranian open source world
Name: Ajax Class
Version: 1.0 
Ajax Class made by : Mohammad Rezaei.
Copyright 2009 Nevec Incorporated. All rights reserved.


*/

Ajax = function(){
	this.connection = false;
	this.url=null;
	this.method=null;
	this.status = 0;
	this.response = null;
	this.param = {};
	this.par="";
	this.string = null;
	var $t = this;
	try {
		this.connection=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			this.connection=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			this.connection=new XMLHttpRequest();
		}
	}
}
Ajax.prototype._open = function(method,url){
	
	for(i in this.param){
		this.par += i+"="+this.param[i]+"&";
	}
	date = new Date();
	var time = date.getTime();
	this.par +="time="+time;
	$t=this;
	this.method=method;
	this.url=url;
	if(this.method == 'GET'){	
		this.connection.open(this.method,this.url+"?"+this.par,true);
		this.connection.send(null);
	}else{
		this.connection.open(this.method,this.url,true);
		this.connection.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		this.connection.setRequestHeader("Content-Lenght",this.par.length);
		this.connection.setRequestHeader("Connection","close");
		this.connection.send(this.par);		
	}
	this.connection.onreadystatechange = this.result;
}
Ajax.prototype.onload=function(){};
Ajax.prototype.notFound=function(){};
Ajax.prototype.loading=function(){};
Ajax.prototype.result = function(){
	if($t.connection.readyState==4){
		$t.status = $t.connection.status;
		if($t.status == 200){
			$t.response = $t.connection.responseXML;
			$t.onload();
		}else{
			$t.notFound();
		}
	}else{
		$t.loading();	
	}
};
