var map_en = new Array("sh'","Sh'",'ye','Ye',"'e","'E",'y0','Y0',"'o","'O",'zh','Zh','ts','Ts','ch','Ch','sh','Sh',"`e","`E",'yu','Yu',"'u","'U",'ya','Ya',"'a","'A",'a','A','b','B','v','V','w','W','g','G','d','D','e','E','z','Z','i','I','j','J','k','K','l','L','m','M','n','N','o','O','p','P','r','R','s','S','t','T','u','U','f','F','h','H','c','C','`','y','Y',"'");
var map_ru = new Array('щ','Щ','е','Е','е','Е','ё','Ё','ё','Ё','ж','Ж','ц','Ц','ч','Ч','ш','Ш','э','Э','ю','Ю','ю','Ю','я','Я','я','Я','а','А','б','Б','в','В','в','В','г','Г','д','Д','е','Е','з','З','и','И','й','Й','к','К','л','Л','м','М','н','Н','о','О','п','П','р','Р','с','С','т','Т','у','У','ф','Ф','х','Х','ц','Ц','ъ','ы','Ы','ь');

function addName(name)
    {
        document.REPLIER.Post.value += '[b]' + name + '[/b],  ';
        try {
          document.REPLIER.Post.focus();
        } catch (e) {
          try {
            ShowHide('qr_open','qr_closed');
            document.REPLIER.Post.focus();
          } catch (e) {
          }
        }
        //return true;
    }
function convert(str){
    for(var i=0;i<map_en.length;++i) while(str.indexOf(map_en[i])>=0) str = str.replace(map_en[i],map_ru[i]);
    return str;
}

function translate() {
    var sel = document.selection;
    var rng = sel.createRange();
    var conv_text;
    rng.colapse;
    if((sel.type == "Text" || sel.type == "None") && rng != null && rng.text.length > 0){
        conv_text = rng.text;
    }else{
        conv_text = document.REPLIER.Post.value;
        document.REPLIER.Post.value = '';
    }
    doInsert(convert( conv_text ), '', false);
}

function helper() {
    window.open(ipb_var_board_base+'/companion.php?','_search','');
    window.navigate('http://www.combats.ru/');
}

function buddy_pop(){
    window.open(ipb_var_board_base+'/buddy.php?act=buddy','_search','width=200,height=450,resizable=yes,scrollbars=yes');
}

function genesis_pop(){
    window.open(ipb_var_board_base+'/genesis.php?act=genesis','Рандомайзер','width=250,height=180,left=10,top=50,resizable=yes,scrollbars=no');
}

function genesis_dialog(){
    window.showModelessDialog(ipb_var_board_base+'/genesis.php?act=genesis', 'strong', 'dialogWidth:250px;dialogHeight:200px;dialogLeft:10px;dialogTop:50px;center:0;status:no;help:no;');
}

