/* MO ****************************************************************/
function MO(parent) {
	this._super = parent;
	this.panset = "on";

	this._res       = null;
	this._Imgres       = null;

	this.mi         = 0;
	this.mj         = 0;
	this.mk                         = 0;	//adver용 초기화변수 2007-09-12 10:14오전 by royes
	this.snum       = "";
	this.csnum      = "";
	this.oldsum     = "";

	// mo 기본 설정
	this.dt         = new Date();
	this.delaytime  = 21000;
	this.gettime    = 10100;
	this.inittime   = 1000;
	this.xsize      = 11;
	this.xborder    = 1;
	this.xdraw      = 1;

	this.tid1       = null;
	this.tid2       = null;
	this.tid3       = null;
	this.tid4       = null;
	this.tid5       = null;
	this.msc        = null;

	//adver text(first play)
	//this.adMsg      = "내가 직접 만드는 나만의 영상컬러링!! |http://mobile.pandora.tv/8800/?mpage=mrbt|||||| ad";
	this.adMsg		= new Array();
//	this.adMsg[0]	= "미인대회 자격박탈!! 김희경 논란의 화보 감상하기 |http://event.pandora.tv/?eventMode=miko | ad";
/*
	this.adMsg		= new Array();
	this.adMsg[0]	= "[눈에는 눈 이에는 이] DVD급 고화질 영상 다운로드!|http://event.pandora.tv/?eventMode=eye | ad";
	this.adMsg[1]	= "▶고화질◀눈눈이이! 보러가기!!!|http://event.pandora.tv/?eventMode=eye | ad";
	this.adMsg[2]	= "눈눈이이 다운로드 하려면 click~click!!!|http://event.pandora.tv/?eventMode=eye | ad";
*/
	this.imgpath	= "http://imgcdn.pandora.tv/static/";
	this.currentShowLogo = 0;


	this.setIni = function(isMO) {	// 0 / 1
		switch(true) {
			case (this.panset == "on" && isMO == 1) : return;
			case (this.panset == "off" && isMO == 0) : return;
		}

		this.panset = (isMO == 1) ? "on" : "off";
		if(this._super.isPlay() == true) {
			if(isMO == 0) this.mo_stop();
			else {
				if(isMO == 1) { this.mo_play(); }
			}
		}
	}

	this.initMsg = function () {	// 메세지 초기화
		$(this._super.PLAYER_ELEMENT_ID).setMo("blank");
	}

	this.writeHtml = function () {	// 메세지 출력
		try {
			var obj = this;
			this.mj++;
			this.csnum = oCookie.get("snum");
			this.msc = this.dt.getSeconds() + "" + this.dt.getMilliseconds();

			this.getMo("snum");

			if ((this.snum != this.oldsnum || this.mj < 2) && (this.snum != "" && this.csnum != this.snum)) {
				this.getMo("msg");
			} else if(this.mj < 2) {
				this.initMsg();
			}

			if(this.mj < 2) {
				this.tid1 = setTimeout( function () { obj.writeHtml(); }, this.inittime);
			} else {
				clearTimeout(this.tid1);
				this.tid2 = setTimeout( function () { obj.writeHtml(); }, this.gettime);
			}
		} catch (e) {
            //alert('writeHtml error');
		}
	}

	this.mo_play = function () {
		this.mo_stop();
		if(this.panset == "off") {
			this.show_logo(0);
		} else {
			if( parseInt(chInfoJson['mychannel'], 10) == 1)	return;		// my channel 
			this.getImg();
			this.writeHtml();
			this.show_logo(1);
		}
	}

	this.mo_stop = function () {
        var obj = this;
        try {
		    this.clearCheck();
        } catch (e) {
            this.tid2 = setTimeout( function () { obj.mo_stop(); }, 2000);
        }
	}

	this.clearCheck = function () {
		try {
			//this.initMsg(); //--> this._super.vodObj.stopMo();
			$(this._super.PLAYER_ELEMENT_ID).stopMo("all");
			clearTimeout(this.tid1);
			clearTimeout(this.tid2);
			clearTimeout(this.tid3);
			clearTimeout(this.tid4);
        } catch (e) {
			//alert('error');
		}
	}

	this.clearSet = function () {
		this.mo_stop();
	}

	this.show_pan = function () {
		try {
			if(this.currentShowLogo==1) {
				this.show_logo(0);
				this.clearSet();
			} else {
				this.show_logo(1);
				this.writeHtml();
				this.getImg();

				this.panset = "on";
			}

        } catch (e) {}
	}

	this.show_logo = function (num) {
        if(num == 1) {
            this.currentShowLogo = 1;
        } else {
            this.currentShowLogo = 0;
        }
	}

	this.displayMsg = function (args) {
		var obj = this;
		var strHTML = "";
		var size    = new Array();
		var size_w  = "";
		var size_h  = "";
		var vmsg    = "";

		if(this.panset != "off") {
			if(args != undefined) this._res = args;
			if((this._res != undefined)) {
				if(this._res.length > this.mi) {
					if (this.mk < 1 && parseInt(this.adMsg.length, 10) > 0) {  //페이지 로딩후 최초1회한 2007-09-12 10:13오전 by royes
						var rn = Math.floor(Math.random()* parseInt(this.adMsg.length, 10));
						strHTML = this.adMsg[rn];
						this.gettime=10100;
						this.mk++;
					}
					else {
						strHTML = this._res[this.mi];
						strHTML = strHTML.replace("\n", "");  //개행문자변경.. only for p3player
						this.gettime=10100;
						this.mi++;
					}
					var vcolor = "";
					var vvmsg = strHTML.substring(0, strHTML.length-2);

					var msgAr = new Array();

					var m_message = "";
					var m_clickURL = "";
					var m_screen = "true";
					var m_font = "Arial,Tahoma, Helvetica, sans-serif";
					var m_fontColor = "#ffffff";
					var m_fontSize = "12";
					var m_rollingTime = "10";
					var m_setting = "";

					// 메시지|URL|새창여부(popup,new)|창 사이즈”_”가 구분자|폰트 색|폰트 종류
					//   0   | 1 |    2              |         3           |   4   |    5
					var is_admin = strHTML.substring(strHTML.length-2,strHTML.length);		//관리자추가(a1:판PD, a2:도라PD)
					msgAr = vvmsg.split("|");

					// 폰트색 정의
					if (is_admin == ")a" || is_admin == "a1" || is_admin == "a2" || is_admin == "ad") {
						if (is_admin == "ad") {
							msgAr[4] = "0x00" + "ff74d0";
							m_fontColor = "#FFFF00";
						} else if (is_admin == "a2") {
							msgAr[4] = "0x00" + "ff74d0";
							m_fontColor = "#febbfe";
						} else {
							msgAr[4] = "0x00" + "00ffff";
							m_fontColor = "#A851FF";
						}
					} else {
						if (msgAr[4] == "" || msgAr[4] == undefined) {
							msgAr[4] = "0x00" + "bbbbbb";
						} else {
							msgAr[4] = "0x00" + msgAr[4].substring(-2) + msgAr[4].substring(2, 2) + msgAr[4].substring(2);
						}
						m_fontColor = "#ffffff";
					}
					// 폰트 정의
					if (msgAr[5] == "" || msgAr[5] == undefined) {
						msgAr[5] = "돋움";
					}

					// 링크 정의
					msgAr_2 = "0";
					// 윈도우 창 크기
					if (msgAr[2] == "p" && (msgAr[3] && msgAr[3] != undefined) ) {
						size = msgAr[3].split("_");
						size_w = size[0];
						size_h = size[1];
						msgAr_2 = "2";
					} else {
						if (msgAr[2] == "n") {
							msgAr_2 = "1";
						}
						size_w = "0";
						size_h = "0";
					}

					// 메세지 정의
					if (msgAr[1] == "" || msgAr[1] == undefined) {
						if (msgAr.length > 1) {
							vmsg = msgAr[0];
						} else {
							vmsg = vvmsg;
						}
						msgAr[1] = " ";
					} else {
						if (msgAr_2 == "0") {
							msgAr_2 = "1";
						}
						vmsg = "[클릭]"+msgAr[0];
						m_clickURL = msgAr[1];
					}
					m_message = vmsg;

					//관리자가 아닌 경우 mo 리스트 경로로 이동(도미노피자 이벤트)
					//if ((is_admin != "a") && (msgAr[1] == "" || msgAr[1] == undefined)) {
					//if (is_admin != "a") {
					if (is_admin != ")a" && is_admin != "a1" && is_admin != "a2" && is_admin != "ad") {
						msgAr_2 = "1";
						m_clickURL = "http://mobile.pandora.tv/mo/r.ptv";
					} else {
						if(m_clickURL == "")	{
							msgAr_2 = "1";
							m_clickURL = "http://mobile.pandora.tv/mo/r.ptv";
						}
					}

					m_setting = '{"m_message":"'+m_message+'","m_clickURL":"'+m_clickURL+'","m_screen":"'+m_screen+'","m_font":"'+m_font+'","m_fontColor":"'+m_fontColor+'","m_fontSize":"'+m_fontSize+'","m_rollingTime":"'+m_rollingTime+'"}';
					$(this._super.PLAYER_ELEMENT_ID).setMo("msg", m_setting);

					clearTimeout(this.tid2);
					if(this._res.length > this.mi) {
						this.tid3 = setTimeout( function () { obj.displayMsg(); }, this.gettime);
					} else {
						this.tid3 = setTimeout( function () { obj.displayMsg(); }, this.delaytime);
					}

				} else {
					this.mi = 0;
					this.initMsg();
					clearTimeout(this.tid2);
					this.tid2 = setTimeout( function () { obj.writeHtml(); }, this.inittime);
				}

			}

		}
	}

	this.getMo = function (res) {
        var targetUrl   = "";
        var dummy = new Date().getTime();
        if (res == "msg" || res == null) {
						targetUrl   = "/data/mo/msg.htm?"+ dummy;
            this.oldsnum = this.snum;
            oCookie.set("snum", this.snum);
        } else {
						targetUrl   = "/data/mo/snum.htm?"+ dummy;
        }

		new Ajax.Request(targetUrl, {
			method : 'get',
			onSuccess : function(res){
				this.ajaxCallback(res);
			}.bind(this),
			onException : function(res){
				throw new Error("Exception : mo list json fail");
			}
		});
	}

	this.ajaxCallback = function (res) {
		if(res.responseText != "") {
			eval("var ajax = " + res.responseText);

			//alert("responseText:"+res.responseText);
			if (res.responseText.indexOf(this.imgpath) == -1)	{

				if (parseInt(res.responseText, 10) > 20070000000000) {
					this.snum = parseInt(res.responseText, 10);
				} else {
					//alert("responseText:"+res.responseText);
					this.displayMsg(ajax[0]);
					if(ajax[1] != "")	{
						var liveAlimi = oCookie.get('chLiveAlimi');
						var liveAlimiEnd = oCookie.get('chLiveAlimiEnd');
						if(liveAlimi !="on" && liveAlimiEnd != "on") {
							var viewText = "";
							var liveThumb = "http://imguser.pandora.tv/pandora/_live_img/" + ajax[1][3] + ".jpg";
							if(ajax[1][1] == "")	{
								var nickname = ajax[1][0];
							} else {
								var nickname = ajax[1][1];
							}

							var moLiveLink = "http://live.pandora.tv/viewer.ptv?redirect=live&ch_userid="+ ajax[1][0];
							if (ajax[1][4]) {
								moLiveLink = ajax[1][4];
							}

							var viewAlimiHtml = new pandora.util.StringBuffer();
							viewAlimiHtml.append('<div style="background-image: url(http://imgcdn.pandora.tv/gimg/liveCh/liveBG.gif); background-repeat: no-repeat; background-position: center center; height: 195px; width: 183px;">');
							viewAlimiHtml.append('<div style="padding-top: 10px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;">');
							viewAlimiHtml.append('<table width="173" border="0" cellspacing="0" cellpadding="0">');
							viewAlimiHtml.append('<tr>');
							viewAlimiHtml.append('<td height="22" align="center" style="font-family: 굴림, Gulim, AppleGothic, sans-serif; font-size: 12px; font-weight: bold; color: #d30e7d; letter-spacing: -1px;"><a href="'+ moLiveLink +'" target="_blank">'+ ajax[1][2].truncate(15) +'</a></td>');
							viewAlimiHtml.append('</tr>');
							viewAlimiHtml.append('<tr>');
							viewAlimiHtml.append('<td height="90" align="center">');
							viewAlimiHtml.append('<div style="background-color: #FFFFFF; padding: 1px; height: 80px; width: 106px; border: 2px solid #000000; margin-right: auto; margin-left: auto;"><a href="'+ moLiveLink +'" target="_blank"><img src="'+ liveThumb +'" width="106" height="80"></a></div>');
							viewAlimiHtml.append('</td>');
							viewAlimiHtml.append('</tr>');
							viewAlimiHtml.append('<tr>');
							viewAlimiHtml.append('<td align="center" style="font-family: 굴림, Gulim, AppleGothic, sans-serif; font-size: 12px; font-weight: normal; color: #4d4d4d; letter-spacing: -1px; line-height: 18px;"><strong><font color="#000000">'+ nickname.truncate(10) +'</font></strong>님의 <font color="#d30e7d"><strong>라이브</strong></font>가 <br />시작되었습니다.</td>');
							viewAlimiHtml.append('</tr>');
							viewAlimiHtml.append('</table>');
							viewAlimiHtml.append('<table width="173" border="0" cellspacing="0" cellpadding="0" style="margin-top: 10px;">');
							viewAlimiHtml.append('<tr>');
							viewAlimiHtml.append('<td style="font-family: 돋움, Dotum, verdana; font-size: 11px; font-weight: normal; color: #4d4d4d; letter-spacing: -1px;"><input id="alimiEnd" type="checkbox" value="" />오늘 하루 보지않기</td>');
							viewAlimiHtml.append('<td align="right"><img src="http://imgcdn.pandora.tv/gimg/liveCh/AlimiClose.gif" width="41" height="18" border="0" id="closeAlimi" style="cursor:pointer" /></td>');
							viewAlimiHtml.append('</tr>');
							viewAlimiHtml.append('</table>');
							viewAlimiHtml.append('</div>');
							viewAlimiHtml.append('</div>');
							var endRight = document.body.clientWidth - 183;
							var endBottom = document.body.scrollTop + document.body.clientHeight - 195;

							if($(this._super._super._layerPop._layerId)) this._super._super._layerPop.closePopup();
							this._super._super._layerPop.set(viewAlimiHtml, this.popRemoveEventListener.bind(this), this, 3, viewText, 183, 195, endBottom, endRight);
							this.popEventListener();

							liveAlimi = "on";
							oCookie.set("chLiveAlimi", liveAlimi, 600);
						}
					}
				}

			} else {
				this.displayImg(ajax);
			}
        }

	}

	this.closeAlimi = function()	{
		if($('alimiEnd').checked == true)	{
			oCookie.set("chLiveAlimiEnd", "on", 86400);
		}
		this._super._super._layerPop.closePopup();
	}

	this.popEventListener = function()	{
		Event.observe('closeAlimi', "click", this.closeAlimi.bindAsEventListener(this));
	}

	this.popRemoveEventListener = function()	{
		var evtPop = this.closeAlimi.bindAsEventListener(this);
		Event.stopObserving('closeAlimi', "click", evtPop);
	}

	this.getImg = function () {
		var targetUrl   = "";
		targetUrl   =  "/php/mo/logo.ptv";

		new Ajax.Request(targetUrl, {
			method : 'post',
			onSuccess : function(res){
				this.ajaxCallback(res);
			}.bind(this),
			onException : function(res){
				throw new Error("Exception : mo list json fail");
			}
		});
	}

	this.displayImg = function (args) {
		this._Imgres = args;

		if(this._Imgres != undefined) {
			var imgStr = "";
			for(var z=0; z<this._Imgres.length; z++) {
				imgStr = imgStr + this._Imgres[z] + ';';
			}
			imgStr = imgStr.substring(0, imgStr.length-1);
			var obj = this;
			var b_setting = "";
			if(this.panset == "off") {
				this.show_logo(0);
			} else {

//				var moBannerImg = "http://imgcdn.pandora.tv/static/mo_1won.swf;http://imgcdn.pandora.tv/static/mo_8800_2008.swf?200803131802";
//				var moBannerUrl = "http://mobile.pandora.tv/8800/?mpage=sms;http://mobile.pandora.tv/8800/teletext/?mpage=broad";
				var moBannerImg = "http://imgcdn.pandora.tv/static/mo_8800_2008.swf?200803131802";
				var moBannerUrl = "http://mobile.pandora.tv/8800/teletext/?mpage=broad";
				//banner_url = "http://mobile.pandora.tv/8800/molist.php;http://show.pandora.tv/mo/r.php;http://show.pandora.tv/mobile/event/skt_200710/index.html";		//by 박유민 2007-10-25
				b_setting = '{"b_url":"'+moBannerImg+'","b_clickURL":"'+moBannerUrl+'","b_screen":"true;true;true","b_rollingTime":"5;5;5"}';
/*
				if(this._Imgres.length == 3){
					var banner_url;
					banner_url = "http://mobile.pandora.tv/8800/molist.php;http://show.pandora.tv/mo/r.php;http://show.pandora.tv/mobile/event/skt_200710/index.html";		//by 박유민 2007-10-25
					b_setting = '{"b_url":"'+imgStr+'","b_clickURL":"'+banner_url+'","b_screen":"true;true;true","b_rollingTime":"5;5;5"}';
				}else if(this._Imgres.length == 2){
					b_setting = '{"b_url":"'+imgStr+'","b_clickURL":"http://mobile.pandora.tv/mo/r.ptv?from=banner;http://mobile.pandora.tv/mo/r.ptv?from=event","b_screen":"true;true","b_rollingTime":"5;5"}';
				}else if(this._Imgres.length == 1){
					b_setting = '{"b_url":"'+imgStr+'","b_clickURL":"http://mobile.pandora.tv/mo/r.ptv","b_screen":"true","b_rollingTime":"5"}';
				}
//*/
				$(this._super.PLAYER_ELEMENT_ID).setMo("banner", b_setting);
				//this.mo_stop();
				this.show_logo(0);
			}
		}
		clearTimeout(this.tid4);
	}
}


