var nowFontSz = 13, nowFontHei = 21 ; // À§ CSSÀÇ article°ú °°Àº Font Å©±â
var minFontSz = 12, maxFontSz = 22, minFontHei = 20;
var ckFontSz = "mzFontSz";
var dzFontSz, dzFontHei;
dzFontSz = getDzCookie(ckFontSz);
var n_value = nowFontSz, n_pathLeft = 13, n_fontHei = nowFontHei;
if (dzFontSz != null && dzFontSz != "") {
 if (dzFontSz.indexOf("^")!=-1) {
  var arr = dzFontSz.split("^");
  if (arr.length==2) {dzFontSz=arr[0]; dzFontHei=arr[1];}
  n_value = dzFontSz; n_pathLeft = eval(n_value-minFontSz)*5-((dzFontSz > 14) ? 5 : 0); n_fontHei = dzFontHei;
 }
 else {
  n_value = dzFontSz; n_pathLeft = eval(n_value-minFontSz)*5-((dzFontSz > 14) ? 5 : 0); n_fontHei = dzFontHei;
 }
}

var A_TPL5h = {
'b_vertical' : false,
'b_watch': true,
'n_controlWidth': 53,
'n_controlHeight': 13,
'n_sliderWidth': 10,
'n_sliderHeight': 12,
'n_pathLeft' : 0,
'n_pathTop' : 3,
'n_pathLength' : 43,
's_imgControl': 'http://image.chosun.com/cs/200708/images/text_bar.gif',
's_imgSlider': 'http://image.chosun.com/cs/200708/images/text_drag.gif',
'n_zIndex': 1
}
var A_INIT5h = {
's_form' : 0,
's_name': 'ArticlePar01',
's_name2': 'ArticlePar02',
'n_minValue' : minFontSz,
'n_maxValue' : maxFontSz,
'n_value' : n_value,
'n_fontHei' : n_fontHei,
'n_step' : 1
}

function popup_focus () {
	var w_url = 'http://image.chosun.com/cs/200712/focus_guide.html';
	window.open(w_url,'graph', 'menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,width=566,height=765,top=0,left=0');
}

document.write("<table width=670 height=30 border=0 cellpadding=0 cellspacing=0><tr><td width=115 style=\"padding: 0px 0px 5px 10px;\" valign=bottom><img src=http://image.chosun.com/cs/200708/images/icon_100.gif align=absmiddle> <a href=#bbs><font color=#c8292a><b>100ÀÚÆò¾²±â</b>(<span id='BBSCNT'>0</span>)</font></a></td><td width=113 valign=bottom style=\"padding: 0px 0px 5px 0px;\"><table align=left width=113 height=16 border=0 cellpadding=0 cellspacing=0><tr><td width=30><a href=\"javascript:fontSz('-');\"><img src=http://image.chosun.com/cs/200708/images/icon_minus.gif border=0 style='cursor:pointer'></a></td><td valign=top>");
new slider(A_INIT5h, A_TPL5h);
document.write("</td><td width=30 align=right><a href=\"javascript:fontSz('+');\"><img src=http://image.chosun.com/cs/200708/images/icon_plus.gif border=0 style='cursor:pointer'></a></td></tr></table></td><td align=right valign=bottom style=\"padding: 0px 0px 5px 0px;\"><img src=http://image.chosun.com/cs/200708/images/icon_email.gif> <a href=\"javascript:mailOpen()\">ÀÌ¸ÞÀÏ</a> <img src=http://image.chosun.com/cs/200708/images/icon_print.gif> <a href=\"javascript:printOpen('')\">ÇÁ¸°Æ®</a> <img src=http://image.chosun.com/cs/200708/images/icon_list.gif> <a href=\"javascript:goList()\">±â»ç¸ñ·Ï</a> <a href='http://rssplus.chosun.com/'><img src=http://image.chosun.com/cs/200805/images/rss.gif align=absmiddle></a> <a href=\"javascript:printOpen('text')\"><img src=http://image.chosun.com/cs/200708/images/btn_article.gif align=absmiddle></a>  <a onclick='javascript:popup_focus()' style='cursor:hand'><img src='http://image.chosun.com/cs/200712/images/focus_btn.gif' align=absmiddle></a></td></tr></table>");

