try{document.domain = 'daum.net';}catch(e){} 
try {document.execCommand("BackgroundImageCache",false,true);}catch(e){}
function checkLogin() {
	if(confirm("먼저 로그인 하셔야 합니다.\n로그인 페이지로 이동 하시겠습니까?")){
	}else{
		UI.$("comment").value = ""; UI.$("comment").blur();
	}
}

//-- 미즈쿡 검색
function _jsSearchForm() {
	var SearchKeyword = document.getElementById("q");
	if(UI.trim(SearchKeyword.value) == "") {
		alert("검색어를 입력해 주세요.");
		return false;
	} else {
		if(document.location.toString().indexOf('/search/')<0 && UI.$('searchquery_text_mimic') && SearchKeyword.value==UI.$('searchquery_text_mimic').value){
			location.href = UI.$('searchquery_link_mimic').value;
			return false;
		} else {
			document.getElementById("daumSearch").submit();
			return true;
		}
	}
}

//--------------------- JES : 2008-12-10
var UI={};
Object.extend=function(a, b){
  for (var property in b) a[property] = b[property];
  return a;
};

UI.$=function(s) { return document.getElementById(s) };
UI.trim=function(s) {return s.replace(/(^\s*)|(\s*$)/g, "") };
UI.toogle=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.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){
		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 "";
};
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.mouseOut=function(e, obj){
	var to = !!e.relatedTarget?e.relatedTarget:event.toElement; 
	while(to) {				
		if(to == obj) return false; 
		to = to.parentNode; 
	} return true;
	UI.stopEvent((e)?e:event);
};


// MODAL
/**
2007-09-18
*/
UI.Modal=function(url,options){
	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.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+'></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);
	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(){
	var d=document.createElement('div');
	var s='';
	s+='<div id="UIModalB" style="z-index:99998;width:100%;height:100%;position:absolute;display:none;background-color:#000;"></div>';
	s+='<div id="UIModalF" style="z-index:99999;position:absolute;display:none;"></div>';
	s+='<div id="UIModalL" style="z-index:99999;display:none;position:absolute;border:2px solid gray;">loading...</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=pos.top+'px';
	w.style.left=pos.left+'px';
	if(document.all)
	{
		w.style.width=pos.width+'px';
		w.style.height=pos.height+'px';
	}
	w.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.$('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();
};
UI.toolTip=function(event, options) {

	var e=event || window.event;
	var el= e.target || e.srcElement;

	el.options={
		className:'UItoolTip',
		mousemove:UI.toolTip.mousemove
	};
	Object.extend(el.options, options);

	if(!el.UItoolTip) 
	{
		el.stitle = el.alt || el.title || el.stitle;
		el.title = el.alt = "";
		if(!el.stitle) return;
		
		var d = document.createElement("DIV");		
		d.className = el.options.className;
		d.style.position="absolute";	
		UI.$('CookToolTip').appendChild(d);
		
		el.UItoolTip=d;
		el.UItoolTip.innerHTML=el.stitle;
	}
	var scroll = UI.getScroll();
	var x = (e.clientX+scroll.left+10) + "px";
	var y = (e.clientY+scroll.top+10) + "px";
	el.UItoolTip.style.left = x;
	el.UItoolTip.style.top =  y;
	el.UItoolTip.style.visibility="visible";

	UI.addEvent(el,'mouseout',UI.toolTip.mouseout);
	if(el.options.mousemove) UI.addEvent(document, "mousemove", el.options.mousemove);
}

document.write('<div id="CookToolTip"></div>');
UI.toolTip.seq = 1;
UI.toolTip.mousemove=function(event){
	var e=event || window.event; var el= e.target || e.srcElement;
	var scroll = UI.getScroll();
	el.UItoolTip.style.left=(e.clientX+scroll.left)+"px";
	el.UItoolTip.style.top=(e.clientY+scroll.top+20)+"px";
};
UI.toolTip.mouseout=function(event){
	var e=event || window.event; var el= e.target || e.srcElement;
	if(!el.UItoolTip) return;
	el.UItoolTip.style.visibility="hidden";
	if(el.options.mousemove) UI.delEvent(document, "mousemove",  el.options.mousemove);	
};

function Paging(prefix, lpp, total) {
	var currentPage = 1;
	var rest = 0;
	document.getElementById(prefix+'Prev').onclick = function(addPage){paginate(-1);}
	document.getElementById(prefix+'Next').onclick = function(addPage){paginate(1);}
	
	var paginate = function(addPage) {
		var page = currentPage + addPage;
		rest = total - lpp * page;
		if (page < 1) {paginate(Math.round(rest/lpp-1));return;}
		if (rest <= lpp * -1) {paginate((currentPage-1)*-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";
		}
		
		if (rest > lpp * -1 && rest <= 0) { // 마지막 page일 경우
			document.getElementById(prefix+'Next').className = "nextOff";
		}
	}
	paginate(0);
}


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);
			}				
		}
	}
};



