var req;
function loadXMLDoc(key,file,sid,loc,tmp) {
var url=file+"?"+sid+"&"+key;
// alert(tmp);
// alert(url);

if (sid && key) {
  url=file+"?"+sid+"&"+key;
} else {
  if (sid) {
    url=file+"?"+sid;
  } else {
    if (key) {
      url=file+"?"+key;
    } else {
      url=file;
    }
  }
}

          // var locelement = document.getElementById(loc);
          var locelement = getElementByIdCompatible(loc);
          // locelement.innerHTML = "loading..."; // tmp;
/*
  try {
       if(tmp && tmp != undefined && tmp != null) {
          var location = document.getElementById(loc);
          location.innerHTML = tmp;
         // getObject(loc).innerHTML = tmp;
       } else {
          var location = document.getElementById(loc);
          location.innerHTML = tmp;
         // getObject(loc).innerHTML = "";
       }
  } catch (e) {
          var location = document.getElementById(loc);
          location.innerHTML = tmp;
    // getObject(loc).innerHTML = "";
  }
*/
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc) { req = null; }
}
if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }
  if (req != null) {
    req.onreadystatechange=function(){if(req.readyState!=4)return;if(req.status==200){getObject(loc).innerHTML = req.responseText}};
    req.open("GET", url, true);
    req.send(null);
  }
}

function getObject(name) {
   var ns4 = (document.layers) ? true : false;
   var w3c = (document.getElementById) ? true : false;
   var ie4 = (document.all) ? true : false;

   if (ns4) return eval('document.' + name);
   if (w3c) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   return false;
}

// http://www.webcodingtech.com/javascript/get-object-by-id-compatible.php
// Get object by ID
// If you've been working with Javascript at all, you've come to use the getElementById method. While this function is a good one for simply getting an object, it's not compatible with all browsers. Today I'm going to show you how to work towards cross-browser compatibility in your JavaScipt code. Just use the following function instead of getElementById().
// Cross-browser compatible getElementById() Function

function getElementByIdCompatible(the_id) {
if (typeof the_id != 'string') {
return the_id;
}

if (typeof document.getElementById != 'undefined') {
return document.getElementById(the_id);
} else if (typeof document.all != 'undefined') {
return document.all[the_id];
} else if (typeof document.layers != 'undefined') {
return document.layers[the_id];
} else {
return null;
}
} // end getElementByIdCompatible
