function wshow(url, width, height)
{
    if (!width) width = 640;
    if (!height) height = 480;
    window.open(url, (winCol++), 
                'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' 
                + width + 
                ',height=' + height + 
                ',left=' + ((screen.width - width) / 2) + 
                ',top=' + ((screen.height - height) / 2));
    return false;
}
function __get(id)
{
    if (document.layers)
    {
        return document.layers[id];
    }
    if (document.getElementById)
    {
        return document.getElementById(id);
    }       
    if (document.all)
    {
        return document.all[id];
    }
}
//-------------------------------------------------------------------
function setTableStyle(tableObject, noHeader, isFooterTr) 
{
    var topLevel = tableObject.childNodes;
    
    for (var j = 0; j < topLevel.length; j++) {

        if (topLevel[j].nodeName == "TBODY") {

            var nodes;
            nodes = topLevel[j].childNodes;

            for (var i = 0, tr = 0; i < nodes.length; i++) {
                if (nodes[i].nodeName == "TR" && nodes[i].className != 'trDelim') {
                    
                    if ((tr == 0) && (!noHeader)) {
                        nodes[i].className = 'head';
                    } else {
                        if (isFooterTr == true && tr == nodes.length-1)  {
                            
                            nodes[i].className = 'footer';
                        } else {

                            if (tr % 2) {
                                nodes[i].className = 'ligth';
                            } else {
                                nodes[i].className = 'dark';
                            }
                        }
                    }
                    
                    var tdNodes;
                    tdNodes = nodes[i].childNodes;
                    for (var k=0, td = 0; k<tdNodes.length; k++) {

                        if (tdNodes[k].nodeName == "TD" && tdNodes[k].className != 'tdDelim') {

                            if (td % 2) {
                                tdNodes[k].className = 'tdLigth';
                            } else {
                                tdNodes[k].className = 'tdDark';
                            }
                            td++;
                        }
                    }
                    tr++;
                }
            }
        }
    }
}
function updateTables(noHeader, isFooterTr, tableClassName) 
{
    all = document.getElementsByTagName("table");
    for (var i = 0; i < all.length; i++) {

        var obj = all[i];
        if ((obj.className == 'colorTable' && !tableClassName) || (obj.className == tableClassName && tableClassName)) {
            setTableStyle(obj, noHeader, isFooterTr);
        } else if (obj.className == 'colorTableWithFooterLine' && !tableClassName) {
            setTableStyle(obj, noHeader, true);
        } else if (obj.className == 'colorTableWithNoHeader' && !tableClassName) {
            setTableStyle(obj, true, isFooterTr);
        } else if (obj.className == 'colorTableWithFooterLineWithNoHeader' && !tableClassName) {
            setTableStyle(obj, true, true);
        }
    }
}
function button(id)
{
    this.object = __get(id);
    this.id = id;

    this.object.onmouseover = function onmouseover() {
        this.style.backgroundColor = '#F8E7AF';    
    }
    this.object.onmouseout = function onmouseout() {
        this.style.backgroundColor = '#FFFFFF';
    }
}

function newItem(id, ref)
{
    this.object = __get(id);
    this.id = id;                                
    this.defaultClassName = this.object.className;
    this.object.object = this;
    
    this.object.onclick = function onclick() {
         
        window.location.href = ref;
    }

    this.object.onmouseover = function onmouseover() {

       this.className = this.object.defaultClassName+'Active';
       
    }

    this.object.onmouseout = function onmouseout() {

        this.className = this.object.defaultClassName;
    
    }
}

function add() 
{

    if ((navigator.appName == "Microsoft Internet Explorer") && 
        (parseInt(navigator.appVersion) >= 4)) { 

        window.external.addFavorite(document.location, "Магнум Аудит")

    } else { 

        if(navigator.appName == "Netscape") alert("Нажмите Ctrl-D"); 
        if(navigator.appName == "Opera") alert("Зайдите в меню браузера Закладки/Bookmarks"); 
    }
}
var browserInfo = new Object;
    browserInfo.agt       = navigator.userAgent.toLowerCase();
    browserInfo.is_ie     = ((browserInfo.agt.indexOf("msie") != -1) && (browserInfo.agt.indexOf("opera") == -1));
    browserInfo.is_opera  = (browserInfo.agt.indexOf("opera") != -1);
    browserInfo.is_mac    = (browserInfo.agt.indexOf("mac") != -1);
    browserInfo.is_mac_ie = (browserInfo.is_ie && browserInfo.is_mac);
    browserInfo.is_win_ie = (browserInfo.is_ie && !browserInfo.is_mac);
    browserInfo.is_gecko  = (navigator.product == "Gecko");

function isFlashIE(v) {

    var res = false;
    var i;
    for (i = 0; i < 3; i++) {
    
        try {
            if (eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.' + i + '")')) {
        
                res = true;
            }
        } catch(e) {
        
        }
    }
    return res;
}
function isFlashNN(v) 
{
    if (navigator.plugins['Shockwave Flash']) 
    {
        var d = navigator.plugins['Shockwave Flash'].description;
        if (parseInt(d.substring(d.indexOf(".") - 1)) >= v) return true;
    }
    return false;
}

function brVersion()
{
    var agent = navigator.userAgent;
    if ((agent.indexOf("iCab") != -1) || (agent.indexOf("MSIE 3") != -1)) return 0;
    if ((agent.indexOf("Opera") == -1) && (agent.indexOf("MSIE") != -1) && (agent.indexOf("Windows") != -1)) return 1;
    return 2;
}
function isFlash(fv) 
{
    var bv = brVersion();
    if (bv == 1) return isFlashIE(fv);
    if (bv == 2) return isFlashNN(fv);
    return false
}

function trim(str) {

    beg = 0;
    while (str.charAt(beg) == " ") { beg++; }
    end = str.length - 1;
    while (str.charAt(end) == " ") { end--; }

    if (beg <= end) { return str.substring(beg, end + 1); }
    else            { return ""; }
}
