﻿/**
 * 動画表示
 */
var createPlayer = function(itemid,thumbnail,width,height,autoplay,divid){
        var item = itemid || window._dai2ntv_embed_itemid;
        var thumb = thumbnail || window._dai2ntv_embed_thumbnail;
        var w = width || window._dai2ntv_embed_width;
        var h = height || window._dai2ntv_embed_height;
        var auto = autoplay || window._dai2ntv_embed_autoplay;
        var src = "http://www.news24.jp/player/src/CoSimplePlayer.swf";
        var id = divid || "embed_player";
        var obj = [
            "<object width='"+w+"' height='"+h+"' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' id='externalSimplePlayer"+(new Date()).getTime()+"'>",
                "<param name='movie' value='",src,"'></param>",
                "<param name='allowscriptaccess' value='always'></param>",
                "<param name='allowfullscreen' value='false'></param>",
                "<param name='wmode' value='transparent'></param>",
                "<param name='flashvars' value='item_id=",item,"&thumbnail=",thumb,"&autoplay=",auto,"&cmctrl=1,0,-1,news24'></param>",
                "<embed src='",src,"' width='"+w+"' height='"+h+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='false' wmode='transparent' flashvars='item_id=",item,"&thumbnail=",thumb,"&autoplay=",auto,"'></embed>",
            "</object><img src='/images/close.gif' class='btnClose' alt='閉じる' style='cursor: pointer;' onclick=\"closeplayer('movie-player')\"/>"
        ].join("");
        $( id ).innerHTML = obj;
}

/**
 * 動画消去
 */
var removePlayer = function(divid){
        var id = divid || "embed_player";
        $(id).innerHTML = '';
}

function execute(element){
    document.getElementById("picture").style.display = "none";

    new Effect.BlindDown(element, {
        from: 0.0, // 開始時透明度
        to: 1.0, // 終了時透明度
        // delay:0, // 開始までの秒数
        fps: 60, // フレームレート
        duration: 1.5, // アニメーションする秒
		afterFinishInternal: function(effect) { 
				createPlayer();
		}
    });
}

function closeplayer(element){
   	removePlayer("embed_player");
	document.getElementById("picture").style.display = "block";

	new Effect.BlindUp(element, {
		from:0.0, // 開始時透明度
		to:1.0, // 終了時透明度
		// delay:0, // 開始までの秒数
		fps:60, // フレームレート
		duration:0.5 // アニメーションする秒
	});
}

function clipBoard(){
	// テキストエリア
	  var target = document.getElementById('newscrip')
	// ボタン
	  var btn = document.getElementById('copy_button')
	// インスタンス
	  var clip = new ZeroClipboard.Client();
	// マウスオン時のカーソルの設定
	  clip.setHandCursor(true);
	  clip.setText(target.value);
	// 2回目以降に備える
	  if (clip.div) {
	    clip.receiveEvent('mouseout', null);
	    clip.reposition(btn);
	  } else {
	    clip.glue(btn);
	  }
}
