function ajax(strURL,qstr,nid) { 
  var xmlHttpReq = false;
  var self = this;
  if (window.XMLHttpRequest) self.xmlHttpReq = new XMLHttpRequest();
  else if (window.ActiveXObject) self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  self.xmlHttpReq.open('POST', strURL, false);
  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  self.xmlHttpReq.send(qstr);
  document.getElementById(nid).innerHTML = self.xmlHttpReq.responseText;
}

function xmlhttpPost(strURL,qstr,nid) { 
  var xmlHttpReq = false;
  var self = this;
  if (window.XMLHttpRequest) self.xmlHttpReq = new XMLHttpRequest();
  else if (window.ActiveXObject) self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  self.xmlHttpReq.open('POST', strURL, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4) {
        updatepage(self.xmlHttpReq,nid);
      }
  }
  self.xmlHttpReq.send(qstr);
}
function updatepage(str,nid){
  document.getElementById(nid).innerHTML = str.responseText;
}

var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;

function movemouse(e) {
  if (isdrag) {
    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    return false;
  }
}

function selectmouse(e) {
  x = nn6 ? e.clientX : event.clientX;
  y = nn6 ? e.clientY : event.clientY;
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";
  while (fobj.tagName != topelement && fobj.className != "dragme") {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }
  if (fobj.className=="dragme") {
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0,10);
    ty = parseInt(dobj.style.top+0,10);
    document.onmousemove=movemouse;
    return false;
  } else {
    document.getElementById("calendario").style.left = (nn6 ? e.clientX : event.clientX);
    document.getElementById("calendario").style.top = (nn6 ? e.clientY : event.clientY)+10;
    document.getElementById("calendario").innerHTML = '';
  }
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