var cPlayerMgr = Class.create();
cPlayerMgr.prototype = {
	VERSION : '1.0.02',
	PLAYER : null,
	PLAYER_ELEMENT_ID : 'flvPlayer',
	PLAYER_ELEMENT_INST : null,
	IS_PLAYER : false,
	isFlashVer : false,
//		isLoaded : false,
	isAutoPlay : false,
	isSerial : false,
	isPlaying : false,	// 영상이 재생중인지 여부...
	oMo : null,
	icfPass : false,
	chkCupiSec : 0,
	cupiFrame : null,
	currIcf : null,

	exticf : true,
	bgicf : true,
	shIcf : true,
	icf_kind : "",


	login_userid : null,
	isAutoBreak : false,

	nowDate : null,

	icfPassLevel : [11030, 11036],
	cupiPassLevel : [11020, 11030, 11036],
	cupiBrandLevel : [11036],


		/* 생성자 함수 */
	initialize : function() {
		var browserLang = oCookie.get('clientLang') || "ko";//Flash Player에서 준비되면 chInfoJson['clientLang']로 변경...
		if(browserLang.toUpperCase() == "KO") { // && parseInt(chInfoJson["chlv"], 10) != 11046) {
			this.oMo = new MO(this);
		}

		this.flvInfo = {}; /* 영상옵션 초기화 */
		this._encode = [
			{ code:'30010', value:'0' },  //재생가능
			{ code:'30003', value:'0' },  //재생가능
			{ code:'30007', value:'0' },  //재생가능 (블라인드 처리 된거 채널 주인일때만 보임)
			{ code:'30002', value:'-2' }, //인코딩중
			{ code:'30001', value:'-3' }  //인코딩실패
		];
		this.login_userid = decodeURIComponent(oCookie.get('glb_mem[userid]'));

		var strDate = chInfoJson['currTime'].substring(0, 8);
		this.nowDate = new Date(parseInt(strDate.substr(0, 4), 10), (parseInt(strDate.substr(4, 2), 10)-1), parseInt(strDate.substr(6, 2), 10), 0, 0, 0);
	},

		/* public
		 * 플레이어의 기본정보를 설정합니다.
		 */
	set : function(parent, options){
		this._super = parent;
		//this.icfPass = parseInt(chInfoJson['exploerer'], 10) || 0;
		this.icfPass = oCookie.get("glb_mem[exploerer]") || 0;
		this.icfPass = (this.icfPass==0) ? oCookie.get("onPlay") || 0 : 1;//새로운 채널 endPlay일때 icf안나오게 2008.11.04 전설희 2009.03.02 이미경씨 지시로 다시 나오게 함
		oCookie.set("onPlay", "");//새로운 채널 endPlay일때 icf안나오게 2008.11.04 전설희
		this.adInfo = {icf:['noicf'], buffer:{type:'nobuffer', url:''},
			             middle:'nomiddle',
			             slideCF:['noslide'],
			             inner:"on", still:['nostill'],
			             stillTime:5};

		var browser = Prototype.Browser.IE ? "IE" : (Prototype.Browser.Opera ? "OP" : (Prototype.Browser.WebKit ? "SF" : (Prototype.Browser.Gecko ? "FF" : "ETC")));
		var countryCode = oCookie.get('ipCountry');
		if(!countryCode || countryCode == "-") countryCode = "KR";
		this.etcInfo = {cdnState:"off", cdnServer:0,
			              miniInst:"off", miniPlay:"off", guideView:"on", playType:"channel",
			              countryCode:countryCode,
			              languageCode:chInfoJson['clientLang'],
			              myChannel:(parseInt(chInfoJson['mychannel'], 10) == 1) ? "on" : "off",
			              browser : browser};

		this.options = Object.extend({target:'FRM_PLAYER', auto:'off', mo:'off', level:'0', chmenu:'video', userAge:0, userSex:"", callback:null }, options || {});

		var currTime = parseInt(chInfoJson['currTime'].substr(0, 4), 10);
		this.options['userAge'] = (oCookie.get("BD") != null) ? (currTime - parseInt(oCookie.get("BD"), 10)) : 0;
		this.options['userSex'] = oCookie.get("glb_mem[gender]") || "";

		this._draw();	// ActiveX설치를 위해 무조건 생성
	},

	getExpireTime : function(sTime) {
		var oDate = {
			year:parseInt(sTime.substr(0, 4), 10),
			month:parseInt(sTime.substr(4, 2), 10),
			day:parseInt(sTime.substr(6, 2), 10),
			hour:parseInt(sTime.substr(8, 2), 10),
			min:parseInt(sTime.substr(10, 2), 10),
			sec:parseInt(sTime.substr(12, 2), 10)
		};
		var currDate = new Date(oDate['year'], oDate['month'], oDate['day'], oDate['hour'], oDate['min'], oDate['sec']);
		var nextDate = new Date(oDate['year'], oDate['month'], oDate['day']+1, 0, 0, 0);
		return (nextDate - currDate)/1000;
	},

	resizePlayer : function(ext) {
		if(this.PLAYER) {
			with(this.PLAYER) {
				if(ext > 0) {
					width = "100%";
					height = "100%";
					with(style) {// opera support
						width = "100%";
						height = "100%";
					}
				} else {
					width = "1px";
					height = "1px";
					with(style) {// opera support
						width = "1px";
						height = "1px";
					}
				}
			}
		}
	},

	setCompleted : function(arg){
		if(this.chkFlashVer() == false && arg != 1 && Prototype.Browser.IE) {	// 플래시가 설치되어 있는데 버전이 낮으면...
			var imgUrl = variable.getChild("skinHost") + "pan_img/player/";
			switch(chInfoJson['clientLang'].toUpperCase()) {
				case "KO" : imgUrl += "install_ko.gif"; break;
				case "JP" : imgUrl += "install_ja.gif"; break;
				case "CN" : imgUrl += "install_ch.gif"; break;
				default : imgUrl += "install_en.gif";
			}
			var oImg = $(this.options['target']).down().next();
			oImg.onclick = null;
			oImg.style.cursor = "";
			oImg.src = imgUrl;

			var flashVer = this.getFlashVer() || 0;
			$('winWiselog').src = variable.getChild('mainHost') + "wiselog/chkflash.ptv?version=" + flashVer + "&mode=AxInstall";
			return false;
		} else {
			if(this.chkFlashVer() == false) return false;
		}

		this.isFlashVer = true;
		if(this.PLAYER == null) {
			this.PLAYER = $(this.PLAYER_ELEMENT_ID);
			setTimeout(function() {
				this.resizePlayer(1);
			}.bind(this), 500);

			var currTime = chInfoJson['currTime'] || 0;
			var updateFlag = false;
			if(this.oMo != null) {
				//var expireTime = this.getExpireTime(currTime);	//금일 하루(자정)로 지정할때 사용
				var autoPlay = oCookie.get('chAutoPlay');
				if(autoPlay == undefined || autoPlay == null) {
					updateFlag = true;
					autoPlay = "on";
					oCookie.set("chAutoPlay", autoPlay, 86400);
				}

				var autoMO = oCookie.get('chAutoMO');
				if(autoMO == undefined || autoMO == null) {
					updateFlag = true;
					autoMO = "on";
					oCookie.set("chAutoMO", autoMO, 86400);
				}
			} else {
				autoPlay = "off";
				autoMO = "off";
			}

			var initInfo = {
				isAutoPlay : autoPlay, isMO : autoMO,
				updateTime : ((updateFlag == true) ? currTime : 0), //년월일시분초(14자리)
				playMode:((this.options['chmenu'].toLowerCase() == "playlist") ? "pl" : "ch")
			};
			this.PLAYER.initPlayer(initInfo);
		}
	},

	chkFlashVer : function() {
		var result = false;
		var flashVer = this.getFlashVer();
		if(flashVer != false) {
			var flashVer = flashVer.split(".");
			if(parseInt(flashVer[0], 10) > 9) result = true;
			else if(parseInt(flashVer[0], 10) == 9 && parseInt(flashVer[1], 10) >= 0 && parseInt(flashVer[2], 10) >= 115) result = true;
		}
//		return result;
		return true;
	},

	_draw : function(){
//		setTimeout(function() {
//			if(this.PLAYER == null && this.chkFlashVer() != false) oCtlJs.startPlayer();
			var html = '<iframe name="frmCupi" src="about:blank" width="0" height="0" border="0" frameborder="0"></iframe>' +
			           '<form id="fmCupi" method="post" target="frmCupi" style="margin:0px">' +
			           '	<input type="hidden" name="json">' +
			           '</form>';
			var oDiv = document.createElement("DIV");
			document.body.appendChild(oDiv);
			oDiv.innerHTML = html;
//		}.bind(this), 2000);
	},

	_draw1 : function() {
		if(this.PLAYER) this.resizePlayer(-1);
		if($(this.options['target']).childNodes.length > 1) return false;

		var html = '<iframe name="winWiselog" src="about:blank" width="0" height="0" border="0" frameborder="0"></iframe>';
		var oDiv = document.createElement("DIV");
		document.body.appendChild(oDiv);
		oDiv.innerHTML = html;
		setTimeout(function(){
			var flashVer = this.getFlashVer() || 0;
			$('winWiselog').src = variable.getChild('mainHost') + "wiselog/chkflash.ptv?version=" + flashVer + "&mode=view";
			}.bind(this)
		, 1000);

		var imgUrl = variable.getChild("skinHost") + "gplayer/";
		switch(chInfoJson['clientLang'].toUpperCase()) {
			case "KO" : imgUrl += "flash_install_ko.gif"; break;
			case "JP" : imgUrl += "flash_install_jp.gif"; break;
			case "CN" : imgUrl += "flash_install_cn.gif"; break;
			default : imgUrl += "flash_install_en.gif";
		}

		$(this.options['target']).style.position = "relative";

		var sHtml = '<img onclick="cPlayerMgr.getInstance().clickFlashInstall()" src="' + imgUrl + '" width="100%" height="100%" border="0" style="position:absolute;top:0px;left:0px;cursor:pointer;">';
		new Insertion.After($(this.options['target']).down(), sHtml);
	},

		/* private
		 * PLAYER 생성 여부 확인 생성되지 않았다면 생성될 때까지 체크합니다.
		 */
		_isExist : function() {
				try { 
					 this.PLAYER = $(this.PLAYER_ELEMENT_ID);
				} catch (e) {}
			(!this.PLAYER) ? setTimeout( this._isExist.bind(this), 200) : this.onPlay();
		},

		/* public
		 * 플레이하려는 영상의 정보를 입력받습니다.
		 * 실제 이 메서드를 통해서 영상이 플레이 됩니다. this.onPlay();
		 */
		setflv : function(options){
			if(this.chkFlashVer() == false) {//this.isFlashVer == false &&
				var ver = this.getFlashVer();
				var arrVer = ver != false ? ver.split(".") : [0, 0, 0];

				if(options['isHD'] == 3 && arrVer[0] >= 8) {
					if(this.isFlashVer == false) this.setCompleted(1);
					else this.resizePlayer(1);
				} else {
					if(ver != false) return false;	// 낮은 버전이 설치가 되어 있는 경우면 브라우저를 종료해야 하므로...
				}
			}

			this.flvInfo = Object.extend({
				flv		: '',	//flv 경로
				encode	: '',	//인코딩
				userid	: '',	//원본 소유자 아이디
				prgid	: '',	//프로그램 고유 번호
				title	: '',	//프로그램 제목
				chname	: '',	//프로그램 채널명
				embed	: '',	//임베디드
				filesize : 0,	// vod file size
				fid : '', 	// flv id
				scrsize : '', //영상의 해상도
				isHD : 'off',	//HD 영상 여부
				isMP4 : 'off', // H.246 여부
				runtime : 0,
				orgChUserid : "",
				orgPrgid : 0,	// 원본 영상의 id
				categ: 0,
				vod_svr: 0,
				reg_date:"",	// 국내에서 3회 이상 봤을 경우 현재 날짜로 업데이트 함 -> 김형조 과장 cdn 분리시 필요 2008-09-23 smith.oh
				greg_date:"",	// 해외에서 1회 이상 봤을 경우 현재 날짜로 업데이트 함 -> 김형조 과장 cdn 분리시 필요 2008-09-23 smith.oh
				isAdult:0
			}, options || {});

			this.flvInfo['embed'] = (options['embed'] == '0') ? 'on' : 'off';


				for(var i=0; i<this._encode.length; i++) {
					if(this.flvInfo['encode'] == this._encode[i]['code']) {
						switch(parseInt(this.flvInfo['encode'], 10)) {
							case 30010 :
								if(this.options['chmenu'] == "video" && this._super.param['status'] == "30008") {
									this.options['level'] = {code:30008, url:variable.getChild('vod')+"/restraint.swf"};
									break;
								}
								// sbs icf 관련 변수 추가 2010.01.07 hc.cho
								if (sbsicf && ipCountry != 'KR') {
									this.options['level'] = {code:90001, url:variable.getChild('vod')+"/restraint.swf?cache"};
									break;
								}
							case 30003 : this.options['level'] = {code:this._encode[i]['value'], url:""};
								// sbs icf 관련 변수 추가 2010.01.07 hc.cho
								if (sbsicf && ipCountry != 'KR') {
									this.options['level'] = {code:90001, url:variable.getChild('vod')+"/restraint.swf?cache"};
								}
								break;
							default :
								if(parseInt(chInfoJson.mychannel, 10) == 1) {	// 채널 주인이면...
									this.options['level'] = {code:this._encode[i]['value'], url:variable.getChild('vod')+"/new_ch_wait_other.swf"};
								} else {	// 방문자이면..
									this.options['level'] = {code:this.flvInfo['encode'], url:variable.getChild('vod')+"/restraint.swf"};
								}
						}
						break;
					}
				}

			this._isExist();
		},

		getAdIcfInfo : function(icf, runtime) {
			/*
			for(var i=0;i<icf.length;i++) {
				if(icf[i]['etime'] == 0) {
					if(icf[i]['info'].length <= 1 || icf[i]['info'][0]['rate'] >= 100) {
						this.currIcf = icf[i]['info'][0]['adInfo'] || null;
					} else {
						var rnd = getRandom(100);
						var rate = 0;
						for(var j=0;j<icf[i]['info'].length;j++) {
							rate += icf[i]['info'][j]['rate'];
							if( rnd <= rate) {
								this.currIcf = icf[i]['info'][j]['adInfo'];
								break;
							}
						}
					}
					break;
				} else {
					if(runtime >= icf[i]['stime'] && runtime <= icf[i]['etime']) {
						if(icf[i]['info'].length <= 1 || icf[i]['info'][0]['rate'] >= 100) {
							this.currIcf = icf[i]['info'][0]['adInfo'] || null;
						} else {
							var rnd = getRandom(100);
							var rate = 0;
							for(var j=0;j<icf[i]['info'].length;j++) {
								rate += icf[i]['info'][j]['rate'];
								if( rnd <= rate) {
									this.currIcf = icf[i]['info'][j]['adInfo'];
									break;
								}
							}
						}
						break;
					}
				}
			}

			var result = [];
			if(this.currIcf != null) {
				for(var i=0;i<this.currIcf.length;i++) {
					result.push(this.currIcf[i]['url']);//+"?ads_no=9975" 9938
				}
			}
			*/
			var result = [];


			return result;
		},

		setAdParam : function(argAdverInfo) {
			//{icf:new Array(), buffer:this.adInfo['buffer'], middle:this.adInfo['middle'], inner:this.adInfo['inner'], still:["nostill"]}

			var adAdultParam = (parseInt(this.flvInfo['isAdult'], 10) < 19) ? "1" : "2";
			if(argAdverInfo['icf'][0] != "noicf" && argAdverInfo['icf'][0] != "exticf") {
				var categ = parseInt(this.flvInfo['categ'].substring(0, 2), 10);
				for(var i=0;i<argAdverInfo['icf'].length;i++) {
					// 2008-09-23 smith 성인 프리미엄 채널 때문에 작업 함. 채널 레벨이 11046 이면 성인 프리미엄 채널임
					if (false && parseInt(chInfoJson['chlv'], 10) == 11046) {
						argAdverInfo['icf'][i] = "noicf";
					} else {
						argAdverInfo['icf'][i] += ((argAdverInfo['icf'][i].indexOf("?") > -1) ? "&" : "?") + "age=" + this.options['userAge'];
						argAdverInfo['icf'][i] += "&edugrade=" + categ;
						argAdverInfo['icf'][i] += "&marital=" + adAdultParam;
					}
				}
			}
			if(argAdverInfo['buffer']['type'] != "nobuffer") argAdverInfo['buffer']['url'] += ((argAdverInfo['buffer']['url'].indexOf("?") > -1) ? "&" : "?") + "age=" + this.options['userAge'];
			if(argAdverInfo['middle'] != "nomiddle") argAdverInfo['middle'] += ((argAdverInfo['middle'].indexOf("?") > -1) ? "&" : "?") + "age=" + this.options['userAge'];

			// 2008-09-23 smith 성인 프리미엄 채널 때문에 작업 함. 채널 레벨이 11046 이면 성인 프리미엄 채널임
			if (false && parseInt(chInfoJson['chlv'], 10) == 11046) {
				argAdverInfo['slideCF'][0] = "noslide";
			}

			if(argAdverInfo['slideCF'][0] != "noslide") {
				// base만 적용
				argAdverInfo['slideCF'][0] += ((argAdverInfo['slideCF'][0].indexOf("?") > -1) ? "&" : "?") + "age=" + this.options['userAge'];
				argAdverInfo['slideCF'][0] += "&sex=" + this.options['userSex'];
				argAdverInfo['slideCF'][0] += "&marital=" + adAdultParam;
			}

			// 2008-09-23 smith 성인 프리미엄 채널 때문에 작업 함. 채널 레벨이 11046 이면 성인 프리미엄 채널임
			if (parseInt(chInfoJson['chlv'], 10) == 11046) {
				argAdverInfo['still'][0] = "cutstill";
				argAdverInfo['still'][1] = outLink;
			} else {
				if(argAdverInfo['still'] != "" && argAdverInfo['still'] != "nostill") {
					for(var i=0;i<argAdverInfo['still'].length;i++) {
						argAdverInfo['still'][i] += ((argAdverInfo['still'][i].indexOf("?") > -1) ? "&" : "?") + "age=" + this.options['userAge'];
						argAdverInfo['still'][i] += "&marital=" + adAdultParam;
					}
				}
			}

			if (argAdverInfo['still'].indexOf("nostill") > -1) { // 해외에서 이상하게 nostill만 이상하게 잡히기 때문에 작업함
				argAdverInfo['still'] = "nostill";
			}

			return argAdverInfo;
		},



		getAdverInfo : function(runtime) {
			this.currIcf = null;
			var adInfo = {
				icf:new Array(),
				buffer:this.adInfo['buffer'],
				middle:this.adInfo['middle'],
				slideCF:this.adInfo['slideCF'],
				inner:this.adInfo['inner'],
				still:["nostill"],
				stillTime:this.adInfo["stillTime"]
			};

			//var prgOrgUserid = this.flvInfo['userid'];
			var prgOrgUserid = this.flvInfo['orgChUserid'];
			if(this.options['chmenu'] == "video" && this.flvInfo['encode'] == 30003) prgOrgUserid = this.flvInfo['orgChUserid'];
			if(prgOrgUserid == this.login_userid || this.options['level']['code'] != 0 || (this.icfPassLevel.indexOf(parseInt(chInfoJson['chlv'], 10)) > -1)) {
				//startNoiCF=false; //2008. 09. 23  17:59:22 추가 이재욱
				adInfo['icf'].push("noicf"); // my video or video exception(status가 30003, 30010이 아닌 모든 경우)
			} else {
				switch(true) {
					case (this.flvInfo['isHD'] == 2): break;	// HD영상이면 ICF 무플 정책을 적용하지 않음(보류)
					case (this.icfPassLevel.indexOf(parseInt(chInfoJson['chlv'], 10)) > -1) :
					case (this.icfPass != 0) :
					//case (parseInt(chInfoJson['mychannel'], 10) == 1 && this.flvInfo['encode'] == 30003):	// mychannel & my-vod
						adInfo['icf'].push("noicf");

				}
			}

			var icf = null;
			var ending = null;

			if(this.etcInfo.languageCode!="ko") {
				if(this.flvInfo['isHD'] == 2) {
					icf = adverInfo['icf_hd'];
					ending = adverInfo['ending_hd'];
					adInfo['inner'] = 'off';
				} else {
					icf = adverInfo['icf'];
					ending = adverInfo['ending'];
				}
			}else{
				icf = adverInfo['icf'];
				ending = adverInfo['ending'];/*ui가 바뀌면서 광고통일 2009.06.11 전설희*/
			}

			if(adInfo['icf'][0] != "noicf") {	// noicf가 아니면...
				adInfo['icf'] = this.getAdIcfInfo(icf, runtime);
				adInfo['icf'] = getRandomArr(adInfo['icf']);
			}

			for(var i=0;i<ending.length;i++) {
				if(ending[i]['etime'] == 0) {
					adInfo['still'] = Object.extend([], ending[i]['url']);
					if(ending[i]['viewtime'] != undefined && ending[i]['viewtime'] > 0) adInfo['stillTime'] = ending[i]['viewtime'];
					break;
				} else {
					if(runtime >= ending[i]['stime'] && runtime <= ending[i]['etime']) {
						adInfo['still'] = Object.extend([], ending[i]['url']);
						if(ending[i]['viewtime'] != undefined && ending[i]['viewtime'] > 0) adInfo['stillTime'] = ending[i]['viewtime'];
						break;
					}
				}
			}

			if((this.icfPassLevel.indexOf(parseInt(chInfoJson['chlv'], 10)) == -1) && (adverInfo['slideCF'] != undefined)) {//hd영상도 슬라이드 광고 외국은 HD일때 안나옴 2009.06.08 전설희

				if(this.etcInfo.languageCode=="ko" || this.etcInfo.languageCode=="jp"){
					if(adverInfo['slideCF']['basic'] != "" && adverInfo['slideCF']['basic'] != "noslide") { // 30초 삭제 ray.kim 2010-11-05 에 변경
						if( adverInfo['slideCF']['gmarket'] != '' ){		// dy.bueon 좌측 영상 광고 2010-12-16
							adInfo['slideCF'] = new Array(adverInfo['slideCF']['basic'], adverInfo['slideCF']['extend'], adverInfo['slideCF']['gmarket']);
						}else
							adInfo['slideCF'] = new Array(adverInfo['slideCF']['basic'], adverInfo['slideCF']['extend']);
					}

					//##################	2010-12-06	Gmarket 광고 추가
					if(adverInfo['slideCF']['basic'] != "noslide" && adverInfo['slideCF']['gmarket'] != "" && this.etcInfo.languageCode == "jp") { // dy.bueon 좌측 광고 2010-12-16
						adInfo['slideCF'] = new Array(adverInfo['slideCF']['basic'], adverInfo['slideCF']['extend'], adverInfo['slideCF']['gmarket']);
					}
				}
			}

			if(this.isSerial) {
				switch(adverInfo['serial']) {
					case "icf" : adInfo['still'] = ["nostill"];
						break;
					case "still" : 
						adInfo['icf'] = ["noicf"]; 
						this.currIcf = null;
						break;
				}
			}

//			if(this.options['userAge'] > 0) {	// 국내 사용자면서 나이가 확인되는 경우면...
				return this.setAdParam(adInfo);
//			} else {
//				return adInfo;
//			}
		},



		/* public
		 * 플레이 영상정보를 플레시 플래이어로 전달합니다.
		 */
		onPlay : function(){
			var activexClose = arguments[0];
			if(!this.PLAYER) {
				try { 
					 this.PLAYER = $(this.PLAYER_ELEMENT_ID);
				} catch (e) {}

				window.setTimeout( this.onPlay.bind(this), 50);
			} else {
				if(this.options['level']['code'] != 10018) this.isAutoBreak = false;

				this.isPlaying = false;

				window.setTimeout( function() {
					// smith.oh 추가 2008-07-08
					if (this.flvInfo['runtime'] && this.flvInfo['runtime'].toString().indexOf(":") > -1) {
						var runtime = this.flvInfo['runtime'] ? getTime2Sec(this.flvInfo['runtime']) : 0;
					} else {
						var runtime = this.flvInfo['runtime'];
					}

					var adInfo = this.getAdverInfo(runtime);
					var scrsize = this.flvInfo['scrsize'] ? this.flvInfo['scrsize'].split("*") : new Array(448, 336);	// 영상의 가로*세로 해상도

					var fixedDay = 1;
					if(this.flvInfo["prgRegDate"]) {
						var oDate1 = 20080801;	// 8월 1일
						var oDate2 = 20080914;	// 9월 14일
						var oDate = this.flvInfo["prgRegDate"].replace(/-/g, "");
						if(oDate1 <= oDate && oDate2 >= oDate) fixedDay = 0;
					}


					var vodInfo = {
						exception	: this.options['level'],
						// flvcdn.pandora.tv --> flvcdn2.pandora.tv, flvg.pandora.tv --> flvg2.pandora.tv
						vodUrl		: parseInt(this.flvInfo['vod_svr'], 10) == 88 ? this.flvInfo['flv'].replace('.pandora.tv', '2.pandora.tv'): this.flvInfo['flv'],
						prgid		: this.flvInfo['prgid'],
						title		: this.flvInfo['title'],
						chname		: this.flvInfo['chname'],
						embed		: this.flvInfo['embed'],
						userid		: this.flvInfo['userid'],
						filesize	: this.flvInfo['filesize'],
						fid			: this.flvInfo['fid'],
						runtime		: runtime,
						vodWidth	: ((scrsize[0] == undefined || scrsize[0] == 0 || scrsize[0] == "") ? ((this.flvInfo['isHD'] == 2) ? 1280: 448) : scrsize[0]),
						vodHeight	: ((scrsize[1] == undefined || scrsize[1] == 0 || scrsize[1] == "") ? ((this.flvInfo['isHD'] == 2) ? 720: 336) : scrsize[1]),
						isHD		: ((this.flvInfo['isHD'] == 2) ? "on":"off"),
						isMP4		: (this.flvInfo['isHD'] == 1 || this.flvInfo['isHD'] == 2) ? "on" : "off",
						regDay		: this.flvInfo['reg_date'],//this.getRegDay(this.flvInfo['reg_date']),
						gRegDay		: this.flvInfo['greg_date'],//this.getRegDay(this.flvInfo['reg_date']),
						category	: this.flvInfo['categ'],
						isAdult		: (parseInt(this.flvInfo['isAdult'], 10) < 19 ? 0 : 1),
						orgPrgid	: ((this.flvInfo['orgPrgid'] > 0) ? this.flvInfo['orgPrgid'] : this.flvInfo['prgid']),
						orgChUserid	: this.flvInfo['orgChUserid'],
						fixedDay	: fixedDay, 
						copyright	: sbsTitle
					};

					/* 멀티비트 (Ray.Kim : 2010-08-10) */
					this.etcInfo['multibitrateVLD']	= this.flvInfo['multibitrateVLD'] ;
					this.etcInfo['multibitrateLD']	= this.flvInfo['multibitrateLD'] ;
					this.etcInfo['multibitrateSD']	= this.flvInfo['multibitrateSD'] ;
					this.etcInfo['multibitrateHD']	= this.flvInfo['multibitrateHD'] ;

					this.etcInfo['miniInst']	= "off" ;
					this.etcInfo['miniPlay']	= "off" ;
					this.etcInfo['login']		= (oCookie.get('glb_mem[userid]')) ? "on" : "off" ;
					this.etcInfo['classType']	= chInfoJson['classType'] ;

					/********* 추가 (2008-12-19 denis.kim)*************************************/
					if (sbsicf){ // sbs icf 관련 변수 추가 2009.12.24 hc.cho
						adInfo['icf'] = [];
						adInfo['icf'].push(sbsicf);

						adInfo['still'] = 'nostill';

//						adInfo['slideCF'] = [];
//						adInfo['slideCF'].push('noslide');
					}
					/********* /추가 *************************************/
					if(this.icf_kind != "bg") {
						if (extIcfJson["kind"]) {
							adInfo['icf'] = [];
							adInfo['icf'].push("exticf");
						}

						// 가끔 오류남 settimeout으로 해결
						try { this.PLAYER.init_Load_Info(adInfo, vodInfo, this.etcInfo); } 
						catch (e) {
							window.setTimeout( this.onPlay.bind(this), 2050);
						}
					}
//					return;

					this.isSerial = false;

					try { this.adultLogChk(); } 
					catch (e) {window.setTimeout( this.adultLogChk(), 200);}

					if (chInfoJson['classType'] == "first") {
						loadJS("http://www.pandora.tv/wiselog/speedfirst.ptv");
					}
				}.bind(this), 10);
				if(this.options['callback']) this.options['callback'].apply(this._super, [true]);
			}
		},
	adultLogChk : function() {
		if(parseInt(this.flvInfo['isAdult'], 10) >= 19) {
			if($('wiselogAdult') == null) {
				var html = '<iframe name="wiselogAdult" id="wiselogAdult" src="about:blank" width="0" height="0" border="0" frameborder="0" style="display:none"></iframe>';
				new Insertion.After(document.body.down(), html);
				setTimeout(function(){this.adultLogChk();}.bind(this), 100);
				return;
			}
			var wiselogUrl = variable.getChild('mainHost') + "wiselog/adultVideo.ptv?type=" + (this.options['chmenu'] != "playlist" ? "ch_video" : "ch_playlist");
			$('wiselogAdult').src = wiselogUrl;
		}
	},

	icfPlay : function(icfInfo) {
		if(icfInfo[0].length > 0 && icfInfo[0].toLowerCase() != "noicf") {
			var rnd = Math.random()*100;
			if(rnd < 40) {
				for(var i=0;i<icfInfo.length;i++) {
					setTimeout(function(icfUrl) { $('icfImsiPlayer').src = icfUrl; }.bind(this, icfInfo[i]), ((i*15000)+5000));
				}
			}
		}
	},

	isPlay : function() {
		return this.isPlaying;
	},

	getRegDay : function(strDate) {
		if(strDate) {
			var arrDate = strDate.split("-");
			var regDate = new Date(parseInt(arrDate[0], 10), parseInt(arrDate[1], 10)-1, parseInt(arrDate[2], 10), 0, 0, 0);
			var cnt = this.nowDate - regDate;
			return cnt/86400000;
		} else {
			return 0;
		}
	},

	setCupi : function(cnt) {
		// 11026, 11036, 11046, 11126 채널레벨이면 기존에 cupi를 호출
		// cupi 추가. 페이지 로딩시 cupi 지급. hc.cho 2009.12.27, 광고를 보고 난 후 여기를 타지 않게 하기 위해 return 해 버림.	
		if (!$("fmCupi")) {
//			this._draw();
		}
		if (channel_level != '11026' && channel_level != '11036' && channel_level != '11046' && channel_level != '11126') {
			return false;
		}

		var oDate = new Date();
		var nowSec = Math.floor(oDate.getTime()/1000);
		if((nowSec - this.chkCupiSec) > 10) {
			this.chkCupiSec = nowSec;
		} else {// 10초 이내에 큐피 적립 요청을 하면 무시한다.
			return false;
		}

		var cupiUrl = variable.getChild('shareHost') + "json/v003/GLGive.dll";//http://embed.pandora.tv/pan_hit/give_v20.dll
		if(this.flvInfo['encode'] == 30010) {
			var ch_userid = this.flvInfo['orgChUserid']
			var prgid = this.flvInfo['orgPrgid']
		} else {
			var ch_userid = chInfoJson['ch_userid'];
			var prgid = this.flvInfo['prgid'];
		}
		var oForm = $('fmCupi');
		oForm.action = cupiUrl;
		var rt  = "15";;
		try {
			// 원래 adverInfo 에 광고 정보에서 runtime을 넘겨 주었었는데 신규채널에서는 없어짐 2010-05-04 smith.oh 혹시 몰라서 남겨둠
			rt = this.currIcf[cnt-1]['runtime']
		} catch(e) {}

		var json = {ch_userid:ch_userid,
		            prg_id:prgid,
		            isHD:((this.flvInfo['isHD'] == 2) ? 2:1).toString(),
//		            vod_type:((this.options['chmenu'] == 'playlist') ? 3 : ((this.flvInfo['encode'] == 30010) ? 2 : 1)).toString(),
//		            ch_level:this._super.chInfo.getInfo('chlv').toString(),
//		            runtime:this.currIcf[cnt-1]['runtime'].toString()};
		            runtime:rt};
		oForm.json.value = Object.toJSON(json);
		oForm.submit();
	},

	instApp : function() {
		var sUrl = variable.getChild('downloadHost') + "?mode=p.tv";
		window.open(sUrl, "downloadWindow");
	},

		getVodUrl : function(){
			return this.flvInfo['flv'];
		},

		setAutoPlay : function(flag){
			$(this.PLAYER_ELEMENT_ID).set_auto_play(flag);
		},

		reset : function(){
			try{ // 채널 오픈시 동기화 문제로 인해...
				$(this.PLAYER_ELEMENT_ID).resetData();
			} catch(e) {}
		},

		endIcf : function(cntICF) {
			// cupi 적립
			var chLevel = parseInt(chInfoJson['chlv'], 10);
			if(cntICF > 0) { // ICF가 나왔을때...
				if(this.cupiPassLevel.indexOf(chLevel) == -1) {
					this.setCupi(cntICF);
				}
			}
		},

		startVod : function() {
			var chLevel = parseInt(chInfoJson['chlv'], 10);
			if(this.cupiBrandLevel.indexOf(chLevel) > -1) { // 브랜드 채널의 정산을 위해...
				this.setCupi(1);
			}

			this.isPlaying = true;

			var vodType = "flv";
			switch(parseInt(this.flvInfo['isHD'], 10)) {
				case 1 : vodType = "mp4"; break;
				case 2 : vodType = "hd"; break;
			}

			var oScripts = document.getElementsByTagName("script");
			oScripts[oScripts.length-1].src = "http://embed.pandora.tv/pan_hit/viewChk.dll?mode=player_" + vodType;

			switch(chInfoJson['ch_userid'].toLowerCase()) {
				case "ddeani" :
				case "ddeani1" :
				case "ddeani2" :
					if(!$('aniForm')) {
						var sHtml = '<div style="position:absolute;left:0px;top:0px;">';
						sHtml += '<form id="aniForm" method="post" action="http://embed.pandora.tv/json/v003/GLGive.dll/hit" target="aniFrame">';
						sHtml += '<input type="text" name="json" value="">';
						sHtml += '</form>';
						sHtml += '<iframe src="about:blank" name="aniFrame" width="100px" height"100px" frameboard="1px" border="1px" style="border-width:0px"></iframe>';
						sHtml += '</div>';
						new Insertion.After(document.body, sHtml);
					}
					setTimeout(function(){
							var oForm = $('aniForm');
							oForm.json.value = '{"ch_userid":"' + chInfoJson['ch_userid'] + '", "prg_id":"' + this.flvInfo['prgid'] + '"}';
							oForm.submit();
						}.bind(this)
					, 5000);
					break;
			}

			// mo control : start
			if(this.oMo != null) {
				this.oMo.mo_play();
			}
		},

		endVod : function(flg){
			this.isPlaying = false;

			// mo stop
			if(this.oMo != null) {
				this.oMo.mo_stop();
			}
		},

		exceptionPlay : function() {
//			var nextPrgInfo = this._super.board.getNextPrg(this._super.getClickPrgId());
			// 2008-06-24 오현섭 수정
			// 연속 재생상태인데 일시적 오류가 뜨면 delaycount초후 다음 영상으로 넘기는 작업
			var nextPrgInfo = "";//this._super.getNextPrg(this._super.prgid);
			nextPrgInfo['prgid'] = 1;
			nextPrgInfo['key'] = 1;
			if(nextPrgInfo['prgid'] != 0 || nextPrgInfo['key'] != null) {
				if(this.isAutoBreak == false && this.isAutoPlay == true) {
					this.PLAYER.delayCount(10);
				}
			}
		},

		endPlay : function(){
			this._super.endPlay();
		},

		phoneSend : function() {
			/*
			var chuserid = this.flvInfo['userid'];
			var prgid = this.flvInfo['prgid'];
			var url = variable.getChild('mobileHost') + "w2p/callback_send_form.ptv?userid=" + chuserid + "&prg_id=" + prgid + "&from_code=player";
			var style = "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=250, height=390";
			window.open(url, "w2p_send", style);
			*/
			alert("2009년 8월 31일로 서비스가 종료 되었습니다.");
		},

		openHD : function(prgid) {
			var sUrl = "/HDPlayer.html?prgid=" + prgid;
			window.open(sUrl, "HDPlayer", "fullscreen=yes");
		},

		setIni : function(isAutoPlay, isMO) {
			this.isAutoPlay = (isAutoPlay == 1) ? true: false;
			if(this.oMo != null) {
				this.oMo.setIni(isMO);
			}
		},

		ax2flash : function(errType) {
			$(this.PLAYER_ELEMENT_ID).hdPlayerError(errType);
		},

		/* public
		 * advertisement company catching tag - dynamic call
		 * @param	{string}	openTag URL
		 */
		adOpenTag : function(u) {
			//var oScripts = document.getElementsByTagName("script");
			//oScripts[oScripts.length-3].src = u;
			//return false;
			var img = $('openTag');
			if(!img) {
				img = document.createElement('IMG');
				img.style.display = 'none';
				img.id = 'openTag';
				document.body.appendChild(img);
			}
			img.src	= u;
		},

	getFlashVer : function() {
		var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
		var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
		var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

		var flashVer = -1;
		switch(true) {
			case (navigator.plugins != null && navigator.plugins.length > 0) : // NS/Opera version >= 3 check for Flash plugin in plugin array
					if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
						var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
						var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
						var descArray = flashDescription.split(" ");
						var tempArrayMajor = descArray[2].split(".");
						var versionMajor = tempArrayMajor[0];
						var versionMinor = tempArrayMajor[1];
						var versionRevision = descArray[3];
						if (versionRevision == "") {
							versionRevision = descArray[4];
						}
						if (versionRevision[0] == "d") {
							versionRevision = versionRevision.substring(1);
						} else if (versionRevision[0] == "r") {
							versionRevision = versionRevision.substring(1);
							if (versionRevision.indexOf("d") > 0) {
								versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
							}
						}
						var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
					}
				break;
			case (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) : flashVer = 4;	break;
			case (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) : flashVer = 3;	break;
			case (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) : flashVer = 2;	break;
			case (isIE && isWin && !isOpera) :	// IE with windows
					var axo;
					var e;

					try { // version will be set for 7.X or greater players
						axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
						flashVer = axo.GetVariable("$version");
					} catch (e) {	}

					if(flashVer == -1) {
						try { // version will be set for 6.X players only
							axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
							flashVer = "WIN 6,0,21,0";

							axo.AllowScriptAccess = "always";
							flashVer = axo.GetVariable("$version");
						} catch (e) {	}
					}

					if(flashVer == -1) {
						try { // version will be set for 4.X or 5.X player
							axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
							flashVer = axo.GetVariable("$version");
						} catch (e) {	}
					}

					if(flashVer == -1) {
						try { // version will be set for 3.X player
							axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
							flashVer = "WIN 3,0,18,0";
						} catch (e) {	}
					}

					if(flashVer == -1) {
						try { // version will be set for 2.X player
							axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
							flashVer = "WIN 2,0,0,11";
						} catch (e) {
							flashVer = -1;
						}
					}
					if(flashVer != -1) flashVer = flashVer.replace("WIN ", "").replace(/,/g, ".");
				break;
			}

		if(flashVer != -1) return flashVer;
		else {
			flashVer = (SharedObject._version != null) ? SharedObject._version.split(" ")[1].replace(/,/g, ".") : false;
			return flashVer;
		}
	},

	clickFlashInstall : function() {
		window.open("http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash", "_blank");
		var flashVer = this.getFlashVer() || 0;
		$('winWiselog').src = variable.getChild('mainHost') + "wiselog/chkflash.ptv?version=" + flashVer + "&mode=click";
	}
};

	cPlayerMgr.__instance__ = null;
	cPlayerMgr.getInstance = function(tag) {
		if(this.__instance__ == null) this.__instance__ = new cPlayerMgr();
		else
			if(tag == 'new') this.__instance__ = new cPlayerMgr();
		return this.__instance__;
	};

