function open_window ( url, w, h, b_resizable, b_scrollbars )
{
        if ( w > screen.width - 100 )
        {
                w = screen.width - 100;
                h += 21;
                b_scrollbars = true;
        }
        if ( h > screen.height - 100 )
        {
                h = screen.height - 100;
                w += 21;
                b_scrollbars = true;
        }

        var x = Math.floor ( ( screen.width - w - 10 ) / 2 );
        var y = Math.floor ( ( screen.height - h - 29 ) / 2 );

        if ( typeof ( gallery_window ) == "undefined" || gallery_window.closed )
        {
                gallery_window = window.open ( url, 'gallery_window', 'menubar=0,toolbar=0,location=0,scrollbars=' + ( b_scrollbars ? '1' : '0' ) + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ',width=' + w + ',height= ' + h + ',resizable=' + ( b_resizable ? '1' : '0' ) );
        }else gallery_window.location.href = url;

        gallery_window.focus();
}

function oo ( url, h )
{
        open_window ( url, 500, h, false, false );
}

function PripravLinky ()
{
        var anchors = document.getElementsByTagName ( "a" );

        for ( var i = 0; i < anchors.length; i++ )
        {
                var anchor = anchors[i];
                var relAttribute = String(anchor.getAttribute("rel"));
                if (anchor.getAttribute("href"))
                {
                        if ( relAttribute.match ( /^oo/ ) )
                        {
                                eval ( "anchor.onclick = function () { " + relAttribute + "; return false; }" );
                                anchor.href = "javascript:void(0)";
                        }
                }
        }
}

if (window.addEventListener) {
        window.addEventListener("load",PripravLinky,false);
} else if (window.attachEvent) {
        window.attachEvent("onload",PripravLinky);
} else {
        window.onload = function() {PripravLinky();}
}
