try{document.domain = 'daum.net';}catch(e){}
try {document.execCommand("BackgroundImageCache",false,true);}catch(e){}
var UI={};
function $A(iterable){if (!iterable) return [];var results = [];for (var i = 0, length = iterable.length; i < length; i++) results.push(iterable[i]);return results;}
Object.extend=function(a, b){
  for (var property in b) a[property] = b[property];
  return a;
};
Function.prototype.bind = function() {
	var __method = this, args = $A(arguments), object = args.shift();
	return function() {
		return __method.apply(object, args.concat($A(arguments)));
	}
}
Function.prototype.bindAsEventListener = function() {
	var __method = this, args = $A(arguments), object = args.shift();
	return function(event) {
		return __method.apply(object, [event || window.event].concat(args));
	}
}
UI.$ = function(id) {if(typeof(id)!="object") return document.getElementById(id); else return id;};
UI.trim=function(s) {return s.replace(/(^\s*)|(\s*$)/g, "") };
UI.toggle=function(id) { UI.$(id).style.display=(UI.getStyle(UI.$(id),'display')=='none') ? 'block':'none' };
UI.getEl=function(e){var E=UI.getE(e);return E.target || E.srcElement}
UI.getE=function(e){return e || window.event}
UI.random=function(min, max){ return Math.floor(Math.random() * (max - min + 1) + min) };
UI.addClassName = function(e, className) {
	var e = UI.$(e);		
	if(e!=undefined) {
		if(e.className.indexOf(className)==-1) {e.className += " " + className};
	}
};
UI.replaceClassName = function(e, oldName, newName) {
	var e = UI.$(e);
	if(e.className.indexOf(e.className)!=-1) {						
		e.className = e.className.replace(oldName,newName);
	}
};
UI.removeClassName = function(e, className) {
	var e = UI.$(e);
	if(e.className.indexOf(e.className)!= -1) {						
		e.className = UI.trim(e.className.replace(className,"")); 
	}
};
UI.addEvent=function(object, type, listener) {	
	if(object.addEventListener) {if(type=='mousewheel')type='DOMMouseScroll'; object.addEventListener(type, listener, false)}
	else { object.attachEvent("on"+type, listener); }
};
UI.delEvent=function(object, type, listener){
	if (object.removeEventListener) {if(type=='mousewheel')type='DOMMouseScroll'; object.removeEventListener(type, listener, false)}
	else object.detachEvent('on'+type, listener);
};
UI.stopEvent=function(event) {
	var e=event || window.event;
	if(e.preventDefault) {e.preventDefault(); e.stopPropagation(); }
	else {e.returnValue = false; e.cancelBubble = true;}
};
UI.getEventWheel=function(e){
	var delta=0;
	if(e.wheelDelta) delta=e.wheelDelta/120;
	else if(e.detail) delta=-e.detail/3;
	return delta;
};
UI.getBrowser=function(){
	var ua=navigator.userAgent.toLowerCase();
	var opera=/opera/.test(ua)
	UI._browser={
		ie:!opera && /msie/.test(ua),
		ie_ver: parseFloat(((ua.split('; '))[1].split(' '))[1]),
		opera:opera,
		ff:/firefox/.test(ua),
		gecko:/gecko/.test(ua)		
	};
	return UI._browser;
};
UI.resizeIframe=function(iframe_id) {
	var h = (self.innerHeight) ? document.documentElement.offsetHeight : document.body.scrollHeight;
	try{parent.UI.$(iframe_id).style.height = h+"px";}catch(e){}
};
UI.rollOver=function(s) {
	var img=(typeof(s)=="string") ? img=UI.$(s):s;
	img.onmouseover=function() { UI.rollOver.over(img) }
	img.onmouseout=function() { UI.rollOver.out(img) }
}
UI.rollOver.over=function(img){ var src=img.src; img.src=src.replace("_off.","_on."); }
UI.rollOver.out=function(img){ var src=img.src; img.src=src.replace("_on.","_off."); };

UI.popUp=function(url,name,w,h,scroll,resize,status,center){
	if(!scroll) scroll=0;
	if(!resize) resize=0;
	if(!status) status=1;
	if(center)	
	{
		var x = (screen.width - w) / 2;
		var y = (screen.height - h) / 2;
		center = ",top="+y+",left="+x;
	}
	return window.open(url,name,"width="+w+",height="+h+",status="+status+",resizable="+resize+",scrollbars="+scroll+center);
};
UI.setCookie=function(name, value, expires, path, domain, secure){
	if(expires)//day로 설정
	{
		var d=new Date(); d.setDate(d.getDate()+expires);
		expires = d.toGMTString();
	}
	document.cookie = name + "=" + escape(value) +
	  ((expires) ? "; expires=" + expires : "") +
	  ((path) ? "; path=" + path : "") +
	  ((domain) ? "; domain=" + domain : "") +
	  ((secure) ? "; secure" : "");
};
UI.getCookie=function(name){
	name += "=";
	cookie = document.cookie + ";";
	start = cookie.indexOf(name);
	if (start != -1)
	{
		end = cookie.indexOf(";",start);
		//return unescape(cookie.substring(start + name.length, end));
		return cookie.substring(start + name.length, end);
	}
	return "";
};

UI.embedSWF=function(f,w,h,options){
	var param={	id:"UIswf_"+f,quality:'high',bgcolor:'#ffffff',allowScriptAccess:'always'}
	Object.extend(param, options);

	var id='id="'+param.id+'"';
	var name = 'name="'+param.id+'"';
	var p='',e='';	

	for(i in param) 
	{
		if(i=='id')continue;
		p+='<param name="'+i+'" value="'+param[i]+'">\n';
		e+=i+'="'+param[i]+'" ';
	}
	var s='<object '+id+' width="'+w+'" height="'+h+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">';
	s+='<param name="movie" value="'+f+'">'+ p;	
	s+='<embed '+name+' src="'+f+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" '+e+'/>';
	s+='</object>';
	document.write(s);
	return s;
};

UI.embedWMP=function(f,w,h,options){
	var param={	id:"UIwmp_"+f,autostart:'1',showstatusbar:'-1',transparentatstart:'1',displaybackcolor:'0',uimode:'full'}
	Object.extend(param, options);

	var id='id="'+param.id+'" name="'+param.id+'"';
	var p='',e='';
	for(i in param) 
	{
		if(i=='id')continue;
		p+='<param name="'+i+'" value="'+param[i]+'">\n';
		e+=i+'="'+param[i]+'" ';
	}
	var s='<object '+id+' width="'+w+'" height="'+h+'" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" style="filter:gray();">';
	s+='<param name="filename" value="'+f+'">'+ p;
	s+='<embed '+id+' src="'+f+'" width="'+w+'" height="'+h+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/mediaplayer/" '+e+' />';
	s+='</object>';
	document.write(s);
};
UI.getStyle=function(el, style) {
	var value = el.style[style];
	if(!value)
	{
		if(document.defaultView && document.defaultView.getComputedStyle) 
		{
			var css = document.defaultView.getComputedStyle(el, null);
			value = css ? css[style] : null;
		} 
		else if (el.currentStyle) value = el.currentStyle[style];
	}
	return value == 'auto' ? null : value;
};
UI.getPosition=function(el)
{
	var left=0,top=0;
	while(el)
	{
		left+=el.offsetLeft || 0;
		top+=el.offsetTop || 0;
		el=el.offsetParent;
	}
	return {'x': left, 'y': top}
};
UI.getScroll=function () {
	if(document.all && typeof document.body.scrollTop != "undefined")
	{
		var cont=document.compatMode!="CSS1Compat"?document.body:document.documentElement;
		return {left:cont.scrollLeft, top:cont.scrollTop, width:cont.clientWidth, height:cont.clientHeight}
	}
	else 
		return {left:window.pageXOffset, top:window.pageYOffset, width:window.innerWidth, height:window.innerHeight}
};
UI.submit=function(f) { 
	var form=UI.$(f)||document.forms[f];	
	if(form.onsubmit && !form.onsubmit()) return;
	form.submit();
};
UI.focus=function(n) { 
	var s=null;
	s = UI.$(n)||document.getElementsByName(n)[0];
	s.focus();
};
UI.$F=function(n) {
	var s=null;
	s = UI.$(n)||document.getElementsByName(n)[0];
	if(s.type=="checkbox")
	{
		var c=[];
		var r=document.getElementsByName(n);
		for(var i=0;i<r.length; i++) if(r[i].checked) c.push(r[i].value);
		return (c.length>0)?c:""; 
	}
	else if(s.type=="radio")
	{
		var r=document.getElementsByName(n);
		for(var i=0;i<r.length; i++) if(r[i].checked) return r[i].value;
		return "";
	}
	return s.value;
};
UI.length=function(str,len,tail){
	if(!tail) tail="";
	var l=0, c=0, l2=0, u="", s="";
	if(len>0) l2=len;	
	for(var i=0;u=str.charCodeAt(i);i++)
	{
		if (u>127) l+=2;
		else l++;
		if(l2) {
			s+=str.charAt(i); 
			if(l>=l2)
			{
				if(l>l2) s=s.slice(0,-1);
				return s+tail;
			}
		}		
	}
	return l2 ? s:l;
};
UI.html2str=function(s,m){
	var s1=["&amp;","&#39;","&quot;","&lt;","&gt;"];
	var s2=["&","'","\"","<",">"];
	var s3=[];
	if(m) {s3=s1;s1=s2;s2=s3;}
	for(var i in s1) s=s.replace(new RegExp(s1[i],"g"), s2[i]);
	return s;
};
UI.setOpacity=function(el,value){
	el.style.filter="alpha(opacity="+value+")";
	el.style.opacity=(value/100);
	el.style.MozOpacity=(value/100);
	el.style.KhtmlOpacity=(value/100);
};
UI.indexOf=function(arr,s){
	for(var i=0;i<arr.length; i++) if(arr[i]==s) return i;
	return -1;
};
UI.resizeImage=function(img,w,h){
	var t = new Image();
	t.src=img.src;	
	if(t.width==0 || t.height==0) return;
	if(t.width>w || t.height >h)
	{
		img.width=w;img.height=h;
		if((t.width/w) > (t.height/h) )	img.height=Math.round(t.height * (w / t.width));
		else img.width = Math.round(t.width *  (h / t.height));
	}
	else
	{
		img.width=t.width;
		img.height=t.height;
	}
	if(img.width==0 || img.height==0) setTimeout(function(){UI.resizeImage(img,w,h)},500);
};
UI.StringBuffer=function(){this.buffer=new Array()}
UI.StringBuffer.prototype={append:function(s){this.buffer.push(s)},toString:function(){return this.buffer.join("")}};
UI.parseQuery=function(s){
	var str=s||location.search.substr(1);
	var r={},t=[];
	var a=str.split('&');
	for(var i=0;i<a.length;i++){t=a[i].split("=");r[t[0]] = t[1];}
	return r;
};
UI.addComma=function(s){
	s+='';
	var re = new RegExp('(-?[0-9]+)([0-9]{3})'); 
	while(re.test(s)) s = s.replace(re, '$1,$2'); 
	return s;
}; 

UI.Ajax = function(options) {
	this.options={
		method:'GET',
		param:'',
		onComplete:null,
		onError:null,
		asynchronous: true,
		contentType: 'application/x-www-form-urlencoded',
		encoding:'UTF-8'
	}
	Object.extend(this.options, options);
	if(this.options.url) this.send();
};
UI.Ajax.prototype={
	getReq:function(){
		var req=null;
		try { req = new XMLHttpRequest(); }
		catch(e)
		{
			try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch(e)
			{
				try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
				catch(e) { }
			}
		}
		return req;
	},
	send:function(){
		this.req = this.getReq();	
		var op=this.options;
		var url=op.url;
		var param=op.param;
		var method=op.method.toUpperCase();
		if(method=='GET' && param) url=url+"?"+param;
		this.req.open(method, url, op.asynchronous);
		this.req.setRequestHeader('Content-Type', op.contentType+';charset='+op.encoding);
		
		var self = this;
		this.req.onreadystatechange = function() { self.onStateChange.call(self) }
		this.req.send(method=='POST'?param:null);
	},
	onStateChange: function() {
		if(this.req.readyState==4)
		{
			if(this.req.status=="200") this.options.onComplete(this.req);
			else
			{
				if(this.options.onError) this.options.onError(this.req);
//				else alert("서버에러입니다! 잠시후에 다시 시도하세요! "+this.req.status);
			}				
		}
	}
};


/* 2007-07-10 */
UI.Radio = function(name)
{
	this.img_on = "http://img-contents.daum-img.net/book/2008_home/book_detail/bt_check_on.gif";
	this.img_off = "http://img-contents.daum-img.net/book/2008_home/book_detail/bt_check_off.gif";
	this.radio = {};
	this.checked_id = "";
	var self=this;

	var ra = null,img=null;
	var cid = "";
	for(var i=0; i<document.getElementsByName(name).length; i++)
	{
		ra = document.getElementsByName(name)[i];
		cid =ra.id;
		img=ra.parentNode.insertBefore(document.createElement('img'), ra);

		img.src = this.img_off;
		if(ra.checked)
		{
			img.src = this.img_on;
			this.checked_id = cid;
		}
		
		img.cid = cid;
		img.onclick = function() {
			self.select(this.cid);
			if(self.radio[this.cid].ra.onclick) self.radio[this.cid].ra.onclick();
		};
		ra.style.display="none";
		this.radio[cid] = {ra:ra, img:img};
	}
};
UI.Radio.prototype={
	select : function(cid) {
		this.radio[cid].img.src = this.img_on;
		this.radio[cid].ra.checked=true;
		if(this.checked_id && this.checked_id!=cid) this.radio[this.checked_id].img.src = this.img_off;
		this.checked_id=cid;
	},
	showValue : function() {
		return this.radio[this.checked_id].ra.value;
	}
};