/* controller ********************************************************************************/
var playerController = Class.create();

playerController.prototype = {
	initialize : function(){
		this.player = cPlayerMgr.getInstance();
	},

	func : function(arg) {
		switch(arg) {
			case "join" :
				if(oCookie.get("glb_mem[userid]") != "") oLogin.chJoin();
				else {
					if(confirm("로그인이 필요합니다. 지금 로그인 하시겠습니까?") == true) {
						location.href = "/sign/signup.ptv";
					}
				}
				break;
			case "guestbook" :	location.href = "guest.ptv?ch_userid=" + chInfoJson['ch_userid'];
				break;
			case "upload" :
					if(chInfoJson.isupload == 1) location.href = "upload.ptv?ch_userid=" + chInfoJson['ch_userid'];
					else alert("업로드 권한이 없습니다.");
				break;

		}
	},



	startPlayer : function(){
		this.player.setCompleted();
	},

	endIcf : function(cntICF) {
		this.player.endIcf(parseInt(cntICF,10));
	},

	startVod : function(){
		this.player.startVod();
	},

	endVod : function(flg){
		// flg에 따라 autopaly 정지 : 1 - 사용자가 플레이어의 stop 버튼을 통해 강제 종료 했을때....
		//if(flg == 1) this.player.endVod(flg);
		this.player.endVod();

		// mo control : stop
	},

	endPlay : function(){
		this.player.endPlay();
	},

	exceptionPlay : function() {
		this.player.exceptionPlay();
	},

	copyEmbed : function(type) {
		var prgInfo = controller.getOneJson();
		switch(type) {
			case "html": window.clipboardData.setData("text", controller.chPrg.flashVars("flashV1", prgInfo["vod_url"], prgInfo["prg_id"]));
			break;
			case "url": window.clipboardData.setData("text", controller.chPrg.flashVars("flashV2", prgInfo["vod_url"], prgInfo["prg_id"]));
			break;
		}
	},

	complateEncode : function() {
		window.location.reload(); //화면 현재 연상으로 다시 보냄 혹은 리프레쉬
		//var flvInfo = this.player.flvInfo;
		//location.href = 'video.ptv?ch_userid='+ flvInfo['userid'] +'#prgid='+ flvInfo['prgid'] +'&categid=all';
	},

	instApp : function() { // goto video accelerator install page
		this.player.instApp();
	},


	setMini : function(stat) {
		switch(stat) {
			case "exec" :	// 실행
					try {
						oLauncher.runStreamer();
					} catch(e) {
					}
				break;
			case "inst" :	// 설치
				break;
		}
	},

	setReconfirm : function() {},

	reSocketChk : function() {},

	chJoin : function() {
		oLogin.memActive("channelJoin");
	},

	chGuest : function() {
		this.func("guestbook");
	},

	chUpload : function() {
		this.func("upload");	// 로그인이 되었을때만 보내야 하는데...
		//location.href = "upload.ptv?ch_userid=" + controller.chInfo.getInfo("ch_userid");	// 자기 채널로 가야 하지 않나....?
	},

	setGuide : function() {},

	viewGuide : function() {},

	instFlash : function() {},

	phoneSend : function() {
		this.player.phoneSend();
	},

	setIni : function(isAutoPlay, isMO) {
		this.player.setIni(isAutoPlay, isMO);
	},

	gotoPage : function(mode) {
		switch(mode) {
			case "up_mng" :
				location.href = "./admin.ptv?ch_userid=" + chInfoJson['ch_userid'] + "#cate=encoding";
				break;	// 관리 페이지의 업로드 히스토리로 이동
		}
	},

	ax2flash : function(errType) {
		this.player.ax2flash(errType);
	},

	/* opentag
	 * @param	{string}	open Tag url
	 */
	adOpenTag : function(u) {
		this.player.adOpenTag(u);
	},

	activePlayer : function() {
		this.player.PLAYER.focus();
	},

	limit : function() {
		window.open("http://info.pandora.tv/?m=1by1&con=" + oCookie.get("ipCountry") +"#code1=Q01");
	},

	premium : function() {
		window.open("http://www.pandora.tv/sign/complete.ptv");
	}
};