/*---------------------------------*/
//	mc : mizcook
/*---------------------------------*/
var mc = {};

// 레시피 인쇄하기
mc.print_recipe = function(articleId,viewType){
	// opt : total / shopping
	var w = (viewType == 'total') ? 760 : 579;
	window.open('http://board.miznet.daum.net/gaia/do/cook/recipe/mizr/print/read?articleId=' + articleId + '&bbsId=Mc001&viewType=' + viewType, 'recipe_print', 'width='+ w + ',height=600,scrollbars=1');
}
// 미즈쿡 일반 공통 인쇄하기 화면
mc.print_page = function(bbsId, articleId){
	window.open('http://board.miznet.daum.net/gaia/do/cook/print/read?articleId=' + articleId + '&bbsId=' + bbsId, 'article_print', 'width=760,height=600,scrollbars=1');	
}
mc.toggle_prints = function(e,opt,obj){
	var evt = e || window.event;
	if(obj==undefined){
		var tgt = 'prints';
		if(e.type == 'click'){
			if(UI.getBrowser().ie){
				var e_pos = UI.getPosition(e.srcElement);
				var mom_pos = UI.getPosition(e.srcElement.parentNode.parentNode);
			} else {
				var e_pos = UI.getPosition(e.target);
				var mom_pos = UI.getPosition(e.target.parentNode.parentNode);
			}
			UI.$(tgt).style.left = e_pos.x - mom_pos.x + 'px';			
		}
	} else {
		var tgt = obj;
		UI.$(obj).style.left = UI.$('bt_read_print').offsetLeft - 16 + 'px';
	}
	UI.$(tgt).style.display = (opt=='show') ? 'block' : 'none';
	
	if (evt.stopPropagation) { evt.stopPropagation();} else {evt.cancelBubble = true;} 		
}
mc.switch_feature = function(no){
 	for(i=1;i<=3;i++){
 	 	UI.$('feature'+i).style.display = (no==i) ? 'block' : 'none';
 	 	UI.$('feature_button'+i).className = (no==i) ? 'on' : '';
 	}
 	if(no==2){UI.$('feature_button1').className += 'no_line';}
 	if(no==3){UI.$('feature_button2').className += 'no_line';}
 		
	UI.$('feature_button1').className = UI.$('feature_button1').className + ' first';
	if(no!=3){UI.$('feature_button3').className = 'last';}
}

// 캘린더 인쇄하기 cl : m or d(monthly daily)
mc.print_calendar = function(cl, ymd){
	var f = (cl=='m') ? 'Monthly' : 'Daily';
	window.open('http://cook.miznet.daum.net/calendar'+f+'Recipe.do?ymd='+ymd+'&print=y', 'calendar_print', 'width=854,height=600,scrollbars=1');
}
// 레시피올리기에서 취소하는 경우
mc.goback = function(){if(document.referrer){location.href=document.referrer;} else {window.history.go(-1);}}

mc.toggle_detail_layer = function(link, tgt){
	if(tgt.style.display=='block'){mc.hide_detail_layer(link,tgt);}else{mc.show_detail_layer(link,tgt);}
	return false;
}
mc.hide_detail_layer = function(link, tgt){tgt.style.display = 'none';link.className = 'arrow_down';}
mc.show_detail_layer = function(link, tgt){tgt.style.display = 'block';link.className = 'arrow_up';}

mc.hide_all_detail_layer = function(obj){mc.hide_detail_layer(UI.$('selector_class'),obj);mc.hide_detail_layer(UI.$('selector_time'),obj);mc.hide_detail_layer(UI.$('selector_difficulty'),obj);}


