/**
 * CVIplayer.js
 *
 * Àü ÆäÀÌÁö °øÅë ½ºÅ©¸³Æ®
 *
 * @author  MIJIN KIM (hasa00-at-skcomms.co.kr)
 * @date    2008-05-28
 *  
 *  // 
 *  <div id="VideoPlayArea" style="width: 600px; height: 400px"></div>
 *  javascript:CVIVideoPlay( ÀÎÇÁ¶ó µ¿¿µ»ó  ¾ÆÀÌµð , µ¿¿µ»óÁ¦¸ñ , ÇÃ·¹ÀÌ ÇÏ´Â »ç¶÷ÀÇ °í°´°íÀ¯¹øÈ£ );
 *  
 *  	<script type="text/javascript" src="http://dbi.video.cyworld.com/player/js/videoplayer.js"></script>
 *  	<script type="text/javascript" src="http://v.nate.com/player/js/videoplayer.js"></script>
 *  	<script type="text/javascript" src="/js/json2.js"></script>
 *  	<script type="text/javascript" src="/js/CVIplayer.js"></script>
***/


function CVIPlayerSetAndPlay(respObj)
{

	var playArea = document.getElementById("VideoPlayArea");
    if (respObj['area'] != null && respObj['area'] != '' && respObj['area'] != undefined && respObj['area'] != "undefined") 
        playArea = document.getElementById(respObj['area']);
		
	CVIPlayerStop(playArea.id);	
		
	if(!checkMajorParam(playArea.id))
		return;
		    
    var paramsObj = {};
    paramsObj.allowScriptAccess = "always"; // µµ¸ÞÀÎÀÌ ´Ù¸£¹Ç·Î Ç×»ó Ãß°¡µÇ¾î¾ß ÇÔ
    paramsObj.allowFullscreen = "true"; // È®´ëº¸±â¸¦ À§ÇØ Ç×»ó Ãß°¡µÇ¾î¾ß ÇÔ

    var attributesObj = {};
    attributesObj.id = "player_"+playArea.id;
    attributesObj.name = "player_"+playArea.id;
    
    
    var optionsObj = {};
    optionsObj.v_key = optionsVal['VKEY'];
    optionsObj.mov_id = optionsVal['MOV_ID'];
    optionsObj.c_id = optionsVal['C_ID'];
    optionsObj.tid = optionsVal['TID'];
    optionsObj.autoPlay = "on";
    optionsObj.skinStyle = "black"; // black or white  ½ºÅ²½ºÅ¸ÀÏ ÁöÁ¤ (±âº»:black)

    //optionsObj.startImageUrl = "img.jpg";
    //optionsObj.useBigSkin = "on";
	//optionsObj.startViewType = "SN";
	//optionsObj.skinFile = "http://video.cyworld.com/player2/miniSkin.swf";//baseSkin.swf";//PannMiniSkin.swf";//MoviePlayer2.swf";
    if(respObj['skin'] != null && respObj['skin'] != "" )
    	optionsObj.sizeStyle = respObj['skin'];
	
    var width = playArea.style.width;
    var height = playArea.style.height;


	embedVideoPlayer(playArea, width, height, optionsObj, paramsObj, attributesObj);
	/*
	//ÀÓ½Ã °øÁö error flash 20090309
	today = new Date(); 
	if (today.getDate() == 9 && ( today.getHours() >= 5 && today.getHours() <= 7) ) {
		var id = "error_flash";
		var source = "/flash/error.swf";
		var addParam = " quality='high' allowScriptAccess='sameDomain' allowFullScreen='false' bgcolor='#000000' ";
		var otherparam = "<param name='allowScriptAccess' value='sameDomain' />";
		otherparam += "<param name='allowFullScreen' value='false' />";
		otherparam += "<param name='bgcolor' value='#000000' />";
		playArea.innerHTML  = FlashWriteText(source, id, width, height, addParam, otherparam);
	} else {
		embedVideoPlayer(playArea, width, height, optionsObj, paramsObj, attributesObj);
	}*/

}


function CVIVideoPlay(mov_id, mov_nm, user_id, area){

	var respObj = eval('( { "method": "CVIPlayerSetAndPlay", "skin": "", "area": "'+area+'" } )');
    callAjaxCVI('play', mov_id, mov_nm, user_id, respObj);
}

function CVIVideoPlayMini(mov_id, mov_nm, user_id, area){
	var respObj = eval('( { "method": "CVIPlayerSetAndPlay", "skin": "mini", "area": "'+area+'" } )');
    callAjaxCVI('play', mov_id, mov_nm, user_id, respObj);
}


function CVIVideoPlayNonAuth(vkey, mov_id, cid, tid, size, area)
{
	optionsVal = eval('({ "VKEY": "'+vkey+'", "MOV_ID": "'+mov_id+'", "CID": "'+cid+'", "TID": "'+tid+'" })');
	var respObj = eval('( { "skin": "'+size+'", "area": "'+area+'" } )');
	CVIPlayerSetAndPlay(respObj);
}