var oCtlJs = new playerController();

/*******************************************
 확장 또는 Background ICF 시작
******************************************/
// 확장 icf호출
var icfNum = 0;
var ads = "";
var vods = "";
var etcs = "";
var ads_icf = "";
var player_w = 0;
var player_h = 0;

var loadJsClass = {
	loadJS : function (path, charset1) {
		if (charset1 == undefined) {
			charset1 = "utf-8";
		}

		var oScript = document.createElement("SCRIPT");
		with(oScript) {
			setAttribute("type", "text/javascript");
			setAttribute("language", "javascript");
			setAttribute("charset", charset1);
			setAttribute("src", path);
			if(id!=undefined){
			setAttribute("id", id);
			}
		}
		document.getElementsByTagName('head')[0].appendChild(oScript);

	}
};

function start_extend_ad(runtime, country, mCAd) {
	if (mCAd && mCAd != undefined) {
		//movieCenterAd = mCAd;
	}
/*
	$("flvIcf").style.display="";
	$('divPlayer').style.width="0px";
	$('divPlayer').style.height="0px";

	// player pause는 플레이어에서 pause 하고 던저 준다.
	if(runtime<1201){
		loadJsClass.loadJS("http://ad.pandora.tv/js.kti/pandoratv/0906_channel@exp_icf_15","euc-kr");
	} else {
		loadJsClass.loadJS("http://ad.pandora.tv/js.kti/pandoratv/0906_channel@exp_icf_30","euc-kr");
	}
*/
//	loadJS("http://ads.pandora.tv/NetInsight/text/pandora/pandora_channel/main@icf");
	try {
		$("flvIcf_2").innerHTML = "";
		$("flvIcf_2").style.display = "none";
	} catch (e) { }
	//loadJS("http://ads.pandora.tv/NetInsight/text/pandora/pandora_channel/main@icf");

	try {
		loadJS("http://ads.pandora.tv/NetInsight/text/pandora/pandora_channel/main@icf_midd");
	} catch (e) { startPlay(); }
	
}


