function init(string)
{
   //println( "iddddddddddnterval=" + string );
    println( "iddddddddddnterval=");
    return "iii";
}



function doQuery()
{
    var sourceLang="en";
    var targetLang="ru";

    var url = "http://translate.google.com/translate_t";
    var path1 = "?text=";
    var path2 = "&hl=en&ie=UTF8&langpair=";
    var path3 = "|";
    var path4 = "&oe=UTF8";


    var msg=WebQueryController.msg();

    //we dont want to translate tags and entities,
    //besides user can past them easily via ctrl+t

    msg=msg.replace(/\&\w+\;/g, " ");
    msg=msg.replace(/<[^>]+>/g, " ");

    msg=msg.replace(/^ +/g, "");
    msg=msg.replace(/ +$/g, "");

    msg=msg.replace(/\&/g, "|_|");
    println( msg);

//     println( url
//                             + path1
//                             + msg
//                             + path2
//                             + sourceLang
//                             + path3
//                             + targetLang
//                             + path4);

    WebQueryController.doDownloadAndFilter( url
                             + path1
                             + msg
                             + path2
                             + sourceLang
                             + path3
                             + targetLang
                             + path4,
                             "UTF-8",
                             "<div id=result_box dir=ltr>([^<]+)</div>"
//                             ,0
                             );

}


function postProcess(string)
{
    var result=string.replace(/\&gt\;/g, ">");
    result=result.replace(/\&amp\;/g, "&");//hm...
    result=result.replace(/\| +\_ +\|/g, "&");
    result=result.replace(/\&\#39\;/g, "'");
    result=result.replace(/\&lt\;/g, "<");

    result=result.replace(/ +$/g, "");

//     sTmp = sTmp.Replace("|@rn|", "\r\n");
//     sTmp = sTmp.Replace("|@n|", "\n");
//     if ( result.endsWith(" "))
//     {
//         result=result.left(result.size()-2);
//     }

    WebQueryController.setResult(result);
}

