
function gamesScroll(type, container){
    if (typeof type      == 'undefined') type = 1; 
    if (typeof container == 'undefined') container = 1;
    if (window.gtimer) clearTimeout(window.gtimer);
    fadeOpacity(5, type, 'games-container-' + container);
}

function fadeOpacity(step, type, box, groth, counter)
{
    if (typeof counter == 'undefined') counter = 100;
    if (typeof groth   == 'undefined') groth   = 1;
    if ((counter -= step) > 0){
        setElementOpacity(document.getElementById(box), (groth > 0 ? counter/100 : (100 - counter)/100));
        window.gtimer = setTimeout( function(){ fadeOpacity(step, type, box, groth, counter); },1);
    }
    else if (groth > 0){
        slideShow(box, type);
        window.gtimer = setTimeout( function(){ fadeOpacity(step, type, box, -1); },100);
    }
}

function classChange(button, class_name)
{
    button.className = class_name;
}

function slideShow(box, type)
{
    var tds = document.getElementById(box).getElementsByTagName('td');
    box    += '_';
    if (!window[box]){
        window[box] = {
            first : [
                {className : tds[0].className, inner : tds[0].innerHTML}
                ,
                {className : tds[2].className, inner : tds[2].innerHTML}
            ],
            
            index : 0
        };
    }
    window[box].index += type;
    if (window[box].index < 0){
        window[box].index = tds.length/3 - 1;
    }
    else if (window[box].index >= tds.length/3){
        window[box].index = 0;
    }
    
    if (window[box].index){
        tds[ 0 ].className = tds[ window[box].index*3 ].className;
        tds[ 2 ].className = tds[ window[box].index*3+2 ].className;
        tds[ 0 ].innerHTML = tds[ window[box].index*3 ].innerHTML;
        tds[ 2 ].innerHTML = tds[ window[box].index*3+2 ].innerHTML;
    }
    else{
        tds[ 0 ].className = window[box].first[0].className;
        tds[ 2 ].className = window[box].first[1].className;
        tds[ 0 ].innerHTML = window[box].first[0].inner;
        tds[ 2 ].innerHTML = window[box].first[1].inner;
    }
}

function setElementOpacity(oElem, nOpacity)
{
	var p = getOpacityProperty();
	(setElementOpacity = p=="filter"?new Function('oElem', 'nOpacity', 'nOpacity *= 100;	var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha;	if (oAlpha) oAlpha.opacity = nOpacity; else oElem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";'):p?new Function('oElem', 'nOpacity', 'oElem.style.'+p+' = nOpacity;'):new Function)(oElem, nOpacity);
}

function getOpacityProperty()
{
	var p;
	if (typeof document.body.style.opacity == 'string') p = 'opacity';
	else if (typeof document.body.style.MozOpacity == 'string') p =  'MozOpacity';
	else if (typeof document.body.style.KhtmlOpacity == 'string') p =  'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) p =  'filter';
	
	return (getOpacityProperty = new Function("return '"+p+"';"))();
}

window.addEvent('load', function() {
    var Tips3 = new Tips($$('.recent-news-link'), {
    	showDelay: 0,
    	hideDelay: 1000,
    	className:'tool',
    	offsets:{x:40,y:20}
    });
});