/* ---------------------------- */
/* XMLHTTPRequest Enable------- */
/* ---------------------------- */
function createObject() {
        var request_type;
        var browser = navigator.appName;
            if(browser == "Microsoft Internet Explorer"){
                request_type = new ActiveXObject("Microsoft.XMLHTTP");
            }else{
                request_type = new XMLHttpRequest();
            }
    return request_type;
}
/* ---------------------------- */
/* XMLHTTPRequest Enable------- */
/* ---------------------------- */

var http = createObject();

/* var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;

function DispHist(id) {
    
    // Set te random number to add to URL request
    nocache = Math.random();
    
    // Show a waiting message in the layer with ID login_response
    document.getElementById(id).innerHTML = "<img src=\"imgs/loading.gif\">"
    
    // Pass the update variables from the form to the PHP script to insert into DB
    http.open('get', 'fullhist.php?caseid='+id+'&a=disp&nocache='+nocache);
    http.onreadystatechange = ShowEntry;
    http.send(null);
    
}

function HideHist(id) {
    
    // Set te random number to add to URL request
    nocache = Math.random();
    
    // Show a waiting message in the layer with ID login_response
    document.getElementById(id).innerHTML = "<img src=\"imgs/loading.gif\">"
    
    // Pass the update variables from the form to the PHP script to insert into DB
    http.open('get', 'fullhist.php?caseid='+id+'&a=hide&nocache='+nocache);
    http.onreadystatechange = ShowEntry;
    http.send(null);
    
}

function ShowEntry() {
    if(http.readyState == 4){
        var response = http.responseText;
        
        var parts = response.split('~')
        
        //alert ('CaseID: '+parts['0']+'\nMessage:'+parts['1'])

    // Show a waiting message in the layer with ID login_response
    document.getElementById(''+parts['0']+'').innerHTML = parts['1'];

        
    }
}
