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': 'Article',
'n_minValue' : minFontSz,
'n_maxValue' : maxFontSz,
'n_value' : n_value,
'n_fontHei' : n_fontHei,
'n_step' : 1
}

document.write("<table width=670 height=25 border=0 cellpadding=0 cellspacing=0><tr><td width=350 style=\"padding: 3px 0px 0px 18px;\" class='navi'><a href='http://careview.chosun.com'>Home</a> > ");
var catid_num = CatID.substring(0, 1);
var catid_num2 = CatID.substring(1, 2);
if (catid_num)
{
	if (catid_num == 1)
		{
		document.write("<a href='http://careview.chosun.com/car_news/index.html'>´º½º</a>");
			if (catid_num2 == 1){
			document.write(" > ÀÚµ¿Â÷</td>");}
			else if (catid_num2 == 2){
			document.write(" > ½ÅÂ÷´º½º</td>");}
			else if (catid_num2 == 3){
			document.write(" > ¾÷°è¼Ò½Ä</td>");}
			else if (catid_num2 == 4){
			document.write(" > ±âÈ¹´º½º</td>");}
			else {document.write("</td>");}
		}
	if (catid_num == 2)
		{
		document.write("<a href='http://careview.chosun.com/car_movie/index.html'>µ¿¿µ»ó</a>");
			if (catid_num2 == 1){
			document.write(" > ½Ã½Â¿µ»ó</td>");}
			else if (catid_num2 == 2){
			document.write(" > ±âÈ¹¿µ»ó</td>");}
			else if (catid_num2 == 3){
			document.write(" > ±¤°í¿µ»ó</td>");}
			else if (catid_num2 == 4){
			document.write(" > ·¹ÀÌ½Ì¸ðµ¨</td>");}
			else {document.write("</td>");}
		}
	if (catid_num == 3)
		{
		document.write("<a href='http://careview.chosun.com/car_photo/index.html'>Æ÷Åä</a>");
			if (catid_num2 == 1){
			document.write(" > ÀÚµ¿Â÷</td>");}
			else if (catid_num2 == 2){
			document.write(" > ·¹ÀÌ½Ì¸ðµ¨</td>");}
			else {document.write("</td>");}
		}
	if (catid_num == 4)
		{
		document.write("<a href='http://careview.chosun.com/common/notice/index.html'>°øÁö»çÇ×</a></td>");
		}
}
document.write("<td width=113 valign=bottom style=\"padding: 0px 0px 0px 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/car/200805/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/car/200805/icon_plus.gif border=0 style='cursor:pointer'></a></td></tr></table></td><td align=right valign=bottom style=\"padding: 0px 0px 0px 0px;\"><img src=http://image.chosun.com/car/200805/icon_email.gif> <a href=\"javascript:mailOpen()\">ÀÌ¸ÞÀÏ</a> <img src=http://image.chosun.com/car/200805/icon_print.gif> <a href=\"javascript:printOpen('')\">ÇÁ¸°Æ®</a> <img src=http://image.chosun.com/car/200805/icon_list.gif> <a href=\"javascript:goList()\">±â»ç¸ñ·Ï</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 ("/svc/news/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 ("/svc/news/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://careview.chosun.com/svc/list_in/list.html?catid=1&js_name=economy
var listnews = "http://careview.chosun.com/car_news/news_list.html";
var listmovie = "http://careview.chosun.com/car_movie/video_all_list.html";
var listphoto = "http://careview.chosun.com/car_photo/photo_all_list.html";
var listurl = "";
if (typeof(CatID) != "undefined") {
var catidif = CatID.substring(0,1)
	if (catidif == 1)
	{
	listurl = "http://careview.chosun.com/car_news/news_list.html?=rtab"+CatID;
	}
	if (catidif == 2)
	{
	listurl = "http://careview.chosun.com/car_movie/video_all_list.html?=rtab"+CatID;
	}
	if (catidif == 3)
	{
	listurl = "http://careview.chosun.com/car_photo/photo_all_list.html?=rtab"+CatID;
	}
	if (catidif == 4)
	{
	listurl = "http://careview.chosun.com/common/notice/index.html";
	}
}
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("Article")){
 fontObj[no] = document.getElementById("Article"); no++;
}
if(document.getElementsByName("Article")){
 for (fidx = 0; fidx < document.getElementsByName("Article").length; fidx++) {
   fontObj[no] = document.getElementsByName("Article")[fidx]; no++;
 }
}
if (arguments.length == 0) {
 for (i=0; i<fontObj.length; i++) {
  fontObj[i].style.fontSize = eval(nowFontSz) + "px" ;
  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_inputs;
	this.n_fontHei = eval(n_value)-eval(minFontSz)+eval(minFontHei);
	e_input = document.getElementById(this.s_name);
	e_inputs = document.getElementsByName(this.s_name);
	if (e_input != null) {
		e_input.style.fontSize = n_value + "px"; e_input.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";
		}
	}
}

// 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;
}