//일반 icf를 확장 처럼
function start_extend_ad2(runtime, country, vodInfo) {
	$("flvIcf").style.display="";
	$('divPlayer').style.width="0px";
	$('divPlayer').style.height="0px";

	var exeICF='';
	if (!(navigator.appVersion.indexOf("MSIE") == -1)) {
	exeICF='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	exeICF+='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="970" HEIGHT="378" id="extIcfPlayer" name="extIcfPlayer" ALIGN="">';
	exeICF+='<param value="wmode" name="transparent"></param><PARAM NAME=movie VALUE="http://imgcdn.pandora.tv/gplayer/normal_icfPlayer.swf">';
	exeICF+='<PARAM NAME=quality VALUE=high><PARAM NAME=wmode VALUE=transparent><PARAM NAME=bgcolor VALUE=#FFFFFF>';
	exeICF+='<param name="allowScriptAccess" value="always" />';
	exeICF+='</OBJECT>';
	}else {
	exeICF+='<EMBED src="http://imgcdn.pandora.tv/gplayer/normal_icfPlayer.swf"';
	exeICF+='quality=high wmode=transparent bgcolor="#FFFFFF" id="extIcfPlayer" name="extIcfPlayer" ALIGN="" WIDTH="970" HEIGHT="378" TYPE="application/x-shockwave-flash"';
	exeICF+='PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always"></EMBED>';
	}

	$("flvIcf").innerHTML=exeICF;
	var ads_icfs = {};
	ads_icfs.icf = ads_icf;
	ads_icfs.prgid = vodInfo.prgid;
	ads_icfs.languageCode = country;
	ads_icfs.category = vodInfo.category;
	setTimeout(function () {
		start_extend_ad2_lode(ads_icfs)
	}, 300);
}