mc.attach_detail_layers = function(){
	// 요리종류
	
	var link_div = document.createElement('div');link_div.className = 'detail_layer';link_div.setAttribute('class','detail_layer');
	document.getElementsByTagName('body')[0].appendChild(link_div);
	
	UI.addEvent(UI.$('selector_class'), 'click', function(){
			var link = UI.$('selector_class');
			link_div.setAttribute('id','layer_class');
			if(link.className=='arrow_up'){mc.hide_all_detail_layer(link_div);return false;} else {mc.hide_all_detail_layer(link_div);}
			var html = '';
			for(i=0;i<classList.length;i++){html += '<li><a href="http://board.miznet.daum.net/gaia/do/cook/recipe/mizr/list?bbsId=MC001&objCate1=' + classList[i].id + '&sortKey=depth&forceTalkro=T">' + classList[i].name + '</a></li>';}
			link_div.innerHTML = '<ul>' + html + '</ul>';
			var pos = UI.getPosition(link);
			link_div.style.top = pos.y + 15 + 'px';link_div.style.left = pos.x + 'px';
			UI.addEvent(link_div, 'mouseout', function(){if(UI.mouseOut(arguments[0],link_div)){mc.hide_detail_layer(link,link_div);}});			
			mc.toggle_detail_layer(link,link_div);return false;
		}
	);
	
	UI.addEvent(UI.$('selector_time'), 'click', function(){
			var link = UI.$('selector_time');
			link_div.setAttribute('id','layer_time');
			if(link.className=='arrow_up'){mc.hide_all_detail_layer(link_div);return false;} else {mc.hide_all_detail_layer(link_div);}
			var html = '';
			for(i=0;i<timeList.length;i++){html += '<li><a href="http://cook.miznet.daum.net/search/detailSearch.do?cookingtime_cate=' + timeList[i].id + '">' + timeList[i].name + '</a></li>';}
			link_div.innerHTML = '<ul>' + html + '</ul>';
			var pos = UI.getPosition(link);
			link_div.style.top = pos.y + 15 + 'px';link_div.style.left = pos.x + 'px';
			UI.addEvent(link_div, 'mouseout', function(){if(UI.mouseOut(arguments[0],link_div)){mc.hide_detail_layer(link,link_div);}});
			mc.toggle_detail_layer(link,link_div);return false;
		}
	);


	UI.addEvent(UI.$('selector_difficulty'), 'click', function(){
			var link = UI.$('selector_difficulty');
			link_div.setAttribute('id','layer_difficulty');
			if(link.className=='arrow_up'){mc.hide_all_detail_layer(link_div);return false;} else {mc.hide_all_detail_layer(link_div);}
			var html = '';
			for(i=0;i<difficultyList.length;i++){html += '<li><a href="http://cook.miznet.daum.net/search/detailSearch.do?difficulty=' + difficultyList[i].id + '">' + difficultyList[i].name + '</a></li>';}
			link_div.innerHTML = '<ul>' + html + '</ul>';
			var pos = UI.getPosition(link);
			link_div.style.top = pos.y + 15 + 'px';link_div.style.left = pos.x + 'px';
			UI.addEvent(link_div, 'mouseout', function(){if(UI.mouseOut(arguments[0],link_div)){mc.hide_detail_layer(link,link_div);}});
			mc.toggle_detail_layer(link,link_div);return false;
		}
	);
}

mc.zzim = function(){
	var f = UI.$('form_add_scrap');
	var popup = window.open('about:blank', 'popup_zzim', 'width=375,height=250,scrollbars=0');
	f.target = 'popup_zzim';
	f.submit();

}

// clipboard로 복사
//source : zeroclipboard ( http://code.google.com/p/zeroclipboard/ )
UI.Clipboard = {
		movieId: "clipboardSwf",
		moviePath: "http://img-contents.daum-img.net/miznet9/2008_home/mizcook/common/CopyClipboard.swf",
		init: function( width, height, text ){
	        this.setText( text );
			var html = this.getHTML( width, height );
			document.write( html );
		},
		setText: function( text ){
	        this.clipText = text;
		},
		dispatch: function( id, type, args ) {
	        if( type == "load" ){
	            if( !this.movie ){ 
	                this.movie = document.getElementById( this.movieId );
	            }
	            this.movie.setText( this.clipText  );
	        
			} else if( type == "complete" ){
	            
				alert("주소가 복사되었습니다.");
			}
		},
		getHTML: function(width, height) {
			// return HTML for movie
			var html = '';
			var flashvars = 'id=' + this.movieId + 
				'&width=' + width + 
				'&height=' + height;
				
			if (navigator.userAgent.match(/MSIE/)) {
				// IE gets an OBJECT tag
				var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
				html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+this.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
			}
			else {
				// all other browsers get an EMBED tag
				html += '<embed id="'+this.movieId+'" src="'+this.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" ></embed>';
			}
			return html;
		}
	};




var YozmUtil = {
	bbs:{
		sourceid:31, // 미즈쿡  31
		link: window.location.href ,
		prefix:"제목",
		submitUrl:"http://yozm.daum.net/api/popup/prePost?sourceid=#SOURCEID&link=#LINK&prefix=#PREFIX",
		el: null,
		save: function(params){
		YozmUtil.bbs.submitUrl = YozmUtil.bbs.submitUrl.replace("#PREFIX", encodeURI(params.prefix || YozmUtil.bbs.prefix));
		YozmUtil.bbs.submitUrl = YozmUtil.bbs.submitUrl.replace("#LINK", escape(params.link || YozmUtil.bbs.link));
		YozmUtil.bbs.submitUrl = YozmUtil.bbs.submitUrl.replace("#SOURCEID", params.sourceid || YozmUtil.bbs.sourceid);
			window.open(YozmUtil.bbs.submitUrl  , 'yozmSend', 'width=466, height=356');
			try { ct.call(YozmUtil.bbs.el); } catch(e) {}  // ct call을 위한 부분
			return false;
		}
	}
}

