function whyBro(varName)
{
    if (document.all){return document.all[varName];}
    else if (document.getElementById){return document.getElementById(varName);}
}
isDOM=document.getElementById?true:false;
isOpera=window.opera && isDOM;


function switchMarker(idUnitMenu,cond)
{
    if (cond == "open")
    {
        whyBro(idUnitMenu).style.backgroundImage = "url('/_Images/marker_bird2S_grey.gif')";
        whyBro(idUnitMenu).style.backgroundPosition = "0 4px";
    }
    else
    {
        whyBro(idUnitMenu).style.backgroundImage = "url('/_Images/marker_bird2E_grey.gif')";
        whyBro(idUnitMenu).style.backgroundPosition = "3px 3px";
    }

}


function switchOn(curUnitId,curUnitMenuId)
{
    if (whyBro(curUnitId))
    {
        if (whyBro(curUnitId).style.display == "block")
        {
            arrAllDiv = document.getElementsByTagName("div");
            var arrAllDivMenuCurrent;
            var arrAllDivMenu = new Array();
            for (var i =0; i < arrAllDiv.length; i++)
            {
                if (arrAllDiv[i].className == "links")
                    {arrAllDiv[i].style.display = "none";}

                if (arrAllDiv[i].className == "head")
                    {switchMarker(arrAllDiv[i].id,"close");}//path
            }
        }
        else
        {
            arrAllDiv = document.getElementsByTagName("div");
            var arrAllDivMenuCurrent;
            var arrAllDivMenu = new Array();
            for (var i =0; i < arrAllDiv.length; i++)
            {
                if (arrAllDiv[i].className == "links")
                    {arrAllDiv[i].style.display = "none";}

                if (arrAllDiv[i].className == "head")
                    {switchMarker(arrAllDiv[i].id,"close");}//path
            }

            whyBro(curUnitId).style.display = "block";
            switchMarker(curUnitMenuId,"open");//path
        }

    }

}

var flagOPenMenu = "";

function switchAll()
{
    if (flagOPenMenu == "")
    {
        var menuCond = "block";
        var menuMarker = "open";
    }
    else
    {
        var menuCond = "none";
        var menuMarker = "close";
    }

    arrAllDiv = document.getElementsByTagName("div");
    var arrAllDivMenu = new Array();
    for (var i =0; i < arrAllDiv.length; i++)
    {
        if (arrAllDiv[i].className == "links")
            {arrAllDiv[i].style.display = menuCond;}

        if (arrAllDiv[i].className == "head")
            {switchMarker(arrAllDiv[i].id,menuMarker);}
    }

    if (flagOPenMenu == "")
        {flagOPenMenu = "yes";}
    else
        {flagOPenMenu = "";}

}


function newWindowCreate(windowWidth, windowHeight, code) {
    var picWidth = windowWidth;
    var picHeight = windowHeight;

    if(screen.width  - 100 < windowWidth) {
        windowWidth = screen.width - 100;
    }
    if(screen.height - 100 < windowHeight) {
        windowHeight = screen.height - 100;
    }

    bigPhotoW = eval('window.open("/popup_showimg.php?code=' + code + '", "newBigPhotoW", "width=' + windowWidth + ',height=' + windowHeight + '")');
    bigPhotoW.focus();
}


function newWindowCreate_url(windowWidth, windowHeight, url) {
    var picWidth = windowWidth;
    var picHeight = windowHeight;

    if(screen.width  - 100 < windowWidth) {
        windowWidth = screen.width - 100;
    }
    if(screen.height - 100 < windowHeight) {
        windowHeight = screen.height - 100;
    }

    bigPhotoW = eval('window.open("' + url + '", "newBigPhotoW", "width=' + windowWidth + ',height=' + windowHeight + '")');
    bigPhotoW.focus();
}


function newWindowCreate_basket(windowWidth, windowHeight, code, auth) {
    var picWidth = windowWidth;
    var picHeight = windowHeight;

    if(screen.width  - 100 < windowWidth) {
        windowWidth = screen.width - 100;
    }
    if(screen.height - 100 < windowHeight) {
        windowHeight = screen.height - 100;
    }

    if (auth==0) bigBasketW = eval('window.open("popup_login.php?code=' + code + '", "newBigBasketW", "width=' + windowWidth + ',height=' + windowHeight + '")');
    else bigBasketW = eval('window.open("popup_sale.php?code=' + code + '", "newBigBasketW", "width=' + windowWidth + ',height=' + windowHeight + '")');
    bigBasketW.focus();
}


function showImg(windowWidth, windowHeight, path) {
    var picWidth = windowWidth;
    var picHeight = windowHeight;

    if(screen.width  - 100 < windowWidth) {
        windowWidth = screen.width - 100;
    }
    if(screen.height - 100 < windowHeight) {
        windowHeight = screen.height - 100;
    }

    bigPhotoW = eval('window.open("/popup_showimg.php?path=' + path + '", "newBigPhotoW", "width=' + windowWidth + ',height=' + windowHeight + '")');
    bigPhotoW.focus();
}


function checkAll( n, fldName ) {
    if (!fldName) {
        fldName = 'cb';
    }
    var f = document.adminForm;
    var c = f.toggle.checked;
    var n2 = 0;
    for (i = 0; i < n; i++) {
        cb = eval( 'f.' + fldName + '' + i );
        if (cb) {
            cb.checked = c;
            n2++;
        }
    }
    if (c) {
        document.adminForm.boxchecked.value = n2;
    } else {
        document.adminForm.boxchecked.value = 0;
    }
}


function isChecked(isitchecked){
    if (isitchecked == true){
        document.adminForm.boxchecked.value++;
    } else {
        document.adminForm.boxchecked.value--;
    }
}
