function banner_rot_start(){
	if( typeof(headers_json)=='undefined' || !headers_json || headers_json.length<1 )
		return;
	for(var a=0;a<headers_json.length;a++) {
		headers_json[a].img = new Image;
		headers_json[a].img.onload = (function(a){
			return function(){
				headers_json[a].load = true;
				var l = true;
				for(var e=0; e<headers_json.length; e++)
					if ( !headers_json[e].load ) {
                        l = false;
                        break;
                    }
				if ( l )
					banner_rotator();
			}
		})(a);
		headers_json[a].img.src = headers_json[a].path;
	}
}
function banner_rotator(){
	var a=document.getElementById("banner_rotator_img1"),c=document.getElementById("banner_rotator_img2"),b=0;
    var cld = $('#products_menu').children();
	if(headers_json.length==1)
		a.src=headers_json[0].img.src;
	else {
		for(var d=0;d<headers_json.length;d++)
			if(headers_json[d].now) {
				b=d+1;
				if(b>=headers_json.length)
					b=0;
				headers_json[d].now=false;
                $(cld[d]).removeClass('highlight');
				break
			}
        $(cld[b]).addClass('highlight');
		headers_json[b].now=true;
		if(a.style.opacity==0) {
			a.style.zIndex=2;
			c.style.zIndex=1;
			a.src=headers_json[b].img.src
		} else if(c.style.opacity==0) {
			c.style.zIndex=2;
			a.style.zIndex=1;
			c.src=headers_json[b].img.src
		}
		if(a.style.opacity==0)
			changeBanner(a,c,b);
		else if(c.style.opacity==0)
			changeBanner(c,a,b);
	}
}
function changeBanner(a, c, b) {
    aopac = (parseInt(a.style.opacity*1000) + 25) / 1000;
    if ( aopac > 1 )
        aopac = 1;
	a.style.opacity = aopac;
	a.style.filter = 'alpha(opacity = '+parseFloat(a.style.opacity)*100+')';
    copac = (parseInt(c.style.opacity*1000) - 25) / 1000;
    if ( copac < 0 )
        copac = 0;
	c.style.opacity = copac;
	c.style.filter = 'alpha(opacity = '+parseFloat(c.style.opacity)*100+')';
	if ( c.style.opacity > 0 )
		timer = setTimeout(function(){changeBanner(a,c,b);}, 25);
	else {
		c.style.opacity = 0;
		a.style.opacity = 1;
		timer = setTimeout("banner_rotator()", 5000);
	}
}
banner_rot_start();
