// Wikipedia
if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() {
  try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
  throw new Error( "This browser does not support XMLHttpRequest." )
};

// Dean Edwards/Matthias Miller/John Resig
function init() {  
  // quit if this function has already been called  
  if (arguments.callee.done) return;  
  // flag this function so we don't do the same thing twice  
  arguments.callee.done = true;  
  // kill the timer  
  if (_timer) clearInterval(_timer);  
	
  onloadaction();
};
  
/* for Mozilla/Opera9 */
if (document.addEventListener) {  
  document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)  
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");  
  var script = document.getElementById("__ie_onload");  
  script.onreadystatechange = function() { 
    if (this.readyState == "complete") {  
      init(); // call the onload handler
    }  
  };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff  
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      init(); // call the onload handler 
    }
  }, 10);
}
       
window.onload = init;

function utfdecode(utftext) {
  var string = "";
  var i = 0;
  var c = c1 = c2 = 0;
 
  while ( i < utftext.length ) {
    c = utftext.charCodeAt(i);
    if (c < 128) {
      string += String.fromCharCode(c);
      i++;
    } else if ((c > 191) && (c < 224)) {
      c2 = utftext.charCodeAt(i+1);
      string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
      i += 2;
    }	else {
      c2 = utftext.charCodeAt(i+1);
      c3 = utftext.charCodeAt(i+2);
      string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
      i += 3;
    }
  }
  return string;
}
