var console = window.console || {log:function(){}};

//카카오톡 보내기
function executeURLLink(a,b,c,d)
{
    kakao.link("talk").send({
        msg : a,
        url : b,
        appid : c,
        appver : "2.0",
        appname : d,
        type : "link"
    });

}

//카카오스토리 보내기
function executeKakaoStoryLink(a,b,c,d,e,f,g)
{
kakao.link("story").send({
post : b,
appid : c,
appver : "1.0",
appname : d,
urlinfo : JSON.stringify({title:a, desc:e, imageurl:[f], type:g})
});
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
      var popup =  window.open(theURL,winName,features);
 popup.focus();
}


function reader_checkForm(){

	formObj = document.rc;

     if (formObj.reader_name.value == '')   

     {
            alert('이름을 입력해 주십시오 ');
            formObj.reader_name.focus();  
            return false;
	 }
     else if(formObj.reader_title.value == '')     
    {
           alert(' 제목을 입력해 주십시오');
           formObj.reader_title.focus();  
               return false;
    }
	else if(formObj.reader_passwd.value == '')     
    {
            alert(' 패스워드를 입력해 주십시오');
           formObj.reader_passwd.focus();  
               return false;
	}
	else if(formObj.reader_body.value == '')     
    {
            alert(' 내용을 입력해 주십시오');
            formObj.reader_body.focus();  
               return false;
	}
	else if(formObj.nospam.value == '')     
    {
            alert(' 스팸검사에 옆의 숫자를 입력해 주십시오');
           formObj.nospam.focus();  
               return false;
	}


	var parameters="d_mode=input&newsuid="+formObj.newsuid.value+"&reader_title=" + encodeURI(formObj.reader_title.value);
		parameters +="&reader_name="+ encodeURI(formObj.reader_name.value);
		parameters +="&reader_passwd="+ encodeURI(formObj.reader_passwd.value);
		parameters +="&reader_body="+ encodeURI(formObj.reader_body.value);
		parameters +="&nospam="+ encodeURI(formObj.nospam.value);
		parameters +="&u_id="+ encodeURI(formObj.d_id.value);

	$.ajax({
		type: "POST",
		url: "./newnews/ins_reader_add_exe.php",
		data: parameters,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				if(data=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(data=="뉴스 번호가 없습니다.")
				{
					alert('뉴스 번호가 없습니다.');
				}
				else
				{
					$('#reader_t').html(data);
					alert('등록되었습니다.');	
				}
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});

	formObj.reader_title.value="";
	formObj.reader_name.value="";
	formObj.reader_passwd.value="";
	formObj.reader_body.value="";
	formObj.nospam.value="";

	return false;
}




function reader_checkForm_sign(){

	formObj = document.rc;

     if (formObj.reader_name.value == '')   

     {
            alert('이름을 입력해 주십시오 ');
            formObj.reader_name.focus();  
            return false;
	 }
     else if(formObj.reader_title.value == '')     
    {
           alert(' 제목을 입력해 주십시오');
           formObj.reader_title.focus();  
               return false;
    }
	else if(formObj.reader_passwd.value == '')     
    {
            alert(' 패스워드를 입력해 주십시오');
           formObj.reader_passwd.focus();  
               return false;
	}
	else if(formObj.reader_body.value == '')     
    {
            alert(' 내용을 입력해 주십시오');
            formObj.reader_body.focus();  
               return false;
	}
	else if(formObj.nospam.value == '')     
    {
            alert(' 스팸검사에 옆의 숫자를 입력해 주십시오');
           formObj.nospam.focus();  
               return false;
	}

	if(!confirm('정당후보자에 대한 지지 또는 반대의 글을 실명인증을 해야 합니다.\r\n 확인을 누르시면 등록이 됨니다.'))
	{
                 return false;
	}

	var parameters="d_mode=input&newsuid="+formObj.newsuid.value+"&reader_title=" + encodeURI(formObj.reader_title.value);
		parameters +="&reader_name="+ encodeURI(formObj.reader_name.value);
		parameters +="&reader_passwd="+ encodeURI(formObj.reader_passwd.value);
		parameters +="&reader_body="+ encodeURI(formObj.reader_body.value);
		parameters +="&nospam="+ encodeURI(formObj.nospam.value);
		parameters +="&u_id="+ encodeURI(formObj.d_id.value);
		parameters +="&se_id="+ encodeURI(formObj.se_id.value);

	$.ajax({
		type: "POST",
		url: "./newnews/ins_reader_add_exe.php",
		data: parameters,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				if(data=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(data=="뉴스 번호가 없습니다.")
				{
					alert('뉴스 번호가 없습니다.');
				}
				else
				{
					$('#reader_t').html(data);
					alert('등록되었습니다.');	
				}
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});

	formObj.reader_title.value="";
	formObj.reader_name.value="";
	formObj.reader_passwd.value="";
	formObj.reader_body.value="";
	formObj.nospam.value="";

	return false;
}

function reader_checkForm_sign2(se_id){

	formObj = document.rc;

	var  parameters ="&se_id="+ encodeURI(formObj.se_id.value);

	$.ajax({
		type: "POST",
		url: "./newnews/ins_check_sign.php",
		data: parameters,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				if(data==1)
				{
					document.rc.name_check.value=1; 
				}
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});


     if (formObj.reader_name.value == '')   

     {
            alert('이름을 입력해 주십시오 ');
            formObj.reader_name.focus();  
            return false;
	 }
	else  if (formObj.name_check.value == '')   

     {
            alert('실명 인증을 해 주십시오 ');
            
            return false;
	 }
	 
     else if(formObj.reader_title.value == '')     
    {
           alert(' 제목을 입력해 주십시오');
           formObj.reader_title.focus();  
               return false;
    }
	else if(formObj.reader_passwd.value == '')     
    {
            alert(' 패스워드를 입력해 주십시오');
           formObj.reader_passwd.focus();  
               return false;
	}
	else if(formObj.reader_body.value == '')     
    {
            alert(' 내용을 입력해 주십시오');
            formObj.reader_body.focus();  
               return false;
	}
	else if(formObj.nospam.value == '')     
    {
            alert(' 스팸검사에 옆의 숫자를 입력해 주십시오');
           formObj.nospam.focus();  
               return false;
	}
   if(!confirm('정당후보자에 대한 지지 또는 반대의 글을 실명인증을 해야 합니다.\r\n 확인을 누르시면 등록이 됨니다.'))
	{
                 return false;
	}

	var parameters="d_mode=input&newsuid="+formObj.newsuid.value+"&reader_title=" + encodeURI(formObj.reader_title.value);
		parameters +="&reader_name="+ encodeURI(formObj.reader_name.value);
		parameters +="&reader_passwd="+ encodeURI(formObj.reader_passwd.value);
		parameters +="&reader_body="+ encodeURI(formObj.reader_body.value);
		parameters +="&nospam="+ encodeURI(formObj.nospam.value);
		parameters +="&u_id="+ encodeURI(formObj.d_id.value);
		parameters +="&se_id="+ encodeURI(formObj.se_id.value);

	$.ajax({
		type: "POST",
		url: "./newnews/ins_reader_add_exe.php",
		data: parameters,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				if(data=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(data=="뉴스 번호가 없습니다.")
				{
					alert('뉴스 번호가 없습니다.');
				}
				else
				{
					$('#reader_t').html(data);
					alert('등록되었습니다.');	
				}
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});

	formObj.reader_title.value="";
	formObj.reader_name.value="";
	formObj.reader_passwd.value="";
	formObj.reader_body.value="";
	formObj.nospam.value="";

	return false;
}


function reader_checkForm_body(){

	formObj = document.rc;

     if (formObj.reader_name.value == '')   

     {
            alert('이름을 입력해 주십시오 ');
            formObj.reader_name.focus();  
            return false;
	 }
    
	else if(formObj.reader_passwd.value == '')     
    {
            alert(' 패스워드를 입력해 주십시오');
           formObj.reader_passwd.focus();  
               return false;
	}
	else if(formObj.reader_body.value == '')     
    {
            alert(' 내용을 입력해 주십시오');
            formObj.reader_body.focus();  
               return false;
	}
	else if(formObj.nospam.value == '')     
    {
            alert(' 스팸검사에 옆의 숫자를 입력해 주십시오');
           formObj.nospam.focus();  
               return false;
	}
	
	var parameters="d_mode=input&newsuid="+formObj.newsuid.value;
		parameters +="&reader_name="+ encodeURI(formObj.reader_name.value);
		parameters +="&reader_passwd="+ encodeURI(formObj.reader_passwd.value);
		parameters +="&reader_body="+ encodeURI(formObj.reader_body.value);
		parameters +="&nospam="+ encodeURI(formObj.nospam.value);
		parameters +="&u_id="+ encodeURI(formObj.d_id.value);

	$.ajax({
		type: "POST",
		url: "./newnews/ins_reader_add_exe.php",
		data: parameters,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				if(data=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(data=="뉴스 번호가 없습니다.")
				{
					alert('뉴스 번호가 없습니다.');
				}
				else
				{
					$('#reader_t').html(data);
					alert('등록되었습니다.');	
				}
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});

	formObj.reader_name.value="";
	formObj.reader_passwd.value="";
	formObj.reader_body.value="";
	formObj.nospam.value="";

	return false;
}


function r_c()
{
   if (ajax.request.readyState == 4)
		 {
         
			if (ajax.request.status == 200)
			{
				result = ajax.request.responseText;
				if(result=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(result=="뉴스 번호가 없습니다.")
				{
					alert('뉴스 번호가 없습니다.');
				}
				else
				{
					document.getElementById('reader_t').innerHTML = result;
					alert('등록되었습니다.');	
				}
				
				           
			}
			else
			{
				alert('입력 에러');
			}
		}

}

function r_c2()
{
   if (ajax.request.readyState == 4)
		 {
         
			if (ajax.request.status == 200)
			{
				result = ajax.request.responseText;
				
				if(result==1)
				{
						document.rc.name_check.value=1; 
				}
							
				
				           
			}
			else
			{
				alert('입력 에러');
			}
		}

}



function bbsetc_checkForm(){

	   bbs_etcform = document.b_etc_ok;

	   if (bbs_etcform.bbs_name.value == '') {
			alert('이름을 입력해 주십시오 ');
			bbs_etcform.bbs_name.focus();
			return false;
		} else if (bbs_etcform.etc_passwd.value == '') {
			alert(' 패스워드를 입력해 주십시오');
			bbs_etcform.etc_passwd.focus();  
			return false;
		} else if (bbs_etcform.bbs_memo.value == '') {
			alert(' 내용을 입력해 주십시오');
			bbs_etcform.bbs_memo.focus();  
			return false;
		} else if (bbs_etcform.nospam.value == '') {
			alert(' 도배 방지를 위한 옆의 숫자를 입력해 주십시오');
			bbs_etcform.nospam.focus();  
			return false;
		}


	var parameters="d_mode=input&bbs_uid="+bbs_etcform.bbs_uid.value;
		parameters +="&bbs_name="+ encodeURI(bbs_etcform.bbs_name.value);
		parameters +="&etc_passwd="+ encodeURI(bbs_etcform.etc_passwd.value);
		parameters +="&bbs_memo="+ encodeURI(bbs_etcform.bbs_memo.value);
		parameters +="&nospam="+ encodeURI(bbs_etcform.nospam.value);
		parameters +="&Table="+ encodeURI(bbs_etcform.Table.value);

	$.ajax({
		type: "POST",
		url: "./bbs/ins_bbs_etc_add_exe.php",
		data: parameters,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				if(data=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(data=="번호가 없습니다.")
				{
					alert('번호가 없습니다.');
				}
				else
				{
					$('#bbs_etc_b').html(data);
				}
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});

	bbs_etcform.bbs_name.value="";
	bbs_etcform.etc_passwd.value="";
	bbs_etcform.bbs_memo.value="";
	bbs_etcform.nospam.value="";

	return false;
}




function bbs_r_c()
{
   if (ajax.request.readyState == 4)
		 {
         
			if (ajax.request.status == 200)
			{
				result = ajax.request.responseText;

				if(result=="스팸검사를 정확히 입력해 주십시오.")
				{
					alert('스팸검사를 정확히 입력해 주십시오');
				}
				else if(result=="번호가 없습니다.")
				{
					alert('번호가 없습니다.');
				}
				else
				{
					document.getElementById('bbs_etc_b').innerHTML = result;
					//alert('등록되었습니다.');	
				}
				
				           
			}
			else
			{
				alert('입력 에러');
			}
		}

}


function reader_point_add(r_uid)
{

	var fdata = "d_mode=point&r_uid="+r_uid;

	$.ajax({
		type: "GET",
		url: "/newnews/ins_reader_add_exe.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				var r_v = data.split(':');
				$('#u_p_s_'+r_v[0]).html(r_v[1]);
				alert('추천되었습니다.');	
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}
	});

	// return false;
}

function r_ok()
{

      if (ajax.request.readyState == 4)
		 {
         
			if (ajax.request.status == 200)
			{
				result = ajax.request.responseText;
				var r_v = result.split(':');
                 
				 document.getElementById('u_p_s_'+r_v[0]).innerHTML = r_v[1]; 
				alert('추천되었습니다.');	
				
				
				           
			}
			else
			{
				alert('입력 에러');
			}
		}

}


function ins_main_create()
{

	alert('aaa');

}




function vod_main_view(v_uid)
{
	var fdata = "d_mode=get&v_uid="+v_uid;

	$.ajax({
		type: "GET",
		url: "/newnews/ins_news_vod_main_view.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				$('#ins_vod_main').html(data);
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});
}



function vod_main_view_sub(v_uid)
{
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = (agent.indexOf('iphone')!=-1);
	var is_andriod = (agent.indexOf('mobile')!=-1);
	if(is_iphone)
	{
		os_type="iphone";
	}
	else if(is_andriod)
	{
		os_type="android";
	}
	else
	{
		os_type="pc";
	}

	var fdata = "d_mode=get&v_uid="+v_uid+"&os_type="+os_type;

	$.ajax({
		type: "GET",
		url: "/newnews/ins_news_vod_main_view_sub.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				$('#ins_vod_main').html(data);
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});
}



function reader_view_main()
{
	var fdata = "";

	$.ajax({
		type: "GET",
		url: "/newnews/ins_reader_view_main.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				$('#ins_vod_main').html(data);
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});
}



function vod_main_view_imtv(v_uid)
{
	var fdata = "d_mode=get&v_uid="+v_uid;

	$.ajax({
		type: "GET",
		url: "/newnews/ins_news_vod_main_view_imtv.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				$('#ins_vod_main').html(data);
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});
}

function vod_ok()
{

      if (ajax.request.readyState == 4)
		 {
         
			if (ajax.request.status == 200)
			{
				result = ajax.request.responseText;
			  
			    document.getElementById('ins_vod_main').innerHTML = result; 
				
				
				           
			}
			else
			{
				alert('입력 에러');
			}
		}

}


function vod_main_view_skin9(v_uid)
{
	var fdata = "d_mode=get&v_uid="+v_uid;

	$.ajax({
		type: "GET",
		url: "/newnews/ins_news_vod_main_view_skin9.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				$('#ins_vod_main').html(data);
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}  
	});
}



function vod_main_view_skin_sbctv_net(v_uid)
{
	var fdata = "d_mode=get&v_uid="+v_uid;

	$.ajax({
		type: "GET",
		url: "/newnews/ins_news_vod_main_view_sbctv_net.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data) {
				$('#ins_vod_main').html(data);
			}
		},
		error:function(e){  
			console.log(e.responseText);
		}
	});
}

/// 기사본문글자크기 조정
var font_a=14;
function fontsizeasc() {
	font_a=font_a+2;
	document.all.textinput.style.fontSize=font_a;
}
function fontsizedesc() {
	font_a=font_a-2;
	document.all.textinput.style.fontSize=font_a;
}


//무단복사 방지 마우스 드래드 금지
function mou()
{
//<![CDATA[
(function(){
 var cancel=function(e){
  if (window.event) {
   window.event.cancelBubble = true;
   window.event.returnValue = false;
  }
  if (e && e.stopPropagation && e.preventDefault) {
   e.stopPropagation();
   e.preventDefault();
  }
  return false;
 };
 var block=function(e){
  e = e || window.event;
  var t=e.srcElement || e.target;
  var tag=t.tagName;
  if (e && tag==='HTML' || tag==='INPUT' || tag==='TEXTAREA' || tag==='BUTTON' || tag==='SELECT' || tag==='OPTION' || tag==='EMBED' || tag==='OBJECT') { return; }
  if (e.type==='keydown' || e.type=='keyup') {
   // keyboard event : only block ctrl-A, ctrl-a, ctrl-C, ctrl-c, meta-A, meta-a, meta-C, meta-c
   if ((e.ctrlKey || e.metaKey) && (e.keyCode == 65 || e.keyCode == 97 || e.keyCode == 67 || e.keyCode == 99)) { return cancel(e); }
  } else if(e.type == "contextmenu"){
   //alert('무단복사를 막기 위해 마우스 드래그 금지가 설정되어 있습니다');
   return cancel(e);
  } else {
   return cancel(e);
  }
 }
 var addEvent = function(el, type, fn){
     if (window.addEventListener) {
         el.addEventListener(type, fn, false);
     }
     else if (window.attachEvent) {
         el.attachEvent('on' + type, fn);
     }
     else {
         el['on' + type] = fn;
     }
 }
 var addBlockEvent = function(){
  addEvent(document.body,'keydown',block);
  addEvent(document.body,'keyup',block);
  addEvent(document.body,'mouseup',block);
  addEvent(document.body,'mousedown',block);
  addEvent(document.body,'dragstart',block);
  addEvent(document.body,'selectstart',block);
  addEvent(document.body,'copy',block);
  addEvent(document.body,'contextmenu', block);
 }
 addEvent(window,'load',addBlockEvent);
})();
//]]>
}

//날개배너 스크롤-s
function layerPosition(direction,time,tmp){
	var blayer_R, blayer_L, D;
	window["blayer_" + direction] = document.getElementById("Scroll_" + direction);
	if(window["blayer_" + direction]) {
	window["blayer_" + direction].style.top = document.body.scrollTop + tmp;
	D = "layerPosition('"+direction+"',"+time+","+tmp+")";
	setTimeout(D,time);
	}
}

var min = 0;      // 레이어 top 초기 값 (레이어 top 값과 일치시킴)
var max = 0;
var moving_speed = 40  // 속도(낮을 수록 빠름)
var moving_amount = 10  // 움직임 (낮을 수록 부드러움)
var itm_R, itm_L, max_R, max_L, itm_R_2, itm_L_2, max_R_2, max_L_2;
var F = '';
function layerPosition2(direction,time,tmp){
	var scroll_R, scroll_L, scroll_R_2, scroll_L_2, F;
		if(!time) {
			var action_time = 500;   // 반응시간 (*/1000 초 후에 반응)
		} else {
			var action_time = time;   // 반응시간 (*/1000 초 후에 반응)
		}
	window["scroll_" + direction] = document.getElementById("Scroll_" + direction);

	if(window["scroll_" + direction]) {
		F = "move_init('"+direction+"')";
		setTimeout(F, action_time);
	}
}

function move_init(t) {
	if(t=='L_2' || t=='R_2') {
		min = 610;
	}	
	window["itm_" + t] = document.getElementById('Scroll_'+t);
	window["itm_" + t].set_pos = function(y){window["itm_" + t].style.top=y;};
	window["itm_" + t].y = min;
	window["itm_" + t].set_pos(window["itm_" + t].y);
	//window["max_" + t] = document.body.scrollHeight /2;
	window["max_" + t] = document.body.scrollHeight - window["itm_" + t].scrollHeight - 200;
	F = "move_func('"+t+"')";
	setTimeout(F, moving_amount);
}
		  
function move_func(t) {
	if(t=='L_2' || t=='R_2') {
		tmp = document.body.scrollTop + min - 600;
	} else {
		tmp = document.body.scrollTop + min - 150;
	}
	window["itm_" + t].y += Math.floor((tmp-window["itm_" + t].y)/moving_speed);
	if( window["itm_" + t].y>window["max_" + t] ) window["itm_" + t].y = window["max_" + t];
	if( window["itm_" + t].y<min ) window["itm_" + t].y = min;
	window["itm_" + t].set_pos(window["itm_" + t].y);
	F = "move_func('"+t+"')";
	setTimeout(F, moving_amount);
}


function layerPosition3(){
	$(window).scroll(function() {
	
		if(!($('#Scroll_L').length || $('#Scroll_R').length)) return false;
		
		var floatBannerLeft = $('#Scroll_L'),
			floatBannerRight = $('#Scroll_R'),
			
			HeadHeight = $('#header').height(),
			footerBoxTop = $('#footer').offset().top,
			footerBoxHeight = $('#footer').height(),

			scrollTop = $(window).scrollTop(),

			flBnLHeight = floatBannerLeft.height(),
			flBnRHeight = floatBannerRight.height(),

			ahtHeight = $('.aht-wrapper').height(),

			flBnLscrollLimit = footerBoxTop - flBnLHeight - footerBoxHeight - floatBannerLeft.data('down-margin'),
			flBnLscrollLimitChk = flBnLscrollLimit + footerBoxHeight + floatBannerLeft.data('down-margin'),
			flBnRscrollLimit = footerBoxTop - flBnRHeight - HeadHeight - floatBannerRight.data('down-margin'),
			flBnRscrollLimitChk = flBnRscrollLimit + footerBoxHeight + floatBannerRight.data('down-margin'),

			flBnLscrollTop = scrollTop - HeadHeight + ahtHeight + floatBannerLeft.data('top-margin'),
			flBnRscrollTop = scrollTop - HeadHeight + ahtHeight + floatBannerRight.data('top-margin');
			
			console.log("HeadHeight: "+HeadHeight+" footerBoxTop: "+footerBoxTop+" footerBoxHeight: "+footerBoxHeight+" flBnLscrollLimit: "+flBnLscrollLimit+" flBnLscrollLimitChk: "+flBnLscrollLimitChk);

		if(floatBannerLeft.data('scroll') == 'y'){
			if(floatBannerLeft.data('duration') > 0) floatBannerLeft.stop();
			if(scrollTop < HeadHeight) floatBannerLeft.animate({top: '0px'}, floatBannerLeft.data('duration'), 'linear');
			else if(scrollTop >= flBnLscrollLimitChk) floatBannerLeft.animate({top:flBnLscrollLimit + 'px'}, floatBannerLeft.data('duration'), 'linear');
			else if(scrollTop >= HeadHeight) floatBannerLeft.animate({top:flBnLscrollTop + 'px'}, floatBannerLeft.data('duration'), 'linear');
		}

		if(floatBannerRight.data('scroll') == 'y'){
			if(floatBannerRight.data('duration') > 0) floatBannerRight.stop();
			if(scrollTop < HeadHeight) floatBannerRight.animate({top: '0px'}, floatBannerRight.data('duration'), 'linear');
			else if(scrollTop >= flBnRscrollLimitChk) floatBannerRight.animate({top:flBnRscrollLimit + 'px'}, floatBannerRight.data('duration'), 'linear');
			else if(scrollTop >= HeadHeight) floatBannerRight.animate({top:flBnRscrollTop + 'px'}, floatBannerRight.data('duration'), 'linear');
		}
	});
}


//window.onload = function(){
    if(typeof jQuery == 'undefined') {
        var jqueryElement = document.createElement('script');
        jqueryElement.src = '/js/jquery-1.11.2.js';
		
		if(jqueryElement.addEventListener) {
			jqueryElement.addEventListener("load",callback,false);
		} else if(jqueryElement.readyState) {
			jqueryElement.onreadystatechange = callback;
		}		

		document.getElementsByTagName('head')[0].appendChild(jqueryElement);
		
		function callback() {
			if(typeof jQuery != 'undefined') {
				var J = $.noConflict(); //플러그인 간의 충돌을 제거합니다.
		 
				J(document).ready(function() {
					var floatBannerLeft = J('#Scroll_L'),
						floatBannerRight = J('#Scroll_R');
					
					//layerPosition("L",100,0);
					//layerPosition("R",100,0);
					if(floatBannerLeft.data('scroll') == 'y' || floatBannerLeft.data('scroll') == 'n' || floatBannerRight.data('scroll') == 'y' || floatBannerRight.data('scroll') == 'n'){
						layerPosition3();
					} else {
						layerPosition2("L",1,0);
						layerPosition2("R",1,0);
						layerPosition2("L_2",1,0);
						layerPosition2("R_2",1,0);
					}					
				});
			}
		}        
    } else {
		$(document).ready(function() {
			var floatBannerLeft = $('#Scroll_L'),
				floatBannerRight = $('#Scroll_R');
			
			//layerPosition("L",100,0);
			//layerPosition("R",100,0);
			if(floatBannerLeft.data('scroll') == 'y' || floatBannerLeft.data('scroll') == 'n' || floatBannerRight.data('scroll') == 'y' || floatBannerRight.data('scroll') == 'n'){
				layerPosition3();
			} else {
				layerPosition2("L",1,0);
				layerPosition2("R",1,0);
				layerPosition2("L_2",1,0);
				layerPosition2("R_2",1,0);
			}
			
		});
	}
//}
//날개배너 스크롤-e

/*! https://mths.be/punycode v1.4.1 by @mathias */
;(function(root) {

	/** Detect free variables */
	var freeExports = typeof exports == 'object' && exports &&
		!exports.nodeType && exports;
	var freeModule = typeof module == 'object' && module &&
		!module.nodeType && module;
	var freeGlobal = typeof global == 'object' && global;
	if (
		freeGlobal.global === freeGlobal ||
		freeGlobal.window === freeGlobal ||
		freeGlobal.self === freeGlobal
	) {
		root = freeGlobal;
	}

	/**
	 * The `punycode` object.
	 * @name punycode
	 * @type Object
	 */
	var punycode,

	/** Highest positive signed 32-bit float value */
	maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1

	/** Bootstring parameters */
	base = 36,
	tMin = 1,
	tMax = 26,
	skew = 38,
	damp = 700,
	initialBias = 72,
	initialN = 128, // 0x80
	delimiter = '-', // '\x2D'

	/** Regular expressions */
	regexPunycode = /^xn--/,
	regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
	regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators

	/** Error messages */
	errors = {
		'overflow': 'Overflow: input needs wider integers to process',
		'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
		'invalid-input': 'Invalid input'
	},

	/** Convenience shortcuts */
	baseMinusTMin = base - tMin,
	floor = Math.floor,
	stringFromCharCode = String.fromCharCode,

	/** Temporary variable */
	key;

	/*--------------------------------------------------------------------------*/

	/**
	 * A generic error utility function.
	 * @private
	 * @param {String} type The error type.
	 * @returns {Error} Throws a `RangeError` with the applicable error message.
	 */
	function error(type) {
		throw new RangeError(errors[type]);
	}

	/**
	 * A generic `Array#map` utility function.
	 * @private
	 * @param {Array} array The array to iterate over.
	 * @param {Function} callback The function that gets called for every array
	 * item.
	 * @returns {Array} A new array of values returned by the callback function.
	 */
	function map(array, fn) {
		var length = array.length;
		var result = [];
		while (length--) {
			result[length] = fn(array[length]);
		}
		return result;
	}

	/**
	 * A simple `Array#map`-like wrapper to work with domain name strings or email
	 * addresses.
	 * @private
	 * @param {String} domain The domain name or email address.
	 * @param {Function} callback The function that gets called for every
	 * character.
	 * @returns {Array} A new string of characters returned by the callback
	 * function.
	 */
	function mapDomain(string, fn) {
		var parts = string.split('@');
		var result = '';
		if (parts.length > 1) {
			// In email addresses, only the domain name should be punycoded. Leave
			// the local part (i.e. everything up to `@`) intact.
			result = parts[0] + '@';
			string = parts[1];
		}
		// Avoid `split(regex)` for IE8 compatibility. See #17.
		string = string.replace(regexSeparators, '\x2E');
		var labels = string.split('.');
		var encoded = map(labels, fn).join('.');
		return result + encoded;
	}

	/**
	 * Creates an array containing the numeric code points of each Unicode
	 * character in the string. While JavaScript uses UCS-2 internally,
	 * this function will convert a pair of surrogate halves (each of which
	 * UCS-2 exposes as separate characters) into a single code point,
	 * matching UTF-16.
	 * @see `punycode.ucs2.encode`
	 * @see <https://mathiasbynens.be/notes/javascript-encoding>
	 * @memberOf punycode.ucs2
	 * @name decode
	 * @param {String} string The Unicode input string (UCS-2).
	 * @returns {Array} The new array of code points.
	 */
	function ucs2decode(string) {
		var output = [],
		    counter = 0,
		    length = string.length,
		    value,
		    extra;
		while (counter < length) {
			value = string.charCodeAt(counter++);
			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
				// high surrogate, and there is a next character
				extra = string.charCodeAt(counter++);
				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
				} else {
					// unmatched surrogate; only append this code unit, in case the next
					// code unit is the high surrogate of a surrogate pair
					output.push(value);
					counter--;
				}
			} else {
				output.push(value);
			}
		}
		return output;
	}

	/**
	 * Creates a string based on an array of numeric code points.
	 * @see `punycode.ucs2.decode`
	 * @memberOf punycode.ucs2
	 * @name encode
	 * @param {Array} codePoints The array of numeric code points.
	 * @returns {String} The new Unicode string (UCS-2).
	 */
	function ucs2encode(array) {
		return map(array, function(value) {
			var output = '';
			if (value > 0xFFFF) {
				value -= 0x10000;
				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
				value = 0xDC00 | value & 0x3FF;
			}
			output += stringFromCharCode(value);
			return output;
		}).join('');
	}

	/**
	 * Converts a basic code point into a digit/integer.
	 * @see `digitToBasic()`
	 * @private
	 * @param {Number} codePoint The basic numeric code point value.
	 * @returns {Number} The numeric value of a basic code point (for use in
	 * representing integers) in the range `0` to `base - 1`, or `base` if
	 * the code point does not represent a value.
	 */
	function basicToDigit(codePoint) {
		if (codePoint - 48 < 10) {
			return codePoint - 22;
		}
		if (codePoint - 65 < 26) {
			return codePoint - 65;
		}
		if (codePoint - 97 < 26) {
			return codePoint - 97;
		}
		return base;
	}

	/**
	 * Converts a digit/integer into a basic code point.
	 * @see `basicToDigit()`
	 * @private
	 * @param {Number} digit The numeric value of a basic code point.
	 * @returns {Number} The basic code point whose value (when used for
	 * representing integers) is `digit`, which needs to be in the range
	 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
	 * used; else, the lowercase form is used. The behavior is undefined
	 * if `flag` is non-zero and `digit` has no uppercase form.
	 */
	function digitToBasic(digit, flag) {
		//  0..25 map to ASCII a..z or A..Z
		// 26..35 map to ASCII 0..9
		return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
	}

	/**
	 * Bias adaptation function as per section 3.4 of RFC 3492.
	 * https://tools.ietf.org/html/rfc3492#section-3.4
	 * @private
	 */
	function adapt(delta, numPoints, firstTime) {
		var k = 0;
		delta = firstTime ? floor(delta / damp) : delta >> 1;
		delta += floor(delta / numPoints);
		for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
			delta = floor(delta / baseMinusTMin);
		}
		return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
	}

	/**
	 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
	 * symbols.
	 * @memberOf punycode
	 * @param {String} input The Punycode string of ASCII-only symbols.
	 * @returns {String} The resulting string of Unicode symbols.
	 */
	function decode(input) {
		// Don't use UCS-2
		var output = [],
		    inputLength = input.length,
		    out,
		    i = 0,
		    n = initialN,
		    bias = initialBias,
		    basic,
		    j,
		    index,
		    oldi,
		    w,
		    k,
		    digit,
		    t,
		    /** Cached calculation results */
		    baseMinusT;

		// Handle the basic code points: let `basic` be the number of input code
		// points before the last delimiter, or `0` if there is none, then copy
		// the first basic code points to the output.

		basic = input.lastIndexOf(delimiter);
		if (basic < 0) {
			basic = 0;
		}

		for (j = 0; j < basic; ++j) {
			// if it's not a basic code point
			if (input.charCodeAt(j) >= 0x80) {
				error('not-basic');
			}
			output.push(input.charCodeAt(j));
		}

		// Main decoding loop: start just after the last delimiter if any basic code
		// points were copied; start at the beginning otherwise.

		for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {

			// `index` is the index of the next character to be consumed.
			// Decode a generalized variable-length integer into `delta`,
			// which gets added to `i`. The overflow checking is easier
			// if we increase `i` as we go, then subtract off its starting
			// value at the end to obtain `delta`.
			for (oldi = i, w = 1, k = base; /* no condition */; k += base) {

				if (index >= inputLength) {
					error('invalid-input');
				}

				digit = basicToDigit(input.charCodeAt(index++));

				if (digit >= base || digit > floor((maxInt - i) / w)) {
					error('overflow');
				}

				i += digit * w;
				t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);

				if (digit < t) {
					break;
				}

				baseMinusT = base - t;
				if (w > floor(maxInt / baseMinusT)) {
					error('overflow');
				}

				w *= baseMinusT;

			}

			out = output.length + 1;
			bias = adapt(i - oldi, out, oldi == 0);

			// `i` was supposed to wrap around from `out` to `0`,
			// incrementing `n` each time, so we'll fix that now:
			if (floor(i / out) > maxInt - n) {
				error('overflow');
			}

			n += floor(i / out);
			i %= out;

			// Insert `n` at position `i` of the output
			output.splice(i++, 0, n);

		}

		return ucs2encode(output);
	}

	/**
	 * Converts a string of Unicode symbols (e.g. a domain name label) to a
	 * Punycode string of ASCII-only symbols.
	 * @memberOf punycode
	 * @param {String} input The string of Unicode symbols.
	 * @returns {String} The resulting Punycode string of ASCII-only symbols.
	 */
	function encode(input) {
		var n,
		    delta,
		    handledCPCount,
		    basicLength,
		    bias,
		    j,
		    m,
		    q,
		    k,
		    t,
		    currentValue,
		    output = [],
		    /** `inputLength` will hold the number of code points in `input`. */
		    inputLength,
		    /** Cached calculation results */
		    handledCPCountPlusOne,
		    baseMinusT,
		    qMinusT;

		// Convert the input in UCS-2 to Unicode
		input = ucs2decode(input);

		// Cache the length
		inputLength = input.length;

		// Initialize the state
		n = initialN;
		delta = 0;
		bias = initialBias;

		// Handle the basic code points
		for (j = 0; j < inputLength; ++j) {
			currentValue = input[j];
			if (currentValue < 0x80) {
				output.push(stringFromCharCode(currentValue));
			}
		}

		handledCPCount = basicLength = output.length;

		// `handledCPCount` is the number of code points that have been handled;
		// `basicLength` is the number of basic code points.

		// Finish the basic string - if it is not empty - with a delimiter
		if (basicLength) {
			output.push(delimiter);
		}

		// Main encoding loop:
		while (handledCPCount < inputLength) {

			// All non-basic code points < n have been handled already. Find the next
			// larger one:
			for (m = maxInt, j = 0; j < inputLength; ++j) {
				currentValue = input[j];
				if (currentValue >= n && currentValue < m) {
					m = currentValue;
				}
			}

			// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
			// but guard against overflow
			handledCPCountPlusOne = handledCPCount + 1;
			if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
				error('overflow');
			}

			delta += (m - n) * handledCPCountPlusOne;
			n = m;

			for (j = 0; j < inputLength; ++j) {
				currentValue = input[j];

				if (currentValue < n && ++delta > maxInt) {
					error('overflow');
				}

				if (currentValue == n) {
					// Represent delta as a generalized variable-length integer
					for (q = delta, k = base; /* no condition */; k += base) {
						t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
						if (q < t) {
							break;
						}
						qMinusT = q - t;
						baseMinusT = base - t;
						output.push(
							stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
						);
						q = floor(qMinusT / baseMinusT);
					}

					output.push(stringFromCharCode(digitToBasic(q, 0)));
					bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
					delta = 0;
					++handledCPCount;
				}
			}

			++delta;
			++n;

		}
		return output.join('');
	}

	/**
	 * Converts a Punycode string representing a domain name or an email address
	 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
	 * it doesn't matter if you call it on a string that has already been
	 * converted to Unicode.
	 * @memberOf punycode
	 * @param {String} input The Punycoded domain name or email address to
	 * convert to Unicode.
	 * @returns {String} The Unicode representation of the given Punycode
	 * string.
	 */
	function toUnicode(input) {
		return mapDomain(input, function(string) {
			return regexPunycode.test(string)
				? decode(string.slice(4).toLowerCase())
				: string;
		});
	}

	/**
	 * Converts a Unicode string representing a domain name or an email address to
	 * Punycode. Only the non-ASCII parts of the domain name will be converted,
	 * i.e. it doesn't matter if you call it with a domain that's already in
	 * ASCII.
	 * @memberOf punycode
	 * @param {String} input The domain name or email address to convert, as a
	 * Unicode string.
	 * @returns {String} The Punycode representation of the given domain name or
	 * email address.
	 */
	function toASCII(input) {
		return mapDomain(input, function(string) {
			return regexNonASCII.test(string)
				? 'xn--' + encode(string)
				: string;
		});
	}

	/*--------------------------------------------------------------------------*/

	/** Define the public API */
	punycode = {
		/**
		 * A string representing the current Punycode.js version number.
		 * @memberOf punycode
		 * @type String
		 */
		'version': '1.4.1',
		/**
		 * An object of methods to convert from JavaScript's internal character
		 * representation (UCS-2) to Unicode code points, and back.
		 * @see <https://mathiasbynens.be/notes/javascript-encoding>
		 * @memberOf punycode
		 * @type Object
		 */
		'ucs2': {
			'decode': ucs2decode,
			'encode': ucs2encode
		},
		'decode': decode,
		'encode': encode,
		'toASCII': toASCII,
		'toUnicode': toUnicode
	};

	/** Expose `punycode` */
	// Some AMD build optimizers, like r.js, check for specific condition patterns
	// like the following:
	if (
		typeof define == 'function' &&
		typeof define.amd == 'object' &&
		define.amd
	) {
		define('punycode', function() {
			return punycode;
		});
	} else if (freeExports && freeModule) {
		if (module.exports == freeExports) {
			// in Node.js, io.js, or RingoJS v0.8.0+
			freeModule.exports = punycode;
		} else {
			// in Narwhal or RingoJS v0.7.0-
			for (key in punycode) {
				punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
			}
		}
	} else {
		// in Rhino or a web browser
		root.punycode = punycode;
	}

}(this));

