/**
 * Common DIV functions
 * Work in IE(4\5\6), NN4, NN6, Mozilla, Opera
 * Kirill Kudryavtsev kck@mail.ru
 **/
var isOPERA = (navigator.userAgent.indexOf('Opera') >= 0) ? true : false;
var isIE    = (document.all) ? true : false;
var isW3C   = (document.getElementById && !isIE) ? true : false;
var isNN4   = (document.layers) ? true : false;
var isNN6   = (navigator.userAgent.indexOf('Netscape6') >= 0) ? true : false;

// isDHTML capable browser for degradability
var isDHTML = (isIE || isW3C || isNN4) ? true : false;


//Навигация
                       function sm(num,type)
                        {
                                if (getObjByName('smenu_' + num))
                                {
                                        t=getObjByName('smenu_' + num);
                                        if (type==0)
                                        {
                                                x = findObjLeft('mimage_' + num) + 2;
                                                y = findObjTop('mimage_' + num)  + 0;
                                        }
                                        else
                                        {
                                                x = findObjLeft('mimage_' + num) + 9;
                                                y = findObjTop('mimage_' + num)  - 1;
                                        }
                                        if (x + findObjWidth('smenu_' + num) > findClientWidth())
                                        {
                                                x = findClientWidth() - findObjWidth('smenu_' + num) - 10;
                                                if (!isIE)
                                                {
                                                        x = x - 10;
                                                }
                                        }
                                moveObjTo('smenu_' + num, x, y);
                                showObj('smenu_' + num);
                                }
                        }
                        function hm(num,type)
                        {
                                if (getObjByName('smenu_' + num))
                                {
                                        hideObj('smenu_' + num);
                                }
                        }
//Навигация

// Get element by name
function getObjByName(objName)
{
        if (!isDHTML) return null;
        return (isIE || isW3C) ?
                ((isIE) ? document.all[objName] : document.getElementById(objName) ) :
                document.layers[objName];
}



// Hide named object
function hideObj(objName)
{
        if (!isDHTML) return null;
        obj = getObjByName(objName);
        if(!obj) return;
        if (isIE || isW3C)
        {
                obj.style.visibility = 'hidden';
        }
        else
        {
                obj.visibility = 'hide';
        }
}

// Show named object
function showObj(objName)
{
        if (!isDHTML) return null;
        obj = getObjByName(objName);
        if(!obj) return;
        if (isIE || isW3C)
        {
                obj.style.visibility = 'visible';
        }
        else
        {
                obj.visibility = 'show';
        }
}

function moveObjTo(objName, x, y)
{
        if (isDHTML)
        {
                if (isIE || isW3C || isOPERA)
                {
                        obj = getObjByName(objName);
                        obj.style.left = x + "px";
                        obj.style.top  = y + "px";
                }
                else
                {
                        document.layers[objName].left = x;
                        document.layers[objName].top = y;
                }
        }
}


function findObjTop(objName)
{
        var tmp    = 0;
        var parent = getObjByName(objName);
        while (parent)
        {
                tmp   += parent.offsetTop;
                parent = parent.offsetParent;
        }
        return tmp;
}

// Get named object's computed left
function findObjLeft(objName)
{
        var tmp    = 0;
        var parent = getObjByName(objName);
        while (parent)
        {
                tmp   += parent.offsetLeft;
                parent = parent.offsetParent;
        }
        return tmp;
}
// Get named object's computed width
function findObjWidth(objName) {
        if (isDHTML) {
                if (isIE) {
                        return eval(objName + '.offsetWidth');
                }
                if (isW3C) {
                        obj = document.getElementById(objName);
                        return parseInt(document.defaultView.getComputedStyle(obj, '').getPropertyValue('width'));
                }
                if (isOPERA) {
                        obj = document.getElementById(objName);
                        return obj.style.pixelWidth;
                }
                // else isNN4
                return document.layers[objName].clip.width;
        }
        return null;
}

// Get named object's computed height
function findObjHeight(objName) {
        if (isDHTML) {
                if (isIE) {
                        return eval(objName + '.offsetHeight');
                }
                if (isW3C) {
                        obj = document.getElementById(objName);
                        return parseInt(document.defaultView.getComputedStyle(obj, '').getPropertyValue('height'));
                }
                if (isOPERA) {
                        obj = document.getElementById(objName);
                        return obj.style.pixelHeight;
                }
                // else is NN4
                return document.layers[objName].clip.height;
        }
        return null;
}

// Get browser width
function findClientWidth() {
        if (isDHTML) {
                if (isIE) {
                        return document.body.clientWidth;
                } // else is NN4 && W3C
                else {
                        return innerWidth;
                }
        }
        else {
                return null;
        }
}

// Get browser height
function findClientHeight() {
        if (isDHTML) {
                if (isIE) {
                        return document.body.clientHeight;
                }
                else { // else isNN4 && W3C
                        return innerHeight;
                }
        }
        else {
                return null;
        }
}
function setBgColor(objName, bgcolor) {
        if (isDHTML) {
                obj = getObjByName(objName);
                if (obj != null) {
                        if (isIE || isW3C) {
                                obj.style.backgroundColor = bgcolor;
                        }
                        else if ( isOPERA ) {
                                obj.style.background = bgcolor;
                        }
                        else {
                                obj.document.bgColor = bgcolor;
                        }
                }
        }
}
function show_big_img(winnum,title,width,height,imgurl)
{
im=window.open('','win'+winnum,'top=40,left=40,width='+width+',height='+height+',scrollbars=no,menu=no,status=yes,resizable=no');
im.focus();
im.document.open ("text/html");
im.document.write ('<html><title>'+title+'</title><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgcolor=#ffffff><img src='+imgurl+'></body></html>');
im.document.close ();
}

function print_map(part) {
im=window.open('feedback.php?part='+part,null,'top=40,left=40,width=640,height=480,scrollbars=yes,toolbars=yes,status=no,resizable=no');
im.focus();
}

function print_map1(part) {
im=window.open('register.php?part='+part,null,'top=40,left=40,width=640,height=480,scrollbars=yes,toolbars=yes,status=no,resizable=no');
im.focus();
}

                       function sm(num,type)
                        {
                                if (getObjByName('smenu_' + num))
                                {
                                        t=getObjByName('smenu_' + num);
                                        if (type==0)
                                        {
                                                x = findObjLeft('mimage_' + num) + 2;
                                                y = findObjTop('mimage_' + num)  + 0;
                                        }
                                        else
                                        {
                                                x = findObjLeft('mimage_' + num) + 9;
                                                y = findObjTop('mimage_' + num)  - 1;
                                        }
                                        if (x + findObjWidth('smenu_' + num) > findClientWidth())
                                        {
                                                x = findClientWidth() - findObjWidth('smenu_' + num) - 10;
                                                if (!isIE)
                                                {
                                                        x = x - 10;
                                                }
                                        }
                                moveObjTo('smenu_' + num, x, y);
                                showObj('smenu_' + num);
                                }
                        }
                        function hm(num,type)
                        {
                                if (getObjByName('smenu_' + num))
                                {
                                        hideObj('smenu_' + num);
                                }
                        }