var Request = new Object();



Request.send = function(urls, method, callback, data, urlencoded) {

	

	var req;	

	if(window.XMLHttpRequest){

		req = new XMLHttpRequest();

	} else if (window.ActiveXObject) {

		req = new ActiveXObject("Microsoft.XMLHTTP");

	}



     req.onreadystatechange = function() {

		if(req.readyState == 4){  // only if req shows "loaded"

       
			if(req.status < 400){   // only if "OK"

				(method=="POST") ? callback(req) : callback(req,data);

			}else{

				alert("There was a problem loading data :\n" + req.status+ "/" + req.statusText);

			}

		}

	}



	if(method=="POST"){

		req.open("POST", urls, true);

		if (urlencoded) req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

		req.send(data);

	}else{

		req.open("GET", urls, true);

		req.send(null);

	}

  

	return req;

}



Request.sendRawPOST = function(url, data, callback) {

	Request.send(url, "POST", callback, data, false);

}



Request.sendPOST = function(url, data, callback) {

	Request.send(url, "POST", callback, data, true);

}



Request.sendGET = function(url, callback, args) {

	return Request.send(url, "GET", callback, args);

}

	String.prototype.trim=trim;
	function trim() {
	  return this.replace(/^\s+|\s+$/g, "");
	}


	function insertOption(mText, mValue, to){

		for(var i=0; i<to.options.length; i++){

			if(to.options[i].value == mValue){

				return;

			}

		}

		to.options[to.options.length] = new Option(mText, mValue, false, false);

	}
	
	function setOption(mText, mValue, to){

		for(var i=0; i<to.options.length; i++){

			if(to.options[i].value == mValue){

				return;

			}

		}

		to.options[to.options.length] = new Option(mText, mValue, false, true);

	}


