﻿
/*****************************************************************************************
' @File : /include/js/mnet_common.js
' @Description	 :
' @Author by		 : 박은식
' @Date				 : 2011 - 02 - 09
var url={
		login	:"mnet"
	}
var ML = new mnetLink(url);
http://www.facebook.com/sharer.php?u=http://music.mnet.com/ArtistAlbum/ArtistInfo.asp?ArtistID=54645
' ********************************************************************************************/


var  gcImgUrl		="/images"
var  gcMnetUrl		="http://www.mnet.com"
var	 gcSocialUrl	="http://my.mnet.com"
var  gcCssUrl		="/css"
var  gcCssVer		="27"
var  gcJsUrl		="/include/js"
var  gcFlashUrl		="http://flvfile.mnet.com/service"
var  gcJsVer		="27"
var  gcGnbUrl		=""
var  gcFooterUrl	=""

mnetCommon = function(){
	var	options	= (arguments[0] || this.url);
	$.extend(this.url,options);
	//this.init();
}

mnetCommon.prototype={
	config : {
		loginMsg_Y		: "이미로그인중",
		loginMsg_M		: "로그인후 이용가능 로그인해줘",
		artinfoID_No	: "2407",
		aodplayerId	: "aodPlayerSender"
	},
	url : {
		flash		: "http://flvfile.mnet.com/" ,
		login		: "http://mnet.com/login" ,
		login_popup : "http://www.mnet.com/login_popup",
		aodplayer	: "http://player.mnet.com/aod/aod.asp" ,
		vodplayer	: "http://player.mnet.com/vod/vod.asp",
		vod			: "http://www.mnet.com/tv",
		art			: "http://www.mnet.com/artist",
		album		: "http://www.mnet.com/album",
		song		: "http://www.mnet.com/track",
		lyrics		: "http://www.mnet.com/panel/lyrics",
		Basket		: "http://www.mnet.com/Basket",
		cp_Ring		: "http://www.mnet.com/common/popup/cp/ring.asp",
		cp_Bell		: "http://www.mnet.com/common/popup/cp/bell.asp",
		wantyou		: "http://www.mnet.com/wantyou",
		sns			: "http://www.mnet.com/sns",
		boomup		: "http://www.mnet.com/boomup",
		search		: "http://www.mnet.com/search",
		program		: "http://www.mnet.com/tv/program.asp?program_id"
    },

	init : function (){
		var	songid		= (arguments[0] || "");
		var	listenType	= (arguments[1] || "now");	// now OR add

		if(songid!=""){
			var fnNm="mnetCom.aodPlay"
		}else{
			var fnNm="N"
		}
		$("<div style=\"position: absolute; width: 10px; height: 10px; top:-9999px;left:-9999px;\"><div id=\""+ this.config.aodplayerId+"\"></div></div>").appendTo("body");
		swfobject.embedSWF(gcFlashUrl+'/player/MnetPlayer_AOD_sender.swf?4', this.config.aodplayerId, '1', '1', '10', gcFlashUrl+'/expressinstall.swf', {domain: "*",fn:fnNm,value:songid+"|"+listenType}, {allowscriptaccess: 'always'}, {id: this.config.aodplayerId});
	},

	setiframe : function (){
		var	url		= (arguments[0] || "about:blank");
		$("<iframe src=\" "+url+ "\" name=\"dummy_ifame\" id=\"dummy_ifame\" style=\"position: absolute; width: 10px; height: 10px; top:-9999px;left:-9999px;\"></iframe>").appendTo("body");
	},

	login : function(){
		var	rtnurl		= (arguments[0] || "");
		var	noredirect	= (arguments[1] || "Y");
		if(rtnurl!=""){ rtnurl=Base64.encode(rtnurl) }

		if(mnetCookie.loginchk()){
			alert(this.config.loginMsg_Y);
			return;
		}
		try{
			mnetAuth.login();
		}catch (e){
			void(window.open("http://newmember.mnet.com/loginproc/popLoginProc.asp?noredirect="+noredirect+"&go_ret_url="+rtnurl,"login",'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,resizable=no,width=300,height=250'));
		}
	},
	login_popup : function(){
		var	rtnurl	= (arguments[0] || 1);
		var	rtntype	= (arguments[1] || 1);

		if(mnetCookie.loginchk()){
			alert(this.url.loginMsg_Y());
			return;
		}
		void(window.open(this.url.loginUrl_popup,"",""));
	},

	aodPlay	: function(){
		var	songid		= (arguments[0] || "");
		var	listenType	= (arguments[1] || "now");	// now OR add

		if(songid == ""){
			alert("감상할 곡을 선택해주세요");
		}else{

			if(swfobject.hasFlashPlayerVersion("10")){

				if(swfobject.getObjectById(this.config.aodplayerId)==null){
					this.init(songid,listenType);
				}else{
					if(!this.mplayer(songid, listenType)){
						if(swfobject.getObjectById(this.config.aodplayerId).isPlayer()){
							swfobject.getObjectById(this.config.aodplayerId).trackAdd(listenType+"|"+songid);
						}else{
							window.open(this.url.aodplayer+"?songid="+songid+"&listenType="+listenType,"AodPlayer",'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,resizable=no,width=750,height=504');
						}
						try{swfobject.getObjectById("VODplayer").aodPlay();}catch(e){}
					}
				}
			}else{
			//	alert("Adobe Flash Player");
			//	window.open("http://www.adobe.com/go/getflashplayer","","");
				window.open(this.url.aodplayer+"?songid="+songid+"&listenType="+listenType,"AodPlayer",'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,resizable=no,width=750,height=504');
			}
		}


	},

	aodPlaySelect : function(){

		var	listenType	= (arguments[0] || "now");
		var	objname		= (arguments[1] || "songIdx");
		var songid = this.chkValue(objname);
		this.aodPlay(songid,listenType);
	},
	aodMplayerSelectPlus : function(){

		var	listenType	= (arguments[0] || "now");
		var	songid		= (arguments[1] || "");

		this.mplayer(songid,listenType);
	},
	aodMplayerSelect : function(){
		var	listenType	= (arguments[0] || "now");
		var	objname		= (arguments[1] || "songIdx");

		var songid = this.chkValue(objname);
		this.mplayer(songid,listenType);
	},
	aodMplayerPlay : function(){

		var	songid	= (arguments[0] || "");
		this.mplayer(songid,"now");
	},
	aodPlayAll : function(){
		var objname = (arguments[0] || "songIdx");
		$("input[name=checkAll]").attr("checked",true);
	 	this.chkAll(objname);
		var songid = this.chkValue(objname);
		this.aodPlay(songid,"now");
	},
	aodMplayerAll : function(){
		var objname = (arguments[0] || "songIdx");
		$("input[name=checkAll]").attr("checked",true);
	 	this.chkAll(objname);
		var songid = this.chkValue(objname);
		this.mplayer(songid,"now");
	},
	vodPlay	: function(){
		var	mvid	= (arguments[0] || "");

		if(mvid == ""){
			alert("노래 없음");
		}else{

		var url="/common/json/json_mv.asp?songid="+mvid;
		var data = $.Ajaxload_rtn(url);
			if(data.gb==null){
				alert("영상이 존재 하지 않습니다.")
				return ;
			}
			if(data.gb=="MV"){
				window.location.href=this.url.vod+"/mv/"+data.id;
			}else if(data.gb=="CLIP"){
				window.location.href=this.url.vod+"/vod/"+data.id;
			}
		}
	},
	vodPlayPop	: function(){
		var	mvid	= (arguments[0] || "");

		if(mvid == ""){
			alert("노래 없음");
		}else{

		var url="/common/json/json_mv.asp?songid="+mvid;
		var data = $.Ajaxload_rtn(url);
			if(data.gb==null){
				alert("영상이 존재 하지 않습니다.")
				return ;
			}
			if(data.gb=="MV"){
				window.open(this.url.vod+"/mv/"+data.id,'mv', 'height=800px,width=800px');
			}else if(data.gb=="CLIP"){
				window.open(this.url.vod+"/vod/"+data.id,'mv', 'height=800px,width=800px');
			}
		}
	},
	vodPlayView	: function(){
		var	mvid	= (arguments[0] || "");
		var	vodtype	= (arguments[1] || "");
		var	popYn	= (arguments[2] || "");

		if(vodtype=="MV"){
			var	url=this.url.vod+"/mv/"+mvid;
		}else if(vodtype=="CLIP"){
			var	url=this.url.vod+"/vod/"+mvid;
		}

		if(mvid == ""){
			alert("노래 없음");
		}else{
			if(popYn=="Y"){
				void(window.open(url,"TV",""));

			}else{
				window.location.href=url;
			}
		}
	},

	vodPlayPopup	: function(){
		var	mvid	= (arguments[0] || "");
		var	vodtype	= (arguments[1] || "");
		void(window.open(this.url.vodplayer+"?vodid="+mvid+"&vodtype="+vodtype,"VodPlayer",'scrollbars=no,toolbar=no,location=no,resizable=yes,status=no,menubar=no,width=640,height=387'));
	},


	albumPlay	: function(){
		var	albumid		= (arguments[0] || "");
		var	listenType	= (arguments[1] || "now");	// now OR add
		var url="/common/json/json_album_song.asp?albumid="+albumid;
		var data = $.Ajaxload_rtn(url);

		if(data.id!=null){
			this.aodPlay(data.id,listenType);
		}else{
			alert("앨범에 노래가 존재 하지 않습니다.")
			return ;
		}
	},

	artInfo	: function(){
		var	artid	= (arguments[0] || "");
		if(artid == ""){
			alert("노래 없음");
		}else{
			if(artid != this.config.artinfoID_No){
				window.location.href=this.url.art+"="+songid;
			}else{
				alert("정보가 없는 아티스트");
			}
		}
	},
	albumInfo : function(){
		var	albumid	= (arguments[0] || "");
		if(albumid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.album+"="+songid;
		}
	},
	songInfo : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.song+"="+songid;
		}
	},
	programInfo : function(){
		var	programid	= (arguments[0] || "");
		if(programid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.program+"="+programid;
		}
	},
	mp3Down : function(){
		var	songid	= (arguments[0] || "");
		if (songid==""){
			alert("다운로드할 곡을 선택해주세요");
			return;
		}
		if(this.browser()=="msie"){
			LF_QM_DownLoad(songid);
		}else{
			alert("해당 브라우저에서는 퀵매니저의 즉시 실행이 지원되지 않습니다.\n IE를 이용해주세요");
		/*	if(confirm("해당 브라우저에서는 퀵매니저 (OR 엠플레이어)의  즉시 실행이 지원되지 않습니다. \n 퀵매니저 (엠플레이어)를 다운로드 하시겠습니까?")){
				window.location.href="http://www.mnet.com/mnet/guide/manager/guide_manager.asp";
			}
		*/

		}

	},
	mp3AlbumDown : function(){
		var	albumid		= (arguments[0] || "");
		var url="/common/json/json_album_song.asp?albumid="+albumid;
		var data = $.Ajaxload_rtn(url);

		if(data.id!=null){
			this.mp3Down(data.id);
		}else{
			alert("앨범에 노래가 존재 하지 않습니다.")
			return ;
		}

	},
	mp3Select : function(){
		var objname = (arguments[0] || "songIdx");
		var songid = this.chkValue(objname);
		this.mp3Down(songid);
	},
	mp3All : function(){
		var objname = (arguments[0] || "songIdx");
		this.chkAll(objname);
		var songid = this.chkValue(objname);
		this.mp3Down(songid);
	},
	lyrics_popup : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			void(window.open(this.url.lyrics+"/lyrics_view.asp?SongID="+songid,"lyrics_view",'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,resizable=no,width=494,height=600'));
		}
	},
	lyricsAdd_popup : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			void(window.open(this.url.lyrics+"/lyrics_write.asp?SongID="+songid,"lyrics_write",'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,resizable=no,width=494,height=312'));
		}
	},
	lyricsError_popup : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			void(window.open(this.url.lyrics+"/lyrics_error.asp?SongID="+songid,"lyrics_error",'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,resizable=no,width=500,height=420'));
		}
	},
	songBasket : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.Basket+"="+songid;
		}
	},
	songBasketSelect : function(){
		var objname = (arguments[0] || "songIdx");
		var obj = (arguments[1] || "");
		var songid = this.chkValue(objname);
		if(songid == ""){
			alert("마이앨범에 담을 곡을 선택해주세요");
		}else{
	        myalbum.addSongSelect(songid,obj);
		}
	},
	songBasketAll : function(){
		var objname = (arguments[0] || "songIdx");
		this.chkAll(objname);
		var songid = this.chkValue(objname);
		if(songid == ""){
			alert("노래 없음");
		}else{
			this.songBasket(songid);
		}
	},
	vodBasket : function(){
		var	vodid	= (arguments[0] || "");
		if(vodid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.lyrics+"="+vodid;
		}
	},
	vodBasketSelect : function(){
		var objname = (arguments[0] || "songIdx");
		var vodid = this.chkValue(objname);
		if(vodid == ""){
			alert("노래 없음");
		}else{
			this.vodBasket(vodid);
		}
	},
	vodBasketAll : function(){
		var objname = (arguments[0] || "songIdx");
		this.chkAll(objname);
		var vodid = this.chkValue(objname);
		if(vodid == ""){
			alert("노래 없음");
		}else{
			this.vodBasket(vodid);
		}
	},
	albumBasket : function(){
		var	albumid	= (arguments[0] || "");
		if(albumid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.lyrics+"="+albumid;
		}
	},
	albumBasketSelect : function(){
		var objname = (arguments[0] || "songIdx");
		var albumid = this.chkAll(objname);
		if(albumid == ""){
			alert("노래 없음");
		}else{
			albumBasket(albumid);
		}
	},
	albumBasketAll : function(){
		var objname = (arguments[0] || "songIdx");
		this.chkAll(objname);
		var albumid = this.chkValue(objname);
		if(albumid == ""){
			alert("노래 없음");
		}else{
			albumBasket(albumid);
		}
	},
	cpRing : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			openPopup(this.url.cp_Ring+"?songid="+songid,'Ring','490','450','100','100','0');
		}
	},
	cpBell : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			openPopup(this.url.cp_Bell+"?songid="+songid,'Ring','520','400','100','100','0');
		}
	},
	cpBellLyaer : function(){
		var	obj		= arguments[0] ;
		var	mType	= (arguments[1] || "none");

		var $obj	  = $(obj).parents("td.down");
		var $selectobj = $obj.find(".over_phone");

		if (mType == "none"){
			$selectobj.hide();
		}else{
			$selectobj.show();
		}
	},
	cpBellLyaerV2 : function(){
		var	obj		= arguments[0] ;
		var	mType	= (arguments[1] || "none");

		var $obj	  = $(obj).parents("td.top100_down");
		var $selectobj = $obj.find(".over_phone");

		if (mType == "none"){
			$selectobj.hide();
		}else{
			$selectobj.show();
		}
	},
	artistLyaer : function(){
		var	obj		= arguments[0] ;
		var	mType	= (arguments[1] || "none");

		var $obj	  = $(obj).parents("td .artist");
		var $selectobj = $obj.find(".over_1");

		if (mType == "none"){
			$selectobj.hide();
		}else{
			$selectobj.show();
		}
	},
	sonAddLyaer : function(){
		var	obj		= arguments[0] ;
		var	mType	= (arguments[1] || "none");

		var $obj	  = $(obj).parents("td.info");
		var $selectobj = $obj.find(".btn_over");

		if (mType == "none"){
			$selectobj.hide();
		}else{
			$selectobj.show();
		}
	},
	wantyou : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.wantyou+"="+songid;
		}
	},
	sns : function(){
		var	songid	= (arguments[0] || "");
		if(songid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.sns+"="+songid;
		}
	},
	boomUp : function(){
		var	albumid	= (arguments[0] || "");
		if(albumid == ""){
			alert("노래 없음");
		}else{
			window.location.href=this.url.boomup+"="+albumid;
		}
	},
	search : function(){
		var word = (arguments[0] || "");
		if(word == ""){
			alert("검색어 넣어주세요..");
			return;
		}
		document.location.href=this.url.search+"?searchword="+encodeURIComponent(word);
	},

	chkAll : function(){
		var objname = (arguments[0] || "songIdx");
		var obj	    = (arguments[1] || "");

		if(obj==""){
			var c=	$("input[name=checkAll]").attr("checked");
			$("input[name="+objname+"]").attr("checked",c);
		}else{
			var c=	$(obj).attr("checked");
			$("input[name="+objname+"]").attr("checked",c);
		}

	},
	chkValue : function(){
		var objname = (arguments[0] || "songIdx");
		var separator  = (arguments[1] || ",");
		var idlist = [];
		var itemstr ="";

		$("input[name="+objname+"]:checked").each(function(){idlist.push(this.value)});
		$.each(idlist,function(index, item){
			itemstr += item ;
			if(index < idlist.length-1){
				itemstr += separator;
			}
		});

		return itemstr;
	},



	report_pop   : function(){
		var content_gb = arguments[0]; // 곡=sn , 뮤비=mv, 영상=cl
		var content_id = arguments[1];
		openPopup('http://www.mnet.com/common/popup/report/report_pop.asp?content_gb='+content_gb+'&content_id='+content_id,'reportPop','490','500','100','100','0');

	},
	report_layer : function(){
		if(!mnetCookie.loginchk()){
			mnetAuth.login();
			return;
		}
		var $layer = $("#report_layer");
		$(":radio[name='report_category']:checked").attr("checked",false);
		$("#report_ready").show();
		$("#report_desc").val("");
		$("#report_finish").hide();
		var content_gb = arguments[0];
		var content_id = arguments[1];
		var content_title = arguments[2];
		$layer.lightbox_me({
			overlaySpeed : 0,
			overlayDisappearSpeed:0,
			lightboxSpeed: 0,
			centered: true,
			onLoad: function() {
				$("#report_content_gb").val(content_gb);
				$("#report_content_id").val(content_id);
				$("#report_layer_title").html(content_title);
				$layer.css("width",500);
			}
		});

		$(".btn.lay_close,.btn.btn_lay_comfirm,.btn.btn_lay_cancel").click(function(){
			$layer.trigger("close");
		});
	},
	reportSend : function(){
		if($(":radio[name='report_category']:checked").size()==0){
			alert('사유를 선택해주세요');
			return;
		}
		var content_gb = $("#report_content_gb").val();
		var content_id = $("#report_content_id").val();
		var category = $(":radio[name='report_category']:checked").val();
		var report_desc = $("#report_desc").val();
		$.ajax({
			url : "/common/popup/report/report_save.asp",
			type: "post",
			data : {
				content_gb	: content_gb,
				content_id : content_id,
				category	: category,
				report_desc	: report_desc
			},
			success : function(data){
				$("#report_ready").hide();
				$("#report_finish").show();

			}
		});
	},

	carlendar : function (){

		var dateFlag	 = (arguments[0] || ""); // 달력모드 0일간 1주간 2월간
		var selectDay	 = (arguments[1] || ""); // 현재 선택된 날짜. 주간일경우 시작일
		var startDay	 = (arguments[2] || ""); // 데이타 시작
		var lastDay		 = (arguments[3] || ""); // 데이타 끝
		var setWeekDay	 = (arguments[4] || "6");// 주간일경우 해당되고. 0일요일 6월요일 5화요일 4수요일 순으로 시작일을 정할수 있다.
		var clickableDay= (arguments[5] || "N");

		var y		=	selectDay.substr(0,4)
		var m		=	selectDay.substr(4,2)
		var d		=	selectDay.substr(6,2)

		if(dateFlag=='D' || dateFlag=='W'){
			sDay=y+"|"+m+"|"+d;
		}else if(dateFlag=='M'){
			sDay=y+"|"+m+"|01";
		}else if(dateFlag=='Y'){
			sDay=y+"|01|01";
		}

		var symd	=	startDay.substr(0,4)+"|"+startDay.substr(4,2)+"|"+startDay.substr(6,2)
		var eymd	=	lastDay.substr(0,4)+"|"+lastDay.substr(4,2)+"|"+lastDay.substr(6,2)

		var obj={
			domain: "*"
			,calMode:dateFlag		 // 달력모드 0일간 1주간 2월간
			,startDay:symd			 // 데이타 시작
			,lastDay:eymd			 // 데이타 끝
			,selectDay:sDay			// 현재 선택된 날짜. 주간일경우 시작일
			,setWeekDay:setWeekDay // 주간일경우 해당되고. 0일요일 6월요일 5화요일 4수요일 순으로 시작일을 정할수 있다.
			,clickableDay:clickableDay//클릭가능한날짜를json형식으로 반환해주는 페이지URL(full url)
		}
		swfobject.embedSWF(gcFlashUrl+'/music/calendar.swf?5', 'calendarType', '261', '193', '10.2', gcFlashUrl+'/expressinstall.swf', obj, {allowscriptaccess: 'always',wmode:'opaque'}, {id: 'calendarType'});
	},
	browser : function (){
		var userAgent = navigator.userAgent.toLowerCase();
		var fnAgentType = "etc";
		if (userAgent.indexOf("msie")>-1 ) {// safari, iPhond , iPod
			fnAgentType = "msie";
		}else if (userAgent.indexOf("opera")>-1 ){
			fnAgentType = "opera";
		}else if (userAgent.indexOf("chrome")>-1 ){
			fnAgentType = "chrome";
		}else if (userAgent.indexOf("mozilla")>-1 ){
			fnAgentType = "mozilla";
		}else if (userAgent.indexOf("safari")>-1 ){
			fnAgentType = "safari";
		}
		return fnAgentType
	},
	mplayer : function (){

	   var songid	 = (arguments[0] || "");
	   var listenType = (arguments[1] || "now");

	   if(songid==""){return false;}
	   if(listenType!="now"){
		    listenType ='add';
	   }


	 //	2.0 버젼
	   var jsonSongList=""
	   var arrsong	= songid.split(',');

		for(var i=0;i <arrsong.length;i++){
			jsonSongList +="{\"songid\":"+arrsong[i]+"}"
			if(i<arrsong.length-1){jsonSongList +=","}
		}
	   jsonSongList = "{\"listenType\": \"" + listenType + "\",\"list\":["+jsonSongList+"]}";

		$("<div><object id='plugin' width='0' height='0' type='application/x-mplayer-plugin'></object></div>").appendTo("body");
		var obj = document.getElementById("plugin");

		if(obj) {
			obj.SessionID = mnetCookie.getCookie("SessionID"); 	// 회원 SessionID.
			try {
				// Mplayer가 설치되어 있고,
				// 웹사이트에서 음악감상시 Mplayer로 듣기가 설정되어 있다면
				// Mplayer를 띄우자!
				if(!obj.IsMplayerPlay()) {
				 //   alert("[ERROR] Mplayer가 설치되어 있지 않습니다.");
					return false;
				}else {
					// Mplayer로 선택한 곡 목록 보내기.
					obj.SendSongList(jsonSongList);
					return true;
				}
			}
			catch(e) {
				return false;
				//alert(e.description);
			}
		}else{
			return false;
		}

	}

}

var mnetCom = new mnetCommon();
$(document).ready(function(){mnetCom.init();});

function M_AOD_noRunPlayer(){
	alert("플레이어가 실행중이지 않습니다.");
}


/*
	console wrapper
*/
if (!window.console) {
    window.console = {
        log: function(obj){
			//do nothing
		},
		debug : function(obj){
			//do nothing
		}
    };
}

function clearbg(id){
	document.getElementById(id).style.backgroundImage='none';
}
function hover_layer(n) {
 $("."+n).toggle();
}


var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}