var ext_lode = 0;
function start_extend_ad2_lode(ads_icfs) {
	try
	{
		$("extIcfPlayer").InitIcfList(ads_icfs);
	}
	catch (e)
	{
		if (ext_lode<50) {
			ext_lode++;
			setTimeout(function () {
				start_extend_ad2_lode(ads_icfs)
			}, 300);
		}else
			startPlay();
	}
}


function startPlay(){
	/* 2010-09-06 mmn 광고 스킵 버튼 혹시 있을수 있으니 없애 주자 start */
	try {
		$("icfSkipDiv").style.display = "none";
	}
	catch (e) {}
	/* 2010-09-06 mmn 광고 스킵 버튼 혹시 있을수 있으니 없애 주자 end */

	exit_extend_ad(1, true);
}


function start_shake_ad(runtime, country) {
	$("flvIcf").style.display="";
	$('divPlayer').style.width="0px";
	$('divPlayer').style.height="0px";
	$("flvIcf").style.top="-26px";
	loadJsClass.loadJS("http://ad.pandora.tv/js.kti/pandoratv/0906_channel@shake_icf_30","euc-kr");
}


// 확장 icf가 끝나면
function exit_extend_ad(cntIcf, play) {
	try {
		$("icfDiv").style.display	= "none";
		$("icfDiv").innerHTML		= "";
	} catch (e) { }

	try {
		$("flvIcf").style.display	= "none";
		$("flvIcf").innerHTML		= "";
	} catch (e) { }

	try {
		$("shakeIcf").style.display = "none";
		$("shakeIcf").innerHTML		= "";
	} catch (e) { }

	/*
	신규 광고는 확장 광고가 끝나고 나서 5초 동안 오른쪽 광고영역에 광고를 뿌려 준다.
	*/
	try {
		extIcfRightAd(); // video 소스에 있음
	} catch (e) {}
	/*
	//신규 광고는 확장 광고가 끝나고 나서 5초 동안 오른쪽 광고영역에 광고를 뿌려 준다.
	*/

	streamStartInit(cntIcf, play);
}