function ascii_to_unicode(src) {
	var Pattern = /\/[0-9]{1,}/;
	var ss = src.match(Pattern);

	var src2 = src.replace("http://", "").replace("https://", "").replace("www.", "");
	var src3 = src.replace("http://", "").replace("https://", "").replace("www.", "").replace(ss[0], "");
	var de = 'http://www.' + punycode.toUnicode(src3) + ss[0];
	return de;
}

/* SNS보내기 URL복사 */
showPopup = function() {
	var IE=(document.all)?true:false;
	var src = $(location).attr('href');
	if (IE) {
		if(confirm("이 글의 주소를 클립보드에 복사하시겠습니까?"))
		window.clipboardData.setData("Text", src);
	} else {
		prompt("이 글의 주소입니다. Ctrl+C를 눌러 클립보드로 복사하세요", src);
	}
}
//한글도메인용
showPopup_han = function() {
	var IE=(document.all)?true:false;
	var src = ascii_to_unicode($(location).attr('href'));
	if (IE) {
		if(confirm("이 글의 주소를 클립보드에 복사하시겠습니까?"))
		window.clipboardData.setData("Text", src);
	} else {
		prompt("이 글의 주소입니다. Ctrl+C를 눌러 클립보드로 복사하세요", src);
	}
}
/* //SNS보내기 URL복사 */