function recipeEventPopup(){
	if(document.referrer.toString().indexOf("/gaia/do/cook/recipe/mizr/write?bbsId=MC001") > -1){
		if(confirm("이벤트에 응모 하시겠습니까?")){
			daum.Browser.popup("http://cook.miznet.daum.net/event/bestfoodiesEventRegist.do",370,240,{name:'',scroll:false,resize:false,status:0}); return false;
		};		
		return false;
	}
}

/* click log */
var sec; var kw; var ks; var sss; var uco=0; var uda2; var usr4;
var URL="http://log.search.daum.net/cgi-bin/";
var etlImg=new Image();

function openWin(u1,u2) {
	var url=u1+"&uco="+(++uco)+u2;
	etlImg.src=url;
	uda2=null;
	return true;
}

function init(s,keyw,keys,ss) {
	sec=s;
	var index=keyw.indexOf("%2F");
	if(index>0){kw=unescape(keyw);
	} else { kw=keyw; }
	ks=keys;
	sss=ss;
}

function cU1(a,scope,r,p,ext) {
	return URL+"s="+sec+"&a="+a+scope+"&q="+kw+"&k="+ks+"&r="+r+"&p="+p+"&ext="+ext;
}

function cU2(o,u1,u2,u3) {
	var u="NONE";
	if(o!=null) u=o.href;
	if(uda2!=null) u2 = uda2;
	return "&usr1="+u1+"&usr2="+u2+"&usr3="+u3+"&t=D&u="+u;
}

function cU3(u,u1,u2,u3) {
	return "&usr1="+u1+"&usr2="+u2+"&usr3="+u3+"&t=D&u="+u;
}
function gLink(o,a,r,p) {
	/*
	"var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"","","");
	return openWin(u1,u2);
	*/
	return true;
}

function gExtraLink(o,a,ext) {
	/*
	var scope="&ss="+sss+"&as=";
	if(o != null) u = o.href;
	var u1=cU1(a,scope,"","",ext); var u2=cU2(o,"","","");
	return openWin(u1,u2);
	*/ 
	return true;
}

function gCRLink(u,a,r,p) {
	/*
	var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,r,p,""); var u2=cU3(u,"","","");
	return openWin(u1,u2);
	*/
	return true;
}

function gCRExtraLink(u,a,ext) {
	/*
	var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,"","",ext); var u2=cU3(u,"","","");
	return openWin(u1,u2);
	*/
	return true;
}

function gUSR1Link(o,a,r,p,usr1) {
	/*
	var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,"","");
	return openWin(u1,u2);
	*/ 
	return true;
}

function gUSR2Link(o,a,r,p,usr2) {
	/*
	var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"",usr2,"");
	return openWin(u1,u2);
	*/
	return true;
}

function gUSR12Link(o,a,r,p,usr1,usr2) {
	/*
	var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,"");
	return openWin(u1,u2);
	*/
	return true;
}

function gUSR123Link(o,a,r,p,usr1,usr2,usr3) {
	/*
	var scope="&ss="+sss+"&as=";
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,usr3);
	return openWin(u1,u2);
	*/
	return true;
}

function gAsLink(o,a,r,p,as) {
	/*
	var scope="&ss="+sss+"&as="+as;
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"","","");
	return openWin(u1,u2);
	*/
	return true;
}

function gAsUSR1Link(o,a,r,p,as,usr1) {
	/*
	var scope="&ss="+sss+"&as="+as;
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,"","");
	return openWin(u1,u2);
	*/
	return true;
}

function gAsUSR12Link(o,a,r,p,as,usr1,usr2) {
	/*
	var scope="&ss="+sss+"&as="+as;
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,"");
	return openWin(u1,u2);
	*/
	return true;
}

function gAsUSR123Link(o,a,r,p,as,usr1,usr2,usr3) {
	/*
	var scope="&ss="+sss+"&as="+as;
	var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,usr3);
	return openWin(u1,u2);
	*/
	return true;
}

var isFF = (navigator.appName.indexOf("Netscape") != -1);
if(isFF) document.captureEvents(Event.MOUSEMOVE);

function cPosChk(e){
	var pos;
	x = (isFF) ? e.pageX : event.clientX + document.body.scrollLeft;
	y = (isFF) ? e.pageY : event.clientY + document.body.scrollTop;
	pos = x + "_" + y;
	return pos;
}

function gUSRXLink(o,a,r,p,as,usr1,usr2,usr3,ext,ext1,ext2,ext4,e){
	/*
	if(o != null) var u = o.href;
	var pos = cPosChk(e);
	var fullUrl = URL + "s="+sec+"&a="+a+"&ss="+sss+"&as="+as+"&q="+kw+"&k="+ks+"&r="+r+"&p="+p+"&ext="+ext+"&uco="+(++uco)+"&usr1="+usr1+"&usr2="+usr2+"&usr3="+usr3+"&t=D&u="+u+"&usr4="+usr4+"&ext1="+ext1+"&ext2="+ext2+"&ext3="+pos+"&ext4="+ext4;
	etlImg.src = fullUrl; 
	*/
	return true;
}

