// Original idea of Dmitry Koteroff.

function Spell_class() {
        //init
        this.msg_bbrowser="Ваш браузер не поддерживает возможность перехвата выделенного текста или тега IFRAME.";
        this.msg_bigtext="Вы выбрали слишком много текста.";
        this.msg_thanks="Спасибо за сотрудничество.";
        this.msg_subject="Орфографическая ошибка";
        this.msg_doc="Документ:";
        this.msg_text="Орфографическая ошибка в тексте:";
        this.msg_send="Послать сообщение об ошибке?\nСтраница не будет перегружена.";

        t=this;
        document.onkeypress=function(e) { 
                return t.onkeypress(e)
        }
}

Spell_class.prototype.onkeypress=function onkeypress(e) {
        var press=0;
    var wevent=0;
    if (window.event) wevent=window.event;
    if (wevent) {
                // IE & Opera
                press=
                        wevent.keyCode==10 ||  // IE
                        (wevent.keyCode==13 && wevent.ctrlKey); // Opera 
    } else if (e) {
                // NN
                press=
                        (e.which==10 && e.modifiers==2) || // NN4
                        (e.keyCode==0 && e.charCode==106 && e.ctrlKey) ||
                        (e.keyCode==13 && e.ctrlKey); // Mozilla
    }
        
    if (press) this.send_form();
}

Spell_class.prototype.send_form=function send_form() {
        var text=null;
        var p=parent;
        var selection=null;
        var s=null;
        var r=0;

        var f=p.document.forms['spell_form'];
    if (!f) return;

    if (navigator.appName.indexOf("Netscape")!=-1 &&
eval(navigator.appVersion.substring(0,1))<5) {
                alert(this.msg_bbrowser);
                return;
    }
    
    if (p.getSelection) {
                text=p.getSelection();
    } else {
                selection=p.document.selection;
                var s=selection.createRange();
                if (!s) return;
                text=s.text;
    }
        if (text==null) { 
                alert(this.msg_bbrowser); 
                return; 
    }
        text=text.toString();
        text=text.replace("\r",' ').replace("\n",' ');

        //alert('text='+text);

    if (text.length<500) {
                var url=p.document.location.href;
                var
r=confirm(this.msg_doc+"\n"+url+"\n\n"+this.msg_text+"\n"+text+"\n\n"+this.msg_send);
                if (r) {
                        f.url.value=url;
                        f.error_text.value=text;
                        f.submit();
                        alert(this.msg_thanks);
                }
        } else {
                alert(this.msg_bigtext);
                return;
        }
}