﻿// 방송에서 사용되는 AOD, VOD 재생기
function Pay_End(szChk,no,id)
{
	if (szChk == "true")
	{
		open_viplayer(no,id);
	}
	else
	{
		alert('결제작업이 취소 되었습니다.');
	}
}


function pay_open(price,goodno,id) 
{
	var url;
	url = "http://www.etomato.com/2002_mem/popup_settle/regist.asp?price="+price+"&goodno="+goodno+"&id="+id+"&r_url=tv_vod";
	winobject =window.open(url,"new","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no,alwaysRaised=yes,width=640,height=440")
	winobject.opener.name="opener";
}


		
function login_check() 
{

	//alert("로그인해주세요");
	document.add_val.val4.value =document.add_val.val2.value;
	document.add_val.val5.value =document.add_val.val3.value;
	document.add_val.val2.value ="<%=r_url%>";
	document.add_val.val3.value ="<%=r_url_query%>&r_pr=1";
	document.add_val.submit();
}

function open_viplayer(no, eb_flag)
{
    
	var width, height, window_width, window_height;

	if (no > 4520)
	{
		screen_width = 680;
		screen_height = 370;

		window_width = screen_width + 8;
		window_height = screen_height + 80;


		window.open("http://tv.etomato.com/home/popup/Viplayer.aspx?no=" + no + "&eb_flag=" + eb_flag + "&screen_width=" + screen_width + "&screen_height=" + screen_height, "vi_player", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + window_width + ",height=" + window_height);			
	}
	else if (no > 1333 && (no < 1479 || no >1539) && (no <1545 || no > 1552) && (no < 1556 || no > 1609))
	    window.open("http://tv.etomato.com/home/popup/Viplayer.aspx?no=" + no + "&eb_flag=" + eb_flag, "vi_player", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=728,height=560");			
	else
	    window.open("http://tv.etomato.com/home/popup/Viplayer.aspx?no=" + no + "&eb_flag=" + eb_flag, "vi_player", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=361,height=420");
}

function open_free_vod(file_name)
{
    window.open("http://www.etomato.com/etomatotv/vi_player_new_free.asp?file_name=" + file_name, "vi_player", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=728,height=560");			
	//window.open("http://www.etomato.com/etomatotv/vi_player_new_free.asp?file_name=" + file_name, "vi_player", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=728,height=560");			
}

function open_freeNews_vod(no)
{
	window.open("http://www.newstomato.co.kr/News/popup_news_vod.asp?no=" + no, "vi_player", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=728,height=560");			
	//window.open("http://www.etomato.com/EtomatoNews/vi_player_new_free1.asp?file_name=" + file_name, "vi_player", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=728,height=560");			
}

// 비회원 결제를 처리할때 로그인 부분입니다.
function login_pass(szId,szPwd)
{
	document.add_val2.log_id.value = szId;
	document.add_val2.log_pwd.value = szPwd;
	document.add_val2.val2.value = "<%=r_url%>";
	document.add_val2.val3.value = "<%=r_url_query%>&r_pr=1";
	document.add_val2.val4.value = document.add_val.val2.value;
	document.add_val2.val5.value = document.add_val.val3.value;
	document.add_val2.submit();
}

/************************************************************************/
/*		유료권한 없으면, stop 시키는 부분; 다른 곳은 수정하지 않았음	*/ 
/************************************************************************/

function mute()
{
	if ((navigator.userAgent.indexOf('IE') > -1) && (navigator.platform == "Win32")) 
	{
		MediaPlayer2.mute = true;
	}
	else
	{
		document.MediaPlayer2.mute = true;
	}    
}

function LoginTimeChk() {
	alert(1);
	display();
}

function TransTimeToNum( var_time )	{
	return var_time.getFullYear() * 100000000 + (var_time.getMonth() + 1) * 1000000  + var_time.getDate() * 10000 + var_time.getHours() * 100 + var_time.getMinutes()
}


//시간지나면 스톱시킨다.
function display() {
	setTimeout("stopIt();", 60000);
}

function stopIt()	{
	if ((navigator.userAgent.indexOf('IE') > -1) && (navigator.platform == "Win32")) 
	{
		MediaPlayer2.Stop();
	}
	else
	{
		document.MediaPlayer2.Stop();
	}
	
}

function main_player_display() {
	setTimeout("timer()", 3000);
	setTimeout("main_player_run('mainplayer')", 3000);
}


function timer() {
	if(start >= 0){
		document.getElementById("player_sec1").innerHTML = "<b>미리보기 화면</b>: <span style='font-family:돋움;font-size:8pt;letterspacing:0px;color:red;font-weight:bold;'>" + start + "</span>초 남았습니다. <a href='javascript:main_player_control();' style='color:green;'>[중지]</a>";
		setTimeout('timer()', 1000);
	}
	start--;
	if(start == -1) {
		main_player_control();
	}
}

function main_player_control() {
	stopIt();
	main_ontomato_player_on.style.display = 'none';
	main_ontomato_player_off.style.display = '';
}

function main_player_run(txtid) {
	document.getElementById("location_mainplayer").innerHTML=document.getElementById(txtid).value;
}
