/* teaser */

function onFinishedPlayingCross() {close_banner();}
function onFinishedPlaying() {close_banner();}

var close_banner = function (){
    $('#lightbox_banner').jqmHide();
}
function show_banner (sec){
	if (!sec) {
		sec=8;
	}
    var modal_window_options =
    {
        overlay:80,
        modal:false
    };
    $('#lightbox_banner').jqm(modal_window_options);    
    $('#lightbox_banner').jqmShow(); 
    $('#countdown').countdown({
        until: sec,
        onExpiry: close_banner
    });
}

/* peel */
var phpads_deliverActiveX = function(content){
    document.write(content);	
}

/* floating */
var iab_hide = function (){
    $('#banner_floating_24sata').hide();
};

function setFlashHeight(divId, divH)
{
	//document.getElementById(divId).style.height = divH + 'px';
    $('#leaderboard.' + divId).attr('style', 'height:' + divH 
										+ 'px; width:'+ $('#leaderboard.' + divId).width() 
										+ 'px; left:' + $('#leaderboard.' + divId).css('left'));
}

function setFlashWidth(divId, divW)
{
	//document.getElementById(divId).style.borderLeft = ( divW > 310 ) ? 'none' : '10px solid #FFF';
	//document.getElementById(divId).style.width = divW + 'px';
    $('#kocka.' + divId).attr('style', 'width:' + divW + 'px;')
}

function setFlashDim(divId, divW, divH)
{
	document.getElementById(divId).style.width = divW + 'px';
	document.getElementById(divId).style.height = divH + 'px';
}

function setFlashWidthRollLeft(divId, divW)
{
	//document.getElementById(divId).style.width = divW + 'px';
    if($("#kocka").length > 0){
   		$('#kocka.' + divId).attr('style', 'width:' + divW + 'px;');
    }
    
    if($("#halfpage").length > 0){
    	$('#halfpage.' + divId).attr('style', 'width:' + divW + 'px;');
    }
}

function setDivHolderVisible()
{
	document.getElementById('xl_container_banner_still').style.overflow = 'visible';
}

$(document).ready(function() {
	
	if($("#peel_off object").length == 0){
		$("#peel_off").hide();
	}
});




/*----------------------------------------------------------------------*/
/* time_banner.js */
_stop_screensaver = false;
var _mmcounter = 0;
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

// waitTime is in milliseconds.
var ScreenSaver = function (waitTime)
{
    this.lastActivity = new Date().getTime();
    this.waitTime = waitTime;

    var $this = this;
    
    this._timer = setInterval
    (
        function ()
        {
            $this._checkTime.call( $this ) 
        }, 
        1000
    );
    
    document.onmousemove = function ()
    {
        if(document.all || is_chrome)
        {
            _mmcounter++;
            if (_mmcounter > 30)
            {
                _mmcounter = 0;
                $this._mouseHandler.call( $this ) 
            }
        }
        else $this._mouseHandler.call( $this ) 
    };
};

ScreenSaver.prototype = 
{
    _timer: null,

    lastActivity: 0,
    started: false,
    waitTime: 0,

    onstart: function () 
    {
        this.bannerShow( true );
    },
    onend: function ()
    {
        this.bannerShow( false );
    },

    dispose: function () 
    {
        if (this._timer) clearInterval(this._timer);
        document.onmousemove = null;
    },

    _checkTime: function () 
    {
        if (!this.started && new Date().getTime() - this.lastActivity >= this.waitTime) 
        {
            this.started = true;
            this.onstart();
        }
    },

    _mouseHandler: function () 
    {
        this.lastActivity = new Date().getTime();
        if (this.started) 
        {
            this.started = false;
            this.onend();
        }
    },
    
    bannerShow: function ( p_state )
    {
        if (document.all) var nodes = 6;
        else nodes = 7;

        if ( p_state == true && document.getElementById("time_banner_content_td").childNodes.length > nodes && !_stop_screensaver) 
        {
            $('#time_banner_background').show();
            $('#time_banner_content').show();
        }else{
            $('#time_banner_content').hide();
            $('#time_banner_background').hide();
        }
    }
};

// 15 sekundi
/*var ss = new ScreenSaver(60000);*/

