flag_load = false;
function getBounds(element)
{
        var left = element.offsetLeft;
        var top = element.offsetTop;
        for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
        {
        left += parent.offsetLeft;
        top += parent.offsetTop;
        }
        return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

function open_div_response()
{
        left = 532;
        if(is_opera)
        {
                left = 510;
        }

        switch(document.getElementById('div_response').className)
        {
                case "div_cl_resp_v": hide_div_response();break;
                case "div_cl_resp_h":
                {
                        bounds = getBounds(document.getElementById('tbl_small'));
                        document.getElementById('div_response').style.left = bounds.left;
                        document.getElementById('div_response').style.top = bounds.top + bounds.height + 20;
                        //document.getElementById('div_response').style.visibility = 'visible';
                        document.getElementById('div_response').className = 'div_cl_resp_v';
                        document.getElementById('div_response').style.width = left;
                }break;
        }

}

function close_div_response()
{
        document.getElementById('div_response').className = 'div_cl_resp_h';
}

function open_div_popup(str)
{
         canva = document.getElementsByTagName((document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY")[0];

         document.getElementById(str).style.width = 140;
         document.getElementById(str).style.height = 49;
         document.getElementById(str).style.borderColor = '#000000';

         document.getElementById(str).style.left = window.event.clientX + 12 + canva.scrollLeft;
         document.getElementById(str).style.top = window.event.clientY - 50 + canva.scrollTop;
         return false;
}

function close_div_popup(str)
{
         document.getElementById(str).style.width = 0;
         document.getElementById(str).style.height = 0;
         document.getElementById(str).style.left = 0;
         document.getElementById(str).style.top = 0;
         document.getElementById(str).style.borderColor = '#FFFFFF';
}

function hide_div_response()
{
        document.getElementById('div_response').className = 'div_cl_resp_h';
        document.getElementById('div_response').style.top = 300;
        get_data('http://neograd.ru/resp/get_resp.php?name_id=' + name_id_good);
}

function show_loading()
{
        parent.flag_load = false;
        document.getElementById('td_response').innerHTML = "<div align='center'>Загрузка...</div>";
}

function hide_loading()
{
        document.getElementById('div_loading').style.visibility = 'hidden';
}

function get_data(str)
{
        show_loading();
        window.frames['fr_response'].location.href = str;
        setTimeout('set_data()',1000);
}

function set_data()
{
        if(parent.flag_load == true)
        {
                document.getElementById('td_response').innerHTML = window.fr_response.document.body.outerHTML;
        }
        if(parent.flag_load == false)
        {
                setTimeout('set_data()',1000);
        }
}

function getxmlhttp()
{
        var xmlhttp = null;
        if(window.XMLHttpRequest)
        {
                try
                {
                        xmlhttp = new XMLHttpRequest();
                }
                catch(e)
                {
                }
        }
        else if(window.ActiveXObject)
        {
                try
                {
                        xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
                }
                catch (e)
                {
                        try
                        {
                                xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
                        }
                        catch(e)
                        {
                        }
                }
        }
        return xmlhttp;
}

function get_state()
{
        if(xmlhttp.readyState == 4)
        {
                document.getElementById('qweasd').innerHTML = xmlhttp.responseText;
        }
}

function replace_string(txt,cut_str,paste_str)
{
        var f=0;
        var ht='';
        ht = ht + txt;
        f=ht.indexOf(cut_str);
        while (f!=-1)
        {
                f=ht.indexOf(cut_str);
                if (f>0)
                {
                        ht = ht.substr(0,f) + paste_str + ht.substr(f+cut_str.length);
                }
        }
        return ht
}

function replace_br()
{
        textt.value = replace_string(textt.value,"\n","<br>");
}

function show_resp_link()
{
        if(is_ie != -1 || is_opera != -1)
        {
                bounds = getBounds(document.getElementById('tbl_small'));
                document.getElementById('img_resp_link').style.left = bounds.left + 40;
                document.getElementById('img_resp_link').style.top = bounds.top + bounds.height - 26;
                setTimeout('show_resp_link()',500);
        }
        else
        {
                document.getElementById('img_resp_link').style.dysplay = 'none';
        }
}