// overeni kompatibility prohlizece
var browser = new verifyCompatibleBrowser();
 
function verifyCompatibleBrowser()
{
        this.ver = navigator.appVersion;
        this.dom = document.getElementById? 1 : 0;
        this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom)? 1 : 0;
        this.ie4 = (document.all && !this.dom) ? 1 : 0;
        this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
        this.ns4 = (document.layers && !this.dom) ? 1 : 0;

        return this;
}

function constructObjects(obj, obj2)
{
        obj2 = (!obj2) ? '' : 'document.' + obj2 + '.';
        this.objekt = browser.dom ? document.getElementById(obj) : browser.ie4 ? document.all[obj] : browser.ns4 ? eval(obj2+'document.'+obj) : 0;
        this.css = browser.dom ? document.getElementById(obj).style : browser.ie4 ? document.all[obj].style : browser.ns4 ? eval(obj2+'document.'+obj) : 0;
        this.scrollHeight = browser.ns4 ? this.css.document.height : this.objekt.offsetHeight;
        this.clipHeight = browser.ns4 ? this.css.clip.height : this.objekt.offsetHeight;
        this.up = MoveAreaUp; 
        this.down = MoveAreaDown;
        this.MoveArea = MoveArea;
        this.y;
        
        return this;
}

// incicializace prostredi
var initialised = false;

function scrollInit()
{
        objScrollArea = new constructObjects('desktop-area');
        objDivContent = new constructObjects('desktop-content','desktop-area');
        objDivContent.MoveArea(0);
        objScrollArea.css.visibility = 'visible';
        
        initialised = true;
}

// skrolovani oblasti
function MoveArea(y)
{
        this.y = y;
        this.css.top = this.y + 'px';
}

var loop;
var interval = 50;

function MoveAreaDown(move)
{
        if(this.y > (- this.scrollHeight) + objScrollArea.clipHeight)
        {
                this.MoveArea(this.y-move);
                if(loop) setTimeout("objDivContent.down(" + move + ")", interval);
        }
}

function MoveAreaUp(move)
{
        if(this.y < 0)
        {
                this.MoveArea(this.y - move);
                if(loop) setTimeout("objDivContent.up(" + move + ")", interval);
        }
}

function scrollStart(speed)
{
        if(initialised)
        {
                loop = true;
                if(speed > 0) objDivContent.down(speed)
                         else objDivContent.up(speed);
        }
}

function scrollStop()
{
        loop = false;
}

// aktivni obrazek v menu
function menuActive(id)
{
        var item = document.getElementById('menu'+id);
        item.src = 'images/menu' + id + 'a.jpg';
}

// neaktivni obrazek v menu
function menuNonActive(id)
{
        var item = document.getElementById('menu'+id);
        item.src = 'images/menu' + id + '.jpg';
}

// objekt pro praci s ajaxem
var xmlHttp = null;

// vraciobjekt pro praci s ajaxem
function getXmlHttpObject()
{
    var xmlHttp = null;
    
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e)
        {
            xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
        }
    }
    
    return xmlHttp;
}

// zakladni obsluha AJAXu
function callAjax(_url, _block, _action)
{ 
    xmlHttp = getXmlHttpObject();
    if(xmlHttp == null)
    {
        alert('AJAX ERROR!');
        return;
    }
    
    var url = _url + '?action=' + _action;

    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById(_block).innerHTML = xmlHttp.responseText;
        }
    };
    xmlHttp.open('GET', url + '&' + Math.random(), true);
    xmlHttp.setRequestHeader('Content-Type', 'text/html; charset=windows-1250'); 
    xmlHttp.send(null);
}