/* 모바일_바로가기 */
function mobile_shortcut(){
	if($('#mobile_shortcut').length < 1 ) {
		var newURL = btoa(window.location.href);
		$('body').before('<p id="mobile_shortcut2" style="clear:both;margin:0 0 0 0"><a href="/m_g.php?out=ok&ref='+newURL+'" style="display:block;padding:50px 0;border-top:1px solid #e7e7e7;background:#f3f3f3;text-align:center;text-decoration:none"><span style="font-family:AppleSDGothicNeo-SemiBold;vertical-align:middle;font-size:50px;color:#0006FF;text-align:center;text-decoration:none;font-weight:bold;">모바일 버전으로 보기<img src="/img/ico_arrow.png?w=160726" style="vertical-align:middle;margin:-3px 0 0 7px;*margin-top:-1px;" alt="모바일 버전으로 이동"></span></a></p>');
		$('body').after('<p id="mobile_shortcut" style="clear:both;margin:10px 0 0"><a href="/m_g.php?out=ok&ref='+newURL+'" style="display:block;padding:50px 0;border-top:1px solid #e7e7e7;background:#f3f3f3;text-align:center;text-decoration:none"><span style="font-family:AppleSDGothicNeo-SemiBold;vertical-align:middle;font-size:50px;color:#0006FF;text-align:center;text-decoration:none;font-weight:bold;">모바일 버전으로 보기<img src="/img/ico_arrow.png?w=160726" style="vertical-align:middle;margin:-3px 0 0 7px;*margin-top:-1px;" alt="모바일 버전으로 이동"></span></a></p>');
	}
}
/* //모바일_바로가기 */