/* 
2007-07-10 

2007-10-10
기능개선
2007-12-04
form으로 value안넘어가는 문제해결 (input 명 중복)
2007-12-11
print() html string 변수 선언 수정

2008-01-17
전체적인 소스변경 (키보드 조작가능,접근성 강화)
*/
UI.Select = function(id,skin){
	this.skin={
		topbox:'border:1px solid #808080;width:200px;',
		subbox:'border:1px solid #808080;width:200px;background-color:#fff',
		default_txt:'color:#000;background-color:#fff;',
		selected_txt:'color:#fff;background-color:#446688;',
		arrow:'<img src="http://img-section.hanmail.net/sports2/arrow_select02.gif" width="15" height="14" border="0">',
		padding:2
	};
	Object.extend(this.skin, skin);

	this.input=UI.$(id);
	this.length=this.input.length;
	this.id=id;
	this.list=[];
	this.isopen=0;
	this.selectedIndex=0;
	this.prevSelectedIndex=0;
	this.moveSelectedIndex=0;//keydown
	this.value='';
	this.topBox= null;
	this.subBox= null;
	this.selBox= null;

	this.print();
};
UI.Select.prototype={
	close:function(){
		if(!this.isopen) return;
		this.subBox.style.display='none';
		this.isopen=0;
		this.focus();
	},
	blur:function(){
		this.selBox.className='default_txt';
	},	
	focus:function(){
		if(this.isopen) return;
		this.selBox.className='selected_txt';
	},
	open:function(){
		if(this.isopen) return;	
		if(UI.Select._openObj) 
		{
			UI.Select._openObj.close();
			UI.Select._openObj.blur();
		}
		this.subBox.style.display='block';
		this.blur();
		this.subBox.getElementsByTagName('DIV')[this.selectedIndex].className='selected_txt';
		this.moveSelectedIndex=this.selectedIndex;
		UI.Select._openObj=this;
		this.isopen=1;		
	},
	toogle:function(e){
		if(this.isopen)	this.close();
		else this.open();
		UI.stopEvent(e);
	},
	subOver:function(e){
		this.el=UI.getEl(e)
		this.subBox.getElementsByTagName('DIV')[this.selectedIndex].className='default_txt';
		this.el.className='selected_txt';
	},
	subOut:function(e){
		this.el=UI.getEl(e)
		this.el.className='default_txt';
	},
	onchange:function(){
		if(this.prevSelectedIndex != this.selectedIndex && this.input.onchange) 
		{
			this.input.onchange.call(this);	
		}
	},
	selected:function(isChange){
		this.value=this.list[this.selectedIndex].value;
		this.selBox.value=this.list[this.selectedIndex].text;
		UI.$(this.id).value=this.list[this.selectedIndex].value; //select input
		if(isChange) this.onchange();
		this.prevSelectedIndex=this.selectedIndex;
	},
	subClick:function(e){
		this.el=UI.getEl(e);
		this.selectedIndex=this.el.index;
		this.selected(true);
		this.close();		
		UI.stopEvent(e);
	},
	keyMove:function(e){
		var e=UI.getE(e);
		var prev_index=-1;
		if(e.keyCode==38 && this.selectedIndex>0)
		{
			prev_index=this.selectedIndex--;
			UI.stopEvent(e);
		}
		else if(e.keyCode==40 && this.selectedIndex < this.length-1)
		{
			prev_index=this.selectedIndex++;
			UI.stopEvent(e);
		}
		else if(e.keyCode==13)
		{
			this.close();
			if(this.moveSelectedIndex != this.selectedIndex && this.input.onchange) this.input.onchange.call(this);
			this.moveSelectedIndex=this.selectedIndex;
		}		
		if(prev_index>-1)
		{
			this.subBox.getElementsByTagName('DIV')[prev_index].className='default_txt';
			this.subBox.getElementsByTagName('DIV')[this.selectedIndex].className='selected_txt';
			this.selected((this.isopen) ? false:true);
		}
	},
	print:function(){
		var id=this.id;
		var opt=this.input.options;
		var sb = new UI.StringBuffer();
		for(var i=0; i<opt.length; i++)
		{
			this.list[i]={text:opt[i].text,value:opt[i].value};
			sb.append('<div style="width:100%;padding:'+this.skin.padding+'px">'+opt[i].text+'</div>');
		}
		this.value=this.list[0].value;

		var s='<style type="text/css">input.default_txt,div.default_txt{'+this.skin.default_txt+'} input.selected_txt,div.selected_txt{'+this.skin.selected_txt+'}</style>'
		+'<div id="UISelectTop_'+id+'" style="position:relative;'+this.skin.topbox+'">'
			+'<input class="default_txt" id="UISelectSel_'+id+'" type="text" value="'+this.list[0].text+'" style="width:100%;border:none;margin:0;padding:'+this.skin.padding+'px" readonly="readonly">'
			+'<div style="position:absolute;right:0;top:0">'+this.skin.arrow+'</div>'
		+'</div>'
		+'<div id="UISelectSub_'+id+'" style="display:none;position:absolute;'+this.skin.subbox+'">'+sb.toString()+'</div>';
		
		this.input.style.display='none';
		document.write(s);

		this.topBox= UI.$('UISelectTop_'+id);
		this.subBox= UI.$('UISelectSub_'+id);
		this.selBox= UI.$('UISelectSel_'+id);

		var self=this;
		UI.addEvent(this.topBox, "mousedown", function(e) { self.toogle(e) } );
		UI.addEvent(this.topBox, "keydown", function(e) {self.keyMove(e)});
		
		UI.addEvent(this.selBox, "blur", function() { self.close(); self.blur(); });
		UI.addEvent(this.selBox, "focus", function() { self.focus(); });
		UI.addEvent(document, "mousedown", function() { self.close();self.blur(); } );

		UI.addEvent(this.subBox, "mousedown", function(e) { UI.stopEvent(e) } );
		var sub=this.subBox.getElementsByTagName('div');
		for(var i=0; i<sub.length; i++)
		{	
			sub[i].index=i;
			UI.addEvent(sub[i], "mouseover", function(e) { self.subOver(e) } );
			UI.addEvent(sub[i], "mouseout",  function(e) { self.subOut(e) } );
			UI.addEvent(sub[i], "mousedown", function(e) { self.subClick(e) } );
		}
	}
};

/**
2007-07-10 

2007-09-10
CSS탭기능, 사용법 업그레이드

2007-12-26
*/
UI.Tab=function(cid,count,options){
	this.options={
		snum:1,					//시작번호
		event_type:'mouseover', //mouseover,click
		menu_type:'img',		//img,css
		class_over:'on',		//over 시 css
		onChange:null			//변경될때 이벤트
	}
	Object.extend(this.options, options);
	this.cid=cid;
	this.count=count;
	var menu;
	for(var i=1; i<=count; i++)
	{
		menu=UI.$("menu_"+cid+"_"+i);
		menu.n=i;
		menu.css=menu.className;
		var self=this;
		menu['on'+this.options.event_type]=function(){ self.on(this.n);return false; }
		if(this.options.event_type=="click"){menu['onfocus']=function(){ self.on(this.n); }}
	}
	this.on(this.options.snum);
}
UI.Tab.prototype = {
	on : function(n){
		this.n=n;
		var type=this.options.menu_type;
		for(var k=1; k<=this.count; k++)
		{
			UI.$("div_"+this.cid+"_"+k).style.display="none";
			if(type=='img')	UI.$("menu_"+this.cid+"_"+k).src=UI.$("menu_"+this.cid+"_"+k).src.replace("_on.","_off.");
			else UI.$("menu_"+this.cid+"_"+k).className=UI.$("menu_"+this.cid+"_"+k).css;
			
		}
		UI.$("div_"+this.cid+"_"+n).style.display="block";
		if(type=='img')	UI.$("menu_"+this.cid+"_"+n).src=UI.$("menu_"+this.cid+"_"+n).src.replace("_off.","_on.");
		else UI.$("menu_"+this.cid+"_"+n).className= UI.$("menu_"+this.cid+"_"+n).css +' '+this.options.class_over;
		if(this.options.onChange) this.options.onChange.call(this);
	}
};

UI.Move=function(id) { 
	this.id=id; 
	this.div=UI.$(id); 
	this.x= parseInt(UI.getStyle(this.div,'left'))||0; 
	this.y= parseInt(UI.getStyle(this.div,'top'))||0; 
}; 
UI.Move.prototype={ 
	slide : function(pos) { 
		this.pos = pos; 
		this.pos_n = 0; 
		this.speed=0.3; 
		this.inteval = 20;
		this.setPos(); 
		this.playing =true; 
		var self=this; 
		this.tid=setInterval(function(){self.play()}, this.inteval);
	}, 
	play : function() { 
		this.x += (this.x2-this.x)*this.speed;
		this.y += (this.y2-this.y)*this.speed;
		this.set(this.x,this.y);
		if(Math.round(this.x)==this.x2 && Math.round(this.y)==this.y2) { 
			this.x=Math.round(this.x);
			this.y=Math.round(this.y);
			this.set(this.x,this.y);
			if(this.pos_n>=this.pos.length) {
				this.playing=false;
				clearInterval(this.tid)
			} else this.setPos(); 
		} 
	}, 
	setPos : function() {
		var arr=this.pos[this.pos_n].split(",");
		this.x2 = arr[0];
		this.y2 = arr[1];
		this.pos_n++;
	}, 
	set : function(x,y) { 
		this.div.style.left = x+"px";
		this.div.style.top = y+"px"; 
	}
}
UI.Modal=function(url,options){
	// if(!pageLoaded) { return false; }
	this.options={
		type:'image',
		alt:'',
		loading:false,
		opacity:30,
		width:0,height:0
	};
	Object.extend(this.options, options);
	var options=this.options;

	if(!UI.$('UIModalB')) UI.Modal.print();
	UI.setOpacity(UI.$('UIModalB'), options.opacity);
	UI.setOpacity(UI.$('UIModalBIframe'), 0);
	
	UI.Modal.setB();
	if(options.loading) UI.Modal.center(UI.$('UIModalL'));

	if(options.type=='image')
	{
		UI.$('UIModalF').innerHTML = '<img id="UIModalImage" src="'+url+'" alt="'+options.alt+'" />';
		if(options.loading) UI.$('UIModalImage').style.display='none';
		UI.addEvent(UI.$('UIModalImage'), 'load', UI.Modal.onload);
	}
	else if(options.type=='iframe')
	{		
		UI.$('UIModalF').innerHTML = '<iframe name="UIModalIframe" id="UIModalIframe" src="'+url+'" '+options.status+' allowtransparency="true"></iframe>';
		if(options.loading) 
		{
			UI.$('UIModalIframe').style.display='none';
			UI.addEvent(UI.$('UIModalIframe'), 'load', UI.Modal.onload);
		}
		UI.Modal.center(UI.$('UIModalF'));
	}
	UI.Modal.self=this;
	UI.addEvent(UI.$('UIModalB'), 'click', UI.Modal.reset);
	if(options.type=='image') UI.addEvent(UI.$('UIModalImage'), 'click', UI.Modal.reset);
	UI.addEvent(window,'resize', UI.Modal.onresize);
	UI.addEvent(window,'scroll', UI.Modal.onscroll);
};
UI.Modal.self={};
UI.Modal.onload=function(){
	UI.$('UIModalL').style.display='none';
	var pos=UI.getScroll();
	UI.Modal.center(UI.$('UIModalF'));	
	if(UI.Modal.self.options.type=='image')
	{
		UI.$('UIModalImage').style.display='block';
		UI.resizeImage(UI.$('UIModalImage'),pos.width,pos.height);	
	}
	else 
	{
		UI.$('UIModalIframe').style.display='block';
	}
	UI.Modal.center(UI.$('UIModalF'));
};
UI.Modal.print=function(){
	// deemed layer size setting
	if (window.innerHeight && window.scrollMaxY) {			
		this.UIModalB_height = window.innerHeight + window.scrollMaxY;			
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		this.UIModalB_height = document.body.scrollHeight;			
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		this.UIModalB_height = document.body.offsetHeight;			
	}
	var d=document.createElement('div');
	var s='';
	s+='<iframe style="z-index:99997;width:100%;height:'+this.UIModalB_height+';position:absolute;left:0;top:0;" name="UIModalBIframe" id="UIModalBIframe"></iframe><div id="UIModalB" style="z-index:99998;width:100%;height:'+this.UIModalB_height+'px;position:absolute;display:none;background-color:#000;"></div>';
	s+='<div id="UIModalF" style="z-index:99999;position:absolute;display:none;background-color:#fff;"></div>';
	s+='<div id="UIModalL" style="z-index:99999;display:none;position:absolute;border:2px solid gray;">로딩중...</div>';
	d.innerHTML=s;
	document.getElementsByTagName('body')[0].appendChild(d);
};
UI.Modal.setB=function(){
	var w=UI.$('UIModalB');
	var pos=UI.getScroll();
	w.style.top='0px';
	w.style.left='0px';
	/*
	if(document.all)
	{
		w.style.width=pos.width+'px';
		w.style.height=pos.height+'px';
	}
	*/
	w.style.display='block'
	UI.$('UIModalBIframe').style.display='block';
};
UI.Modal.center=function(el){
	el.style.display='block';
	var pos=UI.getScroll();
	el.style.left=pos.width/2-el.offsetWidth/2+pos.left+'px';
	el.style.top=pos.height/2-el.offsetHeight/2+pos.top+'px';
};
UI.Modal.reset=function(){
	UI.Modal.self=null;
	UI.$('UIModalF').innerHTML='';
	UI.$('UIModalB').style.display='none';
	UI.$('UIModalBIframe').style.display='none';
	UI.$('UIModalF').style.display='none';
	UI.$('UIModalL').style.display='none';
	UI.delEvent(window,'resize',UI.Modal.onresize);
	UI.delEvent(window,'scroll',UI.Modal.onscroll);
};
UI.Modal.onresize=function(){
	var pos=UI.getScroll();
	if(UI.Modal.self.options.type=='image') UI.resizeImage(UI.$('UIModalImage'),pos.width,pos.height);
	UI.Modal.center(UI.$('UIModalF'));
	UI.Modal.setB();
};
UI.Modal.onscroll=function(){
	UI.Modal.onresize();
};




/* 
2007-07-10 

2007-07-11
move_mode 속성추가 (좌우,상하 방향으로만 움직일수있게)
limit_top,limit_bottom,limit_left,limit_right 속성추가
소스개선

2007-11-20
소스개선
*/
UI.Drag=function(drag, options){

	var el=UI.$(drag);
	el.options={
		handle:'',
		container:'',
		move_mode:'',	//1:horizontal 2,vertical
		limit_top:-1,
		limit_bottom:-1,
		limit_left:-1,
		limit_right:-1,
		onStart:null,
		onStop:null,
		onDrag:null
	}
	Object.extend(el, el.options);
	Object.extend(el, options);

	el.isdrag=true;
	el.width=0;el.height=0;
	el.area_width=0;el.area_height=0;
	
	UI.Drag.setXY(el);
	
	if(el.handle)
	{
		el.handle=UI.$(el.handle);
		el.isdrag=false;
		el.handle.isdrag=true;
		el.handle.target=el;
	}
	if(el.container)
	{
		UI.$(el.container).style.position="relative";
		el.width=parseInt(UI.getStyle(el,"width")) || el.offsetWidth;
		el.height=parseInt(UI.getStyle(el,"height")) || el.offsetHeight;
		el.area_width=parseInt(UI.getStyle(UI.$(el.container),"width")) || UI.$(el.container).offsetWidth;
		el.area_height=parseInt(UI.getStyle(UI.$(el.container),"height")) || UI.$(el.container).offsetHeight;	
	}
	this.obj=el;
};
UI.Drag.setXY=function(el){
	var pos=UI.getPosition(el);
	el.x=parseInt(UI.getStyle(el,"left"));
	el.y=parseInt(UI.getStyle(el,"top"));
	if(isNaN(el.x)) el.x=pos.x;
	if(isNaN(el.y)) el.y=pos.y;
};
UI.Drag.start=function(event){
	var e=event || window.event; var el=e.target || e.srcElement;
		
	if(el.sliderKnob) el=UI.$(el.sliderKnob);//UI.Slider
	if(!el.isdrag) return;
	if(el.target) el=el.target;
	
	_uiDrag.obj=el;
	UI.Drag.setXY(el);

	_uiDrag.gx = e.clientX;
	_uiDrag.gy = e.clientY;

	if(el.onStart) el.onStart.call(el);
	if(el.onStop) _uiDrag.onStop=el.onStop;
	if(el.onDrag) _uiDrag.onDrag=el.onDrag;
};
UI.Drag.move=function(event){
	
	var drag=_uiDrag.obj;
	if(!drag) return;

	var e=event || window.event; var el=e.target || e.srcElement;
	var top =drag.y + e.clientY - _uiDrag.gy;
	var left=drag.x + e.clientX - _uiDrag.gx;

	if(drag.area_width && drag.area_height)
	{
		if(top<=0) top=0;
		else if(top >= drag.area_height-drag.height) top=drag.area_height-drag.height; 
		if(left<=0) left=0;
		else if(left >= drag.area_width-drag.width) left=drag.area_width-drag.width; 
	}
	if(drag.limit_top>-1 && top<drag.limit_top) top=drag.limit_top;
	if(drag.limit_bottom>-1 && top>drag.limit_bottom) top=drag.limit_bottom;
	if(drag.limit_left>-1 && left<drag.limit_left) left=drag.limit_left;
	if(drag.limit_right>-1 && left>drag.limit_right) left=drag.limit_right;
	
	if(!drag.move_mode || drag.move_mode==2) drag.style.top = top+"px";
	if(!drag.move_mode || drag.move_mode==1) drag.style.left = left+"px";	

	if(_uiDrag.onDrag) _uiDrag.onDrag.call(drag);
};
UI.Drag.end=function(event){
	if(_uiDrag.onStop) _uiDrag.onStop.call(_uiDrag.obj);
	_uiDrag.obj=null;	
	_uiDrag.onStop=null;
	_uiDrag.onDrag=null;
};