function streamStartInit(cntIcf, play) {
	serviceInstall = false;

	/* 판도라 서비스 프로그램 설치 */
	if (serviceInstall == true && oCookie.get("serviceInstall_2") != "1") {
//	if (serviceInstall == true	) {
		/* 설치 화면 시작 video.kov4.ptv 파일에 함수 있음 */
		try {
			goInstallService.init();
		} catch (e) {
			oCtlJs.endIcf(cntIcf);									// icf 큐피 적립 기존 큐피가 아니고 1원영업자들의 큐피 적립임
			$('flvPlayer').extendICF_Play();					// Hodding되어있던 영상을 Play시킴.
		}
		serviceInstall = false;
	} else {

		$('divPlayer').style.width="606px";
		$('divPlayer').style.height="368px";

		oCtlJs.endIcf(cntIcf);									// icf 큐피 적립 기존 큐피가 아니고 1원영업자들의 큐피 적립임

		if (play == "endSetup" || movieCenterAd == true) {
			$('flvPlayer').extendICF_Play();					// Hodding되어있던 영상을 Play시킴.
		} else $('flvPlayer').extendICF_Play();					// Hodding되어있던 영상을 Play시킴.
	}
}

// Background ICF 지면 가져오기
var run = 0;
var clintAgent = navigator['userAgent'];
function bgicf_call(runtime, country, adInfo, vodInfo, etcInfo) {
	new Ajax.Request("/php/background_icf.php",{
		method : 'post',
		parameters : {'runtime':runtime, 'country':country},
		onSuccess : function(res){
			// 백그라운드 지면 선택
			adInfo['icf'] = [];
			adInfo['icf'].push(res.responseText);

			/**
			firefox에서 스타일링크 변경시 DOM스크립트가 reload되어 플레이어가 초기화 되는 현상이 발생하여
			플레이어에 전달할 정보를 전역변수에 담아두고, 스타일링크변경후 재 전달
			- 플레이어 hidden 시키는 이유 : 플레이어를 2번 호출하는데 처음에 호출 후 스타일변경 전까지 플레이어가 잠깐 재생되는
			  모습을 숨기기위해
			**/
			ads = adInfo;
			vods = vodInfo;
			etcs = etcInfo;
			$('flvPlayer').init_Load_Info(adInfo, vodInfo, etcInfo);
		}.bind(this),
		onException : function(res) {
//			alert("onException");
		}.bind(this),
		onFailure : function(res) {
//			alert("onFailure");
		}.bind(this)
	});
}