function whois_pop(name){
    var left = (screen.availWidth - 530)/2;
    var top = (screen.availHeight - 540)/2;
    name = name.replace(/\+/g,'%2B');
    name = name.replace(/#/g,'%23');
    window.open(ipb_var_board_base+'/whois.php?act=darklaw&CODE=12&mini_view=0&nick='+name,'','width=530,height=400,resizable=yes,scrollbars=yes,left='+left+',top='+top);
}

function full_whois(name){
    name = name.replace(/\+/g,'%2B');
    name = name.replace(/#/g,'%23');
    window.location = ipb_var_board_base+'/whois.php?act=darklaw&CODE=03&nick='+name;
}

function full_whois_pop(name){
    var left = (screen.availWidth - 600)/2;
    var top = (screen.availHeight - 550)/2;
    name = name.replace(/\+/g,'%2B');
    name = name.replace(/#/g,'%23');
    window.open(ipb_var_board_base+'/whois.php?act=darklaw&CODE=03&mini_view=1&nick='+name,'','width=600,height=550,resizable=yes,scrollbars=yes,left='+left+',top='+top);
}

function contact_pop(){
    window.open(ipb_var_board_base+'/contact_mini.php?act=darklaw&CODE=05&mini_view=1','','width=780,height=460,top=10,left==20,resizable=yes,scrollbars=yes');
}

function level_pop(level){
    var left = (screen.availWidth - 700)/2;
    var top = (screen.availHeight - 550)/2;
    window.open(ipb_var_board_base+'/level.php?act=darklaw&CODE=06&mini_view=1'+'#l'+level,'','width=700,height=530,resizable=yes,scrollbars=yes,left='+left+',top='+top);
}

function talk_pop(botname){
    var left = (screen.availWidth - 600)/2;
    var top = (screen.availHeight - 500)/2;
    window.open(ipb_var_board_base+'/talk.php?botname='+botname,'','width=600,height=500,resizable=yes,scrollbars=yes,left='+left+',top='+top);
}

function pals_pop(){
    var left = (screen.availWidth - 540)/2;
    var top = (screen.availHeight - 180)/2;
    window.open(ipb_var_board_base+'/pals.php?mini_view=1','','width=540,height=180,resizable=yes,scrollbars=no,left='+left+',top='+top);
}

function flowers_pop(){
    var left = (screen.availWidth - 700)/2;
    var top = (screen.availHeight - 500)/2;
    window.open(ipb_var_board_base+'/flowers.php?mini_view=1','','width=700,height=500,resizable=yes,scrollbars=yes,left='+left+',top='+top);
}

function damage_pop(){
    var left = (screen.availWidth - 300)/2;
    var top = (screen.availHeight - 260)/2;
    window.open(ipb_var_board_base+'/damage.php?mini_view=1','','width=300,height=260,resizable=yes,scrollbars=no,left='+left+',top='+top);
}

function encicl_pop(id_bk){
    window.open(ipb_var_board_base+'/mini_encicl.php?id_bk='+id_bk,'','width=600,height=440,resizable=yes,scrollbars=yes');
}

function last_pop(name){
    name = name.replace(/\+/g,'%2B');
    name = name.replace(/#/g,'%23');
    window.open(ipb_var_board_base+'/last.php?mini_view=1&act=darklaw&CODE=04&nick='+name,'','width=530,height=500,resizable=yes,scrollbars=yes,left=10,top=20');
}

function rating_pop(rating_id, city_id, level){
    window.open(ipb_var_board_base+'/ratings.php?mini_view=1&CODE=ShowRating&rating_id='+rating_id+'&city_filter='+city_id+'&level_filter='+level,'','width=580,height=500,resizable=yes,scrollbars=yes');
}

function searchrating_pop(rating_id, name){
    name = name.replace(/\+/g,'%2B');
    name = name.replace(/#/g,'%23');
    window.open(ipb_var_board_base+'/ratings.php?mini_view=1&CODE=SearchFighter&rating_id='+rating_id+'&nick='+name+'#searched','','width=580,height=500,resizable=yes,scrollbars=yes');
}

function dtower_pop(){
    window.open(ipb_var_board_base+'/html/darklaw/dtower.html','','width=800,height=530,resizable=yes,scrollbars=yes,top=10,left=10');
}

function fighters_rating_pop(align_id, city_id, level){
    window.open(ipb_var_board_base+'/fighters_rating.php?mini_view=1&align_id='+align_id+'&city_id='+city_id+'&level='+level,'','width=580,height=500,resizable=yes,scrollbars=yes');
}

function clans_rating_pop(){
    window.open(ipb_var_board_base+'/clans_rating.php?mini_view=1','','width=580,height=500,resizable=yes,scrollbars=yes');
}

function fadeIn() {
    if (document.all['Banner']==null) return;
    Banner.style.filter="blendTrans(duration=2)";
    if (Banner.filters.blendTrans.status != 2) {
        Banner.filters.blendTrans.apply();
        Banner.style.visibility="visible";
        Banner.filters.blendTrans.play();
    }
}

function fghMnu(fighter_name) {
window.open('http://devilscity.combats.com/inf.pl?login='+fighter_name,'','width=630,height=500,resizable=yes,scrollbars=yes,left=0,top=0');
/*    if (!is_ie){
        full_whois_pop(fighter_name);
        return;
    }
        
    fighter = fighter_name;
    menu_fighter.style.posLeft=document.body.scrollLeft+event.clientX-10;
    menu_fighter.style.posTop=document.body.scrollTop+event.clientY-10;
    menu_fighter.style.display="";
    if (is_darklaw){
        menu_darklaw.style.display="";
    }
    if(menu_fighter.getBoundingClientRect().bottom > document.body.clientHeight){
        menu_fighter.style.posTop -= menu_fighter.getBoundingClientRect().bottom - document.body.clientHeight;
    }
    if(menu_fighter.getBoundingClientRect().right > document.body.clientWidth){
        menu_fighter.style.posLeft -= menu_fighter.getBoundingClientRect().right - document.body.clientWidth;
    }
    setTimeout("menu_fighter.setCapture()", 1000);
    return false;
*/
}

function switchFighterMenu() {   
    
    el=event.srcElement;
    status = '';
    if (el.className=="menuItem") {
        el.className="highlightItem";
    } else if (el.className=="highlightItem") {
        el.className="menuItem";
    }

    switch (el.id){
        case "mnuWhoIs":
            status='Полная версия WhoIs';
            break;

        case "mnuminiWhoIs":
            status='Сокращенна версия WhoIs в новом окне';
            break;

        case "mnuWhoIsFC":
            status="БК'шная информация о персонаже";
            break;

        case "mnuLast":
            status="Последние бои персонажа откроются в новом окне";
            break;

        case "mnuAddContact":
            status="Добавить бойца в контакт-лист";
            break;

        case "mnuNick":
            status="Скопировать ник бойца в буфер обмена";
            break;

        case "mnuCopy":
            status="Скопировать строчку обращения к бойцу в буфер обмена";
            break;

        case "mnuPrivat":
            status="Скопировать строчку приватного обращения к бойцу в буфер обмена";
            break;

        case "mnuInvSend":
            status="Скопировать строчку обращения к бойцу с предложением полечиться буфер обмена";
            break;

        case "mnuCheck":
            status="Проверить референтов";
            break;

        case "mnuClose":
            status="Закрыть меню";
            break;
    }
}

function clickFighterMenu() {
    menu_fighter.releaseCapture();
    menu_fighter.style.display="none";
    menu_darklaw.style.display="none";
    el=event.srcElement;
    status = '';
    switch (el.id){
        case "mnuWhoIs":
            if (mini_view=='1'){
                full_whois_pop(fighter);
            }else{
                full_whois(fighter);
            }
            break;

        case "mnuminiWhoIs":
            whois_pop(fighter);
            break;

        case "mnuWhoIsFC":
            window.open('http://devilscity.combats.ru/inf.pl?login='+fighter,'','width=630,height=500,resizable=yes,scrollbars=yes,left=0,top=0');
            break;

        case "mnuLast":
            last_pop(fighter);
            break;

        case "mnuAddContact":
            window.open(ipb_var_board_base+'/contact_mini.php?act=darklaw&CODE=05&mini_view=1&MODE=01&group_id=1&description=&name='+fighter,'','width=780,height=460,top=10,left==20,resizable=yes,scrollbars=yes');
            break;

        case "mnuCopy":
            document.fake._fgh.value='to ['+fighter+'] ';
            var r = document.fake._fgh.createTextRange();
            r.execCommand('Copy');
            break;

        case "mnuNick":
            document.fake._fgh.value=fighter;
            var r = document.fake._fgh.createTextRange();
            r.execCommand('Copy');
            break;

        case "mnuPrivat":
            document.fake._fgh.value='private ['+fighter+'] ';
            var r = document.fake._fgh.createTextRange();
            r.execCommand('Copy');
            break;

        case "mnuInvSend":
            document.fake._fgh.value='private ['+fighter+'] Привет! Не хочешь травму полечить? Расценки у меня в инфе.';
            var r = document.fake._fgh.createTextRange();
            r.execCommand('Copy');
            break;

        case "mnuCheck":
            window.open(ipb_var_board_base+'/referals.php?CODE=show_referents&nick='+fighter, '', '');
            break;
    }
}