$(document).ready(function(){ init(); });

//DOMツリー完成後に実行する処理群
function init(){
//	setSWF();
	cgiGet();
	imageChange();
	pSet();
}

//CGIからデータを受け取る
function cgiGet(){
//	var newsCGIPath = "./news/main.html";
	var newsCGIPath = "./news/index.cgi";
	
	$.ajax({
		url: newsCGIPath,
		dataType: "html",
		cache: false,
		success: function(data){
			var $icw = $("div[class='innerContentWrapper']", data);
			$("div#news").append($icw);
		},
		error: function(xhr,ts,et){
			alert("XMLHttpRequest: " + xhr + ", textStatus: " + ts + ", errorThrown: " + et);
		}
	});
}

//LIVE SCHEDULEの画像切替
function imageChange(){
	var $images = $("img","div#live_info");
	$images.click(function(){
		var $active = $images.filter(".active");
		var $next = $active.next().length ? $active.next() : $images.eq("0") ;
		
		$(this).removeClass("active");
		$next.addClass("active");
	});
}

//FLVを埋め込むための設定（flashSrc以外変更不要！！）
function setSWF(){
	//挿入したいFLVのアドレス（http://~）を入れる
	var flashSrc = "http://www.indie-psc.com/movie/screw/100209_comment.flv";
	
	//FLVの表示に必要なSWFの場所をmain.htmlを基準に相対パスで記入（変更不要)
	var flashSkinPath = "common/main/Corona_Skin_2.swf";
	var flvpProgressive = "common/main/FLVPlayer_Progressive.swf";
	
	//SWFObjectでFLVPlayerを貼り付けるための設定（変更不要）
	var flashvars = {
		MM_ComponentVersion: 1,
		skinName: flashSkinPath.replace("\.swf",""),
		streamName: flashSrc.replace("\.flv",""),
		autoPlay: "true",
		autoRewind: "false"
	}
	
	var params = {
		quality: "high",
		wmode: "opaque",
		scale: "noscale",
		salign: "lt",
		menu: "true",
		bgcolor: "#000000" //6桁で書かないと効かないみたい
	};
	
	var attributes = {
		id: "screwPV",
		name: "screwPV"
	};
	
	swfobject.embedSWF( flvpProgressive, "latestPV", "550", "367", "8.0.0", "expressInstall.swf", flashvars, params, attributes );
	
}

function pSet(){
	$pLeftPosition = $("div#latestPV").width()/2 - $("p", "div#latestPV").width()/2;
	$pTopPosition = $("div#latestPV").height()/2 - $("p", "div#latestPV").height()/2;
	$("p", "div#latestPV").css({
		"top" : $pTopPosition,
		"left" : $pLeftPosition
	});
}
