function getXMLHttp(){
    if(typeof XMLHttpRequest != 'undefined'){
        var ajax = new XMLHttpRequest();
        return ajax;
    }
    else
    {
        var objects = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
        for(counter = 0 ; counter < objects.length ; counter++ ){
            try{
               var ajax = new ActiveXObject(objects[counter]);
               return ajax;
            } catch(e){
                 // do nothing
            }
        }
    }
    throw new Error("Unable to establish AJAX connection with server");
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  //alert(func);
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function is_all_ws(nod) { return !(/[^\t\n\r ]/.test(nod.data)); }
function is_ignorable(nod) { return (nod.nodeType == 8) || ((nod.nodeType == 3) && is_all_ws(nod)); }
function node_before(sib) {
  while ((sib = sib.previousSibling)) {
    if (!is_ignorable(sib)) return sib;
  }
  return null;
}
function node_after(sib) {
  while ((sib = sib.nextSibling)) {
    if (!is_ignorable(sib)) return sib;
  }
  return null;
}
function first_child(par) {
  var res = par.firstChild;
  while(res) {
    if(!is_ignorable(res)) return res;
    res = res.nextSibling;
  }
  return null;
}
function last_child(par) {
  var res = par.lastChild;
  while(res) {
    if(!is_ignorable(res)) return res;
    res = res.previousSibling;
  }
  return null;
}

function remove_all_children(el)
{
    if ( el.hasChildNodes() )
    {
        while ( el.childNodes.length >= 1 )
        {
             el.removeChild( el.firstChild );
        }
   }
}

