$(function()
{
	actionCount = $(actionSelector).length;

	if(actionCount !=0)
	{
		cntActionIdx = 0;
		$(actionSelector + ":eq("+ cntActionIdx + ")").show();
	}

	if( typeof(M_BNR) != "undefined" ){
		var time = (M_BNR[cntActionIdx])? M_BNR[cntActionIdx] : actionInterval;
		setTimeout("ShowAction();", time);
	}
	
	$("[@id=content] img").each(function()
	{
		$(this).load(function()
		{
			var width = $(this).width();
			var height = $(this).height()
			limitWidth = 570;
			limitHeight = 100000;
			
			if(width <= limitWidth && height <= limitHeight)return;
			
			var rsWidth = width;
			var rsHeight = height;
			var Scale = 1.0;
			
			if(width > limitWidth)
			{
				Scale = limitWidth / (width + 0.0);
				rsWidth = width *  Scale;
				rsHeight = height *  Scale;
			}
			
			if (rsHeight > limitHeight)
			{
				Scale = limitHeight / (height + 0.0);
				rsWidth = width *  Scale;
				rsHeight = height *  Scale;
			}
			
			$(this).width(rsWidth);
			$(this).height(rsHeight);
		});
			
	});

});

var cntActionIdx = -1;
var actionCount = 0;
var actionInterval = 6000;
var actionSelector = "[@id=action_bnr] span";

function ShowAction()
{
	if(actionCount < 2) return;

	if(cntActionIdx != -1)
	{
		$(actionSelector + ":eq("+ cntActionIdx + ")").fadeOut("slow",function()
		{
			if(cntActionIdx +1 < actionCount )
			{
				cntActionIdx++;
			}
			else
			{
				cntActionIdx = 0;
			}

			$(actionSelector + ":eq("+ cntActionIdx + ")").fadeIn("slow",function()
			{
				var time = (M_BNR[cntActionIdx])? M_BNR[cntActionIdx] : actionInterval;
				setTimeout("ShowAction();", time);
			});
			
		});
	}
}