//전역변수
var _uiDrag={};
UI.addEvent(document, "mousedown", UI.Drag.start );
UI.addEvent(document, "mousemove", UI.Drag.move );
UI.addEvent(document, "mouseup", UI.Drag.end );




/*
2008-06-04

- SliderDouble
(UI.Drag 와 함께 사용하며 , Slider에서의 필요 속성만가져와 구성함)
*/

UI.SliderDouble=function(area,knob,options) {
	this.options={
		onSlide:null,
		onChange:null,
		max_value:100,
		value:0,
		mode:1				//1:horizontal 2,vertical
	}
	Object.extend(this.options, options);

	this.value=this.options.value;
	this.max_value=this.options.max_value;

	this.area=UI.$(area);
	this.knob=UI.$(knob);

	this.area.width=parseInt(UI.getStyle(this.area,"width"));
	this.area.height=parseInt(UI.getStyle(this.area,"height"));
	this.knob.width=parseInt(UI.getStyle(this.knob,"width"));
	this.knob.height=parseInt(UI.getStyle(this.knob,"height"));

	this.track_length = (this.options.mode==1) ? this.area.width-this.knob.width:this.area.height-this.knob.height;

	var self=this;

	this.drag=new UI.Drag(knob, {
		container:area,
		move_mode:this.mode,
		onDrag:function() { self.slide() },
		onStop:function() { self.change() }
	});
	
	if(this.value>0) {
		if(this.options.mode==1) this.knob.style.left=this.val2pos()+"px";
		else this.knob.style.top=this.val2pos()+"px";
	}
};
UI.SliderDouble.prototype={
	pos2val:function() {
		var val=Math.floor( parseInt(this.getKnobPos()) * this.max_value / this.track_length);
		if(val<0) val=0;
		else if(val>this.max_value) val=this.max_value;
		this.value=val;
		return val;
	},
	val2pos:function(value) {
		if(!value) value=this.value;
		var pos=Math.floor( value * this.track_length / this.max_value);
		return pos;
	},
	getKnobPos:function(){
		return (this.options.mode==1) ? this.knob.style.left:this.knob.style.top;
	},
	setKnobPos:function(pos){
		if(this.options.mode==1) this.knob.style.left=pos+'px';
		else this.knob.style.top=pos+'px';
	},	
	slide:function(){
		this.pos2val();
		if(this.options.onSlide) this.options.onSlide.call(this);
	},
	change:function(){
		this.pos2val();
		if(this.options.onChange) this.options.onChange.call(this);
	}
};




/**
2007-07-18
2007-12-11
2008-06-12 Calender Skin 적용
*/
UI.Calender = function(year,month){
	var d=new Date();
	if(year) d.setFullYear(year);
	if(month) d.setMonth(month-1);

	this.day=d;
	this.day_sweek=-1;
	this.ymd=this.getYMD(d);
	this.today=new Date();
	this.today_ymd=this.getYMD(this.today);
	this.selday=null;
	this.selday_ymd="";
	this.selbox=null;

	this.is_draw=0;
	this.is_show=0;
	this.show_el=null;

	this.pid = "UI_Calender"+String(Math.random()).substring(2,6);

};
UI.Calender.prototype={
	setBox:function(num,ymd,type){ //type 1:prev,2:next,0:now
		var box=UI.$(this.pid+"_"+num);
		box.ymd=ymd;
		
		if(type==1) box.className="UICalender_box_prev";
		else if(type==2) box.className="UICalender_box_next";
		else {
			box.className="UICalender_box";			
			if(num %  10==0) box.className="UICalender_box1";
			if((num-6) %  10==0) box.className="UICalender_box2";
			if(ymd==this.today_ymd) box.className="UICalender_box_today";
		} 
		
		box.innerHTML=ymd.substring(6,8);
		var self=this;
		if(this.onClick) box.onclick=function(){ self.onClick(box) };
		
	},
	getYMD :function(date){
		var y=date.getFullYear();
		var m=date.getMonth()+1;
		if(m<10) m="0"+m;
		var d=date.getDate();
		if(d<10) d="0"+d;
		return y+""+m+""+d;
	},
	getLastDay :function(date){
		return new Date(date.getFullYear(),date.getMonth()+1,0).getDate();
	},
	getSweek:function(date){
		return new Date(date.getFullYear(),date.getMonth(),1).getDay();
	},
	goPrev:function(){
		this.draw(this.day.getFullYear(), this.day.getMonth()-1);
	},
	goNext:function(){
		this.draw(this.day.getFullYear(), this.day.getMonth()+1);
	},
	goToday:function(){
		this.draw(this.today.getFullYear(), this.today.getMonth());
	},
	show:function(el){
		this.show_el=el;
		var pos=UI.getPosition(el);
		var ifa=parent.document.getElementById('UICalenderIfa');
		if(!this.is_show)
		{
			UI.addEvent(parent.document,"mousedown",function(){ ifa.style.display='none' })
			this.is_show=1;
		}
		if(this.selbox)	this.selbox.className="UICalender_box";	
		
		var str="";
		if (el.value!="") str = el.value.replace(/[^0-9]/g,"");	

		if(str.length==8)//
		{
			var selday=new Date(str.substring(0,4), str.substring(4,6)-1, str.substring(6,8));
			this.draw(selday.getFullYear(), selday.getMonth());
			
			var d=selday.getDate();
			var n1=Math.ceil((d+this.day_sweek)/7) - 1;
			var n2= d-(1+(7*n1)-this.day_sweek);
			this.selbox=UI.$(this.pid+"_"+n1+""+n2);
			this.selbox.className="UICalender_box_selday";
		}
		ifa.style.top=pos.y+el.offsetHeight+"px";
		ifa.style.left=pos.x+"px";
		ifa.style.display="block";
	},
	print:function(){
		var s=this.skin();
		document.write('<div id="'+this.pid+'">'+s+'</div>');
		
		var day=this.day;
		var selyear=UI.$(this.pid+"_selyear");
		var selmonth=UI.$(this.pid+"_selmonth");
		var btnprev=UI.$(this.pid+"_btnprev");
		var btnnext=UI.$(this.pid+"_btnnext");

		try{
			var self=this;
			UI.addEvent(selyear, "change", function(){
				self.draw(selyear.value, selmonth.value - 1);
			});
			UI.addEvent(selmonth, "change", function(){
				self.draw(selyear.value, selmonth.value - 1);
			});
			UI.addEvent(btnprev, "click", function(){self.goPrev()});
			UI.addEvent(btnnext, "click", function(){self.goNext()});
		}catch(e){}

		this.draw(day.getFullYear(), day.getMonth());
	},
	draw:function(year,month){
		var day=this.day;
		if(this.is_draw) if(year==day.getFullYear() && month==day.getMonth()) return;
		this.is_draw=1;
		day.setFullYear(year);
		day.setMonth(month);		
		this.day_sweek=this.getSweek(day);

		try{
			UI.$(this.pid+"_selyear").innerHTML=day.getFullYear();
			UI.$(this.pid+"_selmonth").innerHTML=day.getMonth()+1;
		}catch(e){}

		var d0=new Date(year,month,1);
		d0_lastday=this.getLastDay(d0);

		var d1=new Date(year,month-1,1);	//이전달
		var d2=new Date(year,month+1,1);	//다음달
		var d1_lastday=this.getLastDay(d1);
		
		var num=null;
		var d0_day=1,d2_day=1;
		for(var i=0; i<6; i++) 
		{			
			for(var j=0; j<7; j++) 
			{
				num=i+""+j;
				
				if(i==0 && j<this.day_sweek) //이전달
				{	
					d1.setDate( d1_lastday - (this.day_sweek-j) + 1 );
					this.setBox(num, this.getYMD(d1),1)					
				}
				else if(d0_day>d0_lastday)
				{
					d2.setDate(d2_day++);
					this.setBox(num, this.getYMD(d2),2)
				}
				else 
				{
					d0.setDate(d0_day++);
					this.setBox(num, this.getYMD(d0),0)
				}
			}
		}
	},
	skin:function(){
		var s='';
		s=''
		+'<style type="text/css">'
		+'		html{background:#fff;}'
		+'		body {margin:0;padding:0;background-color:#fff;color:#666;}'
		+'		body, td, th, input, textarea, p, div, span {font-size:11px;line-height:1.2em;color:#666;font-family:AppleGothic,굴림,gulim,sans-serif;}'
		+'		#calender {background:url(http://img-contents.daum-img.net/book/2008_home/review/calendar_bg.gif) no-repeat;width:164px;height:156px;padding-left:13px;}'
		+'		#calender .fl{float:left;}'
		+'		#calender .b{font-wight:bold;}'
		+'		#calender .c{text-align:center;}'	
		+'		#calender .dateTop{height:19px;margin:7px 0 0 7px;}'
		+'		#calender .date{margin:0 20px 0 20px;text-valign:center;font:bold 12px AppleGothic,돋움,Dotum,sans-serif; line-height:140%;}'
		+'		#calender .dateM{width:15px;}'
		+'		#calender .dot{margin:0 1px 0 1px;}'
		+'		#calender .btnL{float:left;height:19px;text-indent:-1000em;overflow:hidden;display:block;background:url(http://img-contents.daum-img.net/book/2008_home/common/icon_wing.gif) no-repeat;width:12px;height:14px;cursor:pointer;}'
		+'		#calender .btnR{float:left;height:19px;text-indent:-1000em;overflow:hidden;display:block;background:url(http://img-contents.daum-img.net/book/2008_home/common/icon_wing.gif) no-repeat 0 -14px;width:12px;height:14px;cursor:pointer;}'
		+'		#calender .dateN td {cursor:pointer;font:normal 9px Tahoma;text-align:center;}'
		+'</style>'
		+'<div id="calender">'
		+'<table border="0" width="140">'
		+'<tr>'
		+'	<td colspan="7">'
		+'	<div class="dateTop">'
		+'	<span id="'+this.pid+'_btnprev" class="btnL">이전</span>'
		+'	<span class="date fl">'
		+'		<div id="'+this.pid+'_selyear" class="fl"></div><span class="dot fl">.</span><div id="'+this.pid+'_selmonth" class="dateM fl"></div>'
		+'	</span>'
		+'	<span id="'+this.pid+'_btnnext" class="btnR">다음</span>'
		+' </div>'
		+'	</td>'
		+'</tr>'
		+'<tr class="c">'
		+'	<td class="UICalender_box1">일</td>'
		+'	<td>월</td>'
		+'	<td>화</td>'
		+'	<td>수</td>'
		+'	<td>목</td>'
		+'	<td>금</td>'
		+'	<td class="UICalender_box2">토</td>'
		+'</tr>'		
		+'<tr class="dateN">'
		+'	<td id="'+this.pid+'_00"></td>'
		+'	<td id="'+this.pid+'_01"></td>'
		+'	<td id="'+this.pid+'_02"></td>'
		+'	<td id="'+this.pid+'_03"></td>'
		+'	<td id="'+this.pid+'_04"></td>'
		+'	<td id="'+this.pid+'_05"></td>'
		+'	<td id="'+this.pid+'_06"></td>'
		+'</tr>'
		+'<tr class="dateN">'
		+'	<td id="'+this.pid+'_10"></td>'
		+'	<td id="'+this.pid+'_11"></td>'
		+'	<td id="'+this.pid+'_12"></td>'
		+'	<td id="'+this.pid+'_13"></td>'
		+'	<td id="'+this.pid+'_14"></td>'
		+'	<td id="'+this.pid+'_15"></td>'
		+'	<td id="'+this.pid+'_16"></td>'
		+'</tr>'
		+'<tr class="dateN">'
		+'	<td id="'+this.pid+'_20"></td>'
		+'	<td id="'+this.pid+'_21"></td>'
		+'	<td id="'+this.pid+'_22"></td>'
		+'	<td id="'+this.pid+'_23"></td>'
		+'	<td id="'+this.pid+'_24"></td>'
		+'	<td id="'+this.pid+'_25"></td>'
		+'	<td id="'+this.pid+'_26"></td>'
		+'</tr>'
		+'<tr class="dateN">'
		+'	<td id="'+this.pid+'_30"></td>'
		+'	<td id="'+this.pid+'_31"></td>'
		+'	<td id="'+this.pid+'_32"></td>'
		+'	<td id="'+this.pid+'_33"></td>'
		+'	<td id="'+this.pid+'_34"></td>'
		+'	<td id="'+this.pid+'_35"></td>'
		+'	<td id="'+this.pid+'_36"></td>'
		+'</tr>'
		+'<tr class="dateN">'
		+'	<td id="'+this.pid+'_40"></td>'
		+'	<td id="'+this.pid+'_41"></td>'
		+'	<td id="'+this.pid+'_42"></td>'
		+'	<td id="'+this.pid+'_43"></td>'
		+'	<td id="'+this.pid+'_44"></td>'
		+'	<td id="'+this.pid+'_45"></td>'
		+'	<td id="'+this.pid+'_46"></td>'
		+'</tr>'
		+'<tr class="dateN">'
		+'	<td id="'+this.pid+'_50"></td>'
		+'	<td id="'+this.pid+'_51"></td>'
		+'	<td id="'+this.pid+'_52"></td>'
		+'	<td id="'+this.pid+'_53"></td>'
		+'	<td id="'+this.pid+'_54"></td>'
		+'	<td id="'+this.pid+'_55"></td>'
		+'	<td id="'+this.pid+'_56"></td>'
		+'</tr>'
		+'</div>'
		+'</div>'
		return s;	
	}
};

UI.ByteChecker=function(id,len){
	this.input = UI.$(id);
	this.isAlert=false;
	this.cid=id;
	this.len=len;
	var self=this;
	UI.addEvent(this.input,'keyup', function(){self.check()})
}
UI.ByteChecker.prototype={
	check:function(){		
		var el=this.input;
		var len = UI.length(el.value);
		if(len > this.len && !this.isAlert)
		{
			this.isAlert=true;
			alert("최대 "+this.len+"Byte까지 가능합니다. 초과된 내용은 자동으로 삭제됩니다.");
			this.isAlert=false;
			//this.input.focus();
			el.value=UI.length(el.value, this.len);
			len=this.len;
		}
		UI.$(this.cid+"_byteinfo").innerHTML = len;		
	}
}

var Paging = function(prefix, lpp, total) {
	var currentPage = 1;
	var rest = 0;
	UI.addEvent(UI.$(prefix+'Prev'),'click',function(addPage){paginate(-1);});
	UI.addEvent(UI.$(prefix+'Next'),'click',function(addPage){paginate(1);});
	
	var paginate = function(addPage) {
		var page = currentPage + addPage;
		rest = total - lpp * page;
		if (page < 1 || rest <= lpp * -1) {return;}
		for(i=0;i<total;i++) {
			try { 
				document.getElementById(prefix + '_slide_' + (i + 1)).style.display = (lpp * (page - 1) <= i && lpp * page > i ) ? 'block' : 'none';
			} catch(e){}
		}
		currentPage = page;
		setButton();
	}
	var setButton = function() {
		document.getElementById(prefix+'Prev').className = "prevOn";
		document.getElementById(prefix+'Next').className = "nextOn";

		if (currentPage == 1) {// 첫 page일 경우 prev를 disabled로
			document.getElementById(prefix+'Prev').className = "prevOff";
			UI.addEvent(UI.$(prefix+'Prev'),'click',function(){paginate(0);});
		}
		
		if (rest > lpp * -1 && rest <= 0) { // 마지막 page일 경우
			document.getElementById(prefix+'Next').className = "nextOff";
			UI.addEvent(UI.$(prefix+'Next'),'click',function(){paginate(0);});
		}
	}
	paginate(0);
}

