function orphus_init(label_suggestion,label_badbrowser,label_toobig,label_docmsg,label_yes,label_no) {
  maxlen = 1024;
  send_url = "/sendbug";

/*  Event.observe(
    document,
    'keypress',
    function(event){
      if(event.ctrlKey && event.keyCode == Event.KEY_RETURN) doSend();
    }
  );*/

  // Hook keyboard.
  //parent.document.onkeypress = onkeypress;
  Event.observe(document,'keydown', function (e) {
    var pEnter = 0;
    var we = null;
    if (window.event) we = window.event;
    else if (parent && parent.event) we = parent.event;
    if (we) {
      // IE & Opera
      pEnter = we.keyCode==10 ||  // IE
        (we.keyCode == 13 && we.ctrlKey); // Opera
    } else if (e) {
      // NN
      pEnter = 
        (e.which==10 && e.modifiers==2) || // NN4
        (e.keyCode==0 && e.charCode==106 && e.ctrlKey) ||
        (e.keyCode==13 && e.ctrlKey); // Mozilla
    }
    if (pEnter) doSend();
    if (e.keyCode == Event.KEY_ESC) Dialog.closeInfo();
  });


  function openConfirm(url, content, nodetext) {
    Dialog.confirm(
      label_suggestion+'<textarea id="suggestion" rows="4">'+content+'</textarea>', {
        draggable:true,
        width:400,
	zIndex:999,
        className: "alphacube",
        okLabel: label_yes, cancelLabel: label_no,
	ok:function(win) {
	  var sug = $('suggestion').value;
	  if (content == sug) { sug = '' }
          send(win, url, content, nodetext, sug);
          return false;
        } 
      }
    )
  }

  function doSend(recurrent) {
    var text = null;
    if (navigator.appName.indexOf("Netscape")!=-1 && eval(navigator.appVersion.substring(0,1))<5) {
      alert(label_badbrowser);
      return;
    }
    var w = parent;
    var selection = null;
    if (w.getSelection) {
      text = w.getSelection();
    } else if (w.document.getSelection) {
      text = w.document.getSelection();
    } else {
      selection = w.document.selection;
    }
    var context = null;
    if (selection) {
      var r = selection.createRange(); if (!r) return;
      text = r.text;
      context  = [text, 0];
    } else {
      context = [text, -1];
    }
    if (text == null) { 
      alert(label_badbrowser); 
      return; 
    }
    if (context[0] == "") return;
    var visCont = stripSlashn(context[0]);
    if (visCont.length > maxlen) {
      alert(label_toobig);
      return;
    }
    openConfirm(w.document.location.href,visCont,text.focusNode.textContent);
  }

  function stripSlashn(text) {
    text = ""+text;
    return text.replace("¶","").replace("¶","").replace("\r", "").replace(new RegExp("^\\s+|\\s+$", "g"), "");
  }

  function send(win, url, context, nodetext, suggestion) {
    new Ajax.Request(send_url, {
      method: 'get',
      parameters: {
        ref: url,
	report: String(context),
	nodetext: String(nodetext),
	suggestion: String(suggestion)
      },
      onSuccess: function(transport) {
	win.setContent('orphus_thanks');
	setTimeout(function(){Dialog.closeInfo()}, 500);
      }
    });
  }
}
