
function ajaxCreateHTTP(){
	try{
		xmlhttp	= window.XMLHttpRequest ? new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e){
		xmlhttp	= false;
	}
	return xmlhttp;
}

function ajaxLoadURL(the_url, the_method, post_vars, div_output, waiting_type, output_type){
	var xmlhttp	= ajaxCreateHTTP();
	if ( !xmlhttp ){
		return false;
	}

	xmlhttp.onreadystatechange	= function(){
		ajaxHandleResponse(div_output, waiting_type, output_type);
	}

	the_date	= new Date();
	randCode	= the_date.getTime() +"_"+ (Math.round(Math.random() * 100));
	the_url		+= (the_url.indexOf('?') != -1) ? '&ajaxRand='+ randCode : '?ajaxRand='+ randCode;

	xmlhttp.open(the_method, the_url);
	if ( the_method == 'POST' ){
		xmlhttp.send(post_vars);
	}
	else{
		xmlhttp.send(null);
	}
	return true;
}

function ajaxHandleResponse(div_output, waiting_type, output_type){
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
		if (output_type == 1){
			if (xmlhttp.responseText != ""){
				eval(xmlhttp.responseText);
			}
		}
		else{
			if ( div_output != "" ){
				document.getElementById(div_output).innerHTML	= xmlhttp.responseText;
			}
		}
	}
	else{
		switch (waiting_type){
			case 1:
					document.getElementById(div_output).innerHTML	= "Loading.....";
					break;
			case 2:
					break;
			default:
		}
	}
}

