// オススメ動画の設定
var recommendedMovies = function(param){

	// 初期化
	this.movieDescription = document.getElementById(param.descriptionArea);
	this.space	= document.createTextNode(" ");
	this.movieData	= new Array({
		title: '',
		url: ''
	});

	// 設定
	this.conf = {

		playArea: param.playArea,
		descriptionArea: param.descriptionArea,

		clip: {
			url: '',
			autoPlay: false,
			autoBuffering: true
		},
		plugins: {
			controls: {
			// コントロールバー
			url: 'flowplayer.controls-3.1.3.swf',

			// 位置
			left: 0,
			bottom: 0,
			opacity: 0.95,

			// 表示するボタン
			play: true,
			volume: true,
			mute: true,
			time: true,
			stop: true,
			playlist: false,
			fullscreen: true,

			// 残り時間表示の配色ほか
			timeColor: '#FFFFFF',
			durationColor: '#9CF',
			progressColor: '#69C',
			progressGradient: 'medium',
			bufferColor: '#9CF',
			bufferGradient: 'none',
			sliderColor: '#000000',
			sliderGradient: 'none',
			buttonColor: '#889AA4',
			buttonOverColor: '#92B2BD',

			// 現在時間/残り時間の表示
			scrubber: true,

			// 自動的に隠す
			autoHide: 'always'
			}
		},
		onFinish: function(){
			var oldText = this.movieDescription.childNodes[0];
			this.movieDescription.replaceChild(this.space, oldText);
			this.unload();
		}

	};

	this.clip = $f(param.playArea, "./swf/flowplayer-3.1.3.swf", this.conf);
};

// 再生
function playMovie(e){

	var movieObj	= e.data;
	var player	= movieObj.player;
	var clipUrl = player.movieData[movieObj.id].url;
	var clipTitle = player.movieData[movieObj.id].title;

	if(player.clip.isPlaying()) player.clip.stop();

	sweepChildren(player.movieDescription);
	player.movieDescription.appendChild(clipTitle);
	player.clip.play(clipUrl);

	// 再生回数をカウント
	/*
	var movieId	=	movieObj.id+1;
	movieId	=	(movieId < 10 ? '0' : '') + String(movieId);
	movieCount(movieId);
	*/

	return false;

}

/*
 *	ファイル更新 (ruri)
 */
function movieCount(id){
	xmlhttp = createXMLHttp();
	xmlhttp.open('get','/movielist/dlCount.php?id='+id, true);
	xmlhttp.onreadystatechange	=	function(){
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			var ret = eval('('+xmlhttp.responseText+')');
			if(!isNaN(parseInt(ret.count))){
				var countArea	=	document.getElementById("Movie-"+id+"_cnt");
				sweepChildren(countArea);
				countArea.appendChild(document.createTextNode(ret.count));
			}
		}
	}
	xmlhttp.send("");
}

function checkStatus(){
	if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
		//alert(xmlHttp.responseText);
	}
}

