/* 2008 Copyright Kalamun - GNU GPL 3 */

var timeout=3000,
	currentBanner=0,
	sl_t=null,
	sl_t2=null,
	sl_img=null;

function b3_startSlide() {
	if(!banner||banner.length==0) {
		banner[0]=Array();
		banner[0]['file']='default/boca.jpg';
		banner[0]['img']=new Image();
		banner[0]['img'].src=maindir+banner[0]['file'];
		}
	sl_img.onload=function() {
		this.style.width=banner[currentBanner]['img'].width+'px';
		if(document.all&&banner[currentBanner]['img'].height>810) this.style.height='810px';
		else this.style.height=banner[currentBanner]['img'].height+'px';
		//this.style.top=-(this.height-this.parentNode.offsetHeight)/2+'px';
		this.style.position='relative';
		this.style.top=0+'px';
		this.style.left=-(this.width-this.parentNode.offsetWidth)/2+'px';
		sl_t=setInterval("b3_alphaUp()",50);
		}
	sl_img.src=maindir+banner[currentBanner]['file'];
	sl_img.style.filter="alpha(opacity=0)";
	sl_img.style.MozOpacity=0;
	sl_img.style.opacity=0;
	}
function b3_closeBanner() {
	sl_t=setInterval("b3_alphaDown()",50)
	}
function b3_alphaUp() {
	var op=parseFloat(sl_img.style.opacity);
	sl_img.style.top=0+'px';
	if(op<1) {
		op=op+0.05;
		sl_img.style.filter="alpha(opacity="+(op*100)+")";
		sl_img.style.MozOpacity=op;
		sl_img.style.opacity=op;
		}
	else {
		clearInterval(sl_t);
		sl_t2=setInterval("b3_moveUpSlide()",timeout/100);
		if(banner.length>1) sl_t=setTimeout("b3_closeBanner()",timeout);
		else sl_t=setTimeout("clearInterval(sl_t2)",timeout);
		}
	}
function b3_alphaDown() {
	var op=parseFloat(sl_img.style.opacity);
	clearInterval(sl_t2);
	if(op>0) {
		op=op-0.05;
		sl_img.style.filter="alpha(opacity="+(op*100)+")";
		sl_img.style.MozOpacity=op;
		sl_img.style.opacity=op;
		}
	else {
		clearInterval(sl_t);
		currentBanner++;
		if(currentBanner>=banner.length) currentBanner=0;
		b3_startSlide()
		}
	}
function b3_moveUpSlide() {
	if(parseInt(sl_img.style.height)+parseInt(sl_img.style.top)>400) {
		var increase=(parseInt(sl_img.style.height)-sl_img.parentNode.offsetHeight)/100;
		if(increase<1) increase=1;
		sl_img.style.top=(parseInt(sl_img.style.top)-increase)+'px';
		}
	}