function gReplaceAll(str,o,n) {var pstr=""; for(var i=0;i<str.length;i++){ pstr+=str.charAt(i).replace(o,n); }return pstr;}
function gSetUSR2(v) {v=gReplaceAll(v, "%", "%25");v=gReplaceAll(v, "#", "%23");v=gReplaceAll(v, "&", "%26");v=gReplaceAll(v, "?", "%3F");uda2=v;}
function gSetUSR4(v) {usr4=v;}
function gSetKW(v) {kw=v;}
/* click log */


mc.Social = function(){
	var _url = {
		profile : "http://profile.daum.net/api/popup/Share.daum",
		mypeople : "http://mypeople.daum.net/mypeople/web/share.do",
		thumbPath : ""
	}
	var _options = {
		service : ''
	}
	
	var _params = {};
	var _strIds = null;
	
	var _method = {
		getValue : function( key ){
			if( key == "prefix" ){
				return _params[key];
			} else if( key == "link" ){
				return _params[key];
			} else if( key == "thumb" ){
				return _params[key];
			}
		},
		getUrlParams : function(){
			var p = [];
			p.push('service_name='+ _options.service);
			if(_options.service == "facebook" || _options.service == "yozm") {
				if(this.getValue('thumb').indexOf('noimg') == -1) {
					p.push('image_path='+this.getValue('thumb'));
				} else {
					p.push('image_path=');
				}
				p.push('description='+ encodeURIComponent('오늘 뭐 먹지? Daum 요리 미즈쿡'));
			}
			p.push('prefix='+ encodeURIComponent(daum.String.trim(this.getValue('prefix'))));
			//p.push('link='+ encodeURIComponent(this.getValue('link')));
			p.push('link='+ encodeURIComponent(location.href));
			//p.push('link='+ encodeURIComponent("http://cook.miznet.daum.net/"));
						
			if( _options.service == "yozm"){
				p.push('source_id=31');
				//p.push('meta_type=' + daum.String.trim(this.getValue('meta')));
				//p.push('meta_key=' + strIds);
			}
			return p.join('&');
		},
		open : function(){
			if( _options.service == "mypeople" ){
				daum.Browser.popup(_url.mypeople+"?source_id=31&"+_method.getUrlParams(), 680, 560, {name:'social'});
			}  else {
				daum.Browser.popup(_url.profile+"?"+_method.getUrlParams(), 400, 350, {name:'social'});
			}
		},
		moreSns : function(type) {
			if(type == "show") {
				daum.Element.show(daum.$("snsLayerContainer"));
			} else {
				daum.Element.hide(daum.$("snsLayerContainer"));
			}
		}
	}
	
	return {
		add : function( service, param ){
			_options = {service:service};
			if( param ){
				this.setParams(param);
			}
			_method.open();
		},
		setParams : function( params ){
			_params = params;
		},
		moreSns : function(type) {
			_method.moreSns(type)
		}
	}
}();

/*!
 * extracted and modified from 
 *    jQuery JavaScript Library v1.3.2
 *    http://jquery.com/
 *
 *    Copyright (c) 2009 John Resig
 *    Dual licensed under the MIT and GPL licenses.
 *    http://docs.jquery.com/License
 */
(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
        daum.Event.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
                daum.Array.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;
})();


/**
 * 모바일 페이지 가기 
 **/
