function makeRequest(url, container) {
    var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            // Читайте ниже об этой строке
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
            }
        }
    }
    if (!http_request) {
        alert('Не вышло  Невозможно создать экземпляр класса XMLHTTP ');
        return false;
    }
    http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                document.getElementById(container).innerHTML = http_request.responseText;
            } else {
                alert('С запросом возникла проблема.');
            }
        }
    };
    http_request.open('GET', url, true);
    http_request.send(null);
    return false;
}

function getmodule(m, params){
    makeRequest("getmodule.php?m="+m+"&r="+Math.random()+"&"+params, "mcenter");
    return false;
}

function showhide(nm, action){
    obj = document.getElementById(nm);
    if(action){
        obj.style.visibility = "visible";
    }else{
        obj.style.visibility = "hidden";
    }
}
function showhide_dyn(nm){
    obj = document.getElementById(nm);
    if(obj.style.display == "none"){
        obj.style.display = "inline";
    }else{
        obj.style.display = "none";
    }
}
function showhide_type(n){
    var razhschs = ["SWF", "SWF", "SWF", "ZIP", "ZIP", "ZIP", "SWF"];
    n ? 0 : n=0;
    if(n>=0){
        for(i=0;i<7;i++) {
            if(i!=n){
                document.getElementById("project_"+i).style.display = "none";
            }else{
                document.getElementById("project_"+i).style.display = "inline";
            }
        }
        document.getElementById("filerazsh").innerHTML = "Файл проекта ("+razhschs[n]+"):";
    }
}
function bannerOff(){
    makeRequest("banneroff.php", "mbanner");
}
function hide(nm){
    document.getElementById(nm).style.display = "none";
}
function show(nm){
    document.getElementById(nm).style.display = "inline";
}
function change_rating(id, rating, votes){
    document.getElementById("project_rating_"+id).innerHTML = rating;
    document.getElementById("project_votes_"+id).innerHTML = votes;
}
function delete_this(cat, id){
    if(document["del_"+cat+"_"+id].why.value!=""){
        document["del_"+cat+"_"+id].submit();
    }else{
        alert("Напиши причину отказа.");
    }
}

function insert (txt) {
    if(txt){
        var form_name = document.add_message_form.message;
        form_name.focus();
        if (document.selection) {
            SelectedText = form_name.document.selection.createRange();
            SelectedText.text = txt;
        }
    }
}

function openSmiles(){
    add_message_form.message.focus();
    popup=window.open('includes/smilesAll.php','smilesAll','scrollbars=yes,toolbar=no,location=no,resizable=no,width=600,height=400');
    popup.focus()
}


function econfirm(txt){
    if(confirm(txt))
        return true;
    else return false;
}

function quoting(nm, txtid){
    var txt = document.getElementById("crystalmessage"+txtid).innerHTML;
    txt = txt.split('<SPAN class="quote">«').join('').split('»</SPAN>').join('');
    txt = txt.split('<b>').join('[b]').split('</b>').join('[/b]');
    txt = txt.split('<i>').join('[i]').split('</i>').join('[/i]');
    txt = txt.split('<u>').join('[u]').split('</u>').join('[/u]');
    txt = txt.split('<s>').join('[s]').split('</s>').join('[/s]');
    txt = txt.split('<BR>').join('\n').split('<br>').join('\n');
    insert_yo('[q user='+nm+']'+txt, '[/q]')
}
