// <SCRIPT type='text/javascript' src='/JS/ajax_dowork.js'></SCRIPT>
var IB_Blab; 
function IB_processReqChange() 
{
 if(req.readyState == 4) 
 {
   if(req.status == 200)
   {
     document.getElementById(IB_Blab).innerHTML = req.responseText;
   }
   else
     document.getElementById(IB_Blab).innerHTML = '<font color=red>Error 11 Failed to reach server.</font>';
 }
}
// ===============================
// this just submits the form as a link
function getd_sb()
{
  document.mainfm.newblk.value=1;
  document.mainfm.submit();
}

function sb_sbfrm() { document.getElementById('sbfrm').submit(); }
function showsomething(id) { document.getElementById(id).style.visibility="visible"; }


// --------------------------------
function getd(furl,Ba,i,f,w,dv)
{
  IB_Blab = Ba;

  //var oldval = document.mainfm.working.value;
  //var chkit=oldval+w;
  //alert("Oldw:"+oldval+" new:"+w+" == "+chkit);

  // This is a simply "overall cancel" link, when something is being done: cases 1,2 and 7
  //if(w==1 || w==2 || w==7) {
    //document.getElementById('CancL').innerHTML = '<a href=http://www.webtb.org/Targets/?edit=true>[Cancel the current action]</A>';
  //}

  // IF working == 1, 2 or 7, close it out if 3,4,8 are NOT the ones subsequently clicked
  // So, if oldval == 7 and new val is != 8, close it out
  // if oldval == 1 and new val is != 3 close it out
  // if oldval == 2 and new val is != 4 close it out
  //if(oldval==1 && chkit != 13) { alert("Please choose a status change or select --No change-- in the drop down."); return false; }
  //else if(oldval==2 && chkit != 24) { alert("Please enter the changes for the 'reason' field and click the [Change] button"); return false; }
  //else if(oldval==7 && chkit != 78) { alert("Please enter the name changes, and click the [Change] button."); return false; }
  //alert("D:"+document.mainfm.working.value);

  // assign this to the old val
  //document.mainfm.working.value=w;


  // Replace all \n's with HTML BR's in here first!
//alert("dv:"+dv+" w="+w);
//if(w==3) alert("st:"+document.mainfm.status_id[document.mainfm.status_id.selectedIndex].value);
//if(w==3) alert("st:"+document.mainfm.status_id.selectedIndex);

  if(w==10)  // we must get the value from the selected box
  {
    var nv = document.getElementById(dv).value;
  }
  else if(isNumeric(dv)) var nv=dv;
  else var nv=dv.replace(/\n/g, "<BR>");

  url = furl+"/ajax_get_data.php?loc="+Ba+"&ix="+i+"&ff="+f+"&w="+w+"&dv="+nv;
//alert("url:"+url);
  
  document.getElementById(IB_Blab).innerHTML = '<i>working</i>';

  if(window.XMLHttpRequest) 
  {
    req = new XMLHttpRequest();
    req.onreadystatechange = IB_processReqChange;
    req.open("GET", url, true);
    req.send(null);
  } 
  else if(window.ActiveXObject) 
  {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if(req) 
    {
      req.onreadystatechange = IB_processReqChange;
      req.open("GET", url, true);
      req.send();
    }
  }
}

// --------------------------------
function getGd(furl,Ba,i,w)
{
  IB_Blab = Ba;

  url = furl+"/general_get_data.php?loc="+Ba+"&ix="+i+"&w="+w;

  //alert("url:"+furl);
  
  document.getElementById(IB_Blab).innerHTML = '<i>working</i>';

  if(window.XMLHttpRequest) 
  {
    req = new XMLHttpRequest();
    req.onreadystatechange = IB_processReqChange;
    req.open("GET", url, true);
    req.send(null);
  } 
  else if(window.ActiveXObject) 
  {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if(req) 
    {
      req.onreadystatechange = IB_processReqChange;
      req.open("GET", url, true);
      req.send();
    }
  }
}

// --------------------------------
// --------------------------------
function get_gecGRID(furl,Ba,w,siz,col,rl)
{
  IB_Blab = Ba;

  //siz=document.mainfm.siz.value;
  //col=document.mainfm.col.value;
  url = furl+"/lcl_getdata.php?loc="+Ba+"&w="+w+"&rl="+rl+"&siz="+siz+"&col="+col;

  //alert("url:"+furl);
  
  document.getElementById(IB_Blab).innerHTML = '<i>working</i>';

  if(window.XMLHttpRequest) 
  {
    req = new XMLHttpRequest();
    req.onreadystatechange = IB_processReqChange;
    req.open("GET", url, true);
    req.send(null);
  } 
  else if(window.ActiveXObject) 
  {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if(req) 
    {
      req.onreadystatechange = IB_processReqChange;
      req.open("GET", url, true);
      req.send();
    }
  }
}


// taken from the web
function isNumeric(expression) 
{
  var nums = "0123456789";
  if(expression.length==0) return(false);
  for(var n=0; n < expression.length; n++) {
    if(nums.indexOf(expression.charAt(n))==-1) return(false);
  }
  return(true);
}
function helpmsg(obj,L,T) 
{ 
  with(obj.style)
  {
    display = "block"; 
    position = "absolute";
    left = L;
    top = T;
  }
}
function unpop( obj ) { obj.style.display = "none"; }

