function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

function sndReq(page,ID,elemID) {
	http = createRequestObject();
	httpResult = '';
    http.open('get', 'includes/sndreq/'+page+'?ID='+ID+'&elemID='+elemID);
    http.onreadystatechange = handleData;
    http.send(null);
}

function sndReqDelete(page,table,ID,elemID) {
	http = createRequestObject();
	httpResult = '';
    http.open('get', 'includes/sndreq/'+page+'?table='+table+'&ID='+ID+'&elemID='+elemID);
    http.onreadystatechange = handleDataDelete;
    http.send(null);
}

function sndReqDeleteOrder(page,table,ID,elemID,order) {
	http = createRequestObject();
	httpResult = '';
    http.open('get', 'includes/sndreq/'+page+'?table='+table+'&ID='+ID+'&elemID='+elemID+'&order='+order);
    http.onreadystatechange = handleDataDelete;
    http.send(null);
}

function handleData() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();
        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            if(update[0] == 'toVar'){
            	httpResult = update[1];
            } else {
            	document.getElementById(update[0]).innerHTML = update[1];
			}
        }
   }
}

function handleDataDelete() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
			if(update[0] != 'false'){
				document.getElementById(update[0]).className = 'ajaxDelete';
            	document.getElementById(update[0]).innerHTML = update[1];
			}
        }
   }
}

function hideSearchBoxes(){
	document.getElementById('contextBox').style.display='none';
	document.getElementById('searchBox').style.display='none'; 
}
function hideSearchBox(){
	document.getElementById('searchBox').style.display='none'; 
}
