// ============================ Cookie 관련 함수 =============================0
function delCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function setCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}
// ============================ Cookie 관련 함수 =============================0
//============================================================================0
//============================================================================
// ============================ Font 관련 함수 =============================
	
	//폰트크기 쿠키값 가져옴
	var article_fontSize = parseInt(getCookie("article_fontSize")); 		

    //페이지로드시 설정
   	function initFont() { 
        if ( (article_fontSize < 11) || (article_fontSize > 18) || (isNaN(article_fontSize) == true)) {
			article_fontSize = 11;	
		}
        
        setFont(article_fontSize);
	}
	
	//articleBody 콘트롤 폰트설정
	function setFont(article_fontSize) { 	
		//alert('폰트크기' + article_fontSize);
		document.getElementById("articleBody").style.fontSize = article_fontSize+"pt";
		setFontCookie(article_fontSize);
	}	
	
	//폰트크기 쿠키설정
	function setFontCookie(article_fontSize)
	{
		var expiry = new Date();
		var path = "/";
		var domain = ".yonhapnews.co.kr";
		//var domain = "localhost";
		var secure = "";

		expiry.setTime(expiry.getTime() + 90 * (24 * 60 * 60 * 1000));

		setCookie("article_fontSize", article_fontSize, expiry, path, domain, secure);
	}	
	
	//폰트키우기
	function fontPlus() {		
		//alert('+' + article_fontSize);
		if (article_fontSize < 17) {
			article_fontSize = article_fontSize + 1; 
			
			setFont(article_fontSize); 
		}
	}

    //폰트줄이기
	function fontMinus() {
		//alert('-' + article_fontSize);
		if (article_fontSize > 9) {
			article_fontSize = article_fontSize - 1; 
			
			setFont(article_fontSize); 
		}
	}	
// ============================ Font 관련 함수 =============================

// ========================== Font 관련 함수(EN) ===========================
	
	//폰트크기 쿠키값 가져옴
	//var article_fontSize = parseInt(getCookie("article_fontSize")); 		

    //페이지로드시 설정
   	function initFontEN() { 
          if ( (article_fontSize < 11) || (article_fontSize > 18) || (isNaN(article_fontSize) == true)) {
			article_fontSize = 11;	
		}
        
        setFontEN(article_fontSize);
	}
	
	//articleBody 콘트롤 폰트설정
	function setFontEN(article_fontSize) { 	
		//alert('폰트크기' + article_fontSize);
		document.getElementById("articleBody").style.fontSize = article_fontSize+"pt";
		setFontCookieEN(article_fontSize);
	}	
	
	//폰트크기 쿠키설정
	function setFontCookieEN(article_fontSize)
	{
		var expiry = new Date();
		var path = "/";
		var domain = ".yonhapnews.co.kr";
		//var domain = "localhost";
		var secure = "";

		expiry.setTime(expiry.getTime() + 90 * (24 * 60 * 60 * 1000));

		setCookie("article_fontSize", article_fontSize, expiry, path, domain, secure);
	}	
	
	//폰트키우기
	function fontPlusEN() {		
		//alert('+' + article_fontSize);
		if (article_fontSize < 17) {
			article_fontSize = article_fontSize + 1; 
			
			setFontEN(article_fontSize); 
		}
	}

    //폰트줄이기
	function fontMinusEN() {
		//alert('-' + article_fontSize);
		if (article_fontSize > 10) {
			article_fontSize = article_fontSize - 1; 
			
			setFontEN(article_fontSize); 
		}
	}	
// ========================== Font 관련 함수(EN) ===========================

//프린트뷰어작업
function sendprint(pagepart, contents_id)
{
	var sWinName = "printarticle";
	var cScroll = 1;
	var cResize = 1;
	var cTool = 1;
	var sWinopts = 'left='+0+', top='+0+', width='+655+', scrollbars='+cScroll+', resizable='+cResize;
	
	var fileurl = '';
        
        
    if(contents_id.substring(1,3)=="KR")
        {
		if(pagepart == 'article')  
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showArticlePrintView.aspx?contents_id=' + contents_id;
		else if(pagepart == 'press')
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showPressPrintView.aspx?contents_id=' + contents_id;
        }
	else if(contents_id.substring(1,3)=="AR")
	{
		if(pagepart == 'article')  
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showARArticlePrintView.aspx?contents_id=' + contents_id;
		else if(pagepart == 'press')
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showPressPrintView.aspx?contents_id=' + contents_id;
		else if(pagepart == 'search')
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showEnSearchPrintView.aspx?contents_id=' + contents_id;
        }
  else if(contents_id == "AEN20101231005400315")
  	{
  		fileurl = 'http://english.yonhapnews.co.kr/jscript/EnPrint.html';
  	}
	else if(contents_id.substring(1,3)=="EN")
	{
		if(pagepart == 'article')  
			//fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showEnArticlePrintView.aspx?contents_id=' + contents_id;
			fileurl = 'http://english.yonhapnews.co.kr/jscript/EnPrint.html';
			
		else if(pagepart == 'search')
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showEnSearchPrintView.aspx?contents_id=' + contents_id;
    }
	else
	{
		if(pagepart == 'article')  
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showEnArticlePrintView.aspx?contents_id=' + contents_id;
		else if(pagepart == 'press')
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showPressPrintView.aspx?contents_id=' + contents_id;
		else if(pagepart == 'search')
			fileurl = 'http://app.yonhapnews.co.kr/YNA/Basic/Article/Print/YIBW_showEnSearchPrintView.aspx?contents_id=' + contents_id;
        }
	window.open(fileurl, sWinName, sWinopts);
}

//판매인터페이스로 이동함
function sendsales(salesurl, contentsId)
{
   //--판매URL--
   var urlsales = salesurl + 
                'contentsid=' + contentsId + '&memberid=' + getCookie('YNA_MEMBER_ID') + '&mode=basic&MenuId='; 
   //--판매URL-- 
    
   window.open(urlsales, 'Buy', 'width=800, height=600, resizeble=no, scrollbars=yes, toolbar=no, status=yes, menubar=no');
}