UI.goToMobile = function(){
	var pc2mobileReExp = /lgtelecom|Opera.*SKT|PPC.*Opera|Smartphone.*Opera|800*480;NATE|NATE.*Browser|Mobile Safari|iriver|IEMobile NAVI|POLARIS|iPhone|Dolfin/;
	if(pc2mobileReExp.test(navigator.userAgent)){
		// set cookie (referrer가 모바일 검색일때만)
		if(document.referrer.indexOf("http://m.search.daum.net/search?q=") > -1) {
			document.cookie = 'M_P2M=N;expires=;domain=.daum.net;path=/;';
		}
		 
		var goMobileTemplate = new daum.Template([ 	
  		'<div id="goMobileArea" style="padding:40px 0 40px 40px;margin:10px 0 0 0;border-top:1px solid #e6e6e6;display:none;">',
		'<a href="http://cook.miznet.daum.net" id="goMobileTop" style="display:block;width:440px;margin:0 0 0 1px;">',
		'<img src="http://icon.daum-img.net/mobile/simple/polaris/2010_common/bt_move3.png" width="430" height="115" alt="모바일화면 이동" />',
		'</a>',
		'</div>'
		].join('') ); 
		
		var goMobileAreaWrap = goMobileTemplate.toElement ();
		document.body.appendChild(goMobileAreaWrap);
		daum.$("goMobileArea").style.display = "block";				
		daum.addEvent(daum.$('goMobileTop'), 'click', function() {
			var expireDate = new Date();
	    	expireDate.setDate( expireDate.getDate() - 1 );
			document.cookie = 'M_P2M=;expires=' + expireDate.toGMTString() + ';domain=.daum.net;path=/;';
			var mobileUrl = document.location.href;
			if(mobileUrl.indexOf("/search/search.do") > -1) {
				mobileUrl = mobileUrl.replace("cook.miznet.daum.net", "m.cook.miznet.daum.net");
				mobileUrl = mobileUrl.replace("/search/search.do", "/search");
			} else if(mobileUrl.indexOf("/search/detailSearch.do") > -1 || mobileUrl.indexOf("/recipe/dishGroupRecipeList.do") > -1) {
				mobileUrl = "http://m.cook.miznet.daum.net/";
			}
			if(mobileUrl.indexOf("bbsId=MC001") > -1) {
				mobileUrl = mobileUrl.replace("board.miznet.daum.net", "m.board.miznet.daum.net");
				mobileUrl = mobileUrl.replace("/gaia/do/cook/recipe/mizr", "/gaia/do/mobile/cook/recipe");
				if(mobileUrl.indexOf("searchKey=") > -1 && mobileUrl.indexOf("searchValue=") > -1) {
					mobileUrl = "http://m.cook.miznet.daum.net/";
				}
			} else {
				mobileUrl = "http://m.cook.miznet.daum.net/";
			}
			daum.$("goMobileTop").href = mobileUrl;
	    });
	}
};

UI.recommendTheme = function(id) {
	var url = "http://cook.miznet.daum.net/theme/themeRecommendJson.do";
	var options =  {
		method : "POST",
		paramString  : "themeId=" + id,
		onsuccess : UI.recommendCallback,
		onfailure : function() {
			alert("서버와의 접속이 원활하지 못하여 추천에 실패하였습니다.");
		}
	};
	new daum.Ajax(options).request(url);
};

UI.recommendCallback = function(res) {
	try {
		var recommendData = daum.jsonToObject(res.responseText);
		
		if(recommendData.result.type == "SUCCESS"){
			$("recommendCount").innerHTML = recommendData.result.recommendCount;
		}else{
			alert(recommendData.result.message);
		}
	} catch (e) {
		alert("서버와의 접속이 원활하지 못하여 추천에 실패하였습니다.");
	}
};

//우측상단 여백 광고
//스페이스 배너 공통 함수
var SpaceAD = {
	width : "130",  //배너 width
	height : "250", //배너 height
	parentElement : "", //삽입되는 상위 element
	top : "0",    //상위엘리먼트에서의 top
	left : "0",   //상위엘리먼트에서의 left
	secid : "00549", // 라이프 서비스 secid 

	insert : function(){
		if(SpaceAD.hasFlashPlugin){
			var sapaceAD_EL = document.createElement("DIV");
			sapaceAD_EL.innerHTML = '<div id="RIGHT_SPACE_BANNER" style="top:'+SpaceAD.top+'px;left:'+SpaceAD.left+'px;position:absolute;"><iframe src="http://amsv2.daum.net/ad/adview?secid='+ SpaceAD.secid + '" width="'+SpaceAD.width+'" height="'+SpaceAD.height+'" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe></div>';
			//오른쪽 날개 얼어버려서. innerHTML 말고 appendChild 형식으로 바꿈
			//SpaceAD.parentElement.innerHTML += '<div id="RIGHT_SPACE_BANNER" style="top:'+SpaceAD.top+'px;left:'+SpaceAD.left+'px;position:absolute;"><iframe src="http://amsv2.daum.net/ad/adview?secid='+ SpaceAD.secid + '" width="'+SpaceAD.width+'" height="'+SpaceAD.height+'" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe></div>';
			SpaceAD.parentElement.appendChild(sapaceAD_EL);
		}
	},
	hasFlashPlugin : (function(){
		var hasFlashPlugin = false;
		if(daum.Browser.ie && daum.Browser.win){
			result = false;
			document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.1"))</SCRIPT>\n');
			if (result){
				hasFlashPlugin = true;
			}
		} else {
			hasFlashPlugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;
		}
		return hasFlashPlugin;
	})()
};