//Remove Space
function strtrim(str){
   	while (str.charAt(0) == ' ')
   		str = str.substring(1);
   	while (str.charAt(str.length - 1) == ' ')
   		str = str.substring(0, str.length - 1);
   	return str;
}

//Open Popup
function popup(url, name, w, h) {
	window.open(url,name,'width='+w+',height='+h+',resizable=no,scrollbars=no');
}

function viewLargeImage(imageUrl){
	if(imageUrl!="") {
		new UI.Modal('/detail/viewCover.html',{type:'iframe',status:'height=200 frameborder=0 scrolling=no style=\'padding:0;margin:0;\'' });
	} else {
		alert('크게 볼 이미지가 없습니다.');
	}
}

function viewCopyBookInfo(bookid) {
	new UI.Modal('/detail/copyBookInfo.html?bookid=' + bookid,{type:'iframe',status:'width=516 height=100 frameborder=0 scrolling=no style=\'padding:0;margin:0;\'' });
}

//책 검색
function viewSearchBook(bookid) {
	new UI.Modal('/search/popup.do?bookid=' + bookid,{type:'iframe',status:'width=451 height=522 frameborder=0 scrolling=no style=\'padding:0;margin:0;\'' });
}

//단골 서점 레이어
function customBookStore(heightSize) {
	new UI.Modal('/detail/favorite/list.do',{type:'iframe',status:'width=371 height=' + heightSize + ' frameborder=0 scrolling=no style=\'padding:0;margin:0;\'' });
}

// 책정보 신고
function inform(what,id) {
	var code = (what=='book') ? 'BK' : 'RV';
	window.open("http://book.daum.net/common/report.do?targetCode=" + code + "&targetID=" + id, 'informWindow','width=400,height=260');
}


// 오른쪽 날개 베스트셀러 탭
function showRightBestsellerTab(no) {
	for(i=1;i<=2;i++){
		UI.$('bestseller_tab' + i).className = (no == i) ? 'on' : 'off';
		UI.$('bestseller_div' + i).style.display = (no == i) ? 'block' : 'none';
	}
}
function toggleRealtimePopulars(onoff) {
	UI.$('realtime_ranking').style.display = (onoff == 'on') ? 'block' : 'none';
}

function showCategoryMenu(where) {
	if(where=='domestic') {
		UI.$('link_domestic').className = 'domestic_on';
		UI.$('link_foreign').className = 'foreign';		
		UI.$('domestic_category').style.display = 'block';
		UI.$('foreign_category').style.display = 'none';
	} else {
		UI.$('link_domestic').className = 'domestic';
		UI.$('link_foreign').className = 'foreign_on';		
		UI.$('domestic_category').style.display = 'none';
		UI.$('foreign_category').style.display = 'block';	
	}
}

// 분류별책찾기용
function showLeftCategoryMenu(where) {
	if(where=='domestic') {
		var link = UI.$('link_domestic_l'); 
		link.className = 'domestic_on';		
		UI.$('link_foreign_l').className = 'foreign';		
		UI.$('domestic_category_l').style.display = 'block';
		UI.$('foreign_category_l').style.display = 'none';
	} else {
		var link = UI.$('link_foreign_l'); 
		UI.$('link_domestic_l').className = 'domestic';
		link.className = 'foreign_on';		
		UI.$('domestic_category_l').style.display = 'none';
		UI.$('foreign_category_l').style.display = 'block';	
	}
	link.blur();
}
// 평점주기 관련
//function showNetizenPointLayer(){
//	try{UI.$('book_character_layer').style.display = 'none';}catch(e){}
//	UI.$('netizen_point_layer').style.display = 'block';
//}

function showNetizenPointLayer(bookId){
	evaluateController.findCurrentUserEvaluateByBookid(bookId, currentUserEvaluateByBookidCallback);
}

// 
function currentUserEvaluateByBookidCallback(result){
	if(result == null){
		try{UI.$('book_character_layer').style.display = 'none';}catch(e){}
		UI.$('netizen_point_layer').style.display = 'block';
	}
	else{
		if(confirm("이미 참여하셨습니다. 수정하시겠습니까?")){
			try{UI.$('book_character_layer').style.display = 'none';}catch(e){}
			UI.$('netizen_point_layer').style.display = 'block';
		}
	}	
}


function setNetizenPoint(point){
	if(UI.$('point').value!=point) {
		UI.$('point').value = point;
		UI.$('star_width').style.width=(point * 10) + "%";
		UI.$('star_point').innerHTML = point + '.0';
		var msg = ''; 
		if(point < 1) {msg = '평점을 주세요~';}
		else if(point > 0 && point <= 2) {msg = '읽으면 후회';}
		else if(point > 2 && point <= 4) {msg = '읽으나 마나';}
		else if(point > 4 && point <= 6) {msg = '보통이다';}
		else if(point > 6 && point <= 8) {msg = '좋은 책이다';}
		else if(point > 8 && point <= 10) {msg = '꼭 읽어보길!';}
		UI.$('netizen_point_message').innerHTML = msg;				
	}
}

function setNetizenStarPoint(point){
	if(UI.$('article_point').value!=point) {
		UI.$('article_point').value = point;
		UI.$('article_star_width').style.width = point * 10 + "%";
		UI.$('article_star_point').innerHTML = point + '.0';
		var msg = ''; 
		if(point < 1) {msg = '평점을 주세요~';}
		else if(point > 0 && point <= 2) {msg = '읽으면 후회';}
		else if(point > 2 && point <= 4) {msg = '읽으나 마나';}
		else if(point > 4 && point <= 6) {msg = '보통이다';}
		else if(point > 6 && point <= 8) {msg = '좋은 책이다';}
		else if(point > 8 && point <= 10) {msg = '꼭 읽어보길!';}
		UI.$('article_netizen_point_message').innerHTML = msg;				
	}
}

// 평점주기
function evaluateNetizenPoint(bookId) {
	try{UI.$('bt_evaluate').onclick='return false';}catch(e){}
	try{
		evaluateController.evaluate(bookId,UI.$F('point'),evaluateNetizenPointCallback);
	} catch(e) {
		alert(e);
	}
}
// 평점주기 콜백
function evaluateNetizenPointCallback(result){
	if(result==1){
		alert('저장되었습니다.');
		var url = location.toString().replace('&act=eval','');
		var url = url.replace('#','');
		self.location = url;
	} else {
		alert('저장에 실패하였습니다.');
		location.reload();
	}
}

// 이책의 성격은
function showCharacterLayer(bookid) {
	bookCharController.findVoteByBookidUserId(bookid,function(myVote){
		if(myVote.bookid == null){
			try{UI.$('netizen_point_layer').style.display = 'none';}catch(e){}
			try{UI.$('book_character_layer').style.display = 'block';}catch(e){}
			return;
		}else {
			if(confirm("이미 참여하셨습니다. 수정하시겠습니까?")){
				try{UI.$('netizen_point_layer').style.display = 'none';}catch(e){}
				try{UI.$('book_character_layer').style.display = 'block';}catch(e){}
			
//				UI.$('x1').checked =(myVote.voteItem0=='00') ? true : false;
//				UI.$('x2').checked =(myVote.voteItem0=='01') ? true : false;
//				UI.$('y1').checked =(myVote.voteItem1=='10') ? true : false;
//				UI.$('y2').checked =(myVote.voteItem1=='11') ? true : false;
//				UI.$('z1').checked =(myVote.voteItem2=='20') ? true : false;
//				UI.$('z2').checked =(myVote.voteItem2=='21') ? true : false;
			}
		}
	});
}

// 이 책의 성격은 - 과거 내역 가져 오기
function getMyCharacter(bookid) {
	bookCharController.findVoteByBookidUserId(bookid,function(myVote){
		if(myVote.bookid == null){return;}
		else {
//			UI.$('x1').checked =(myVote.voteItem0=='00') ? true : false;
//			UI.$('x2').checked =(myVote.voteItem0=='01') ? true : false;
//			UI.$('y1').checked =(myVote.voteItem1=='10') ? true : false;
//			UI.$('y2').checked =(myVote.voteItem1=='11') ? true : false;
//			UI.$('z1').checked =(myVote.voteItem2=='20') ? true : false;
//			UI.$('z2').checked =(myVote.voteItem2=='21') ? true : false;
		}
	});
}



// 성격 투표
function voteCharacter(bookid) {
	// vote 데이타 생성
	var vote = {'bookid':bookid,'voteItem0':UI.$F('x'),'voteItem1':UI.$F('y'),'voteItem2':UI.$F('z')};
	var tot = vote.voteItem0 + vote.voteItem1 + vote.voteItem2; 
	if(tot.length!=6){alert('이 책의 성격을 모두 선택해 주세요.');return false;}
	try{UI.$('bt_vote').onclick='return false;';}catch(e){}
	try {
		bookCharController.vote(vote,voteCharacterCallback);
	} catch(e){alert(e);}
}

// 성격 투표 콜백
function voteCharacterCallback(result) {
	if(result==1){
		alert('저장되었습니다.');
		var url = location.toString().replace('&act=char','');
		var url = url.replace('#','');
		self.location = url;
	} else {
		alert('저장에 실패하였습니다.');
		location.reload();
	}
}

// 오른쪽 날개
function show_float(el) {
	var pos = UI.getPosition(el);
	$('book_float_layer').style.left = pos.x - 80 + "px";
	$('book_float_layer').style.top = pos.y - 24 + "px";
}
function hide_float() {
	$('book_float_layer').style.left = -1000 + "px";
}
// 검색폼
function set_form_action(f) {
	var v = UI.$('search_filter').value;
	UI.$('search_keyword').value = UI.trim(UI.$('search_keyword').value);
	if(v==""){return false;}
	if(v=="daumSearch"){
		UI.$('search_keyword').name = 'q';
		var new_input = document.createElement("input");
		new_input.setAttribute('type','hidden');
		new_input.setAttribute('name','w');
		new_input.setAttribute('value','tot');
		UI.$('book_search_form').appendChild(new_input);		
		f.action = "http://search.daum.net/search";
		f.target = "_blank";
	} else {
		UI.$('search_keyword').name = 'query';
		if(v.indexOf("|") > 0) {
			var type = v.split("|");
			var new_input = document.createElement("input");
			new_input.setAttribute('type','hidden');
			new_input.setAttribute('name','searchType');
			new_input.setAttribute('value',type[1]);
			UI.$('book_search_form').appendChild(new_input);
			f.action = "http://book.daum.net/search/" + type[0] + '.do';
		} else {
			f.action = "http://book.daum.net/search/" + v + ".do";
		}
		f.target = "_self";
	}
	if(UI.$F('search_keyword').length < 1){
		alert('검색어를 입력해 주세요.');
		UI.$('search_keyword').focus();
		return false;
	}
	return true;
}

// 광고폼 추가
function keyback(){
	try{
		if(document.getElementById('keywordChk').value=='adkeyword'){
			document.getElementById('search_keyword').value="";
			document.getElementById('keywordChk').value= "";
		}
	} catch(e){}
}	
function ADSearch(frm){
	menu = document.getElementById('keywordChk').value;
	tit = document.getElementById('search_keyword').value;
	
	if (document.getElementById('search_keyword').value==""){
			alert('검색어를 입력해 주세요.');
			UI.$('search_keyword').focus();
			return false;
	}else {
		if((menu == "adkeyword")&&(tit == title_array[n])) {
			//document.getElementById('search_keyword').value="";
			//frm.action = link_array[n];
			document.location.href = link_array[n];
			return false;
		} else {
			set_form_action(frm);
		}
	}
}


function check_submit(){
	set_form_action(UI.$('book_search_form'));
	UI.$('book_search_form').submit();
}

// GNB 상세검색 쇼하이드
function _jsGnbSearchChg(){
	if (UI.$("wrapPromotion").style.left == "0px") { ControlGNBLayer.toggle(); }
	
	if(UI.$('selectblocker').src.indexOf('gnbsearch') == -1) {
		UI.$('selectblocker').src = 'http://book.daum.net/gnbsearch.html';	
	}
	UI.$("gnbSearchLayer").style.display = (UI.$("gnbSearchLayer").style.display == "block") ? 'none' : 'block';
}

function _jsGnbSearchChgIF(){
	if (parent.UI.$("gnbSearchLayer").style.display == "block") {
		parent.UI.$("gnbSearchLayer").style.display = "none";
	} else {
		parent.UI.$("gnbSearchLayer").style.display = "block";
	}
}

// 날짜 String 생성 
function _jsMakeDateString(sdDate, str_dot) {
	var str_date;
	
	if(!sdDate.length) {		//sdDate가 Date Object인 경우
		if ( sdDate.getYear() <= 99 ) {	//1999년 이전일 경우 처리
			str_date = "19" + sdDate.getYear();
		} else if (sdDate.getYear() < 2000 ) { //FF에서는 2000부터 1붙어서 총 3자리로 나옴.
			str_date = (2000 + (sdDate.getYear()-100));
		} else {
			str_date = sdDate.getYear();
		}

		if ( sdDate.getMonth()+1 <= 9)
			str_date = str_date + "0" + (sdDate.getMonth()+1);
		else 
			str_date = str_date + (sdDate.getMonth()+1);
		if ( sdDate.getDate() <= 9)
			str_date = str_date + "0" + sdDate.getDate();
		else
			str_date = str_date + sdDate.getDate();
	} else {
		str_date = sdDate;
	}

	if (str_dot != "" ) 
		str_date = _jsMmakeDotDate(str_date, str_dot);

	return str_date;
}
function _jsMmakeDotDate(str_date, str_dot) {
	var return_str;
	var str_len;
	var s_dot;

	if (str_date.length) {
		str_len = str_date.length;
	} else {
		str_len = 0;
		return_str = "";
	}

	if (str_dot != "" )
		s_dot = str_dot;
	else
		s_dot = ".";
	
	if (str_len >= 6) 
		return_str =  str_date.substring(0,str_len-4) + s_dot + str_date.substring(str_len-4,str_len-2) + s_dot + str_date.substring(str_len-2,str_len);
	
	return return_str;
}


// 구매하기(낱권 구매시)
function registCart(barcode,categoryType){
//	if( categoryType.search(/001|DGT|002|AUD/) != -1 ){
//		alert('죄송합니다.\n\n교보문고는 현재 시스템 점검중 입니다.\n다른 서점을 이용해 주세요.');
//		return;
//	}
	
	var url = '';
	switch(categoryType) {
		case "001" :
		case "DGT" : {
			url += 'http://my.book.daum.net/myroom_index.jsp?retGb=G&retpath=';
			url += encodeURIComponent('/daum/cartMain.laf?cartType=addMast&productCd=001&cartBarcode=\'' + barcode + '\'');
			logRegister.addLog(url, 'CART','1', 'GN');
			top.location.href = url;
			break;
		}
		case "002" :
		case "AUD" : {
			url += 'http://my.book.daum.net/myroom_index.jsp?retGb=G&retpath=';
			url += encodeURIComponent('/daum/cartMain.laf?cartType=addAudioMast&cartBarcode=\'' + barcode + '\'');
			logRegister.addLog(url, 'CART','1', 'GN');
			top.location.href = url;
			break;
		}
		default : location.href = "/detail/price/list.do?bookid=" + (categoryType + barcode); break;
	}
	if(!barcode || !categoryType){alert('구매정보가 없습니다.');return;}

	/*
	
	
	if(categoryType == '001' || categoryType == 'DGT'){
		url += 'http://my.book.daum.net/myroom_index.jsp?retGb=G&retpath=';
		url += encodeURIComponent('/daum/cartMain.laf?cartType=addMast&productCd=001&cartBarcode=\'' + barcode + '\'');
		logRegister.addLog(url, 'CART','1', 'GN');
		top.location.href = url;
	}
	else if(categoryType == '002' || categoryType == 'AUD'){
		url += 'http://my.book.daum.net/myroom_index.jsp?retGb=G&retpath=';
		url += encodeURIComponent('/daum/cartMain.laf?cartType=addAudioMast&cartBarcode=\'' + barcode + '\'');
		logRegister.addLog(url, 'CART','1', 'GN');
		top.location.href = url;
	}
	else{
		url += 'http://my.book.daum.net/cart/cartAdd.laf?barcode=' + barcode + '&ejkGb=' + categoryType + '&qty=1';
		logRegister.addLog(url, 'CART','1', 'KY');
		top.location.href = url; 
	}
	 */
}	

