//モーダルへのHTMLの渡し方
function getModalHTML(id){
	var htm;
	if(id == "archive"){
		htm = $('#archive').html();
	}else{
		htm = $("#"+id).html() + $('#archive').html();
	}
	return close_btn + htm;
}

//FlashへXMLを渡す処理
function sendXML2Fl(){
	var htm = $('#flash-list').html().toString().toLowerCase();
	$.trim(htm);
	//alert(htm);
	htm = htm.split('alt="">').join('alt="" />');
	htm = htm.split('.jpg">').join('.jpg" />');
	htm = htm.split('</a>').join('</a></li>');
	htm = htm.split('</li></li>').join('</li>');
	htm = htm.split('</li> </li>').join('</li>');
	//alert(htm)
	var xml = htm
	return "<flash>"+xml.toString()+"</flash>";
} 


var requiredMajorVersion = 8;
var requiredMinorVersion = 0;
var requiredRevision = 0;

function writeFlash(){
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
	var hasProductInstall = DetectFlashVer(6, 0, 65);
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if ( hasProductInstall && !hasRequestedVersion ) {
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
	    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
	    var MMdoctitle = document.title;
	
		AC_FL_RunContent(
			"src", "common/files/playerProductInstall",
			"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
			"width", "720",
			"height", "500",
			"align", "middle",
			"id", "externalInterface",
			"quality", "high",
			"name", "mainfla",
			"wmode", "transparent",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} else if (hasRequestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed
		AC_FL_RunContent(
				"src", 'common/files/main',
				"width", "720",
				"height", "500",
				"align", "middle",
				"id", "externalInterface",
				"quality", "high",
				"name", "externalInterface",
				"wmode", "transparent",
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = '<p style="clear:both">このコンテンツはAdobe Flash Playerが必要です。<br /> '
   	+ '<a href=http://www.adobe.com/go/getflash/>FlashPlayerをダウンロード</a>して下さい。</p>';
    document.write(alternateContent);  // insert non-flash content
  }
}

function showNewTopics(){
	$(news_arr[0]).fadeOut("fast", function(){
		//alert($.isArray(news_arr))
		news_arr.push(news_arr.shift());
		$(news_arr[0]).fadeIn("fast");
	});
}

var news_arr = new Array();
$(document).ready(function(){
		//バナー設定
		$.each($("#feature dt"), function(){
			$(this).bind("mouseover", function(){
				$(this).next().css('opacity', 0.5);
			});
			$(this).bind("mouseout", function(){
				$(this).next().css('opacity', 1);
			})
		});
		//ニュース
		
		$.each($("#topics ul li"), function(){
			news_arr.push(this)
		})
		$("#topics ul li").css('visibility', 'visible');
		$("#topics ul li").hide();
		setInterval(showNewTopics, 3000);
		$(news_arr[0]).fadeIn("fast");
		
		//modal window's link
		initModalLink(getModalHTML);
});