var AdManager = {
	
	getBanner : function(size, type, id) {
		var rand = Math.random().toString(); 
		var ordval = rand.substring(2,rand.length); 
		var clintAgent = navigator.userAgent;
		var couple_ordval = ordval;
		var url = document.location.toString();
		var secid = '00555';
		var ad_url = "http://amsv2.daum.net/ad/adview?secid="+secid;
		var EXUI = {};
		
		EXUI.StringBuffer=function(){this.buffer=new Array();};
		EXUI.StringBuffer.prototype={append:function(s){this.buffer.push(s);},toString:function(){return this.buffer.join("");}};
		
		var banner = new EXUI.StringBuffer();
		switch(size) {
			case 250 : {
				var curUrl = document.location.href;
				if(curUrl.indexOf("write")==-1 && curUrl.indexOf("reply")==-1 && curUrl.indexOf("edit")==-1 ){
					document.domain = 'daum.net';
				}
				banner.append('<div id="EXTENSIBLE_BANNER_WRAP"><div id="EXTENSIBLE_BANNER"></div></div>');
				banner.append('<iframe src="'+ad_url+'" width="250" height="250" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowTransparency="true" id="AMS_250exp" name="AMS_250exp" title=" "></iframe>');
				banner.append('<div id="TAKEOVER"><sc'+'ript src="http://amsv2.daum.net/ad/adview?secid=03L16&type=cpm&tag=javascript&mkvid=1&ord='+couple_ordval+'" type="text/javascript"></sc'+'ript></div>');
				break;
			}
			case 300 : {
				banner.append('<iframe src="http://amsv2.daum.net/ad/adview?secid=03L14&type=cpm&tag=iframe&mkvid=1&ord='+ordval+'" width="300" height="250" border="0" frameborder="0" scrolling="no" marginheight="0 "  name="AMS_250exp"  marginwidth="0" allowTransparency="true" id="AMS_250exp" title=""></iframe>');
				banner.append('<div id="TAKEOVER"><sc'+'ript src="http://amsv2.daum.net/ad/adview?secid=03L17&type=cpm&tag=javascript&mkvid=1&ord='+couple_ordval+'" type="text/javascript"></sc'+'ript></div>');
				break;
			}
			case "moving" : {
				banner.append('<div class="DaumUI__banner">');
				if(!!banners.length) {
					var bannerNo = Math.floor(Math.random()*banners.length);
					bannerNo = (banners[bannerNo])?bannerNo:bannerNo-1;				
					banner.append('<a href="'+banners[bannerNo].link+'"><img src="' + banners[bannerNo].img + '" border="0" alt=""></a>');				
				} else {				
					banner.append("<iframe src=\"http://amsv2.daum.net/ad/adview?secid=03L21&type=cpm&tag=iframe&mkvid=1&ord=" + ordval + "\" width=200 height=39 border=0 frameborder=0  name=AMS_250exp  scrolling=no marginheight=0 marginwidth=0 id=AMS_250exp></iframe>");
				}
				banner.append('</div>');
				break;
			}
			case "countdown" : {
				banner.append("<iframe src=\"http://amsv2.daum.net/ad/adview?secid=03L19&type=cpm&tag=iframe&mkvid=1&ord=" + ordval + "\" width=168 height=18 border=0 frameborder=0 scrolling=no marginheight=0 marginwidth=0 id=AMS_250exp  name=AMS_250exp ></iframe>");
				break;
			}		 
			default : {break;}
		};
		
		if(type=="return") {
			return banner.toString();
		} else if(!!id) {
			var wrapper = document.getElementById(id);
			wrapper.innerHTML = "<div id='banner250'>" + banner.toString() + "</div>"; 
		} else {
			document.writeln(banner.toString());
		};
	}
};


/******************************************
탑
******************************************/
function SlidingVisual(options){
	this.options={
		wrap:$$(".wrap_event")[0],
		els:$$(".wrap_event li"),
		big:389,
		small:196,
		defaultIndex:0
	};
	daum.extend(this.options,options);
	
	this.init();
};
SlidingVisual.prototype={
	activeIndex:null,
	init:function(){
		var that=this;
		var opt=this.options;
		
		opt.els.each(function(o,i){
			var buttons = daum.$C(o, "button_expand")[0];
			daum.addEvent(o,'mouseover',that.active.bind(that,i));
			daum.addEvent(buttons,'click',that.active.bind(that,i));
		});
		that.setPos(opt.defaultIndex);
	},
	active:function(i){
		this.movePos(i);
	},
	getPos:function(selectedIndex){
		var opt=this.options;
		var r=[], pos;
		
		opt.els.each(function(o,i){
			pos=i*opt.small;
			if(i>selectedIndex) pos+=opt.big-opt.small;
			r.push(pos);
		});
		return r;
	},
	movePos:function(index){
		var opt=this.options;
		var pos=this.getPos(index);

		opt.els.each(function(o,i){
			daum.Fx.animate(o,"left:"+pos[i]+"px");
			daum.Fx.animate(o.getElementsByTagName("div")[0],"left:0px",{duration:0.7});
		});
		daum.Fx.animate(opt.els[index].getElementsByTagName("div")[0],"left:-"+opt.small+"px",{duration:0.01});

		this.activeIndex=index;
	},
	setPos:function(index){
		var opt=this.options;
		var pos=this.getPos(index);

		opt.els.each(function(o,i){
			daum.setStyle(o,"left:"+pos[i]+"px");
		});
		daum.setStyle(opt.els[index].getElementsByTagName("div")[0],"left:-"+opt.small+"px");

		this.activeIndex=index;
	}
};


