var d=document;

function ById(id){
    return d.getElementById(id)
}

var click_block=0;
var Domain='efremova.info/search/';
var IE=(navigator.appName=='Microsoft Internet Explorer' && navigator.userAgent.indexOf("Opera")==-1?1:0);

function dict()
{
    if(click_block){
        click_block=0;
        return;
    }

    if(!IE){
        t=d.getSelection();
        nwin(t);
    } else{
        t=d.selection.createRange();

        if(d.selection.type=='Text'&&t.text!=''){
            d.selection.empty();nwin(t.text);
        }
    }
}

function nwin(text){
//    if(!window.encodeURIComponent)
//        return;

    while(text.substr(text.length-1,1)==' ')
      text=text.substr(0,text.length-1)

    while(text.substr(0,1)==' ')
      text=text.substr(1)

    if(text>''){
//        var newloc='http://www.'+Domain+'?q='+encodeURIComponent(text);
        var newloc='http://www.'+Domain+'?q='+text;

        if(d.location.toString().toLowerCase()!=newloc.toLowerCase())
            d.location=newloc;
    }
}

function qs(el,p) {

    if (window.RegExp && window.encodeURIComponent) {

        var ue=el.href;

//        var qe=encodeURIComponent(d.f.sw.value);
        var qe=d.f.sw.value;

        if(ue.indexOf(p+"=")!=-1){
            el.href=ue.replace(new RegExp(p+"=[^&$]*"),p+"="+qe);
        } else {
            el.href=ue+"&"+p+"="+qe;
        }
    }

    return 1;
}

function ws(el) {
//    if (window.encodeURIComponent) {
        var ue=el.href;
//        var qe=encodeURIComponent(d.f.sw.value);
        var qe=d.f.sw.value;
        el.href=ue+qe;
//    }
    return 1;
}

function grs() {
    var af=d.forms;
    for(i=0;i<af.length;i++){
        if(af[i].name.length==0 && af[i].q){
            af[i].q.value=d.f.sw.value;
            af[i].submit();
            return;
        }
    }
}