// Background ICF 결과값 (flash에서 호출)
function ad_icf_result(type, adsNo) {
	// type = bg면 백그라운드 icf로 ads번호 값으로 생성될 버튼(투명)의 클릭수를 제어한다.
	// icf클릭과 버튼클릭의 빈도수를 따로 체크하지만 동일한 icf건으로 인식하기 위해
	if(clintAgent['indexOf']("Firefox")>-1) $('flvPlayer').style.visibility = "hidden";
	if(type == "bg") loadJS("http://ad.pandora.tv/js.kti/pandoratv/"+adsNo);
}

function bgicf_result(json) {
	/***********************************************************************************************
	ad_icf_result함수가 실행되면 ad서버에 지면을 넘기고 광고코드에서 bgicf_result 함수를 호출
	json.bgcolor : white | black (기본 css타입)
	json.bgcss : 백그라운드 이미지가 적용된 css
	json.btn_url : 백그라운드 icf가 적용되면 링크시킬수 있는 버튼이미지
	json.click_url : 버튼 클릭으로 링크될 경로(애드서버로 링크를 걸어 클릭수 체크 가능)
	***********************************************************************************************/
	if(clintAgent['indexOf']("Firefox")>-1) {
		$('flvPlayer').style.visibility = "visible";

		if(run == 0) {	// 무한 루프방지
			setTimeout(function () {
				try{
					$('flvPlayer').init_Load_Info(ads, vods, etcs);
					run++;
				}catch(e) {bgicf_result(json);}
			}, 300);
		}
	}

	var skinElement = $('skincss');
	if(json.bgcolor != "" && json.bgcolor != "undefinde") skinElement.href = "http://imgcdn.pandora.tv/css/ch/"+json.bgcolor+".css";

	if(json.bgcss != "" && json.bgcss != "undefinde") {
		var linkElm = document.createElement("link");
		linkElm.rel = "stylesheet";
		linkElm.href = json.bgcss;

		document.getElementsByTagName("head")[0].appendChild(linkElm);
	}

	// 버튼 이미지 & 링크
	if(json.btn_url!="" && json.btn_url != "undefinde") {
		$('mAdver').style.display = "none";
		$('bgicfBtn').style.display = "block";
		$('bgicfBtn').innerHTML = "<a href='"+json.click_url+"' target='_blank'><img src='http://imgcdn.pandora.tv/static/blank.gif' BORDER='0' ALT='' align='absmiddle' width='186' height='22'></a>";
	}
}


function start_alimi(){
	if(!oCookie.get('chLiveAlimi') && parseInt(screen.height, 10) > 768){
		loadJsClass.loadJS("http://ad.pandora.tv/js.kti/pandoratv/channel@alimi","euc-kr");
	}
}

function end_alimi(){
	$('ad_alimi_div').style.display="none";
	$('ad_alimi').innerHTML='';clearTimeout(stopSet);
}

function moveEvent() {
	var tp		= document.body.scrollTop || document.documentElement.scrollTop;
	var ht		= document.body.clientHeight || document.documentElement.clientHeight;
	var etop	= tp + ht - 270;
	$('ad_alimi_div').style.top = etop + "px";
	stopSet		= setTimeout("moveEvent()", 150);
}

var tp2=document.body.scrollTop || document.documentElement.scrollTop;
var ht2=document.body.clientHeight || document.documentElement.clientHeight;
var etop2 = 30;

function startEvent(){
	$('ad_alimi_div').style.top = tp2 + ht2 - etop2 + "px";
	etop2=etop2+10;
	if(etop2<=270){
		var startSet=setTimeout("startEvent()", 10);
	}else{
		clearTimeout(startSet);
		moveEvent();
		setTimeout("end_alimi()", 40000);
	}
}

