function enc(s) {
  var len = s.length;
  var s2 = "";
  var ascii = 0;
  var c = "";
  for (var i = 0; i < len; i++) {
    c = s.charAt(i);
    ascii = s.charCodeAt(i);
    if ( (ascii >= 48 && ascii <= 57) || (ascii >= 65 && ascii <= 90) || (ascii >= 97 && ascii <= 122) ) s2 += c;
    else {
      if (ascii < 10) ascii = "00" + ascii;
      else ascii = ascii < 100 ? "0" + ascii : ascii;
      s2 += "_" + ascii;
    }
  }
  return s2;
}

function dec(s) {
  var len = s.length;
  var s2 = "";
  var c = "";
  var code = "";
  for (var i = 0; i < len; i++) {
    c = s.charAt(i);
    if (c == "_") {
      code = s.charAt(i + 1) + s.charAt(i + 2) + s.charAt(i + 3);
      c = String.fromCharCode(parseInt(code, 10));
      i += 3;
    }
    s2 += c;
  }
  return s2;
}

function AppendDivDialog() {
	if ($('#dialog').size() == 0)
	{
		$('body').append('<div id="dialog"></div>');
		$('#dialog').dialog({
	        autoOpen: false,
	        modal: true,
	        hide: 'fadeOut',
	        width: 600,
	        buttons: {
	            "OK": function() {
	                $(this).dialog("close");
	            }
	        }
	    });
	}
}

function MsgBox(title, html) {
	AppendDivDialog();
    $('#dialog').data('title.dialog', title).html(html).dialog('open');
}
