function sendText()
{
  var yourinputtext= document.getElementById("yourinputtext");
  var url="/tw/shortenurl.php?txt="+encodeURIComponent(yourinputtext.value);

  var theresulttext= document.getElementById("theresulttext");
  theresulttext.innerHTML="Please wait....";

  var req;
  if (window.XMLHttpRequest)
  {
    req = new XMLHttpRequest();
    req.onreadystatechange = showres(req);
    req.open("GET", url, true);
    req.send(null);
  }
  /** branch for IE/Windows ActiveX version **/
  else if (window.ActiveXObject)
  {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req)
    {
      req.onreadystatechange = showres(req);
      req.open("GET", url, true);
      req.send();
    }
  }
}
/**
The call-back function that displays the returned text on the "theresulttext" div
*/
function showres(req)
{
  return function()
  {
    if (req.readyState == 4)
    {
      /** only if "OK" */
      if (req.status == 200)
      {

  		var theresulttext= document.getElementById("theresulttext");
        theresulttext.innerHTML=req.responseText;

      }
    }
  }
}

