var stepOp = 0;
var speedOp = 100;   //скорость изменения прозрачности
var viewTime = 8000; //продолжительность показа

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+"';"))();
}
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 hiddTxt(){
	div = document.getElementById('banners_content');
	stepOp = stepOp - 0.1;
	setElementOpacity(div, stepOp);
	if(stepOp <= 0){
		clearInterval(stopOp);
	        aniation_end();
	}
}

function endView(){
	stopOp = setInterval("hiddTxt()",speedOp);
}

function viewTxt(){
	div = document.getElementById('banners_content');
	stepOp = stepOp + 0.1;
	setElementOpacity(div, stepOp);
	if(stepOp >= 1){
		setElementOpacity(div, 1);
		clearInterval(stopOp);
		setTimeout("endView()",viewTime);
	}
}
	

function aniation_start(data){
        var div = document.getElementById('banners_content');
        setElementOpacity(div, 0);
        div.innerHTML = data;
        stopOp = setInterval("viewTxt()",speedOp);
}

function aniation_end(){
	wkGetPage();		
}

function wkGetPage(){
	function wkShowResult(data){
		aniation_start(data);
	}
			
	var TID = CPHttpRequest.InitThread();
	CPHttpRequest.SetAction(TID, wkShowResult);
	CPHttpRequest.Send(TID, '/banners_ajax/index.php', {'mode':'ajax'});
	return false; 
}

