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

var http = createRequestObject();

  function sndReq(action,arg) {
    http.open('get', 'rpc.php?action='+action+'&arg='+arg);
    http.onreadystatechange = handleResponse;
    http.send(null);
  }


function handleResponse() {
    if(http.readyState == 4){
    	//get response from rpc.php
        var response = http.responseText;
        var update = new Array();
	
       // alert(response);
        //if there is some kind of response then split it into the update array
        if(response.indexOf('|' != -1)) {
            update = response.split('|');
          
           //each update array element has a timeslot in it
          var slots = update.length;
          document.getElementById('timeslot').length = 0;
          for (var i=0; i<slots; i++) {
		var varitems = new Array();
		varitems = update[i].split('~');
	          	var elOptNew = document.createElement('option');
		elOptNew.text = varitems[1];
		elOptNew.value = varitems[0];
		var elSel = document.getElementById('timeslot');
		try {
		elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		elSel.add(elOptNew); // IE only
		}
          }
	       	
           }
    }
}

