
var httpObj = createRequestObject();
var ajax_SetInnerHtmlObjectId;

function createRequestObject() {
  var ro;
  try {ro = new XMLHttpRequest();}
  catch(e) {
    try {ro = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e) {
      try {ro = new ActiveXObject("Microsoft.XMLHTTP");}
      catch(e) {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  return ro;
}

var functions = new Array ()
functions["CurrencyString"] = "get_currency_value_string"
functions["GetSpashPage"] = "get_splash_page"

function handleHttpResponse() {
	if (ajax_SetInnerHtmlObjectId == null) return;
//alert (http.readystate)
//		alert ("resp:" + http.responseText)
        if (httpObj.responseText != "") {
//		alert ("resp:" + httpObj.responseText)
//		ajax_SetInnerHtmlObjectId.innerHTML = http.responseText;
               document.getElementById(ajax_SetInnerHtmlObjectId).innerHTML = httpObj.responseText;
        }
}

function handleHttpResponse1() {
        if (httpObj.responseText != "") {
			alert ("resp:" + httpObj.responseText)
        }
}

///////////////////////////////////////////////////////

function ajax_SetCookie(name, value) {
	ajax_SetInnerHtmlObjectId = null;
	httpObj.open('get', ROOT_PATH + "php/ajax/set_cookie.php?name=" + name + "&value=" + value );
	httpObj.onreadystatechange = null;
	httpObj.send(null);
//	do {} while (httpObj.responseText == "");
//	alert (httpObj.responseText);

}

function ajax_GetCookie(name, value) {
	ajax_SetInnerHtmlObjectId = null;
	httpObj.open('get', ROOT_PATH + "php/ajax/get_cookie.php?name=" + name );
	httpObj.onreadystatechange = handleHttpResponse1;
	httpObj.send(null);
}

function SetObjectsInnerHTML(func, val, objectid) {
	ajax_SetInnerHtmlObjectId = objectid
	
	httpObj.open('get', ROOT_PATH + "php/ajax/" + functions[func] + ".php?val=" + val );
	httpObj.onreadystatechange = handleHttpResponse;
	httpObj.send(null);
}

function xxSetObjectsInnerHtml( val) {
	httpObj.open('get', ROOT_PATH + "php/ajax/get_currency_value_string.php?val=" + val );
	httpObj.onreadystatechange = handleHttpResponse;
	httpObj.send(null);
}
