// SACK

var URL = '/';


    var boxiDnesNews1 = new sack();
        boxiDnesNews1.requestFile = URL+'includes/js.php';
        boxiDnesNews1.method = 'POST';
        boxiDnesNews1.element = 'boxClankyRealityJS';
        boxiDnesNews1.onLoading = boxLoading;
        boxiDnesNews1.onLoaded = boxLoaded;
        boxiDnesNews1.onCompletion = boxCompletion;

    boxiDnesNews1.update = function ()
    {
        this.setVar('s', 'idnesRSS');
        this.setVar('t', 'reality');
        this.setVar('c', '5');
        this.runAJAX();
    }
    
    var boxiDnesNews2 = new sack();
        boxiDnesNews2.requestFile = URL+'includes/js.php';
        boxiDnesNews2.method = 'POST';
        boxiDnesNews2.element = 'boxClankyEkonomikaJS';
        boxiDnesNews2.onLoading = boxLoading;
        boxiDnesNews2.onLoaded = boxLoaded;
        boxiDnesNews2.onCompletion = boxCompletion;

    boxiDnesNews2.update = function ()
    {
        this.setVar('s', 'idnesRSS');
        this.setVar('t', 'ekonomikah');
        this.setVar('c', '5');
        this.runAJAX();
    }

    var adv = new sack();
        adv.requestFile = URL+'includes/js.php';
        adv.method = 'POST';
        adv.element = 'advContainer';
        adv.onLoading = boxLoading;
        adv.onLoaded = boxLoaded;
        adv.onCompletion = boxCompletion;
        //adv.onInteractive = whenInteractiveMy;
        //adv.onCompletion = updateChat;
        
    chatIndex = 1;

    adv.update = function ()
    {
        this.setVar('s', 'advert');
        this.setVar('c', '1');
        this.runAJAX();
    }
    
    function boxLoading()
    {
        if ( this.elementObj )
        {
            this.elementObj.style.filter = 'alpha(opacity=50)';
            this.elementObj.style.opacity = '.60';
//            this.elementObj.innerHTML = 'loading...'+URL+'images/loadingTransparent.gif';
            this.elementObj.innerHTML = '<div class="loadingTransparent"></div>';
        }
    }
    
    function boxLoaded()
    {
        if ( this.elementObj )
        {
            this.elementObj.style.filter = 'alpha(opacity=100)';
            this.elementObj.style.opacity = '1';
            //this.elementObj.innerHTML = 'initializing...';
        }
    }
    
    function boxCompletion()
    {
        if ( typeof(this.elementObj) == 'object' )
        {
            var scripts=this.elementObj.getElementsByTagName("script");
            for (var i=0; i<scripts.length; i++)
            {
                eval(scripts[i].text)
            }
            var styles=this.elementObj.getElementsByTagName("style")
            for (var i=0; i<styles.length; i++)
            {
                eval(styles[i].text)
            }
        }
    }

function doFade(elementFrom, content) {

	this.elementFrom = elementFrom;
	this.content = content;
	this.opacity = 100;
	this.timer = 2;
	this.step = 4;
	
	var fadeObject = this;
	this.fadeOut = function()
    {
        this.elementFrom.style.filter = 'alpha(opacity='+this.opacity+')';
        this.elementFrom.style.opacity = this.opacity/100;
        this.opacity -= this.step;
        if ( this.opacity >= 0)
            setTimeout( function(){ fadeObject.fadeOut(); }, this.timer);
        else
        {
            this.elementFrom.innerHTML = this.content;
            setTimeout( function(){ fadeObject.fadeIn(); }, this.timer);
        }
    }
    
	this.fadeIn = function()
    {
        this.elementFrom.style.filter = 'alpha(opacity='+this.opacity+')';
        this.elementFrom.style.opacity = this.opacity/100;
        this.opacity += this.step;
        if ( this.opacity <= 100)
            setTimeout( function(){ fadeObject.fadeIn(); }, this.timer);
        else
        {
            
        }
    }
    
    this.run = function()
    {
        setTimeout( function(){ fadeObject.fadeOut(); }, this.timer);
    }
    
    this.run();
    
    
    
	
function delay(cmd) {
    if (typeof(axTimer)!='undefined')
        clearTimeout(axTimer);
    axTimer = setTimeout(cmd, 200);
}

function resetSelectOptions(e)
{
    for (i=(e.length - 1); i>=0; i--)
    {
        e.remove(i);
    }
}

function changeSelectOptions(e, xml)
{
    resetSelectOptions(e);
    opts = xml.getElementsByTagName('option');
    for (var i=0; i<opts.length; i++)
    {
        text = (opts[i].firstChild) ? opts[i].firstChild.nodeValue : '';
        try {
            text = opts[i].firstChild.nodeValue;
        }   catch(ex) {
            text = opts[i].childNodes[0].text;
        }
        try {
            value = opts[i].attributes.getNamedItem("value").nodeValue;
        } catch(ex) {
            value = opts[i].attributes[0].nodeValue;
        }
        var opt = document.createElement('option');
        opt.text = text;
        opt.value = value;
        try {
            e.add(opt, null);
        } catch(ex) {
            e.add(opt);
        }
    }
}

}