// 트랙백 안내 팝업
function viewTrackbackInfo(bookid){
	new UI.Modal('/detail/viewTrackbackInfo.html?bookid=' + bookid,{type:'iframe',status:'height=160 width=561 frameborder=0 scrolling=no style=\'padding:0;margin:0;\'' });
}

// 공감
// <script type='text/javascript' src='/dwr/interface/agreeController.js'> <\/script>
// <button  onclick="agreeRegister.agree('${item.reviewSequence}', ${item.recommendCount})"><div id="bt_agree_${item.reviewSequence}">$item.recommendCount</div></button>
// <script type='text/javascript' src='/dwr/interface/cpLogController.js'><\/script>

var agreeRegister = {
	count: 0,
	revSeq: "",
	ReviewObject: function() {
		this.reviewSequence = null;
	},

	agree: function(reviewSequence, count) {
		var review = new agreeRegister.ReviewObject();
		review.reviewSequence = reviewSequence;
		agreeRegister.revSeq = reviewSequence;
		agreeRegister.count = count;
		agreeController.registAgree(review, agreeRegister.saveCallback);
	},
	
	saveCallback: function(result) {
		if(result == 1) {
			agreeRegister.count++;
			document.getElementById('bt_agree_' + agreeRegister.revSeq).innerHTML =  agreeRegister.count;
		}else if(result == 0) {
			alert("이미 반영하였습니다.");
		}else if(result == 2) {
			alert("본인의 게시물을 본인이 공감 할 수 없습니다.");
		} else {
			if(confirm("로그인이 필요합니다. 로그인 하시겠습니까?")) {
				location.href="http://www.daum.net/Mail-bin/login.html?daumauth=1&url=" + escape(document.location);
			}
		}
	}
}
//아웃링크 로그 등록
var logRegister = {
	cpLogObject : function(){
		this.link = ""; // Link URL
		this.linkType = ""; // "CART":장바구니 등록, "REVIEW":리뷰, "EVENT":이벤트 
		this.orderCount = ""; // 구매의 경우에만 쓰임, 총 구매한 책의 수
		this.source = ""; // "KY":교보 관련 링크, "GN":제노마드 관련 링크	
	},
	
	addLog : function(link, linkType, orderCount, source){
		var cpLog = new logRegister.cpLogObject();
		cpLog.link = link;
		cpLog.linkType = linkType;
		cpLog.orderCount = orderCount;
		cpLog.source = source;
		try{
			cpLogController.addCpLog(cpLog, logRegister.callBack);
		}catch(e){}
	},
	
	callBack: function(result){
	}
}

// 코멘트폼 validation
function validateCommentForm() {
	if(UI.trim(UI.$('comment').value).length < 1) {
		alert('내용을 입력해 주세요.');
		UI.$('comment').focus();
		return false;
	}
	try{
		UI.$('scrollY').value = document.all ? (!document.documentElement.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop) : (window.pageYOffset ? window.pageYOffset : window.scrollY);
	} catch(e){}  
	UI.$('bt_comment_submit').disabled = 'disabled';
}


//쇼하이드
function _jsShowHide(obj,action) {
	obj.style.display = action;
}
function _jsShowHideYN (obj) {
	var value = (obj.style.display=="none") ? false : true ;
	return value;
}
function _jsShowHideArray(id , num) {
	var num ;
	var tr = document.getElementsByName(id);
	var len = tr.length;		

	if (len == null)	{
		(_jsShowHideYN(tr)) ? _jsShowHide(tr,"none") : _jsShowHide(tr,"block")
	} else{
		for ( i = 0; i < len ; i++){
			if (i == num){
				(_jsShowHideYN(tr[num])) ? _jsShowHide(tr[num],"none") : _jsShowHide(tr[num],"block")
			} else {
				_jsShowHide(tr[i],"none");
			}
		}
	}
}


//쇼하이드
function _jsShowHide(obj,action) {
	obj.style.display = action;
}
function _jsShowHideYN (obj) {
	var value = (obj.style.display=="none") ? false : true ;
	return value;
}
function _jsShowHideArray(id , num) {
	var num ;
	var tr = document.getElementsByName(id);
	var len = tr.length;		

	if (len == null)	{
		(_jsShowHideYN(tr)) ? _jsShowHide(tr,"none") : _jsShowHide(tr,"block")
	} else{
		for ( i = 0; i < len ; i++){
			if (i == num){
				(_jsShowHideYN(tr[num])) ? _jsShowHide(tr[num],"none") : _jsShowHide(tr[num],"block")
			} else {
				_jsShowHide(tr[i],"none");
			}
		}
	}
}

// 책탑 쇼하이드
function _jsBookTopSH(id,num,c0,c1,link) {
	var num ;
	var tr = "";

	for ( i = 0; i < 2 ; i++){
		if (i == num){
			tr = UI.$(id+"_div_"+num);
			if (_jsShowHideYN(tr)==false) {
				_jsShowHide(tr,"block");
				var CHclass = eval("c"+i);
				UI.replaceClassName (id+"_"+i, CHclass, CHclass+"On");
				if (link!="")
					UI.$(id+"_M").innerHTML = '<a href="'+ link +'"><img src="http://img-contents.daum-img.net/book/2008_home/common/bt_more_text.gif" width="31" height="9" alt="더보기"/></a>';
			}
		} else {
			tr = UI.$(id+"_div_"+i);
			_jsShowHide(tr,"none");
			var CHclass2 = eval("c"+i);
			UI.replaceClassName (id+"_"+i, CHclass2+"On", CHclass2);
		}
	}
}

// 검색 더보기
function _jsCategoryBoxOnOff(obj1, obj2) {
	var e = UI.$(obj1);
	var enm = UI.$(obj2);
	
	if(_jsShowHideYN(enm)) {
		e.innerHTML = "더보기";
		_jsShowHide(enm,"none");
		UI.replaceClassName(obj1, "morebtn2", "morebtn1");
	} else {
		e.innerHTML = "감추기";
		_jsShowHide(enm,"block");
		UI.replaceClassName(obj1, "morebtn1", "morebtn2");
	}	
}

// 검색 더보기 우측네비
function _jsCategoryBoxOnOffRight(obj) {
	var e = UI.$("rMorebtn_"+obj);
	var enm = UI.$("rMore_"+obj);	
	var chke = "";
	var chkenm = "";
	
	if(_jsShowHideYN(enm)) {
		e.innerHTML = "더보기";
		_jsShowHide(enm,"none");
		UI.replaceClassName("rMorebtn_"+obj, "morebtn2", "morebtn1");
	} else {
		for (i = 1; i < 4; i++) {
			if (i != obj) {
				chke = UI.$("rMorebtn_" + i);
				chkenm = UI.$("rMore_" + i);
				if (chkenm != null) { 
					if (_jsShowHideYN(chkenm)) {
						chke.innerHTML = "더보기";
						_jsShowHide(chkenm, "none");
						UI.replaceClassName("rMorebtn_" + obj, "morebtn2", "morebtn1");
						;
					}
				}
			}
		}
		e.innerHTML = "감추기";
		_jsShowHide(enm,"block");
		UI.replaceClassName("rMorebtn_"+obj, "morebtn1", "morebtn2");
	}
}

//체크박스에 선택된 항목을 찜 함 
function registWish(bookid) {
	if(bookid == ""){
		alert("책을 선택하여주십시오");
	} else {
		url = "http://book.daum.net/my/wish/regist.do?bookidCommaList=" + bookid;
		targetName="book_wish";
		window.open(url, targetName, "width=371,height=272,scrollbars=no,status=no");
	}
}

// 분류별 책찾기 레이어 ShowHide
function toggle_category() {
	var isIE = UI.getBrowser().ie && (UI.getBrowser().ie_ver==6);
	var selectCate = null;	
	var ctg = UI.$("category_current_list");

	var layerRange = 0
	if (!!!UI.$('arrow_float_image')) {
		var arrow = document.createElement('img');
		arrow.src = 'http://img-contents.daum-img.net/book/2008_home/menu2/arrow_book_1.gif';
		arrow.id = 'arrow_float_image';
		arrow.style.position = 'absolute';
		arrow.style.left = '120px';
		arrow.style.display = 'block';
		arrow.style.zIndex = 9999;
		UI.addEvent(arrow, 'mouseover', function(event){
			var evt = event || window.event;
			ct.ov(selectCate, evt);			
		})
		UI.addEvent(arrow, 'mouseout', function(event){
			var evt = event || window.event;
			ct.out(selectCate, evt);
			ct.highlight(selectCate, 'off');			
		})
	}
	if(window.location.toString().indexOf('bbs2.book.daum.net') > 0){
		var link1 = 'http://bbs2.book.daum.net/review/free/category.json.js';
		var link2 = 'http://bbs2.book.daum.net/review/free/left_category_layer.html';
	} else {
		var link1 = 'http://book.daum.net/scripts/category.json.js';
		var link2 = 'http://book.daum.net/left_category_layer.html';
	}
	
	if(!!ctg){		
		if(ctg.style.display!='block') {
			ctg.style.display = 'block';
			try{UI.$('iframe_ie2').style.display = 'block';}catch(e){}
		} else {
			ctg.style.display = 'none';
			try{UI.$('iframe_ie2').style.display = 'none';}catch(e){}		
		}
		return;
	} else {
		
		var tgt = UI.$('category_current') || UI.$('bt_category');
		
		new UI.Ajax( { url:link1, param:"", onComplete:function(res){
			eval(res.responseText);
			new UI.Ajax( { url:link2, param:"", onComplete:function(result){
				tgt.innerHTML += result.responseText;
				var cateLayer = UI.$("category_current_list")	;			
				cateLayer.style.display = 'block';
				if(isIE){
					tgt.innerHTML += '<iframe id="iframe_ie2" frameborder="0" src="about:blank" style="position:absolute;top:0;left:0;z-index:1;"></iframe>';
					UI.$('iframe_ie2').height = UI.$("category_current_list").offsetHeight;
					UI.$('iframe_ie2').width = UI.$("category_current_list").offsetWidth;
				};				
				ct = {					
					ov:function(el, event){
						var target = UI.getEl(event);
						var height = UI.$("category_current_list").offsetHeight + 30;						
						if( target.id != arrow.id ) selectCate = target;
						var sub = UI.$('category_float_layer');
						sub.style.visibility = 'hidden';
						sub.style.display = 'block';						 
						var cateId = el.href.toString().match(/[0-9A-Z]+$/);
						var cateTitle = el.innerHTML.toString().replace(/<(\/)?span>/ig,'');												
						var category = ctg[cateId];																	
						if(category){
							var pos = UI.getPosition(el);
							var subPosY = 0;
							var arrowPosY = 0;														
							var html = '<div class="subbox" id="subbox">';
							if(isIE){html += '<iframe id="iframe_ie" frameborder="0" src="about:blank" style="z-index:1;"></iframe>';}						
							html += '<ul style="z-index:10;position:relative;">';
							html += '<li class="title"><a href="http://book.daum.net/category/book.do?categoryID=' + cateId + '">' + cateTitle + '</a></li>';
							for(i=0;i<category.length;i++){
								html += '<li class="items"><a href="http://book.daum.net/category/book.do?categoryID=' + category[i].id + '">' + category[i].desc + '</a></li>';
							}
							html += '</ul>';
							html += '</div>';
							sub.innerHTML = html;											
							if(isIE){
								if(chkBrowser.brIE7) {
									UI.$('iframe_ie').height = UI.$('subbox').scrollHeight - 4;
									UI.$('iframe_ie').width = UI.$('subbox').scrollWidth  - 4;
								} else {							
									UI.$('iframe_ie').height = UI.$('subbox').scrollHeight - 4 + 'px';
									UI.$('iframe_ie').width = UI.$('subbox').scrollWidth - 2 + 'px';
									UI.$('iframe_ie').style.top = '1px';
								}
							}							
							subPosY = pos.y-(sub.offsetHeight/2)-124;							
							if (subPosY < 0) {subPosY = 30}
							else if (subPosY+sub.offsetHeight > height) {subPosY = height-sub.offsetHeight}
							sub.style.top = subPosY + 'px';														
							arrowPosY = (isIE) ? (pos.y - 128) : (pos.y - 129);							
							arrow.style.top = arrowPosY + 'px';																												
							if(!!!UI.$(arrow.id)) {tgt.appendChild(arrow); };							
							// 레이어, 화살표 표시
							ct.highlight(el, 'on');
							sub.style.visibility = 'visible';
							UI.stopEvent(event);
						}						
					},		
					out:function(el, event){	
						UI.$('category_float_layer').style.display = 'none';
						ct.highlight(el, 'off');
						UI.stopEvent(event);						
					},
					highlight:function(el, status) {
						var pEl = el.parentNode;						
						if (status == 'on') {
							UI.addClassName(pEl, 'on');
							UI.removeClassName(pEl, 'off');													
							arrow.style.display= 'block';		
						} else {
							UI.addClassName(pEl, 'off');
							UI.removeClassName(pEl, 'on');						
							arrow.style.display= 'none';
						}						
					}					
				};
				try{
					if(ctg.scrollHeight + 400 > UI.$('page_body').scrollHeight){
						UI.$('body_center').style.height = ctg.scrollHeight + 400 + 'px';
					};
				}catch(e){}
			} } );			
		}});
	}	
}
// 분류별 eBook찾기 레이어 ShowHide
var current_dct = 0;
function e_toggle_category() {

	var tgt = UI.$('category_current');
	var ctg = UI.$('dcontent_categories');
	
	if(!!ctg){		
		if (ctg.style.display=='block') {
			UI.$('title_img').src = "http://img-contents.daum-img.net/book/2008_home/menu2/bt_ebook_1.gif";
			ctg.style.display = 'none';
		} else {
			UI.$('title_img').src = "http://img-contents.daum-img.net/book/2008_home/menu2/bt_ebook_2.gif";
			ctg.style.display = 'block';
		}
		return;
	} else {

		var link2 = 'http://book.daum.net/left_e_category_layer.html';
		
		new UI.Ajax( { url:link2, param:"", onComplete:function(result){
			tgt.innerHTML += result.responseText;
			ctg = UI.$('dcontent_categories');
			UI.$('title_img').src = "http://img-contents.daum-img.net/book/2008_home/menu2/bt_ebook_2.gif";
			ctg.style.display = 'block';
			ctg.style.top = "24px";

		}});
	}
}


var arrow = null;

var dct = {
		tgt : UI.$('dsubs'), 
		ov : function(el,subno){
			var obj = UI.$('dsubs');
			if(current_dct != subno){
        		el.className = "on";
				pos = UI.getPosition(el);
				for(i=0;i<obj.childNodes.length;i++){
					if((obj.childNodes[i].tagName == 'DIV')){
						el = obj.childNodes[i];
						if(el.id == 'dsub_' + subno){
							el.style.display = 'block';
						} else {
							el.style.display = 'none';
						}
					}
				}
				obj.style.display = 'block';
				var subPosY =0;
				if(!UI.$('category_current')){
				subPosY = pos.y-(obj.offsetHeight/2)-270;	
				if(subPosY <-30){subPosY =-30;}
				}else{
				subPosY = pos.y-(obj.offsetHeight/2)-150;	
				if(subPosY <-50){subPosY =0;}
				}
				obj.style.top = subPosY + 'px';
				var arrowPosY = pos.y-(obj.offsetHeight/2);	
				if(!UI.$('cat_arrow')){
    				arrow = document.createElement('img');
    				arrow.id = 'cat_arrow';
    				arrow.src = 'http://img-contents.daum-img.net/book/2008_home/menu2/arrow_book_1.gif';
    				arrow.className = 'arrow_float_image';
    			}
				arrow.style.top = pos.y-UI.getPosition(obj).y+4+"px";
				obj.appendChild(arrow);
			}
			current_dct = subno;
		},
		out : function(el){var obj = UI.$('dsubs');obj.style.display = 'none';current_dct=0;el.className = "";}
};



