function RotateTopImages()
{
	var min = 0;
	var max = top_imgs.length - 1;
	if (max < 1) return;
	if (!last_img.match(/^[0-9]/)) return;
	var num = 0;
//	do { num = Math.floor(Math.random() * (max - min + 1) + min); }
//	while (last_img == top_imgs[num-1]);
	for (i=0; i<=max; i++)
		if (last_img == top_imgs[i])
		{
			if (i != max) num = i + 1;
			break;
		}

	var img = new Image();
	img.onload = function()
	{
		var frame1 = MEL.d.getEl("frame1");
		var frame2 = MEL.d.getEl("frame2");

		if (MEL.ua.ie)
			frame2.childNodes[0].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='crop')";
		else
			frame2.childNodes[0].style.backgroundImage = "url(" + img.src + ")";
		var anim = MEL.animation.Create(frame1, 500);
		anim.animateOpacity(frame1, 1, 0, 0.05);
		anim.onFinish = function()
		{
			var anim = MEL.animation.Create(frame1, 700);
			anim.animateOpacity(frame2, 0, 1, 0.05);
			anim.onFinish = function()
			{
				if (MEL.ua.ie)
				{
					frame1.childNodes[0].style.filter = frame2.childNodes[0].style.filter;
					MEL.dom.setAttribute(frame1, "filters.alpha.opacity", 100);
					MEL.dom.setAttribute(frame2, "filters.alpha.opacity", 0);
				}
				else
				{
					frame1.childNodes[0].style.backgroundImage = frame2.childNodes[0].style.backgroundImage;
					frame1.style.opacity = 1;
					frame2.style.opacity = 0;
				}

				window.setTimeout(RotateTopImages, 5000);
				last_img = top_imgs[num];
			}
			anim.start();
		}
		anim.start();
	}
	img.src = img_path + top_imgs[num] + ".png";
}


var top_logos = ["bma", "bmr", "bma", "pbk", "bma", "ren", "bma", "mk"];
var last_logo = 0;
var next_logo = new Image();
function RotateTopLogos()
{
	var min = 0;
	var max = top_logos.length - 1;
	if (max < 1) return;
	var num = 0;

	if (last_logo >= max)
		last_logo = 0;
	else
		last_logo++;
	num = last_logo;

	next_logo.onload = function()
	{
		var logo = MEL.d.getEl("top_logo");
		var anim = MEL.animation.Create(logo, 500);
		anim.animateOpacity(1, 0, 0.05);
		anim.onFinish = function()
		{
			logo.src = next_logo.src;
			var anim = MEL.animation.Create(logo, 700);
			anim.animateOpacity(0, 1, 0.05);
			anim.onFinish = function()
			{
				window.setTimeout(RotateTopLogos, 3000);
			}
			anim.start();
		}
		anim.start();
	}
	next_logo.src = logo_path + top_logos[num] + ".gif";
}

function onLoadPage()
{
	window.setTimeout(RotateTopImages, 5000);
	window.setTimeout(RotateTopLogos, 3000);
}