function getDzCookie(name) {
var cookies = document.cookie;
var value  = "";
if(cookies.indexOf(name) != -1) {
var start = cookies.indexOf(name) + name.length + 1;
var end   = cookies.indexOf(";",start);

if(end == -1) end = cookies.length;
value = cookies.substring(start,end);
value = unescape(value);
}
return value;
}

//ÇÁ¸°Æ®
function printOpen(type) {
windowOpen ("http://books.chosun.com/svc/printContent.html?type="+type, 615, 550, 'yes');
}
//ÀÌ¸ÞÀÏ
function mailOpen() {
if(!getDzCookie('SMSESSION') || getDzCookie('SMSESSION') == "LOGGEDOFF" || !getDzCookie('SM_USER') || !getDzCookie('dz_info')) {
alert('±â»ç ÀÌ¸ÞÀÏº¸³»±â ±â´ÉÀº ·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
location.href = "http://membership.chosun.com/login/protect_sso/sso_user_info.jsp?returl=" + escape(location.href);
return false;
}
windowOpen ("http://books.chosun.com/svc/sendContent.html", 480, 500, 'no');
}

function windowOpen (url, width, height, isresize) {
winopen=window.open(url, 'pbml_win','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars='+isresize+',width='+width+',height='+height);
}

//±â»ç¸ñ·Ï
function goList () {
//http://books.chosun.com/svc/list.html
var listurl = "http://books.chosun.com/svc/list.html";
if (typeof(CatID) != "undefined") {
if (CatID == "1B")
listurl = "http://books.chosun.com/svc/list.html";
else
listurl += "?catid="+CatID; if (typeof(CatCODE) != "undefined") listurl += "&js_name"+CatCODE;
}
location.href = listurl;
}

//¼³Á¤µÈ±ÛÀÚÅ©±â
if (dzFontSz != null && dzFontSz != "") {
 nowFontSz = dzFontSz;
 nowFontHei = dzFontHei;
 //fontSz(dzFontSz,dzLineHei);
 setTimeout("fontSz()",1000);
 setTimeout("fontSz()",2000);
}

//±ÛÀÚÅ©±âÁ¶Àý
function fontSz(){
var no=0;
var fontObj = new Array();
if(document.getElementById("ArticlePar01")){
 fontObj[no] = document.getElementById("ArticlePar01"); no++;
}
if(document.getElementById("ArticlePar02")){
 fontObj[no] = document.getElementById("ArticlePar02"); no++;
}
if(document.getElementsByName("ArticlePar01")){
 for (fidx = 0; fidx < document.getElementsByName("ArticlePar01").length; fidx++) {
   fontObj[no] = document.getElementsByName("ArticlePar01")[fidx]; no++;
 }
}
if(document.getElementsByName("ArticlePar02")){
 for (fidx = 0; fidx < document.getElementsByName("ArticlePar02").length; fidx++) {
   fontObj[no] = document.getElementsByName("ArticlePar02")[fidx]; no++;
 }
}
if (arguments.length == 0) {
 for (i=0; i<fontObj.length; i++) {
  fontObj[i].style.fontSize = eval(nowFontSz) + "px" ;
  if (nowFontHei != "" && nowFontHei != null)
   fontObj[i].style.lineHeight = eval(nowFontHei) + "px" ;
 }
}
else {
var o_slider = window.A_SLIDERS[0];
if (arguments[0] == "-"){
 if (nowFontSz <= minFontSz) return ;
 nowFontSz = eval(nowFontSz)-1;
 nowFontHei = eval(nowFontHei)-1;
 for(i=0;i<fontObj.length;i++){
  fontObj[i].style.fontSize = nowFontSz + "px" ;
  fontObj[i].style.lineHeight = nowFontHei + "px" ;
 }
 o_slider.f_setValue(nowFontSz, null);
}
else if (arguments[0] == "+"){
 if (nowFontSz >= maxFontSz) return ;
 nowFontSz = eval(nowFontSz)+1;
 nowFontHei = eval(nowFontHei)+1;
 for(i=0;i<fontObj.length;i++){
  fontObj[i].style.fontSize = nowFontSz + "px" ;
  fontObj[i].style.lineHeight = nowFontHei + "px" ;
 }
 o_slider.f_setValue(nowFontSz, null);
}  
// ResizeµÈ FontÀÇ °ªÀ» ÄíÅ°¿¡ Àû¿ë
setCookies ();
}
}

function setCookies () {
var expTime = new Date() ;
expTime.setTime(expTime.getTime()+(24*60*60*1000*365)) ; // 365??¡Æ? ??¢¯?
if (arguments.length == 2) {
document.cookie = ckFontSz + "=" + arguments[0]+"^"+arguments[1]+"; path=/; domain=chosun.com; expires=" + expTime.toGMTString() ;
}
else {
document.cookie = ckFontSz + "=" + nowFontSz+"^"+nowFontHei+"; path=/; domain=chosun.com; expires=" + expTime.toGMTString() ;
}
}

// Title: tigra slider control
// Tech. Support: http://www.softcomplex.com/forum/
function slider (a_init, a_tpl) {
	this.f_setValue  = f_sliderSetValue;
	this.f_getPos    = f_sliderGetPos;
	
	// register in the global collection	
	if (!window.A_SLIDERS)
		window.A_SLIDERS = [];
	this.n_id = window.A_SLIDERS.length;
	window.A_SLIDERS[this.n_id] = this;

	// save config parameters in the slider object
	var s_key;
	if (a_tpl)
		for (s_key in a_tpl)
			this[s_key] = a_tpl[s_key];
	for (s_key in a_init)
		this[s_key] = a_init[s_key];

	this.n_pix2value = this.n_pathLength / (this.n_maxValue - this.n_minValue);
	if (this.n_value == null)
		this.n_value = this.n_minValue;

	// generate the control's HTML
	document.write(
		'<div style="width:' + this.n_controlWidth + 'px;height:' + this.n_controlHeight + 'px;border:0; background-image:url(' + this.s_imgControl + ')" id="sl' + this.n_id + 'base">' +
		'<img src="' + this.s_imgSlider + '" width="' + this.n_sliderWidth + '" height="' + this.n_sliderHeight + '" border="0" style="position:relative;left:' + n_pathLeft + 'px;top:' + this.n_pathTop + 'px;z-index:' + this.n_zIndex + ';cursor:hand;visibility:hidden;" name="sl' + this.n_id + 'slider" id="sl' + this.n_id + 'slider" onmousedown="return f_sliderMouseDown(' + this.n_id + ')"/></div>'
	);
	this.e_base   = document.getElementById('sl' + this.n_id + 'base');
	this.e_slider = document.getElementById('sl' + this.n_id + 'slider');
	
	// safely hook document/window events
	if (document.onmousemove != f_sliderMouseMove) {
		window.f_savedMouseMove = document.onmousemove;
		document.onmousemove = f_sliderMouseMove;
	}
	if (document.onmouseup != f_sliderMouseUp) {
		window.f_savedMouseUp = document.onmouseup;
		document.onmouseup = f_sliderMouseUp;
	}
	// preset to the value in the input box if available
	this.e_slider.style.visibility = 'visible';
}

function f_sliderSetValue (n_value, b_noInputCheck) {
	if (n_value == null)
		n_value = this.n_value == null ? this.n_minValue : this.n_value;
	if (isNaN(n_value))
		return false;
	// round to closest multiple if step is specified
	if (this.n_step)
		n_value = Math.round((n_value - this.n_minValue) / this.n_step) * this.n_step + this.n_minValue;
	// smooth out the result
	if (n_value % 1)
		n_value = Math.round(n_value * 1e5) / 1e5;

	if (n_value < this.n_minValue)
		n_value = this.n_minValue;
	if (n_value > this.n_maxValue)
		n_value = this.n_maxValue;

	this.n_value = n_value;

	// move the slider
	//alert (this.b_vertical);
	if (this.b_vertical)
		this.e_slider.style.top  = (this.n_pathTop + this.n_pathLength - Math.round((n_value - this.n_minValue) * this.n_pix2value)) + 'px';
	else
		this.e_slider.style.left = (this.n_pathLeft + Math.round((n_value - this.n_minValue) * this.n_pix2value)) + 'px';

	// save new value
	var e_input, e_input2, e_inputs, e_input2s;
	this.n_fontHei = eval(n_value)-eval(minFontSz)+eval(minFontHei);
	e_input = document.getElementById(this.s_name);
	e_input2 = document.getElementById(this.s_name2);
	e_inputs = document.getElementsByName(this.s_name);
	e_input2s = document.getElementsByName(this.s_name2);
	if (e_input != null) {
		e_input.style.fontSize = n_value + "px"; e_input.style.lineHeight = this.n_fontHei + "px";
	}
	if (e_input2 != null) {
		e_input2.style.fontSize = n_value + "px"; e_input2.style.lineHeight = this.n_fontHei + "px";
	}
	if (e_inputs != null) {
		for (eidx = 0; eidx < e_inputs.length; eidx++) {
			e_inputs[eidx].style.fontSize = n_value + "px"; e_inputs[eidx].style.lineHeight = this.n_fontHei + "px";
		}
	}
	if (e_input2s != null) {
		for (eidx = 0; eidx < e_input2s.length; eidx++) {
			e_input2s[eidx].style.fontSize = n_value + "px"; e_input2s[eidx].style.lineHeight = this.n_fontHei + "px";
		}			
	}
}

// get absolute position of the element in the document
function f_sliderGetPos (b_vertical, b_base) {
	var n_pos = 0,
		s_coord = (b_vertical ? 'Top' : 'Left');
	var o_elem = o_elem2 = b_base ? this.e_base : this.e_slider;
	
	while (o_elem) {
		n_pos += o_elem["offset" + s_coord];
		o_elem = o_elem.offsetParent;
	}
	o_elem = o_elem2;

	var n_offset;
	while (o_elem.tagName != "BODY") {
		n_offset = o_elem["scroll" + s_coord];
		if (n_offset)
			n_pos -= o_elem["scroll" + s_coord];
		o_elem = o_elem.parentNode;
	}
	return n_pos;
}

function f_sliderMouseDown (n_id) {
//alert('1');
	window.n_activeSliderId = n_id;
	return false;
}

function f_sliderMouseUp (e_event, b_watching) {
	if (window.n_activeSliderId != null) {
		var o_slider = window.A_SLIDERS[window.n_activeSliderId];
		o_slider.f_setValue(o_slider.n_minValue + (o_slider.b_vertical
			? (o_slider.n_pathLength - parseInt(o_slider.e_slider.style.top) + o_slider.n_pathTop)
			: (parseInt(o_slider.e_slider.style.left) - o_slider.n_pathLeft)) / o_slider.n_pix2value);
		if (b_watching)	return;
		window.n_activeSliderId = null;

		setCookies (o_slider.n_value, o_slider.n_fontHei);
	}
	if (window.f_savedMouseUp)
		return window.f_savedMouseUp(e_event);
}

function f_sliderMouseMove (e_event) {

	if (!e_event && window.event) e_event = window.event;

	// save mouse coordinates
	if (e_event) {
		window.n_mouseX = e_event.clientX + f_scrollLeft();
		window.n_mouseY = e_event.clientY + f_scrollTop();
	}

	// check if in drag mode
	if (window.n_activeSliderId != null) {
		var o_slider = window.A_SLIDERS[window.n_activeSliderId];

		var n_pxOffset;
		if (o_slider.b_vertical) {
			var n_sliderTop = window.n_mouseY - o_slider.n_sliderHeight / 2 - o_slider.f_getPos(1, 1) - 3;
			// limit the slider movement
			if (n_sliderTop < o_slider.n_pathTop)
				n_sliderTop = o_slider.n_pathTop;
			var n_pxMax = o_slider.n_pathTop + o_slider.n_pathLength;
			if (n_sliderTop > n_pxMax)
				n_sliderTop = n_pxMax;
			o_slider.e_slider.style.top = n_sliderTop + 'px';
			n_pxOffset = o_slider.n_pathLength - n_sliderTop + o_slider.n_pathTop;
		}
		else {
			var n_sliderLeft = window.n_mouseX - o_slider.n_sliderWidth / 2 - o_slider.f_getPos(0, 1) - 3;
			// limit the slider movement
			if (n_sliderLeft < o_slider.n_pathLeft)
				n_sliderLeft = o_slider.n_pathLeft;
			var n_pxMax = o_slider.n_pathLeft + o_slider.n_pathLength;
			if (n_sliderLeft > n_pxMax)
				n_sliderLeft = n_pxMax;
			o_slider.e_slider.style.left = n_sliderLeft + 'px';
			n_pxOffset = n_sliderLeft - o_slider.n_pathLeft;
		}
		if (o_slider.b_watch)
			 f_sliderMouseUp(e_event, 1);

		return false;
	}
	
	if (window.f_savedMouseMove)
		return window.f_savedMouseMove(e_event);
}

// get the scroller positions of the page
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_sliderError (n_id, s_message) {
	alert("Slider #" + n_id + " Error:\n" + s_message);
	window.n_activeSliderId = null;
}