// 임시 자동 실행
/*
UI.addEvent(document, 'load', function(){
	toggle_category()
});
*/

function _jsSHideLayer(el) {
	if (layercheck>0) 
		return; 
	UI.$(el).style.display='none';
}
function _jsSHideText(id,chk) {
	if(chk){
		UI.$(id).className = "titleon";
	} else {
		UI.$(id).className = ""; 
	}
}

//페이지이동
function _jsGotoUrl(url) {
	document.location.href = url;
}

function setCheckBoxOnOff(chk, on, id) {
	if(chk != null) {
		if(on.checked) {
			if(chk[0]) {
				for(var i=0;i<chk.length;i++) {
					if(chk[i].id == id+"_simple") {
    					if(chk[i].disabled == false)	chk[i].checked = true;
    					else chk[i].checked == false;
					}
				}
			}
			else {
				if(chk.disabled == false)	chk.checked = true;
				else chk.checked == false;
			}
		}
		else {
			if(chk[0]) {
   				for(var i=0;i<chk.length;i++) {
    				if(chk[i].id == id+"_simple") {
       					if(chk[i].disabled == false)	chk[i].checked = false;
       				}
       			}
			}
			else {
       				chk.checked = false;
			}
		}
	}
}


function setCheckBoxOnOffDouble(chk, on, id) {
	var chkN = document.getElementsByName(id);
	if(chk != null) {
		if(on.checked) {
			if(chk[0]) {
				for(var i=0;i<chk.length;i++) {
					if(chk[i].id == id+"_simple") {
    					if(chk[i].disabled == false)	chk[i].checked = true;
    					else chk[i].checked == false;
					}
				}
			}
			else {
				if(chk.disabled == false)	chk.checked = true;
				else chk.checked == false;
			}
			
			for (var i = 0; i < chkN.length; i++) { chkN[i].checked = true; }
		}
		else {
			if(chk[0]) {
   				for(var i=0;i<chk.length;i++) {
    				if(chk[i].id == id+"_simple") {
       					if(chk[i].disabled == false)	chk[i].checked = false;
       				}
       			}
			}
			else {
       				chk.checked = false;
			}
			
			for (var i = 0; i < chkN.length; i++) { chkN[i].checked = false; }
		}
	}
}

function onZzimSeries(){
	var chk_cnt = 0;
	var first = 0;
	var idList = [];
    for(i=0;i<document.seriesForm.checked.length;i++) {
   		if(document.seriesForm.checked[i].checked){
   			if(document.seriesForm.checked[i].value==""){
   				first = 1;
   			}else{
   				idList.push( document.seriesForm.checked[i].value );
   			}
   		}
   	}
	if(idList.length <= 0){
		alert('찜하실 항목을 선택하세요');
	}else{
		if(confirm("총 "+idList.length+"권의 책을 찜하시겠습니까?")){
			registWish(idList.join(","));			
		}		
	}   	
}

function buyCartSeries(){
	var chk_cnt = 0;
	var first = 1;	
	var indexCnt = 1;
	var dgtCnt = 0; // 장바구니에 들어간 eBook 갯수
	var audCnt = 0; // 장바구니에 들어가 오디오북 갯수
	var bookCnt = 0; // 장바구니에 들어간 종이책 갯수
	var dgt_barcode = ""; // 장바구니에 들어갈 디지털 컨텐츠(eBook, 오디오북) 리스트
	var barcode="";
	var categoryType="";
	//var url_digital = "http://daum.genomad.co.kr/cartInsert.laf?"
	var url_digital = "http://my.book.daum.net/myroom_index.jsp?retGb=G&retpath="
	var url = "http://my.book.daum.net/cart/cartAdd.laf?";
  
  	if(document.seriesForm.checked.length == undefined){
  		document.seriesForm.checked.length = 1;
  	}
	
    for(i=0;i<document.seriesForm.checked.length;i++) {
		if(document.seriesForm.checked.length == 1){
	   		if(document.seriesForm.checked.checked){
	   			if(document.seriesForm.checked.value==""){
	   				first = 1;
	   			}else{
	   				if(first == 1){
	   					barcode = document.seriesForm.checked.value.substring(3, 16);
	   					categoryType = document.seriesForm.checked.value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += "\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += "\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}   					
	   				}else{
	   					barcode = document.seriesForm.checked[i].value.substring(3, 16);
	   					categoryType = document.seriesForm.checked[i].value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "&barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}
	   				}
	   			}
	   		}		
		}else{    
	   		if(document.seriesForm.checked[i].checked){
	   			if(document.seriesForm.checked[i].value==""){
	   				first = 1;
	   			}else{
	   				if(first == 1){
	   					barcode = document.seriesForm.checked[i].value.substring(3, 16);
	   					categoryType = document.seriesForm.checked[i].value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += "\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += "\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}   					
	   				}else{
	   					barcode = document.seriesForm.checked[i].value.substring(3, 16);
	   					categoryType = document.seriesForm.checked[i].value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "&barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}
	   				}
	   			}
	   		}		
		}

   	}
   	if(bookCnt > 0 && dgtCnt > 0){
   		alert('책과 eBook은 같이 구매하실 수 없습니다.');
   		return;   		
   	}
   	else if(bookCnt > 0 && audCnt > 0){
   		alert('책과 오디오북은 같이 구매하실 수 없습니다.');
   		return;
   	}
   	else if(dgtCnt > 0 && audCnt > 0){
   		alert('eBook과 오디오북은 같이 구매하실 수 없습니다.');
   		return;
   	}   	

   	if(bookCnt > 0){
   		if(confirm("총 "+chk_cnt+"권의 책을 구하시겠습니까?")){
   			logRegister.addLog(url, 'CART', chk_cnt, 'KY');
			document.location.href = url;		
		}		
	}else if(dgtCnt > 0){
		if(confirm("총 "+dgtCnt+"권의 eBook을 구하시겠습니까?")){			
			//url_digital += "cartBarcode=" + dgt_barcode + "&productCd=001&cartType=addMast";			
			url_digital += encodeURIComponent("/daum/cartMain.laf?cartType=addMast&productCd=001&cartBarcode=" + dgt_barcode);
			logRegister.addLog(url_digital, 'CART', dgtCnt, 'GN');
			window.location.href = url_digital;			
		}	
	}else if(audCnt > 0){
		if(confirm("총 "+audCnt+"권의 오디오북을 구하시겠습니까?")){
			url_digital += encodeURIComponent("/daum/cartMain.laf?cartType=addAudioMast&cartBarcode=" + dgt_barcode);
			//url_digital += "cartBarcode=" + dgt_barcode + "&productCd=002&cartType=addAudioMast";
			logRegister.addLog(url_digital, 'CART', audCnt, 'GN');		
			window.location.href = url_digital;
		}
	}else{
		alert('구매하실 항목을 선택하세요');
	}  
}

function onZzimLibrary(){
	var chk_cnt = 0;
	var first = 0;	
	var str="";
    for(i=0;i<document.libaryForm.checked.length;i++) {
   		if(document.libaryForm.checked[i].checked){
   			if(document.libaryForm.checked[i].value==""){
   				first = 1;
   			}else{
   				chk_cnt++;
   				str += document.libaryForm.checked[i].value + ",";
   			}
   		}
   	}
	if(chk_cnt <= 0){
		alert('찜하실 항목을 선택하세요');
	}else{
		//alert(url);
		if(confirm("총 "+chk_cnt+"권의 책을 찜하시겠습니까?")){
			registWish(str);
		}		
	}   	
}

function buyCartLibrary(){
	var chk_cnt = 0;
	var first = 1;	
	var indexCnt = 1;
	var dgtCnt = 0; // 장바구니에 들어간 eBook 갯수
	var audCnt = 0; // 장바구니에 들어가 오디오북 갯수
	var bookCnt = 0; // 장바구니에 들어간 종이책 갯수
	var dgt_barcode = ""; // 장바구니에 들어갈 디지털 컨텐츠(eBook, 오디오북) 리스트
	var barcode="";
	var categoryType="";
	//var url_digital = "http://daum.genomad.co.kr/cartInsert.laf?"
	var url_digital = "http://my.book.daum.net/myroom_index.jsp?retGb=G&retpath="
	var url = "http://my.book.daum.net/cart/cartAdd.laf?";
  
  	if(document.libaryForm.checked.length == undefined){
  		document.libaryForm.checked.length = 1;
  	}

    for(i=0;i<document.libaryForm.checked.length;i++) {
    	if(document.libaryForm.checked.length == 1){
	   		if(document.libaryForm.checked.checked){
	   			if(document.libaryForm.checked.value==""){
	   				first = 1;
	   			}else{
	   				if(first == 1){
	   					barcode = document.libaryForm.checked.value.substring(3, 16);
	   					categoryType = document.libaryForm.checked.value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += "\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += "\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}   					
	   				}else{
	   					barcode = document.libaryForm.checked.value.substring(3, 16);
	   					categoryType = document.libaryForm.checked.value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "&barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}
	   				}
	   			}
	   		}      	
    	}else{
	   		if(document.libaryForm.checked[i].checked){
	   			if(document.libaryForm.checked[i].value==""){
	   				first = 1;
	   			}else{
	   				if(first == 1){
	   					barcode = document.libaryForm.checked[i].value.substring(3, 16);
	   					categoryType = document.libaryForm.checked[i].value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += "\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += "\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}   					
	   				}else{
	   					barcode = document.libaryForm.checked[i].value.substring(3, 16);
	   					categoryType = document.libaryForm.checked[i].value.substring(0, 3);
	   					if(categoryType == "DGT"){
	   						dgtCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'"; 						   
							first=0; 						
	   					}else if(categoryType == "AUD"){
	   						audCnt++;
	   						dgt_barcode += ",\'" + barcode + "\'";
							first=0;   					
	   					}else{
	   						bookCnt++;
	   						url += "&barcode=" + barcode;
							url += "&ejkGb=" + categoryType;
							url += "&qty=1";
							url += "&indexCnt=" + indexCnt;
							chk_cnt++;				
							indexCnt++;
							first=0;
	   					}
	   				}
	   			}
	   		}    	
    	} 
   	}
   	if(bookCnt > 0 && dgtCnt > 0){
   		alert('책과 eBook은 같이 구매하실 수 없습니다.');
   		return;   		
   	}
   	else if(bookCnt > 0 && audCnt > 0){
   		alert('책과 오디오북은 같이 구매하실 수 없습니다.');
   		return;
   	}
   	else if(dgtCnt > 0 && audCnt > 0){
   		alert('eBook과 오디오북은 같이 구매하실 수 없습니다.');
   		return;
   	}   	

   	if(bookCnt > 0){
   		if(confirm("총 "+chk_cnt+"권의 책을 구하시겠습니까?")){
   				logRegister.addLog(url, 'CART', chk_cnt, 'KY');
			document.location.href = url;		
		}		
	}else if(dgtCnt > 0){
		if(confirm("총 "+dgtCnt+"권의 eBook을 구하시겠습니까?")){						
			url_digital += encodeURIComponent("/daum/cartMain.laf?cartType=addMast&productCd=001&cartBarcode=" + dgt_barcode);
			logRegister.addLog(url_digital, 'CART', dgtCnt, 'GN');
			window.location.href = url_digital;			
		}	
	}else if(audCnt > 0){
		if(confirm("총 "+audCnt+"권의 오디오북을 구하시겠습니까?")){
			url_digital += encodeURIComponent("/daum/cartMain.laf?cartType=addAudioMast&cartBarcode=" + dgt_barcode);
			logRegister.addLog(url_digital, 'CART', audCnt, 'GN');		
			window.location.href = url_digital;
			
		}
	}else{
		alert('구매하실 항목을 선택하세요');
	}
	
   	/*
	if(chk_cnt <= 0){
		alert('구매하실 항목을 선택하세요');
	}else{
		//alert(url);
		
		if(confirm("총 "+chk_cnt+"권의 책을 구하시겠습니까?")){
			document.location.href = url;			
		}
	} 
	*/ 
}

	var Browser = new Object();		
	Browser.isIE = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
	Browser.isIE_SV1 = (navigator.userAgent.toLowerCase().indexOf("sv1")!=-1);
	Browser.isIE_SV2 = (navigator.userAgent.toLowerCase().indexOf("sv2")!=-1);
	Browser.isIE_7 = (navigator.userAgent.toLowerCase().indexOf("msie 7")!=-1);
	Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
	Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari")!=-1);
	Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
	Browser.isNetscape = (navigator.userAgent.toLowerCase().indexOf("netscape")!=-1);
	Browser.isEtc = (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1 && navigator.userAgent.toLowerCase().indexOf("firefox")==-1 && navigator.userAgent.toLowerCase().indexOf("netscape")==-1 );

var onScrap = function(){
	document.getElementById('scrap').style.display = "block";;
	document.getElementById('scrap').style.visibility = "visible";
	if (document.addEventListner) document.getElementById("scrap").addEventListener('mouseout',closeScrap,false);
	else if (document.attachEvent) document.getElementById("scrap").attachEvent('onmouseout',closeScrap);
	else document.getElementById("scrap").onmouseout = closeScrap;
}

var closeScrap = function(e){
	var msgdiv = document.getElementById("scrap")
	var msglink = document.getElementById("scrap").getElementsByTagName("A");
	var msgnum = 0;
	for (var i=0; i<msgdiv.length; i++) {
		// When IE6, 7
		if (e.toElement) {
			if (e.toElement == msgdiv[i] || e.toElement.id == "scrap") msgnum++;
		}
		else if (e.fromElement) {
			if (e.fromElement == msgdiv[i]) eknum++;
		}
		// When Mozilla or etc...
		else if (e.relatedTarget && e.target) {
			if (e.relatedTarget == msgdiv[i] || e.relatedTarget.id == "scrap") msgnum++;
		}
	}
	for (i=0; i<msglink.length; i++) {
		// When IE6, 7
		if (e.toElement) {
			if (e.toElement == msglink[i] || e.toElement.id == "scrap") msgnum++;
		}
		else if (e.fromElement) {
			if (e.fromElement == msglink[i]) eknum++;
		}
		// When Mozilla or etc...
		else if (e.relatedTarget && e.target) {
			if (e.relatedTarget == msglink[i] || e.relatedTarget.id == "scrap") msgnum++;
		}
	}

	if (msgnum == 0) {
		document.getElementById("scrap").style.display = "none";
		document.getElementById("scrap").style.visibility = "hidden";
	}
}

var changeColorOver = function(_id){
	var s = "Planet";
	if(_id == "Planet") s = "blog";
	document.getElementById(_id).className = "ovC";
	document.getElementById(s).className = "novC";
}

function scrapToBlog() {
	var f = document.getElementById("scrapForm");
	var url = f.url.value;
	var title = f.title.value;
	var source1 = f.source1.value;
	var source2 = f.source2.value;
	var daumname = f.daumname.value;
	var key = f.key.value; 
	var link = "http://blog.daum.net/_blog/SendScrap.do";
	link +="?title="+title+"&url="+url+"&source1="+source1+"&source2="+source2+"&daumname="+daumname+"&key="+key;
	
	var win = popup(link, "scrapWindow", 417,245, "resizable=no,scrollbars=no");
	
	/*
	document.getElementById("scrapForm").action = "http://blog.daum.net/_blog/SendScrap.do";
	document.getElementById("scrapForm").method = "get";
	document.getElementById("scrapForm").submit();
	*/
}

