/*###########################
#           Ajax            #
###########################*/
function createRequestObject(){
	var ro;
	try{
		ro = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(err){
			ro = null;
		}
	}
	if(!ro && typeof XMLHttpRequest != "undefined")
		ro = new XMLHttpRequest();
	return ro;
}

function loader(method, url, display, vars, loading, loadingaddr, time){
	var http = false;
	// Connect to XML channel **********
	var http = createRequestObject();
	// Set method **********************
	show(display);
	if (method == "GET"){
		http.open(method, url+"?"+vars, true);
		vars = "";
	}else{
		http.open(method, url, true);
		http.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	}		
	if(loading == 1){
		if(loadingaddr)
			var img = loadingaddr;
		else
			var img = 'http://iossd.org/theme/green/img/loading.gif';
		document.getElementById(display).innerHTML = '<img src=' + img + '>';
	}
	http.onreadystatechange = function staticResponse(){
					if(http.readyState == 4){
						if(http.status == 200){
							var helloMessage = http.responseText;
							document.getElementById(display).innerHTML = helloMessage;
							if(time != null)
										    //loader(method, url, display, vars, loading, loadingaddr, time)
								tagtime = setTimeout("loader('" + method + "', '" + url + "', '" + display + "', '" + vars + "', '" + loading + "', '" + loadingaddr + "', '" + time + "')", time);
						}else
							document.getElementById(display).innerHTML = "<IMG CLASS=blur STYLE=\"cursor : pointer;\" TITLE=\"Reload Please...\" SRC=http://iossd.org/theme/green/img/ajax_error.gif ONCLICK=\"loader('POST', '" + url + "', '" + vars + "', '" + display + "', 1);\">";
					}
				};
	http.send(vars);
}