var accordian = function(container, options){
	var _container;
	var _pleats;
	var _presentivePleat;
	var _expanded;
	var _contracted;
	var _options = { 
	};
	var _isPlaying = false;
	var _startTime;
	var _tid;
	var _nowWidth;
	var _nowExpandingLeft; 
	var _nowContractingLeft;
	
	var _stop = function(){
		if(_tid != null){
			_nowWidth = _options.expandedWidth;
			_nowExpandingLeft = 0;
			_nowContractingLeft = _contracted.contractedLeft;
			_update();
			clearInterval(_tid);
			_tid = null;
			daum.replaceClassName(_contracted, "expand","compact"); 
			daum.replaceClassName(_expanded, "link_none","link_accesble"); 
			_isPlaying = false;
			return true;
		} else {
			_isPlaying = false;
			return false;
		}
	};
	
	var _update = function(){
		var expandingWidth = Math.round(_nowWidth);
		var contractingWidth = _options.expandedWidth - expandingWidth + _options.contractedWidth;
		var expandingLeft = Math.round(_nowExpandingLeft);
		var contractingLeft = Math.round(_nowContractingLeft);

		daum.setStyle(_expanded, "width", expandingWidth + "px");
		daum.setStyle(_contracted, "width", contractingWidth + "px");
		daum.setStyle(_expanded.movableItem, "left", expandingLeft + "px");
		daum.setStyle(_contracted.movableItem, "left", contractingLeft + "px");
	};
	
	var _step = function(){
		var t = (new Date()).getTime();
		if (t >= _options.duration + _startTime){
			_stop();
			return false;
		} else {
			var n = t - _startTime;
			var pos = _options.easing(n, 0, 1, _options.duration);
			_nowWidth = _options.contractedWidth + ((_options.expandedWidth - _options.contractedWidth) * pos);
			_nowExpandingLeft = _expanded.contractedLeft - (_expanded.contractedLeft * pos);
			_nowContractingLeft = _contracted.contractedLeft * pos;
			_nowOpacity = pos;
			_update();
		}
		return true;
	};
	
	var _play = function(){
		_isPlaying = true;
		_startTime = (new Date()).getTime();
		_tid = daum.Function.interval(_step, 28);
		daum.replaceClassName(_contracted, "link_accesble","link_none"); 
		daum.replaceClassName(_expanded, "compact", "expand"); 
	};
	
	var _mouseMoveHandler = function(e){
		if(_isPlaying == false){
			var source = daum.getElement(e);
			var pleat = source;
			while(true){
				if(daum.hasClassName(pleat, "pleat")){
					break;
				} else if(pleat === document.body){
					return false;
				}
				pleat = pleat.parentNode;
			}
			if(pleat === _expanded){
				return true;
			}
			_contracted = _expanded;
			_expanded = pleat;
			_play();
		}
	};
	
	var _revisePosition = function(){
		daum.setStyle(_presentivePleat.movableItem, "left", "0");		
		daum.replaceClassName(_presentivePleat, "compact", "expand"); 
		_pleats.each(function(pleat, i){
			if(!daum.hasClassName(pleat, "presentive")){
				daum.setWidth(pleat, _options.contractedWidth);
			}
		});
	};
	
	var _attachDataToPleats = function(){
		_pleats.each(function(pleat, i){
			pleat.movableItem = daum.$E(daum.$C(pleat, "movableItem")[0]);
			if(daum.hasClassName(pleat, "presentive")){
				pleat.contractedLeft = _options.presentiveLeft;
			}else{
				pleat.contractedLeft = daum.Number.toInt(daum.getStyle(pleat.movableItem, "left"));
			}
		});
	};
	
	var _attachEvents = function(){
		_pleats.each(function(pleat, i){
			var buttons = daum.$C(pleat, "button_expand")[0];
			daum.addEvent(pleat, "mousemove", _mouseMoveHandler);
			daum.addEvent(buttons, "click", _mouseMoveHandler);
		});
	};
	
	var _initialze = function(){
		try{
			_container = container;
			_pleats = daum.$A(daum.$C(_container, "pleat"));
			_presentivePleat = daum.$E(daum.$C(_container, "presentive")[0]);
			_expanded = _presentivePleat;
		}catch(e){
			console.log(e);
		}
		_options.expandedWidth = daum.Number.toInt(daum.getStyle(_presentivePleat, "width"));
		//_options.contractedWidth = (daum.Number.toInt(daum.getStyle(_container, "width")) - _options.expandedWidth) / (_pleats.length - 1);
		_options.contractedWidth = 196;
		_options.presentiveLeft = -65;
		_options.duration = 325;
		_options.easing = function (t, b, c, d) { return c*(t/=d)*t + b; };
		daum.extend(_options, options, true);
		_attachDataToPleats();
		_attachEvents();
		_revisePosition();
	};
	_initialze();
};