/* 즐겨찾기/북마크 */
function bookmarksite(title,url){
	var browser = {
		chk : navigator.userAgent.toLowerCase()
	};

	browser = {
		ie : browser.chk.indexOf('msie') != -1,
		ie6 : browser.chk.indexOf('msie 6') != -1,
		ie7 : browser.chk.indexOf('msie 7') != -1,
		ie8 : browser.chk.indexOf('msie 8') != -1,
		ie9 : browser.chk.indexOf('msie 9') != -1,
		ie10 : browser.chk.indexOf('msie 10') != -1,
		ie11 : browser.chk.indexOf('rv:11') != -1,
		chrome : browser.chk.indexOf('chrome') != -1,
		firefox : browser.chk.indexOf('firefox') != -1,
		safari : browser.chk.indexOf('safari') != -1,
		opera : browser.chk.indexOf('opr') != -1
	};

	if(browser.ie || browser.ie11){
		window.external.AddFavorite(url, title);
	}else if(browser.opera || browser.firefox || browser.safari || browser.chrome){
		alert("Ctrl+D키를 누르시면 즐겨찾기에 추가하실 수 있습니다.");
	}else{
		alert("지원하지 않는 브라우저입니다.");
	}
}
/* //즐겨찾기/북마크 */

/* 본문 사이 광고 : 시작 */
function tree_ad(line, style, up_down) {
	line = typeof line !== 'undefined' ? line : 1;
	style = typeof style !== 'undefined' ? style : 'float:right; width:336px; height:280px; padding: 0 0 0 10px; position: relative; z-index:999999999;';
	up_down = typeof up_down !== 'undefined' ? up_down : 'up';
	//text-align: center; width:100%; height:280px; padding: 10px 0 10px 0; position: relative; z-index:999999999;
	var p_i = 0;
	var div_i = 0;
	var br_i = 0;
	var chk = 0;

	$("#textinput").find('p').each(function(){
		if($.trim(this.innerHTML) !== "&nbsp;" && this.innerHTML !== " " && $(this).attr('class') !== 'body_img_caption' && $(this).find('img').attr('id') !== 'img_pop_view') {
			p_i++;
			if(p_i==line) {
				var index = $('#textinput p').index(this);
				if(up_down=='up') {
					$("#textinput p:eq("+index+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
				} else {
					$("#textinput p:eq("+index+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
				}
				window['tree_line_'+line] = $("#tree_line_"+line);
				window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
				window['tree_line_tmp_'+line].css('display','block');
				window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
				if(window['tree_line_'+line].height()==0) {
					window['tree_line_'+line].css("padding","0 0 0 0");
				}
				chk = 1;
				return false;
			}
		}
	});
	
	if(chk==0) {
		$("#textinput").find('br').each(function(){
			if($.trim(this.innerHTML) !== "&nbsp;" && this.innerHTML !== " " && $(this).attr('class') !== 'body_img_caption') {
				br_i++;
				if(br_i==line) {
					var index = $('#textinput br').index(this);
					if(up_down=='up') {
						$("#textinput br:eq("+index+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
					} else {
						$("#textinput br:eq("+index+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
					}
					window['tree_line_'+line] = $("#tree_line_"+line);
					window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
					window['tree_line_tmp_'+line].css('display','block');
					window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
					chk = 1;
					return false;
				}
			}
		});
	}
	
	if(chk==0) {
		$("#textinput").find('div').each(function(){
			if($(this).attr('id')) {
				if($.trim(this.innerHTML) !== "&nbsp;" && $.trim(this.innerHTML) !== "" && $(this).attr('class') !== 'thumb_box' && $(this).attr('class') !== 'body_img_table2' && $(this).attr('id').indexOf('tree_line_') !== -1 && $(this).attr('id').indexOf('mov') !== -1 && $(this).attr('id').indexOf('tree_line_tmp_') !== -1) {
					div_i++;
					if(div_i==line) {
						var index2 = $('#textinput div').index(this);
						if(up_down=='up') {
							$("#textinput div:eq("+index2+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
						} else {
							$("#textinput div:eq("+index2+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
						}
						window['tree_line_'+line] = $("#tree_line_"+line);
						window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
						window['tree_line_tmp_'+line].css('display','block');
						window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
						chk = 1;
						return false;
					}
				}
			} else {
				if($.trim(this.innerHTML) !== "&nbsp;" && $.trim(this.innerHTML) !== "" && $(this).attr('class') !== 'thumb_box' && $(this).attr('class') !== 'body_img_table2') {
					div_i++;
					if(div_i==line) {
						var index2 = $('#textinput div').index(this);
						if(up_down=='up') {
							$("#textinput div:eq("+index2+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
						} else {
							$("#textinput div:eq("+index2+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
						}
						window['tree_line_'+line] = $("#tree_line_"+line);
						window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
						window['tree_line_tmp_'+line].css('display','block');
						window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
						chk = 1;
						return false;
					}
				}
			}
		});
	}
	
	if(chk==0) {
		window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
		window['tree_line_tmp_'+line].css('display','none');
	}
}


function tree_ad2(line, style, up_down) {
	line = typeof line !== 'undefined' ? line : 1;
	style = typeof style !== 'undefined' ? style : 'float:right; width:336px; height:280px; padding: 0 0 0 10px; position: relative; z-index:999999999;';
	up_down = typeof up_down !== 'undefined' ? up_down : 'up';
	//text-align: center; width:100%; height:280px; padding: 10px 0 10px 0; position: relative; z-index:999999999;
	var p_i = 0;
	var div_i = 0;
	var br_i = 0;
	var chk = 0;

	$("#textinput").find('p').each(function(){
		if($.trim(this.innerHTML) !== "&nbsp;" && this.innerHTML !== " ") {
			p_i++;
			if(p_i==line) {
				var index = $('#textinput p').index(this);
				if(up_down=='up') {
					$("#textinput p:eq("+index+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
				} else {
					$("#textinput p:eq("+index+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
				}
				window['tree_line_'+line] = $("#tree_line_"+line);
				window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
				window['tree_line_tmp_'+line].css('display','block');
				window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
				chk = 1;
				return false;
			}
		}
	});
		
	if(chk==0) {
		$("#textinput").find('br').each(function(){
			if($.trim(this.innerHTML) !== "&nbsp;" && this.innerHTML !== " ") {
				br_i++;
				if(br_i==line) {
					var index = $('#textinput br').index(this);
					if(up_down=='up') {
						$("#textinput br:eq("+index+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
					} else {
						$("#textinput br:eq("+index+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
					}
					window['tree_line_'+line] = $("#tree_line_"+line);
					window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
					window['tree_line_tmp_'+line].css('display','block');
					window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
					chk = 1;
					return false;
				}
			}
		});
	
		$("#textinput").find('div').each(function(){
			if($.trim(this.innerHTML) !== "&nbsp;" && $.trim(this.innerHTML) !== "" && $(this).attr('class') !== 'thumb_box' && $(this).attr('id').indexOf('tree_line_') !== -1) {
				div_i++;
				if(div_i==line) {
					var index2 = $('#textinput div').index(this);
					if(up_down=='up') {
						$("#textinput div:eq("+index2+")").before("<div id='tree_line_" + line + "' style='" + style + "'></div>");
					} else {
						$("#textinput div:eq("+index2+")").after("<div id='tree_line_" + line + "' style='" + style + "'></div>");
					}
					window['tree_line_'+line] = $("#tree_line_"+line);
					window['tree_line_tmp_'+line] = $("#tree_line_tmp_"+line);
					window['tree_line_tmp_'+line].css('display','block');
					window['tree_line_'+line].append(window['tree_line_tmp_'+line]);
					return false;
				}
			}
		});
	}
}
/* 본문 사이 광고 : 끝 */

if(typeof jQuery != 'undefined') {
	$(document).ready(function(){
		//tts
	  $("#tts_on").click(function(){
		  var a= $(this).attr('tts_url');
		  var b= $(this).attr('tts_uid');
		  var c= $(this).attr('speak');
		  var  s=document.getElementById("tts_on");
		  var data="tts_url="+a+"&tts_uid="+b;
				//alert(data);
				 $.ajax({
					data: data,
					type: 'GET',
					url: 'https://tts2.inswave.net/tts_ins_ms.php',

					success:function(args){   
						
						var audio ="<audio src='"+args+"' id='myaudio'></audio>"; 
					
						if(c=="on")
						{	
												 
						   s.innerHTML=audio;
						  var vid = document.getElementById("myaudio"); 
							  vid.play(); 
						  $("#tts_on").attr("speak","off");
						 
						}else 
						{
						   var vid = document.getElementById("myaudio");  
							 vid.pause();
						   $("#tts_on").attr("speak","on");
												
						 }
						
					},   
					
					//beforeSend:showRequest,  
					error:function(e){  
						alert(e.responseText);  
					}  
				
				});
	  });

	  /* 모바일웹 여부 체크 후 모바일 접속이면 모바일 버전으로 보기 노출 */

		/*var cmaDns = location.href.split("//");
		var url_tmp = "http://m."+cmaDns[1].substr(0,cmaDns[1].indexOf("/")).replace(/www./g,'');
		var arSplitUrl   = document.URL.split("/");
		
		$.ajax({
			 url: url_tmp+"/chk.php",
			 dataType: 'jsonp',
			 jsonpCallback: "myCallback",
			 success: function (chk) {
				if(chk['chk'] == "ok") {
					var filter = "win16|win32|win64|mac|macintosh|macintel|macosx";
		 
					if(navigator.platform){
						if(0 > filter.indexOf(navigator.platform.toLowerCase())){
							if(arSplitUrl[3]!='admin') {
								mobile_shortcut();
							}
						}
					}
					console.log(url_tmp+" : 사용중");
				} else {
					console.log(url_tmp+" : 미사용중");
				}
			 },
			 error: function () {
				  console.log(url_tmp+" : 미사용중");
			 }
		});*/
	/* //모바일웹 여부 체크 후 모바일 접속이면 모바일 버전으로 보기 노출 */
	  
	});
}

/* 복사시 출처 달기 */
/*
 * AutoSourcing (Opensource ver)
 * @author gony (AjaxUI3 Team)
 */
var AutoSourcing={id_tmp:"",div:null,id:"",timer:null,regex:null,strings:[],skip:false,handlers:{},init:function(format,enable){var t=this;var n=navigator;var is_safari=(n.userAgent.indexOf("WebKit")>-1&&n.vendor.indexOf("Apple")>-1);this.div=document.createElement("div");this.div.className=(/MSIE|Gecko/.test(n.userAgent)&&!is_safari)?"autosourcing-stub":"autosourcing-stub-extra";this.id="autosourcing_tmp_"+(Math.random()*10000);this.regex=new RegExp(format.replace("%id%","(\\D+)"));this.handlers.copy=function(){t.copy()};this.handlers.keydown=function(evt){t.keydown(evt)};this.handlers.keypress=function(evt){t.keypress(evt)};if(typeof enable=="undefined")enable=true;this.setEnable(enable);},setEnable:function(bool){if(bool){if(typeof document.body.oncopy!="undefined"){this.addEvent(document.body,"copy",this.handlers.copy);}else{this.addEvent(document,"keydown",this.handlers.keydown);this.addEvent(document,"keypress",this.handlers.keypress);this.addEvent(document,"contextmenu",this.handlers.copy);}}else{if(typeof document.body.oncopy!="undefined"){this.removeEvent(document.body,"copy",this.handlers.copy);}else{this.removeEvent(document,"keydown",this.handlers.keydown);this.removeEvent(document,"keypress",this.handlers.keypress);this.removeEvent(document,"contextmenu",this.handlers.copy);}}},getId:function(rng){var range_s,range_e,par,id;range_s=this.cloneRange(rng)
range_s.collapse(true);par=this.getParentElement(range_s);while(par&&par.parentNode){if(par.nodeType==1&&this.regex.test(par.id)){id=(RegExp.$1);return id;}
par=par.parentNode;}
range_e=this.cloneRange(rng)
range_e.collapse(false);par=this.getParentElement(range_e);while(par&&par.parentNode){if(par.nodeType==1&&this.regex.test(par.id)){id=(RegExp.$1);return id;}
par=par.parentNode;}
return 0;},getSelection:function(){if(window.getSelection){return window.getSelection();}else{return document.selection;}},getRange:function(selection){selection=selection||this.getSelection();if(selection.getRangeAt){return selection.getRangeAt(0);}else{return selection.createRange();}},cloneRange:function(rng){rng=rng||this.getRange();if(rng.duplicate){return rng.duplicate();}else{return rng.cloneRange();}},getParentElement:function(range){var par=range.parentElement?range.parentElement():range.commonAncestorContainer;if(!par)return null;while(par.nodeType!=1){par=par.parentNode;}
return par;},setString:function(id,sTitle,sName,sLink){id_tmp=id;var data={name:sName,link:sLink,title:sTitle};this.strings[id]=this._template.replace(/\{(\w+)\}/g,function(m0,m1){return data[m1]?data[m1]:"";});},copy:function(evt){var evt=evt||window.event;var self=this;var sel=this.getSelection();var rng=this.getRange(sel);var rngtmp=this.cloneRange(rng);var regcopy=/(?:p|<div)[^<>]+class\s*=\s*"?autosourcing\-stub(?:\-extra)?\-saved(?:\b|")/i;var regtag=/textarea|input/i;var id=this.getId(rng);var node_rng;this.skip=false;clearTimeout(this.timer);if(id!=id_tmp){try{this.div.parentNode.removeChild(this.div)}catch(e){};return;}
if(evt&&evt.srcElement&&evt.srcElement.tagName.toUpperCase()=="A")return;this.div.innerHTML=this.strings[id];if(window.getSelection){var html=(window.XMLSerializer)?new XMLSerializer().serializeToString(rng.cloneContents()):"";if(regcopy.test(html)||regtag.test(rng.commonAncestorContainer.tagName)){this.skip=true;return;}
rngtmp.collapse(false);rngtmp.insertNode(this.div);if(this.div.nextSibling){rng.setEndBefore(this.div.nextSibling);}else{rng.setEndAfter(this.div);}
sel.removeAllRanges();sel.addRange(rng);}else if(document.selection){var body=document.body||document.getElementsByTagName("body")[0];var div=document.createElement("div");var span=document.createElement("span");span.id=this.id;if(regcopy.test(rng.htmlText)||regtag.test(rng.parentElement().tagName)){this.skip=true;return;}
rngtmp.collapse(false);rngtmp.pasteHTML(span.outerHTML+'&nbsp;<a></a>');span=document.getElementById(this.id);(span||rngtmp.parentElement()).insertAdjacentElement("afterEnd",this.div);do{rng.moveEnd("character",1);(rngtmp=rng.duplicate()).collapse(false);}while(rngtmp.offsetLeft==0);try{rng.select();}catch(e){}
if(span&&span.parentNode){span.parentNode.removeChild(span.nextSibling.nextSibling);span.parentNode.removeChild(span.nextSibling.nextSibling);span.parentNode.removeChild(span);}
if(div.parentNode){div.parentNode.removeChild(div);}}
if(typeof document.body.oncopy!="undefined"){this.timer=setTimeout(function(){self.aftercopy(rng);},1);}},aftercopy:function(rng){if(this.skip)return;try{this.div.parentNode.removeChild(this.div);if(/WebKit/.test(navigator.userAgent)){var sel=this.getSelection();sel.removeAllRanges();sel.addRange(rng);}}catch(e){}},keydown:function(e){if((e.ctrlKey||e.metaKey)&&e.keyCode==67){this.copy();}},keypress:function(e){if((e.ctrlKey||e.metaKey)&&e.keyCode==67){var t=this;this.timer=setTimeout(function(){t.aftercopy();},10);}},mousedown:function(e){},setTemplate:function(html){this._template=html;},addEvent:function(obj,sEvent,pFunc){function addEventIE(obj,sEvent,pFunc){obj.attachEvent("on"+sEvent,pFunc);}
function addEventFF(obj,sEvent,pFunc){obj.addEventListener(sEvent,pFunc,false);}
if(obj.attachEvent)this.addEvent=addEventIE;else this.addEvent=addEventFF;this.addEvent(obj,sEvent,pFunc);},removeEvent:function(obj,sEvent,pFunc){function removeEventIE(obj,sEvent,pFunc){obj.detachEvent("on"+sEvent,pFunc);}
function removeEventFF(obj,sEvent,pFunc){obj.removeEventListener(sEvent,pFunc,false);}
if(obj.detachEvent)this.removeEvent=removeEventIE;else this.removeEvent=removeEventFF;}}
if(typeof jQuery != 'undefined') {
	var AutoSourcing_onoff = 'true';
	
	$(document).ready(function() {
		if($('meta[name="AutoSourcing"]').length) {
			AutoSourcing_onoff = $('meta[name="AutoSourcing"]').attr('content');
		}
	
		if(AutoSourcing_onoff=='true') {
			AutoSourcing.init('%id%');

			var link_tmp = document.location.href;
			var title = $('meta[name="title"]').attr('content');
			AutoSourcing.setTemplate("<div>출처: <a href=\"{link}\">{title}</a> - {link}</div>");
			AutoSourcing.setString('textinput', title,'' , link_tmp);
		}
	});
}
/* //복사시 출처 달기 */

if(typeof jQuery != 'undefined') {
	$(document).ready(function(){

// 좋아요 
     
	  $('.btn_like').click(function(i)
		{
			
			 var uid = $(this).attr("data-uid");
			 var domain = $(this).attr("data-domain");
			 var title = $(this).attr("data-title");
			 var fdata = "d_mode=input&uid="+uid+"&domain="+domain+"&title="+title;
			 
			 $(this).attr('class','btn_like_on');

			$.ajax({
				type: "POST",
				url: "https://tts2.inswave.net/php_bin/ins_wave_like_el.php",
				data: fdata,
				cache: false,
				async: false,
				success: function(data){
					if(data) {
						$('.like_cnt').html(data);
						var todayDate = new Date(); 
                        todayDate.setDate( todayDate.getDate() + 3600*30*365 ); 
                        document.cookie = "uid_"+uid+ "=" + escape(uid) + "; path=/; expires=" + todayDate.toGMTString() + ";" 

					}  else {
			
					}
				}
             });
		
		 });

	 
		// 분문 이미지 
		$('#textinput').find('img').each(function(){
             var src_tmp = $(this).attr("src");
		     $(this).addClass("img_zoom");

		});

	  $('.img_zoom').click(function(i)
		{
			
			 var img_name = $(this).attr('src');
			 var h =   $(this).height();
			 var w =   $(this).width()+80;
			
			
			$.blockUI(
			{
				
				message: '<img src="'+img_name+'" /  id="img_close"  onclick="img_pop_close()" style="cursor:pointer"></div> ',
				fadeIn: 700, 
				fadeOut: 700, 
				//onOverlayClick: $.unblockUI, 
				//blockMsgClass: 'PhotoAdd',
				css: { 
					position: 'absolute',
					top: ($(window).scrollTop()+70)+'px',
				    left: (($(window).width()-w)/2)-100 + 'px', 
					width: w+'px' 



				} 
			});
			setTimeout($.unblockUI, 50000);
		});


	});
}


function img_pop_close()
	{
		
		$.unblockUI();
		//setTimeout($.unblockUI, 1000);
	};
	

/* 맨하단에서 스크롤시 다음 기사로 이동 */
//////////////////////////////////////////////
// scroll_next_news                         //
// Source : zum https://www.zum.com         //
// https://news.zumst.com/scripts/view.js   //
//////////////////////////////////////////////
// /newnews/ajax_nextnews.php               //
/*
sub_read_skin.html 또는 serial_read_skin.html 에 적용

<!-- scroll next news : start -->
<script>
wheelEventEnable = true; //사용여부 true,false
wheelSectonEnable = false; //섹션1 true,false
wheelSecton2Enable = false; //섹션2 true,false
fadeOutN = 0; //페이지 전환효과 초 단위
</script>
<!-- scroll next news : end -->

*/

if(typeof jQuery != 'undefined') {
	
var lastchk = false;
var wheelEventEnable = false;
var wheelSectonEnable = false;
var wheelSecton2Enable = false;
var wheel_wdate = 'none';
var wheel_sc = 'none';
var wheel_sc2 = 'none';
var fadeOutN = 0;

function urlParam(name){
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
	var results2 = window.location.href.replace($(location).attr('protocol')+"//"+$(location).attr('host')+'/','');
    if (results==null){
		if($.isNumeric(results2)) {
			return results2;
		} else {
			return null;
		}
    }
    else{
       return results[1] || 0;
    }
}

function nextNews(e) {
	var fdata = "";
	$.ajax({
		type: "POST",
		url: "/newnews/ajax_nextnews.php",
		data: "mode=wdate&uid="+urlParam('uid'),
		cache: false,
		async: false,
		success: function(data){
			if(data.rCode==2) {
				if($.isNumeric(data.rWdate)) {
					wheel_wdate = data.rWdate;
					wheel_sc = data.rSection;
					wheel_sc2 = data.rSection2;
				}
			} else {
				window.console && console.log(data.rMsg);
			}
		}
	});
	
	if(wheelSectonEnable) {
		if(wheelSecton2Enable) {
			fdata = "mode=next&uid="+urlParam('uid')+"&wdate="+wheel_wdate+"&section="+wheel_sc+"&section2="+wheel_sc2;
		} else {
			fdata = "mode=next&uid="+urlParam('uid')+"&wdate="+wheel_wdate+"&section="+wheel_sc;
		}
	} else {
		fdata = "mode=next&uid="+urlParam('uid')+"&wdate="+wheel_wdate;
	}
	
	if(fadeOutN) {
		fadeOutN = (1000*fadeOutN);
	}
	
	$.ajax({
		type: "POST",
		url: "/newnews/ajax_nextnews.php",
		data: fdata,
		cache: false,
		async: false,
		success: function(data){
			if(data.rCode==2) {
				if($.isNumeric(data.rUid)) {
					if(window.location.pathname=="/serial_read.html") {
						$("body").fadeOut(fadeOutN, function () {
							location.href = $(location).attr('protocol')+"//"+$(location).attr('host')+"/serial_read.html?uid="+data.rUid;
						});
					} else {
						$("body").fadeOut(fadeOutN, function () {
							location.href = $(location).attr('protocol')+"//"+$(location).attr('host')+"/"+data.rUid;
						});
					}
				}
			} else {
				if(data.rMsg=="last") {
					lastchk = true;
					$("#lastmsg").fadeIn(200, function () {
						setTimeout(function () {
							$("#lastmsg").fadeOut(200);
						}, 3000);
					});
				} else {
					window.console && console.log(data.rMsg);
				}
			}
		}
	});
}

var wheelEvent = {
    enabled: false,
    scrollInfo: false,
    nextAction: false,
    $parentWindow: $(window),
    $parentDocument: $(document),

    init: function() {
		$("body").append('<div id="scrollInfo" style="display: none; width: 100%; position: fixed; bottom: 0px; height: 50px; line-height: 50px; white-space: nowrap; background: #fff; border: 1px solid #ededed; padding: 0 10px; text-align: center;"><p style="font-size: 18px; letter-spacing: -0.7px; color: #212121; color: rgba(0, 0, 0, 0.87);"><strong style="color: #1b52ed;">한번 더 스크롤</strong>하면 다음 기사로 이동합니다.</p></div><div id="lastmsg" style="display: none; width: 100%; position: fixed; bottom: 0px; height: 50px; line-height: 50px; white-space: nowrap; background: #fff; border: 1px solid #ededed; padding: 0 10px; text-align: center;"><p style="font-size: 18px; letter-spacing: -0.7px; color: #212121; color: rgba(0, 0, 0, 0.87);"><strong style="color: #1b52ed;">마지막 기사입니다.</strong></p></div>');

        $("html, body").on('mousewheel DOMMouseScroll onmousewheel', function (e) {
            wheelEvent.enabled && wheelEvent.executeAction(e);
        });

        this.$parentDocument.find("html, body").on('mousewheel DOMMouseScroll onmousewheel', function (e) {
            wheelEvent.enabled && wheelEvent.executeAction(e);
        });

		this.$parentWindow.on('keydown',function(e) {
            if(wheelEvent.enabled && e.keyCode === 40) {
                wheelEvent.executeAction(e);
            }
        });

        this.enabled = true;
    },

    isLastScroll: function() {
		var myHeight = 0;
		if (typeof (window.innerHeight) == 'number') { //Chrome
			 myHeight = window.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			 myHeight = document.documentElement.clientHeight;
		} else if (document.body && document.body.clientHeight) { //IE9
			 myHeight = document.body.clientHeight;
		}
			
		var myScrollTop = "";
		if (this.$parentWindow.scrollTop()) {
			 myScrollTop = this.$parentWindow.scrollTop();
		} else if (document.body && document.body.scrollTop) { //IE9
			 myScrollTop = document.body.scrollTop;
		}
        //return this.$parentWindow.scrollTop() + this.$parentWindow.height() >= this.$parentDocument.height();
		return myScrollTop + myHeight >= this.$parentDocument.height();
    },

    onWheelEvent: function() {
        if(!this.isLastScroll()) {
            this.offWheelEvent();
            return;
        }

        if(this.$parentDocument.find("#scrollInfo").is(":not(:visible)")) {
            this.scrollAlertAction();
        }

        this.enabled = true;
    },

    offWheelEvent: function() {
        this.enabled = false;
    },

    executeAction: function(e) {
        var isDown = (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0 || e.originalEvent.deltaY > 0 || e.type === 'keydown');

        if(isDown && this.$parentDocument.find("#scrollInfo").is(":not(:visible)")) {
            this.scrollAlertAction();
        }
        if(isDown && this.$parentDocument.find("#scrollInfo").is(":visible")){
            if(this.scrollInfo && !this.nextAction) {
                this.nextAction = true;
                nextNews(e);
            } else if(lastchk) {
				$("#lastmsg").fadeIn(200, function () {
					setTimeout(function () {
						$("#lastmsg").fadeOut(200);
					}, 3000);
				});
			}
        }
    },

    scrollAlertAction: function() {
		if(wheelEventEnable){
			if(!this.scrollInfo && this.isLastScroll()) {
				this.$parentDocument.find("#scrollInfo").fadeIn(200, function () {
					wheelEvent.scrollInfo = true;
					setTimeout(function () {
						wheelEvent.$parentDocument.find("#scrollInfo").fadeOut(200);
						wheelEvent.scrollInfo = false;
					}, 3000);
				});
			}
		}
    }
};

$(window).on('load', function() {
    wheelEvent.init();

    $(parent.window).scroll(function() {
        wheelEvent.onWheelEvent();
    });
});
}
/* //맨하단에서 스크롤시 다음 기사로 이동 */

/* 본문에 유튜브, 네이버 iframe 영상이 있을 경우 iframe에 y_n_video_iframe 클래스 추가-시작 */
if(typeof jQuery != 'undefined') {
	$(document).ready(function(){
		$("#textinput").find('iframe').each(function(){
			var if_src = $(this).attr('src');
			if(if_src.indexOf('youtube') != -1 || if_src.indexOf('naver') != -1) {
				$(this).addClass("y_n_video_iframe");
			}
		});
	});
}
/* 본문에 유튜브, 네이버 iframe 영상이 있을 경우 iframe에 y_n_video_iframe 클래스 추가-끝 */

/* 구글 번역기 : 시작 */
//<script>googleTranslateE('ko,en,ja,zh-CN,de,fr');</script> 노출시킬 국가 ,구분으로 입력 노출 시킬 위치에 해당 소스 추가
function lang_kr(lang) {
	var $lang_txt = '';
	switch(lang) {
		case "gl": $lang_txt = "갈리시아어"; break;
		case "gu": $lang_txt = "구자라트어"; break;
		case "el": $lang_txt = "그리스어"; break;
		case "nl": $lang_txt = "네덜란드어"; break;
		case "ne": $lang_txt = "네팔어"; break;
		case "no": $lang_txt = "노르웨이어"; break;
		case "da": $lang_txt = "덴마크어"; break;
		case "de": $lang_txt = "독일어"; break;
		case "lo": $lang_txt = "라오어"; break;
		case "lv": $lang_txt = "라트비아어"; break;
		case "la": $lang_txt = "라틴어"; break;
		case "ru": $lang_txt = "러시아어"; break;
		case "ro": $lang_txt = "루마니아어"; break;
		case "lb": $lang_txt = "룩셈부르크어"; break;
		case "lt": $lang_txt = "리투아니아어"; break;
		case "mr": $lang_txt = "마라티어"; break;
		case "mi": $lang_txt = "마오리어"; break;
		case "mk": $lang_txt = "마케도니아어"; break;
		case "mg": $lang_txt = "말라가시어"; break;
		case "ml": $lang_txt = "말라얄람어"; break;
		case "ms": $lang_txt = "말레이어"; break;
		case "mt": $lang_txt = "몰타어"; break;
		case "mn": $lang_txt = "몽골어"; break;
		case "hmn": $lang_txt = "몽어"; break;
		case "my": $lang_txt = "미얀마어 (버마어)"; break;
		case "eu": $lang_txt = "바스크어"; break;
		case "vi": $lang_txt = "베트남어"; break;
		case "be": $lang_txt = "벨라루스어"; break;
		case "bn": $lang_txt = "벵골어"; break;
		case "bs": $lang_txt = "보스니아어"; break;
		case "bg": $lang_txt = "불가리아어"; break;
		case "sm": $lang_txt = "사모아어"; break;
		case "sr": $lang_txt = "세르비아어"; break;
		case "ceb": $lang_txt = "세부아노"; break;
		case "st": $lang_txt = "세소토어"; break;
		case "so": $lang_txt = "소말리아어"; break;
		case "sn": $lang_txt = "쇼나어"; break;
		case "su": $lang_txt = "순다어"; break;
		case "sw": $lang_txt = "스와힐리어"; break;
		case "sv": $lang_txt = "스웨덴어"; break;
		case "gd": $lang_txt = "스코틀랜드 게일어"; break;
		case "es": $lang_txt = "스페인어"; break;
		case "sk": $lang_txt = "슬로바키아어"; break;
		case "sl": $lang_txt = "슬로베니아어"; break;
		case "sd": $lang_txt = "신디어"; break;
		case "si": $lang_txt = "신할라어"; break;
		case "ar": $lang_txt = "아랍어"; break;
		case "hy": $lang_txt = "아르메니아어"; break;
		case "is": $lang_txt = "아이슬란드어"; break;
		case "ht": $lang_txt = "아이티 크리올어"; break;
		case "ga": $lang_txt = "아일랜드어"; break;
		case "az": $lang_txt = "아제르바이잔어"; break;
		case "af": $lang_txt = "아프리칸스어"; break;
		case "sq": $lang_txt = "알바니아어"; break;
		case "am": $lang_txt = "암하라어"; break;
		case "et": $lang_txt = "에스토니아어"; break;
		case "eo": $lang_txt = "에스페란토어"; break;
		case "en": $lang_txt = "영어"; break;
		case "or": $lang_txt = "오리야어"; break;
		case "yo": $lang_txt = "요루바어"; break;
		case "ur": $lang_txt = "우르두어"; break;
		case "uz": $lang_txt = "우즈베크어"; break;
		case "uk": $lang_txt = "우크라이나어"; break;
		case "cy": $lang_txt = "웨일즈어"; break;
		case "ug": $lang_txt = "위구르어"; break;
		case "ig": $lang_txt = "이그보어"; break;
		case "yi": $lang_txt = "이디시어"; break;
		case "it": $lang_txt = "이탈리아어"; break;
		case "id": $lang_txt = "인도네시아어"; break;
		case "ja": $lang_txt = "일본어"; break;
		case "jw": $lang_txt = "자바어"; break;
		case "ka": $lang_txt = "조지아어"; break;
		case "zu": $lang_txt = "줄루어"; break;
		case "zh-CN": $lang_txt = "중국어(간체)"; break;
		case "ny": $lang_txt = "체와어"; break;
		case "cs": $lang_txt = "체코어"; break;
		case "kk": $lang_txt = "카자흐어"; break;
		case "ca": $lang_txt = "카탈로니아어"; break;
		case "kn": $lang_txt = "칸나다어"; break;
		case "co": $lang_txt = "코르시카어"; break;
		case "xh": $lang_txt = "코사어"; break;
		case "ku": $lang_txt = "쿠르드어"; break;
		case "hr": $lang_txt = "크로아티아어"; break;
		case "km": $lang_txt = "크메르어"; break;
		case "rw": $lang_txt = "키냐르완다어"; break;
		case "ky": $lang_txt = "키르기스어"; break;
		case "tl": $lang_txt = "타갈로그어"; break;
		case "ta": $lang_txt = "타밀어"; break;
		case "tg": $lang_txt = "타지크어"; break;
		case "tt": $lang_txt = "타타르어"; break;
		case "th": $lang_txt = "태국어"; break;
		case "tr": $lang_txt = "터키어"; break;
		case "te": $lang_txt = "텔루구어"; break;
		case "tk": $lang_txt = "투르크멘어"; break;
		case "ps": $lang_txt = "파슈토어"; break;
		case "pa": $lang_txt = "펀자브어"; break;
		case "fa": $lang_txt = "페르시아어"; break;
		case "pt": $lang_txt = "포르투갈어"; break;
		case "pl": $lang_txt = "폴란드어"; break;
		case "fr": $lang_txt = "프랑스어"; break;
		case "fy": $lang_txt = "프리지아어"; break;
		case "fi": $lang_txt = "핀란드어"; break;
		case "haw": $lang_txt = "하와이어"; break;
		case "ha": $lang_txt = "하우사어"; break;
		case "hu": $lang_txt = "헝가리어"; break;
		case "iw": $lang_txt = "히브리어"; break;
		case "hi": $lang_txt = "힌디어"; break;
		case "ko": $lang_txt = "한국어"; break;
		default: $lang_txt = "한국어"; break;
	};
	return $lang_txt;
}

function googleTranslateE(lang) {
	lang = typeof lang !== 'undefined' ? lang : 'ko,en,ja,zh-CN,de,fr';
	var lang_a = new Array("ko","en","ja","zh-CN","de","fr");
	var strArray=lang.split(',');
	
	var jqueryElement = document.createElement('script');
        jqueryElement.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
	function googleTranslateE_callback() {}
	if(jqueryElement.addEventListener) {
		jqueryElement.addEventListener("load",googleTranslateE_callback,false);
	} else if(jqueryElement.readyState) {
		jqueryElement.onreadystatechange = googleTranslateE_callback;
	}		

	document.getElementsByTagName('head')[0].appendChild(jqueryElement);
	
	var styletag = "<style>";
		styletag += ".googleTranslate_i {margin: 0 0 0 7px;}";
		styletag += ".googleTranslate_i > a > span {background:url('/img/trans-icon.png') no-repeat}";
		styletag += ".googleTranslate_i > a.en > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:0 0}";
		styletag += ".googleTranslate_i > a.ja > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:-46px 0}";
		styletag += ".googleTranslate_i > a.zh-CN > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:-92px 0}";
		styletag += ".googleTranslate_i > a.de > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:-138px 0}";
		styletag += ".googleTranslate_i > a.fr > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:-184px 0}";
		styletag += ".googleTranslate_i > a.ko > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:-230px 0}";
		styletag += ".googleTranslate_i > a.es > span {display: inline-block;width: 24px;height: 24px;vertical-align: middle;margin: 0 5px 0 0;background-position:-276px 0}";
		styletag += "#google_translate_element,.goog-te-banner-frame, .skiptranslate {display: none!important;}";
		styletag += "body{top:0px!important;}";
		styletag += "</style>";
	$('head').append(styletag);
	
	$('body').append("<div id='google_translate_element' style='display: none!important;'></div>");
	
	/*var googleTrans = {
		evtPageInit:function(){
			var langs = $('.goog-te-menu-frame:first').contents().find('.goog-te-menu2 a');
			langs.each(function(){
			var txtHtml = $(this).find('span.text').html();
			if (txtHtml == "한국어") {
				langs.eq($(this).index()).find('span.text').click();
			}
			});
		}
	}
	googleTrans.evtPageInit();*/
		
	var viewtag = "<span class='googleTranslate_i'>";
	for (var i in strArray)
	{
		var l = $.trim(strArray[i]);
		//if(lang_a.indexOf(l) >= 0)  {
			viewtag += "<a href='javascript:;' data-lang='"+l+"' class='"+l+"' title='"+lang_kr(l)+"'><span></span></a>";
		//}
	}
	/*	viewtag += "<a href='javascript:;' data-lang='ko' class='ko'><span></span></a>";
		viewtag += "<a href='javascript:;' data-lang='en' class='en'><span></span></a>";
		viewtag += "<a href='javascript:;' data-lang='ja' class='ja'><span></span></a>";
		viewtag += "<a href='javascript:;' data-lang='zh-CN' class='cn'><span></span></a>";
		viewtag += "<a href='javascript:;' data-lang='de' class='de'><span></span></a>";
		viewtag += "<a href='javascript:;' data-lang='fr' class='fr'><span></span></a>";*/
		viewtag += "</span>";
	return document.write(viewtag);
}

function googleTranslateElementInit() {//, layout: google.translate.TranslateElement.InlineLayout.SIMPLE
    new google.translate.TranslateElement({pageLanguage: 'ko', includedLanguages: 'ko,gl,gu,el,nl,ne,no,da,de,lo,lv,la,ru,ro,lb,lt,mr,mi,mk,mg,ml,ms,mt,mn,hmn,my,eu,vi,be,bn,bs,bg,sm,sr,ceb,st,so,sn,su,sw,sv,gd,es,sk,sl,sd,si,ar,hy,is,ht,ga,az,af,sq,am,et,eo,en,or,yo,ur,uz,uk,cy,ug,ig,yi,it,id,ja,jw,ka,zu,zh-CN,ny,cs,kk,ca,kn,co,xh,ku,hr,km,rw,ky,tl,ta,tg,tt,th,tr,te,tk,ps,pa,fa,pt,pl,fr,fy,fi,haw,ha,hu,iw,hi', autoDisplay: false, multilanguagePage: false}, 'google_translate_element');
}

$(document).ready(function() {
	/*$('.googleTranslate_i a').click(function(e) {
		e.preventDefault();
		var $frame = $('.goog-te-menu-frame:first');
		if (!$frame.size()) {
			alert("Error: Could not find Google translate frame.");
			return false;
		}

		var langs = $('.goog-te-menu-frame:first').contents().find('.goog-te-menu2 a');
		var $lang = $(this).data('lang'),
		
		$lang_txt = lang_kr($lang);
		
		langs.each(function(){
			var txtHtml = $(this).find('span.text').html();
			if (txtHtml == $lang_txt) {
				//langs.eq($(this).index()).find('span.text').click();
				$(this).find('span.text').click();
			}
		});
		return;
	});*/
	$('.googleTranslate_i a').click(function(e) {
		e.preventDefault();
		var gtcombo = document.querySelector('.goog-te-combo');
		var $lang = $(this).data('lang'),
		
		$lang_txt = lang_kr($lang);
		
		if (gtcombo == null) {
			alert("Error: Could not find Google translate Combolist.");
			return false;
		}
		gtcombo.value = $lang;
		gtcombo.dispatchEvent(new Event('change'));
		return;
	});
});
/* 구글 번역기 : 끝 */

if(typeof jQuery != 'undefined') {
	$(document).ready(function() {
		$("#textinput").find('img').each(function(){
			var img_alt = $(this).attr('alt');
			if(!img_alt) {
				$(this).attr('alt','본문이미지');
			}
		}); 
	});
}