// JavaScript Document
var xmlHttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlHttp=false
  }
 }
@else
 xmlHttp=false
@end @*/

if (!xmlHttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlHttp = new XMLHttpRequest();
 } catch (e) {
  xmlHttp=false
 }
}
function myXMLHttpRequest() {
  var xmlHttplocal;
  try {
    xmlHttplocal= new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlHttplocal= new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
    xmlHttplocal=false;
  }
 }

if (!xmlHttplocal && typeof XMLHttpRequest!='undefined') {
 try {
  var xmlHttplocal = new XMLHttpRequest();
 } catch (e) {
  var xmlHttplocal=false;
  alert('couldn\'t create xmlHttp object');
 }
}
return(xmlHttplocal);
}

function makePOSTRequest(url, parameters) {
	if (xmlHttp.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		xmlHttp.overrideMimeType('text/html');
	}
	
	xmlHttp.open('POST', url, true);
	xmlHttp.onreadystatechange = handleResponse;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");	
	xmlHttp.send(parameters);
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function handleResponse() {
    if(xmlHttp.readyState == 4){
		if (xmlHttp.status == 200){
       	
        var response = xmlHttp.responseText.split('|');
        changeText(trim(response[1]), response[2]);
		
		}
    }
}

function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"

    if (DOM) {
        var viewer = document.getElementById(div2show)
        viewer.innerHTML=text
    }
    else if(IE) {
        document.all[div2show].innerHTML=text
    }
}