function scrapToPlanet() {
	popup("about:blank", "scrapWindow", 417,245, "resizable=no,scrollbars=no");
	document.getElementById("scrapForm").action = "http://planet.daum.net/pcp/story/ShowForm.do";
	document.getElementById("scrapForm").submit();
}


function mouseover(e, obj, _id, rv, cnt) {
	/*
    var from = e?e.relatedTarget:event.fromElement; 
    while(from) { 
        if(from == obj) return; 
        from = from.parentNode; 
    }
     */
	var object = document.getElementById("img"+_id+"_"+rv);
	UI.setOpacity(object , 90);
	object.style.display = "block";	
	for(i=1;i<=cnt;i++){
		if(i != _id){
			document.getElementById("img"+i+"_"+rv).style.display = "none";		
		}
	}
} 

function mouseout(e, obj ,_id, rv) {
    var to = e?e.relatedTarget:event.toElement; 
    while(to) { 
        if(to == obj) return; 
        to = to.parentNode; 
    }
	document.getElementById("img"+_id+"_off").style.display = "none";
} 

// paging옆에 리뷰쓰기버튼삽입
function insertWriteReviewButton(){
	try{
		var source = "<a href='http://book.daum.net/review/bbs/write.do' class='bt_write'><img src='http://img-contents.daum-img.net/book/2008_home/common/bt_review_1.gif' width='76' height='24' class='bt_write_img'></a>" + UI.$('pagination').innerHTML;
		UI.$('pagination').innerHTML = source;
	}catch(e){
		document.write("<div id='pagination' class='pagination'></div>");
		insertWriteReviewButton();
	}
}

// 검색어가 있을 경우 GNB의 검색창에 넣어준다.
function setQueryStringToGNB(queryString){
	if(queryString!=""){try{UI.$('search_keyword').value = queryString;} catch(e){}}
}

// 서지종합 시리즈
function toggle_series_view(alink,number){
	var tgt = UI.$('book_series');
	if(alink.innerHTML.indexOf('더보기') > 0){
		alink.innerHTML = alink.innerHTML.replace('더보기','접기');
		alink.className = 'no_more';
		for(i=0;i<tgt.childNodes.length;i++){
			var el = tgt.childNodes[i];
			if(el.nodeName.toUpperCase() == 'LI'){
				el.style.display = 'block';
			}
		}
	} else {
		alink.innerHTML = alink.innerHTML.replace('접기','더보기');
		alink.className = 'more';
		var cnt = 0;	
		for(i=0;i<tgt.childNodes.length;i++){
			var el = tgt.childNodes[i];
			if(el.nodeName.toUpperCase() == 'LI'){
				el.style.display = (cnt < number) ? 'block' : 'none';
				cnt++;
			}
		}
	}
	var category_current = UI.$('category_current');
	for(i=0;i<category_current.childNodes.length;i++){
		var el = category_current.childNodes[i];
		if(el.className=='cocomo'){el.style.display = (alink.innerHTML.indexOf('더보기') < 0)  ? 'none' : 'block';}
	}	
}

// 지원가능 MP3 팝업 - from 교보
function openSupportedMP3List(){
    var x = window.open('http://digital.kyobobook.co.kr/audio/audioMP3Popup.jsp','audioMP3Popup','height=647,width=600,scrollbars=no');
}

// 오른쪽 날개  탭
function _jsShowRightTab(no) {
	for (i = 1; i <= 3; i++) {
		UI.$('sh_right_tab' + i).className = (no == i) ? 'on' : 'off';
		UI.$('sh_right_div' + i).style.display = (no == i) ? 'block' : 'none';
		
		if (UI.$('reviewmore')) {
			if (no == i) {
				if (no == 1) {
					UI.$('reviewmore').innerHTML = "<a href='http://book.daum.net/review/bbs/list.do' class='more'>네티즌 리뷰 더보기</a>"
				} else if (no == 2) {
					UI.$('reviewmore').innerHTML = "<a href='http://book.daum.net/review/bbs/blogger.do' class='more'>블로거 리뷰 더보기</a>"
				} else if (no == 3) {
					UI.$('reviewmore').innerHTML = "<a href='http://book.daum.net/review/media/list.do' class='more'>미디어 리뷰 더보기</a>"
				}
			}
		}
	}
}



//좌측_분류별검색레이어
function _jsSHrightover(event,id,onoff) {
	var e = event;
	var scroll = UI.getScroll();
	UI.$(id).style.top=(e.clientY+scroll.top-130)+"px";
	UI.$(id).style.display = (onoff == 'on') ? 'block' : 'none';
}

// 서지종합 다음책리뷰 접기/펴기
function toggle_daumbook_recommend_fold(a){
	if(a.innerHTML=='펼치기'){
		UI.$('recommendation').style.display = 'block';
		a.innerHTML = '접기';
		a.className = 'close';
	} else {
		UI.$('recommendation').style.display = 'none';
		a.innerHTML = '펼치기';
		a.className = 'open';	
	}
}
function recommend_gopage(no){
	for(i=1;i<=5;i++){
		UI.$('recommend_img0' + i).style.display = (i==no) ? 'block' : 'none';
		UI.$('recommend_navi_' + i).src = (i==no) ? 'http://img-contents.daum-img.net/book/2008_home/common/bt_book_on_'+i+'.gif' : 'http://img-contents.daum-img.net/book/2008_home/common/bt_book_off.gif';
	}
}
// 서지 본문검색
function validate_bookdetail_search(){
	var k = UI.trim(UI.$F('content_search_input'));
	if(k.length < 1) {
		alert('검색어를 입력해 주세요.');
		UI.$('content_search_input').value = '';
		UI.$('content_search_input').focus();
		return false;
	}
}

//리뷰 이책의 성격보기
function _jsSHcharacters(onoff){
	var e = UI.$("estimation");
	if (onoff == "on")
		_jsShowHide(e,"block");
	else
		_jsShowHide(e,"none");
}

// 리뷰 주간화제의 책
function _jsChangeDiv(id1 , id2) {
	var tr1 = UI.$(id1);
	var tr2 = UI.$(id2);	
	
	if (_jsShowHideYN(tr1))	{
		_jsShowHide(tr1,"none")
		_jsShowHide(tr2,"block")
	} else{
		_jsShowHide(tr1,"block")
		_jsShowHide(tr2,"none")
	}
}

// img가 404일 경우
function imgError(obj,title){
	try{obj.src = "http://photo-book.daum-img.net/images/nbook/common/110x160.jpg";}catch(e){}
	try{nopic(obj,title)}catch(e){}
}
// img가 없을 경우
function nopic(obj,title){
		
		var isIE = UI.getBrowser().ie;
		var src = UI.$('category_current') || UI.$('bt_category') || UI.$('promotion');
		var src_pos = UI.getPosition(src);
		var obj_pos = UI.getPosition(obj);
		var obj_width = (isIE) ? obj.width : obj.clientWidth;
		var obj_height = (isIE) ? obj.height : obj.clientHeight;
		 
		var alink = document.createElement("a")
		alink.className = 'cocomo';
		//alink.appendChild(document.createTextNode(title));
		alink.innerHTML = title;
		alink.href = obj.parentNode.href;
		alink.target = obj.parentNode.target;
	
		alink.style.top = (obj_pos.y - src_pos.y) + 'px';
		alink.style.left = (obj_pos.x - src_pos.x ) + 'px';
			
		if(obj_width > 0){
			alink.style.width = (obj_width - 16) + 'px';
			alink.style.height = (obj_height -16) + 'px';
		}
		
		try{
			if(obj.parentNode.parentNode.style.display!='none'){
				src.appendChild(alink);
			}
		} catch(e){
			if( src ){
				src.appendChild(alink);
			}
		}
		
}
// 서비스가이드 호출
function service_guide(sec){
	// sec : 01 - 함께읽기 ~ 07 디지털북
	window.open('http://book.daum.net/service_guide/index.html?' + sec, 'service_guide','width=900,height=500');
}



chkBrowser = new function() {	
	// Browsers
	this.brIE = navigator.appName === "Microsoft Internet Explorer",
	this.brOpera = navigator.appName === "Opera",
	this.brNetscape = navigator.appName === "Netscape",

	// Browsers Ver
	this.brIE6 = navigator.userAgent.indexOf('MSIE 6') !== -1,
	this.brIE7 = navigator.userAgent.indexOf('MSIE 7') !== -1,
	this.brIE8 = navigator.userAgent.indexOf('MSIE 8') !== -1,
	this.brFF = navigator.userAgent.indexOf('Firefox') !== -1,
	this.brFF2 = navigator.userAgent.indexOf('Firefox/2') !== -1,
	this.brFF3 = navigator.userAgent.indexOf('Firefox/3') !== -1,
	this.brSafari = navigator.userAgent.indexOf('Safari') !== -1,

	// Rendering Engines
	this.reWin = navigator.userAgent.indexOf('Windows') !== -1,
	this.reTrident = navigator.appName === "Microsoft Internet Explorer",
	this.reGecko = navigator.userAgent.indexOf('KHTML') === -1 && navigator.userAgent.indexOf('Gecko') > -1,
	this.reWebkit = navigator.userAgent.indexOf('AppleWebKit/') > -1,
	this.rePresto = navigator.appName === "Opera",
	this.reKHTML = navigator.userAgent.indexOf('KHTML') !== -1,
	this.reMac = navigator.userAgent.indexOf("Macintosh") !== -1,
	this.reUbuntu = navigator.userAgent.indexOf('Ubuntu') !== -1
}

function cutstring(str,len){
	var result = str.toString().substring(0,len);
	return (result != str) ? result + '..' : result;
}

function agrPop(){
	window.open("http://book.daum.net/popup/agree.html", 'agreeWindow','width=613,height=620');
}

function qnaPop(){
//	window.open("http://my.book.daum.net/cscenter/qnaForm_dgl.laf?code=1-929f", 'qnaWindow','width=500,height=520');
	window.open("http://cs.daum.net/mail/mail_form.jsp?LOGIN_TYPE=1&SITE_ID=135", 'qnaWindow');
}

function myProfile(){
	window.open("https://user.daum.net/DaumUser/loginUserInfo.daum?nil_profile=p&nil_loginbox=modify",'profile','width=800,height=600'); 
}

var initTextArea = function(eId) {
	var imgUrl = 'http://fn.daum-img.net/image/finance/plaza/2008/stock/common/txt_wn.gif';
	try 
	{
		var obj = document.getElementById(eId);
		if(obj!=null)
		{
			if(obj.value.length==0) {	
				obj.value = "";
				obj.style.background = "#fff url("+imgUrl+") no-repeat 3px 3px";
			} else {
				obj.style.background = "#fff";
				obj.focus();		
			}				
			if(obj.attachEvent) {
				obj.attachEvent("onfocus", new  Function("clearTextArea('"+eId+"')"))
			} else {
				obj.addEventListener("focus", new  Function("clearTextArea('"+eId+"')"), false)
			}
		}	
	} catch(e){}
}
function clearTextArea(eId) {try{document.getElementById(eId).style.background = "#fff";}catch (e){}}

//---------------------- XMLFromString
function jsXMLFromString(string) {
	var xmlDocument;
	var xmlParser;
	if(window.ActiveXObject){   //IE일 경우
		xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
		xmlDocument.async = false;
		xmlDocument.loadXML(string);
	} else if (window.XMLHttpRequest) {   //Firefox.. 경우
		xmlParser = new DOMParser();
		xmlDocument = xmlParser.parseFromString(string, 'text/xml');
	} else {
		return null;
	}
	return xmlDocument;
}

function content_search(element, barcode, bookid){
	var keyword = UI.trim(UI.$F(element));
	if(keyword.length < 1){
		alert('검색어를 입력해 주세요.');
		UI.$(element).value = '';
		UI.$(element).focus();
		return false;
	}
	var url = "http://book.daum.net/detail/preview/list.do?keyword=" + encodeURIComponent(keyword) + "&barcode=" + barcode + "&bookid=" + bookid +"&sortType=relevance&tab=02";
	self.location = url;
}
function content_search_enter(e,element, barcode, bookid){
	if(window.event){keynum = e.keyCode;}else if(e.which) {keynum = e.which;}
	if(keynum==13){
		content_search(element, barcode, bookid);
	}
}


//반값 이벤트
function half_findByYmd(type){
	var year = document.getElementsByName("year");
	var month = document.getElementsByName("month");
	var paramYear = year[0].value;
	var paramMonth = "";	

	if(type == 'Y'){
		if(paramYear == "2008"){
			paramMonth = "12";
		}else{
			paramMonth = "01";
		}
	}else{
		paramMonth = month[0].value;
	}

	paramYear = paramYear + paramMonth;

	if(paramYear != null){
		window.location.href="http://book.daum.net/event/half.do?showDate=" + paramYear;
	}
}

function half_popup() {
	new UI.Modal('/event/half_popup.html',{type:'iframe',status:'width=346 height=199 frameborder=0 scrolling=no style=\'padding:0;margin:0;\'' });
}

function half_href(id) {
	window.location.href = "http://book.daum.net/detail/book.do?bookid="+id;
}

function half_getinfo(type) {
	var link = "http://book.daum.net/xml/half.do";
	new UI.Ajax({ url:link, param:"", onComplete:half_getinfo_res});
}	

function half_getinfo_res(req) {
	var bookTitle = "";
	var tooltip = "";
	var bookSTitle = "";
	var bookCover = "";
	if(req.status == 200){
		bookTitle = req.responseXML.getElementsByTagName("BOOKNAME").item(0).firstChild.nodeValue;
		bookCover = req.responseXML.getElementsByTagName("IMAGE").item(0).firstChild.nodeValue;
		tooltip = bookTitle;
		bookSTitle = bookTitle;
		if(bookTitle.length > 20){
			bookSTitle = UI.length(bookTitle,20,"...");		
		}
	}
	
	if(UI.$('half_link_box')){
		UI.$('half_link_box').innerHTML ="<img src=\"http://img-contents.daum-img.net/book/2008_home/common/50dc_title.gif\" width=\"94\" height=\"12\" alt=\"오늘만50%세일\" onclick=\"half_getinfo()\" />&nbsp;<a href=\"http://book.daum.net/event/half.do\" class=\"b\" title=\""+bookTitle+"\" id=\"half_alink\" title=\""+bookTitle+"\">"+bookSTitle+"</a>";
	}
	if(UI.$('half_cover_box')){
		UI.$('half_cover_box').style.display = "block";
		
		UI.$('cover_box').innerHTML = "<img src=\""+bookCover+"\" width=\"54\" height=\"78\" alt=\""+tooltip+"\" title=\""+tooltip+"\"><div class=\"cover_image_half_s\" title=\""+tooltip+"\"></div>";
	}
}


/**
 * '오늘 본 책' 썸네일 이미지 마우스 오버
 */
function thumbItemOver(type, targetNum) {
	try	{
		var overPanel = document.getElementById("todayview_over_panel" + targetNum);

		if(type == "on") {
			overPanel.style.display = "block";

		} else {
			if(overPanel.style.display != "block") {
				overPanel.style.display = "block";
			} else {
				overPanel.style.display = "none";
			}						
		}
	}
	catch (e){ }
}
/**
 * '오늘 본 책' 항목 삭제
 */
function delTodayview(targetNum,bookid) {
	if(confirm('삭제하시겠습니까?')){
		//var target = document.getElementById("today_slide_" + targetNum);
		//document.getElementById("todayview_list").removeChild(target);
		new UI.Ajax( { url:'http://book.daum.net/ajax/removeTodayBook.do',param:'bookid='+bookid, onComplete:today_viewed_items} );
	}
}

