function xmlhttpPost(params) {
    var xmlHttpReq = false;
    var self = this;
    var strURL = 'ajaxfunctions.aspx';
    document.body.style.cursor = 'wait'; 
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    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.responseText);
        }
    }
    self.xmlHttpReq.send(params);
}		

function xmlhttpPostForHeader(params) {
    var xmlHttpReq = false;
    var self = this;
    var strURL = 'ajaxfunctions.aspx';
    document.body.style.cursor = 'wait'; 
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    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) {
            updatepageforheader(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(params);
}		


///////////////////////////////////////////////////////
var slidingTimer = null;
var slidingTarget = null;
var slidingLeft = null;
var slidingTop = null;

function startSlidePos(obj, toLeft, toTop) {
  if (slidingTimer != null)
    window.clearTimeout(slidingTimer);
  slidingTarget = document.getElementById(obj);
  slidingLeft = toLeft;
  slidingTop = toTop;

  slidingTimer = window.setTimeout(slideNextPos, 5);
} // startSlidePos


function slideNextPos() {
  var left = parseInt(slidingTarget.style.left);
  var top  = parseInt(slidingTarget.style.top);
  var dx, dy, len, delta;
  
  // calc the remaining vector
  dx = slidingLeft - left;
  dy = slidingTop - top;

  // calc the movement length along the vector
  len = Math.sqrt(dx * dx + dy * dy);
  delta = Math.min(20, len/3);
  
  if (len <= 2) {
    // snap exactly
    left = slidingLeft;
    top = slidingTop;

  } else {
    left += Math.round(dx * delta / len);
    top += Math.round(dy * delta / len);
  } // if

  // move it
  //slidingTarget.style.left = left + "px";
  slidingTarget.style.top = top + "px";

  // check for more need to move
  if ((left != slidingLeft) || (top != slidingTop))
    slidingTimer = window.setTimeout(slideNextPos, 100);
  else
    slidingTimer = null;
} // slideNextPos

function startExpandPos(obj, toLeft, toTop) {
  if (slidingTimer != null)
    window.clearTimeout(slidingTimer);
  slidingTarget = document.getElementById(obj);
  slidingLeft = toLeft;
  slidingTop = toTop;
  slidingTimer = window.setTimeout(expandNextPos, 10);
} // startSlidePos


function expandNextPos() {
  var left = parseInt(slidingTarget.style.width);
  var top  = parseInt(slidingTarget.style.height);
  var dx, dy, len, delta;
  
  // calc the remaining vector
  dx = slidingLeft - left;
  dy = slidingTop - top;

  // calc the movement length along the vector
  len = Math.sqrt(dx * dx + dy * dy);
  delta = Math.min(20, len/3);
  
  if (len <= 2) {
    // snap exactly
    left = slidingLeft;
    top = slidingTop;

  } else {
    left += Math.round(dx * delta / len);
    top += Math.round(dy * delta / len);
  } // if

  // move it
  //slidingTarget.style.width = left + "px";
  slidingTarget.style.height = top + "px";
  // check for more need to move
  if ((left != slidingLeft) || (top != slidingTop))
    slidingTimer = window.setTimeout(expandNextPos, 20);
  else
    slidingTimer = null;
} // slideNextPos



