var xmlhttp;
var resp_location;

// *********************************************************************** //

function GetXmlHttpObject()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

// ******************* RESULTSET FUNCTIONS *********************************** //

function server_show_response() 
{
    dest = document.getElementById(resp_location);
    if (! dest) return;
    if (xmlhttp.readyState == 4) {
        var text = xmlhttp.responseText;
        dest.innerHTML = text;
    }
}

function switch_page(res_id, page_n) 
{
    xmlhttp = GetXmlHttpObject();
    resp_location = res_id;
    
    var body = "id=" + res_id + "&page_n=" + page_n;
    xmlhttp.onreadystatechange = server_show_response;
    xmlhttp.open("POST", "/ajax_resultset.php?action=switch_page", true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", body.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(body);
    return false;
}

function set_res_pp(res_id) 
{
    xmlhttp = GetXmlHttpObject();
    resp_location = res_id;
    
    var value = document.getElementById('res_pp').value;
    var body = "id=" + res_id + "&res_pp=" + value;
    xmlhttp.onreadystatechange = server_show_response;
    xmlhttp.open("POST", "ajax_resultset.php?action=set_res_pp", true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", body.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(body);
    return false;
}

// ******************* SHOW / HIDE SOMETHING *********************************** //

function showHide(what, visible)
{
  var obj = document.getElementById(what);
  if (obj.style.display == 'none')
    obj.style.display = 'block';
  else 
    obj.style.display = 'none';
}