function decodeUTF8(str) { // only works up to 0xffff
  var out = "";
  var i = 0, length = str.length;

  while (i<length) {
    var n = str.charCodeAt(i++);

    if ((n&0xE0)==0xC0) { // <0x800
      var n1 = str.charCodeAt(i++);
      n = ((n&0x1F)<<6) | (n1&0x3F);
    } else if ((n&0xF0)==0xE0) { // <0x10000
      var n1 = str.charCodeAt(i++);
      var n2 = str.charCodeAt(i++);
      n = ((n&0x0F)<<12) | ((n1&0x3F)<<6) | (n2&0x3F);
    }

    out += String.fromCharCode(n);
  }

  return out;
}

function openBrWindow(theURL,winName,features,ff) { //v2.0
  if (ff.charCodeAt(0)!=0xFF) // ff is to see if the url is properly decoded by the browser from UTF-8. always pass '%C3%BF'.
    theURL = decodeUTF8(theURL);
  window.open(theURL,winName,features);
}