// 검색 품절관련 조건 추가
function soldoutSorting(url,obj) {
	/*
	if(obj.checked){
		url += "&salesStatusType=exclusion";
	}
	top.location.href= url;
	*/
	
	var form = UI.$('book_search_form');
	if(obj.checked){
		var _salesStatusType = document.createElement("input");
		_salesStatusType.type = "hidden";
		_salesStatusType.name = "salesStatusType";
		_salesStatusType.value = "exclusion";				
		form.appendChild(_salesStatusType);
	}
	form.action = "http://book.daum.net/search/bookSearch.do";
	var defCharset=document.charset;
	if (/MSIE/.test(navigator.userAgent)) {
		document.charset = 'euc-kr';
	}
	form.submit();
	document.charset=defCharset;
}	

/* 테마 기획전 */
var select_num  = 0;
var select_price = 0;

function sum_price(obj,price){
	if(obj.checked){
		select_price += Number(price);
		select_num++;
		var cur_num = select_num ;
		UI.$('selectCount').innerHTML = cur_num;
		UI.$('selectCount2').innerHTML = cur_num;
	}else{ // 선택안되었을 경우
		select_price -= Number(price);
		select_num--;
		var cur_num = select_num ;
		UI.$('selectCount').innerHTML = cur_num;
		UI.$('selectCount2').innerHTML = cur_num;
	}
	
}


function before_addition(){
	var chk_cnt = 0;
	var first = 0;
    for(i=0;i<document.libaryForm.checked.length;i++) {
   		if(document.libaryForm.checked[i].checked){
   			if(document.libaryForm.checked[i].value==""){
   				first = 1;
   			}else{
   				chk_cnt++;
   			}
   		}
   	}
   if(chk_cnt <= 0){
		alert('선택하신 도서가 없습니다.');
	}else{
		window.open("http://book.daum.net/event/theme_popup.html","themePopup","width=350,height=203,scrollbars=no,status=no");
	}
}

function mouseover_theme(e, obj, _index, _id , rv, cnt) {

	var object = document.getElementById("img_"+_id+"_"+rv);
	//UI.setOpacity(object , 90);
	object.style.display = "block";	
	for(i=1;i<=cnt;i++){
		if(i != _index){
			object.style.display = "none";		
		}
	}
} 


function all_addition(){
	var chk_cnt = 0;
	select_price = 0;
    for(i=0;i<document.libaryForm.checked.length;i++) {
   		if(document.libaryForm.checked[i].checked){
   			if(document.libaryForm.checked[i].value==""){
   				first = 1;
   			}else{
   				select_price += Number(document.libaryForm.price[i].value);
   				chk_cnt++;
   			}
   		}
   	}
   	UI.$('selectCount').innerHTML = chk_cnt;
	UI.$('selectCount2').innerHTML = chk_cnt;
	select_num = chk_cnt;
	
}

UI.each = function(a, func){		
	for(var i=0,len=a.length; i<len; i++){
		func(a[i]);
	}
};

(function(){
    
    var readyBound = false;
    function bindReady(){
        // run only once
        if(readyBound) return;
        readyBound = true;

        // Mozilla, Opera and webkit nightlies currently support this event
        if(document.addEventListener){
            document.addEventListener("DOMContentLoaded", function(){
                document.removeEventListener("DOMContentLoaded", arguments.callee, false);
                ready();
            }, false);

        // If IE event model is used
        }else if(document.attachEvent){
            // ensure firing before onload,
            // maybe late but safe also for iframes
            document.attachEvent("onreadystatechange", function(){
                if(document.readyState === "complete"){
                    document.detachEvent("onreadystatechange", arguments.callee);
                    ready();
                }
            });

            // If IE and not an iframe
            // continually check to see if the document is ready
            if(document.documentElement.doScroll && window == window.top) (function(){
                if(isReady) return;
                try{
                    // If IE is used, use the trick by Diego Perini
                    // http://javascript.nwbox.com/IEContentLoaded/
                    document.documentElement.doScroll("left");
                }catch(error){
                    setTimeout(arguments.callee, 0);
                    return;
                }
                // and execute any waiting functions
                ready();
            })();
        }

        // A fallback to window.onload, that will always work
        UI.addEvent(window, "load", ready);
    }

    var isReady = false;
    var readyList = [];        
    function ready(){
        // Make sure that the DOM is not already loaded
        if(!isReady){
            // Remember that the DOM is ready
            isReady = true;

            // If there are functions bound, to execute
            if(readyList){
                // Execute all of them
                UI.each(readyList, function(fn){
                    fn.call(document, null);
                });

                // Reset the list of functions
                readyList = null;
            }
        }
    }

    function domReady(fn){
        bindReady();
        if(isReady){
            fn.call(document, null);
        }else{
            readyList.push(fn);
        }
        return this;
    }

    // export handler
    window.domReady = domReady;
})();

/**
 * GNB 특가세일 레이어 관리
 */
var ControlGNBLayer = function(){
	var id = "wrapPromotion";
	var container = null;
	var isShow = null;
	
	var method = {
		init: function(){
			isShow = ( UI.getCookie("daumBookGNBLayerDisplay") == "hide") ? false : true;
			container = UI.$(id);
			
			if (UI.getCookie("daumBookGNBLayerDisplay") != "todayHide") {
				if( isShow ) {
					UI.setCookie("daumBookGNBLayerDisplay", "hide", 0, "/", ".daum.net");
					( document.referrer.indexOf("www.daum.net") > 0 || document.referrer == "" )
					? this.show()
					: this.hide();
				} else {
					this.hide();
				}
			} else { this.hide(); }
		},
		linkFramePage : function(){
			var frameContainer = UI.$("gnbPromotionFrame");
			if( frameContainer && frameContainer.src == "about:blank" ) {
				var date = new Date();
				var dummy = date.setMinutes(Math.floor( date.getHours() / 10 ) * 10,0,0);
				frameContainer.src = "http://book.daum.net/promotion/gnbLayer.html?dummy="+dummy;
			}
		},
		show : function(){
			if (UI.getCookie("daumBookGNBLayerDisplay") == "todayHide") { UI.$("todayShow").style.display = "none"; }
			if( container ){
				container.style.left = "0px"; isShow = true;
				this.linkFramePage();
				container.style.display = "block";
			} else {
				//alert("[개발용 도움말] 프로모션용 Warpper가 존재하지 않습니다. 페이지를 갱신하여 주세요")
			}
		},
		hide : function(){
			if( container ){
				container.style.left = "-999em"; isShow = false;
			} else {
				//alert("[개발용 도움말] 프로모션용 Warpper가 존재하지 않습니다. 페이지를 갱신하여 주세요")
			}
		},
		toggle : function(){
			UI.$("gnbSearchLayer").style.display = "none";
			if( isShow ) this.hide();
			else this.show();
		}
	};
	return method;
}();
var shoppingHowSearch = function(q) {
	var _q, service;
	if( UI.getBrowser().ie ){
		_q = document.createElement("<input type='hidden' name='q' value='"+q+"'>");
		_service = document.createElement("<input type='hidden' name='service' value='book'>");
	} else {
		_q = document.createElement("input");
		_q.type = "hidden";
		_q.name = "q";
		_q.value = q;				
		_service = document.createElement("input");
		_service.type = "hidden";
		_service.name = "service";
		_service.value = "book";				
	}

	var form = document.getElementById("formShoppingHowSearch");
	if( !form ){
		form = document.createElement("FORM");
		form.target = "_blank";
		form.method = "GET";
		form.acceptCharset = "EUC-KR";
		form.appendChild(_q);
		form.appendChild(_service);
		form.action = "http://shopping.daum.net/product/searchresult.daum";
		var defCharset=document.charset;
		if (/MSIE/.test(navigator.userAgent)) {
			document.charset = 'euc-kr';
		}
		document.body.appendChild( form );
		form.submit();
		document.charset=defCharset;
	}
};

/**
 * cp별 독립된 구매 URL을 리턴 
 * @param cpCode	cp code
 * @param key		구매관련 key
 * 					교보문고에는 categoryType이 추가로 존재함, 이때에 객체의 배열로 넘겨줌 
 * 					key = [ {barCode:"...", categoryType:"..."},{..} ]
 * @return { url, name }
 */
var getBuyUrl = function( cpCode, key ){
	var url = "";
	var name = "";
	var target = "top";
	if( typeof key == "string" ){
		key = [key];
	}
	
	switch( cpCode ){
	case "YE":
		name = "YES24";
		url = "http://www.yes24.com/Order/FTCartReg.aspx?PID=108313&AllGoodsNo=" + key.join(",");
		break;
	case "AL":
		name = "알라딘";
		url = "http://www.aladdin.co.kr/shop/wbasket.aspx?partner=daum&AddBook=" + key.join(",");
		break;
	case "KY":
		name = "교보문고";
		if( key.length == 1 ){
			// 단권
			url = "http://my.book.daum.net/cart/cartAdd.laf?barcode=" + key[0].barCode + "&ejkGb=" + key[0].categoryType + "&qty=1";
		} else {
			// 복수권
			var param = [];
			for( var i=0,cnt=key.length; i<cnt; i++ ){
				param.push( "barcode=" + key[i].barCode + "&ejkGb=" + key[i].categoryType + "&qty=1&indexCnt="+(i+1) );
			}
			url = "http://my.book.daum.net/cart/cartAdd.laf?" + param.join("&");				
		}
		break;
	case "LI":
		name = "리브로";
		url = "http://www.libro.co.kr/joins.aspx?id=daumshop&pagename=/Order/AddToShoppingCart.aspx?goods_id=" + key.join(",");
		break;
	case "BO":
		name = "북코아";
		// 북코아는 단권만 구매 가능함
		url = "http://www.bookoa.com/module/cooperating/shareProgram/gateway.asp?shareNO=257&url=" + key[0];			
		break;
	case "IN":
		name = "인터파크";
		url = "http://book.interpark.com/gate/ippgw.jsp?biz_cd=P13316&prdNos=" + key.join(",011055016001|") + ",011055016001";
		break;
	case "BA":
		name = "반디앤루니스";
		url = "http://www.bandinlunis.com/front/order/coShopCart.do?partner=121&prodId=" + key.join("&prodId=");
		break;
	case "YO":
		name = "영풍문고";
		url = "http://www.ypbooks.co.kr/ypbooks/WebHome/daum/cart.jsp?gubun=DM&quantity=1&method=ins&Goods_cd=" + key.join("&gubun=DM&quantity=1&method=ins&Goods_cd=");
		break;
	case "11":
		name = "도서11번가";
		url = "http://book.11st.co.kr/Affiliate.do?cmd=gateway&PARTNER_CD=2004&returnUrl=%2FCart.do%3Fcmd%3DfindCartList";
		for (var i = 0, len = key.length; i < len; ++i) {
			url += "%26gdsNo%3D" + key[i] + "%26untgdsNo%3D" + key[i] + "001%26qty%3D1";  
		}
		break;
	case "KA":
		name = "강컴";
		url = "http://kangcom.com/basket/cart.asp?partnerid=daum&sku=" + key.join("&sku=");
		break;
	case "BS":
		name = "북스캔";
		url = "http://www.bookscan.co.kr/e-commerce/link/connect.do?SERVICE_CD=DAUM_PRODUCT_DETAIL&RURL=/e-commerce/partnership/btbNewMemberVirBasket.do&PRODUCT_NO=" + key.join(",");
		break;
	}
	return { url: url, name: name };
};


/**
 * 쇼핑하우 연계 상품 구매
 * @param cpCode	CP Code ( AL, YE, KY, LI )
 * @param totalKey	상품 구매코드
 * @param price		상품 가격
 * @return
 */
var moveCpBuy = function( cpCode, totalKey, price ){
//	if( cpCode == 'KY'){
//		alert('죄송합니다.\n\n교보문고는 현재 시스템 점검중 입니다.\n다른 서점을 이용해 주세요.');
//		return false;
//	}
	
	// 연결 form을 체크
	var checkForm = function(){
		var getEle = function( _name, _value ){
			var el;
			if( UI.getBrowser().ie ){
				el= document.createElement("<input type='hidden' name='"+_name+"' value='"+_value+"'>");
			} else {
				el= document.createElement("input");
				el.type = "hidden";
				el.name = _name;
				el.value = _value;				
			}
			return el;
		};
		
		var form = document.getElementById("formBuyProxy");
		if( !form ){
			form = document.createElement("FORM");
			form.target = "_blank";
			form.method = "GET";
			form.acceptCharset = "EUC-KR";
			document.body.appendChild( form );
			
			
			form.appendChild( getEle("service", "book") );
			form.appendChild( getEle("shopname", "") );
			form.appendChild( getEle("url", "") );
		}
		

		
		return {
			getForm: function(){
				return form;
			},
			setAction: function( _action ){
				form.action = _action
			},
			setShopName: function( _val ){
				form.shopname.value = _val;
			},
			setUrl: function( _val ){
				form.url.value = _val;
			},
			submit: function(){
				form.submit();
			}
		}
	}();
	
	if( price == 0 ){
		alert("구매를 원하시는 책을 선택해주세요.");
	} else {
		var inf = getBuyUrl( cpCode, totalKey );
		
		switch( cpCode ){
		case "KY":// 교보문고는 기존 구매 프로세스로 이동
			top.location.href = inf.url;
			break;
		default:
			var defCharset=document.charset;
			if (/MSIE/.test(navigator.userAgent)) {
				document.charset = 'euc-kr';
			}
			
			checkForm.setAction( "http://go.shopping.daum.net/link/go.daum" );
			checkForm.setShopName( inf.name );
			checkForm.setUrl( inf.url );
			checkForm.submit();
			document.charset=defCharset;
		}
	}
};

var gotoOutLink = function(shopname, url) {
	var _shopname, _url, _service;
	switch (shopname) {
		case "KY"	:	shopname = "교보문고";break;
		case "YE"	:	shopname = "YES24";break;
		case "AL"	:	shopname = "알라딘";break;
		case "LI"	:	shopname = "리브로";break;
		case "BO"	:	shopname = "북코아";break;
		case "IN"	:	shopname = "인터파크";break;
		case "BA"	:	shopname = "반디앤루니스";break;
		case "YO"	:	shopname = "영풍문고";break;
		case "11"	:	shopname = "도서11번가";break;
		case "KA"	:	shopname = "강컴";break;
		case "BS"	:	shopname = "북스캔";break;
		default		:	shopname = "";
	}
	if( UI.getBrowser().ie ){
		if(shopname) { _shopname = document.createElement("<input type='hidden' name='shopname' value='"+shopname+"'>"); }
		if(url) { _url = document.createElement("<input type='hidden' name='url' value='"+url+"'>"); }
		_service = document.createElement("<input type='hidden' name='service' value='book'>");
	} else {
		if(shopname) {
			_shopname = document.createElement("input");
			_shopname.type = "hidden";
			_shopname.name = "shopname";
			_shopname.value = shopname;	
		}
		if(url) {
			_url = document.createElement("input");
			_url.type = "hidden";
			_url.name = "url";
			_url.value = url;
		}
		_service = document.createElement("input");
		_service.type = "hidden";
		_service.name = "service";
		_service.value = "book";				
	}
	
	var form = document.getElementById("formOutLinkProxy");
	if( !form ){
		form = document.createElement("FORM");
		form.target = "_blank";
		form.method = "GET";
		form.acceptCharset = "EUC-KR";
		if(shopname) { form.appendChild(_shopname); }
		if(url) { form.appendChild(_url); }
		form.appendChild(_service);
		form.action = "http://go.shopping.daum.net/link/go.daum";
		var defCharset=document.charset;
		if (/MSIE/.test(navigator.userAgent)) {
			document.charset = 'euc-kr';
		}
		document.body.appendChild( form );
		form.submit();
		document.charset=defCharset;
	}
};