var doc = document;
try{doc.domain="daum.net";}catch(e){}
try{doc.execCommand("BackgroundImageCache",false,true);}catch(ignored){}
function $(id){return doc.getElementById(id);}
function $C(node){return doc.createElement(node);}
function $T(text){return doc.createTextNode(text);}
function $A(iterable){
	if (!iterable) return [];
	var results=[];
	for (var i=0,length=iterable.length; i<length; i++)
		results.push(iterable[i]);
	return results;
}
/*
Thanks for JES
*/
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));
	}
}

// Common
function _debug( val ){
	try{
//		console.log( val );	
	}catch (e){}
}
var UI={};
UI.$=function(s) { return doc.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.show=function(id) { UI.$(id).style.display="block"; };
UI.hide=function(id) { UI.$(id).style.display="none"; };
UI.getEl=function(e){var E=UI.getE(e);return E.target || E.srcElement}
UI.getE=function(e){return e || window.event}
UI.StringBuffer=function(){this.buffer=new Array()}
UI.StringBuffer.prototype={append:function(s){this.buffer.push(s)},toString:function(){return this.buffer.join("")}};
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.toogle=function(id) { UI.$(id).style.display=(UI.getStyle(UI.$(id),'display')=='none') ? 'block':'none' };
UI.getScroll=function () {
	if(doc.all && typeof doc.body.scrollTop != "undefined")
	{
		var cont=doc.compatMode!="CSS1Compat"?doc.body:doc.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.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.getStyle=function(el,style) {
	var value=el.style[style];
	if(!value)
	{
		if(doc.defaultView && doc.defaultView.getComputedStyle)
		{
			var css=doc.defaultView.getComputedStyle(el,null);
			value=css ? css[style]:null;
		}
		else if (el.currentStyle) value=el.currentStyle[style];
	}
	return value=='auto' ? null:value;
};
//add event
UI.addEvent=function(object,type,listener) {
	try{
	if(object.addEventListener) {if(type=='mousewheel')type='DOMMouseScroll'; object.addEventListener(type,listener,false)}
	else { object.attachEvent("on"+type,listener); }
	}catch(e){}
};
//delete event
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);
};
//stop event
UI.stopEvent=function(event) {
	var e=event || window.event;
	try {
		if(e.preventDefault) {e.preventDefault(); e.stopPropagation(); }
		else {e.returnValue=false; e.cancelBubble=true;}

	} catch (e) {}
};
//get style
UI.getStyle=function(el,style) {
	var value=el.style[style];
	if(!value)
	{
		if(doc.defaultView && doc.defaultView.getComputedStyle)
		{
			var css=doc.defaultView.getComputedStyle(el,null);
			value=css ? css[style]:null;
		}
		else if (el.currentStyle) value=el.currentStyle[style];
	}
	return value=='auto' ? null:value;
};
UI.addComma=function(s){
	s+='';
	s=s.replace(/,/gi,'');
	var re=new RegExp('(-?[0-9]+)([0-9]{3})');
	while(re.test(s)) s=s.replace(re,'$1,$2');
	return s;

};
UI.delComma=function(s){
	s=s.replace(/,/gi, "");
	return s;
}
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),
		chrome:/chrome/.test(ua),
		gecko:/gecko/.test(ua)
	};
	return UI._browser;
};




// option
UI.initOption=function(obj){obj.length=0;};
UI.createOption=function(text,value){
	var objOpt=doc.createElement("OPTION"); // create object
	objOpt.text=text; // Text(Keyword)
	objOpt.value=value; // Value
	return objOpt;
};
UI.addOption=function(selectObj,keyword,value){
	if(selectObj==null)return;
	// add option
	var option = UI.createOption(keyword ,value);
	selectObj.options.add(option);
	return option;
};


UI.TabDynamic=function(id,options){
	this.options={
		eventType:"click",// event type on active [focus,mouseover]
		defaultIndex:0,//start num (1~[length])
		tabName:"tabBtn",
		bodyName:"tabBody",
		tabId:null,//["tabTest1","tabTest2"]
		bodyId:null,//["tabTestBody1","tabTestBody2"]
		focusBlur:false,
		pattern:/((tab)[0-9]{1,2})(_on)*/ig // tab1,tab1_on,tab2,tab2_on ,...
	}
	Object.extend(this.options,options);
	this.cid=id; // root container id
	this.tabBtn=[]; // tab button object list
	this.tabBody=[]; // tab body object list
	this.index=null; // current list index
	this.tabStyle="auto";
	if (this.options.tabId != null && this.options.bodyId != null && this.options.tabId.length > 0 && this.options.tabId.length==this.options.bodyId.length){
		this.tabStyle="userId";
	}
	if(UI.$(this.cid)){
		this.init();
		return this;
	} else {
		return false;
	}
}
UI.TabDynamic.prototype={
	init: function(){
		if (this.tabStyle=="userId"){
			var len=this.options.tabId.length;
			for (var i=0; i<len; i++) {
				var tabObj=UI.$(this.options.tabId[i]);
				var bodyObj=UI.$(this.options.bodyId[i]);
				// tab
				tabObj.index=this.tabBtn.length;
				this.tabBtn.push(tabObj);
				// add event
				UI.addEvent(tabObj,this.options.eventType,this.on.bind(this,tabObj.index));

				// body
				bodyObj.index=this.tabBody.length;
				this.tabBody.push(bodyObj);
			}
		} else { // auto
			var child=UI.$(this.cid).childNodes;
			var childCnt=child.length;
			// filtering
			for (var i=0; i<childCnt; i++){
				var className=child[i].className;
				if (child[i].nodeType==1 && className != undefined){
					if (className.indexOf(this.options.tabName) > -1){
						child[i].index=this.tabBtn.length;
						this.tabBtn.push(child[i]);
						// add event
						UI.addEvent(child[i],this.options.eventType,this.on.bind(this,child[i].index));
					} else if (className.indexOf(this.options.bodyName) > -1){
						child[i].index=this.tabBody.length;
						this.tabBody.push(child[i]);
					}
				}
			}
		}

		// auto active by 'this.options.num-1'='obj.index'
		this.on(this.options.defaultIndex);
	},
	on:function(index){
		var pattern=this.options.pattern;
		// set prev
		if (this.index==-1){
			return false;
		} else if (this.index != null){
			this.tabBtn[this.index].className=this.tabBtn[this.index].className.replace(pattern,"$1");
			this.tabBody[this.index].style.display="none";
		}
		// set current
		this.tabBtn[index].className=this.tabBtn[index].className.replace(pattern,"$1_on");
		this.tabBody[index].style.display="block";
		this.index=index;
		if (this.options.focusBlur==true){
			//this.tabBtn[index].blur();
		}
	}
}
UI.TabDynamic2009 = function(id,options){
	try{
	this.options={
		eventType:"click",// event type on active [focus,mouseover]
		defaultIndex:0,//start num (1~[length])
		tabName:"tabBtn",
		bodyName:"tabBody",
		tabId:null,//["tabTest1","tabTest2"]
		bodyId:null,//["tabTestBody1","tabTestBody2"]
		focusBlur:false,
		moreUrl:null,
		pattern:/((tab)[0-9]{1,2})(_on)*/ig // tab1,tab1_on,tab2,tab2_on ,...
	}
	Object.extend(this.options,options);
	this.cid=id; // root container id
	this.tabBtn=[]; // tab button object list
	this.tabBody=[]; // tab body object list
	this.index=null; // current list index
	this.tabStyle="auto";
	if (this.options.tabId != null && this.options.bodyId != null && this.options.tabId.length > 0 && this.options.tabId.length==this.options.bodyId.length){
		this.tabStyle="userId";
	}
	if(UI.$(this.cid)){
		this.init();
		return this;
	} else {
		return false;
	}
	}catch(e){}
}
UI.TabDynamic2009.prototype={
	init: function(){
		try{
		if (this.tabStyle=="userId"){
			var len=this.options.tabId.length;
			for (var i=0; i<len; i++) {
				var tabObj=UI.$(this.options.tabId[i]);
				var bodyObj=UI.$(this.options.bodyId[i]);
				// tab
				tabObj.index=this.tabBtn.length;
				this.tabBtn.push(tabObj);
				// add event
				UI.addEvent(tabObj,this.options.eventType,this.on.bind(this,tabObj.index));

				// body
				bodyObj.index=this.tabBody.length;
				this.tabBody.push(bodyObj);
			}
		} else { // auto
			var child=UI.$(this.cid).childNodes;
			var childCnt=child.length;
			// filtering
			for (var i=0; i<childCnt; i++){
				var className=child[i].className;
				if (child[i].nodeType==1 && className != undefined){
					if (className.indexOf(this.options.tabName) > -1){
						child[i].index=this.tabBtn.length;
						this.tabBtn.push(child[i]);
						// add event
						UI.addEvent(child[i],this.options.eventType,this.on.bind(this,child[i].index));
					} else if (className.indexOf(this.options.bodyName) > -1){
						child[i].index=this.tabBody.length;
						this.tabBody.push(child[i]);
					}
				}
			}
		}

		// auto active by 'this.options.num-1'='obj.index'
		this.on(this.options.defaultIndex);
		}catch(e){}
	},
	on:function(index){
		try{
		var pattern=this.options.pattern;
		// set prev
		if (this.index==-1){
			return false;
		} else if (this.index != null){
			this.tabBtn[this.index].getElementsByTagName('a')[0].className = ""; 
			this.tabBody[this.index].style.display="none";
			if(this.options.moreUrl!=null){
				UI.$(this.options.moreUrl.id).href = this.options.moreUrl.url[this.index];
			}	
		}
		// set current
		this.tabBtn[index].getElementsByTagName('a')[0].className = "on"; 
		this.tabBody[index].style.display="block";
		
		if(this.options.moreUrl!=null){
			UI.$(this.options.moreUrl.id).href = this.options.moreUrl.url[index];
		}	
		
		this.index=index;
		if (this.options.focusBlur==true){
			//this.tabBtn[index].blur();
		}
		}catch(e){}		
	}
}
UI.SimpleSlide=function(listId,btnPrevId,btnNextId,options){
	this.options={
		listTagName:"LI",
		showNum:1,
		loop:false,
		onComplete:function(){},
		offComplete:function(){}
	}
	Object.extend(this.options,options);
	this.list=UI.$(listId).getElementsByTagName(this.options.listTagName);
	this.listCnt=this.list.length;
	this.btnPrev=UI.$(btnPrevId);
	this.btnNext=UI.$(btnNextId);
	this.index=null;
	this.prevIndex=null;
	if(this.list.length){
		UI.addEvent(this.btnPrev,"click",this.prev.bind(this));
		UI.addEvent(this.btnNext,"click",this.next.bind(this));
		this.index=0;
		this.on();
	}
}
UI.SimpleSlide.prototype={
	on:function(){
		this.chkBtnView();

		for (var i=0,num=0; i<this.options.showNum ; i++){
			num=this.index*this.options.showNum+i;

			if (this.options.loop==false && num >= this.listCnt){ // loop 제한이면 최대값 고정
				num=this.listCnt-1;
			}
			this.list[ num ].style.display="block";
		}
		this.options.onComplete(this);
	},
	off:function(){
		for (var i=0,num=0; i<this.options.showNum ; i++){
			num=this.index*this.options.showNum+i;
			if (this.options.loop==false && num > this.listCnt){ // loop 제한이면 최대값 고정
				num=this.listCnt;
			}
			if (num < this.listCnt){
				this.list[ num ].style.display="none";
			}
		}
		this.options.offComplete(this);
	},
	prev:function(){

		this.off();
		this.index--;//=this.options.showNum;
		if (this.index < 0){
			if (this.options.loop==true){
				this.index=this.listCnt-1;
			} else {
				this.index=0;
			}
		}
		this.on();
	},
	next:function(){
		this.off();
		this.index++;//=this.options.showNum;
		if (this.index >= Math.ceil(this.listCnt/this.options.showNum)-1){
			if (this.options.loop==true){this.index=0;} 
			else {this.index=Math.ceil(this.listCnt/this.options.showNum)-1;}
		}
		this.on();
	},
	chkBtnView:function(){
		if (this.options.loop==false){
			if (this.index==0){this.setBtnView(this.btnPrev,"off");} 
			else {this.setBtnView(this.btnPrev,"on");}
			if (this.index >= Math.ceil(this.listCnt/this.options.showNum)-1){this.setBtnView(this.btnNext,"off");} 
			else {this.setBtnView(this.btnNext,"on");}
		}
	},
	setBtnView:function(obj,view){
		if( obj ){
			switch(view){
				case "on":obj.style.backgroundPosition="left top";break;
				case "off":obj.style.backgroundPosition="left bottom";break;
			}
		}
	}
}

// DynamicScript from "JES UI.DynamicScript"
/**
2007-12-10
*/
UI.DynamicScript=function(url,enc){
	this.url=url||'';
	this.enc=enc||'';
	this.head=doc.getElementsByTagName("head").item(0);
	if(this.url) this.call(this.url);
};
UI.DynamicScript.prototype={
	noCacheParam:function(){
		var b=(this.url.indexOf('?')==-1) ? '?':'&';
		return b+'nOcAchE='+(new Date()).getTime();
	},
	call:function(url){
		try{this.head.removeChild(this.script)}catch(e){};
		this.url=url;
		this.script=doc.createElement("script");
		this.script.setAttribute("type","text/javascript");
		this.script.setAttribute("src",this.url+this.noCacheParam());
		if(this.enc) this.script.setAttribute("charset",this.enc);
		this.head.appendChild(this.script);
	}
};


// Scrolling from "JES UI.Scrolling"
/* 2007-07-10 */
UI.yScrolling=function(cid,millisec1,millisec2,speed,height)
{
	this.cid= cid;
	this.millisec1=millisec1;	//start term
	this.millisec2=millisec2; //runtime term
	this.speed=speed;			//moving pixel
	this.height=height;

	this.h =0;
	this.div=UI.$(this.cid);
	this.htmltxt=this.div.innerHTML;
	this.div.innerHTML=this.htmltxt+this.htmltxt;
	this.div.isover=false;
	this.div.onmouseover=function(){ this.isover=true; }
	this.div.onmouseout=function(){	this.isover=false; }
	this.div.scrollTop=0;
	var self =this;
	window.setTimeout(function(){self.play()},this.millisec1);
}
UI.yScrolling.prototype={
	play:function(){
		var self =this;
		if(!this.div.isover)
		{
			this.div.scrollTop += this.speed;
			if(this.div.scrollTop >= this.div.scrollHeight/2)
			{
				this.div.scrollTop=0;
				//this.h=0;
			}
			else(this.height)
			{
				this.h += this.speed;
				if(this.h>=this.height)
				{
					if(this.h>this.height)
					{
						this.div.scrollTop -= this.h % this.height;
						//window.status=this.div.scrollTop +":"+this.h % this.height;
					}
					this.h=0;
					window.setTimeout(function(){self.play()},this.millisec1);
					return;
				}
			}
		}
		window.setTimeout(function(){self.play()},this.millisec2);
	}
};

// Scrolling from "JES UI.Move"
/* 2007-07-10 */
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.45;
		this.inteval=10;
		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";
	}
};


// From JES
UI.length=function(str,len,tail){
	if(!str) str="";
	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;
};

var pos_n=0;
function topMoveSlide(type)
{
	if(slide_div.playing) return;
	if(type=="prev" && pos_n>0) {
		slide_div.slide(pos[--pos_n]);
	} else if(type=="next" && pos_n<pos.length-1) {
		slide_div.slide(pos[++pos_n]);
	}
}


UI.BtnList=function(id,childEl,options){
	this.id=id;
	this.childEl=childEl;
	this.options={
		num:0,
		pnum:null,// prev num
		count:0,
		loop:true
	};
	this.err=false;
	Object.extend(this.options,options);
	this.init();
}
UI.BtnList.prototype={
	init:function(){
		var base=UI.$(this.id);
		var childs=base.getElementsByTagName(this.childEl);
		this.options.count=childs.length;
		if (this.options.count <= 0){
			this.err=true;
		} else {
			this.show();
		}
		base=null;
		childs=null;
	},
	prev:function(){
		if (this.err==true) {
			return false;
		}
		this.options.num--;
		if (this.options.num<0){
			if (this.options.loop==true) {
				this.options.num=this.options.count-1;
			} else {
				this.options.num=0;
			}
		}
		this.show();
	},
	next:function(){
		if (this.err==true) {
			return false;
		}
		this.options.num++;
		if (this.options.num>=this.options.count){
			if (this.options.loop==true) {
				this.options.num=0;
			} else {
				this.options.num=this.options.count-1;
			}
		}
		this.show();
	},
	show:function(){
		var base=UI.$(this.id);
		var childs=base.getElementsByTagName(this.childEl);
		if (this.options.pnum != null){
			childs[this.options.pnum].style.display="none";
		}
		childs[this.options.num].style.display="block";
		this.options.pnum=this.options.num;
		base=null;
		childs=null;
	}
}

// 서제스트
function renderSuggest(){
	var layout='\
	<h3>Suggest</h3>\
	<div id="SugArea">\
	   <div id="SugMark"></div>\
	   <iframe id="SugFrame" frameborder="0"></iframe>\
	   <div id="SugResult">\
		  <ul id="SugList">\
			<li></li>\
		  </ul>\
		  <div id="SugInfoOn">현재 <b>서제스트</b>를 사용하고 있습니다.<br>검색어 입력시 자동으로 적합한 종목을 제시합니다.</div>\
		  <div id="SugInfoOff">\
		  <b>서제스트</b>를 사용해 보세요. <a href="javascript:;" id="BTon">기능켜기</a><br>검색어 입력시 자동으로 적합한 종목을 제시합니다.</div>\
		  <div id="SugLink">\
			 <a href="#">서제스트란?</a> | \
			 <a id="BToff" href="javascript:;">기능끄기</a>\
			 <a id="BTclose" href="javascript:;">닫기</a>\
		  </div>\
	   </div>\
	</div>\
	';

	doc.write(layout);

}

UI.ListDisplay = function( options ){
	this.options = {
		listId : null,
		listEl : "LI",
		btnPrevId : null,
		btnNextId : null,
		amount : 4,
		defaultIndex : 0,
		loop : false
	}
	Object.extend( this.options, options );
	this.init();
}
UI.ListDisplay.prototype = {
	init : function(){
		this.index = this.options.defaultIndex;
		this.objList = UI.$(this.options.listId);
		this.objListEl = this.objList.getElementsByTagName( this.options.listEl );
		this.objCnt = this.objListEl.length;
		this.objPrev = UI.$(this.options.btnPrevId);
		this.objNext = UI.$(this.options.btnNextId);
		this.lastPage = Math.ceil( this.objCnt /this.options.amount )-1;
		if( this.objCnt == this.lastIndex ) this.lastIndex - this.options.amount;
		UI.addEvent( this.objPrev , "click", this.prev.bind(this) );
		UI.addEvent( this.objNext , "click", this.next.bind(this) );

		this.reset();
	},
	reset : function(){
		var start = (this.index*this.options.amount);
		var end = (this.index*this.options.amount) + this.options.amount;

		for ( var i=0; i<this.objCnt ; i++ ){
			
			//if( i>=this.index && i<this.index+this.options.amount ){this.objListEl[i].style.display = "block";
			if( i>=start && i<end ){this.objListEl[i].style.display = "block";
			} else {
				this.objListEl[i].style.display = "none";
			}
		}
		this.check();
	},
	check : function(){
	/*
		if( this.options.loop == false ){
			if( this.index == 0 ){
				this.objPrev.className = "btnOff";
			} else {
				this.objPrev.className = "btnOn";
			}

			if ( this.index == this.lastIndex ){
				this.objNext.className = "btnOff";
			} else {
				this.objNext.className = "btnOn";
			}
			
		} else {
			this.objPrev.className = "btnOn";
			this.objNext.className = "btnOn";
			
		}*/
	},
	prev : function(){
		this.index--;
		if( this.index < 0 ){
			if( this.options.loop ){
				this.index = this.lastPage;//(this.lastPage-1)*this.options.amount;
			} else {
				this.index = 0;
			}
		}
		this.reset();
	},
	next : function(){
		this.index++;//=this.options.amount;
		if( this.index >= this.lastPage ){
			if( this.options.loop ){
				this.index = 0;
			} else {
				this.index = this.lastPage;//(this.lastPage-1)*this.options.amount;
			}
		}
		this.reset();
	}
}


UI.SelectObject = new Array();
UI.SelectObj = function( obj, btnObj, options ){
	this.obj = obj;
	this.btnObj = btnObj;
	this.isOpen = false;
	this.isOver = false;
	this.openComplete = null;
	this.closeComplete = null;
	this.toogleComplete = null;
 
	if( this.obj ){
		UI.SelectObject.push( this );
	}
	this.options = {
		autoOff : true
	}
	Object.extend( this.options, options );
	if( this.options.autoOff == true ){
		UI.addEvent( this.obj, "mouseover", this.open.bindAsEventListener(this) );
//		UI.addEvent( this.obj, "mouseout", this.close.bindAsEventListener(this) );
		UI.addEvent( document, "click", this.condClose.bindAsEventListener(this) );
	}

	if( this.btnObj ){
		UI.addEvent( this.btnObj, "click", this.toogle.bindAsEventListener(this) );
//		UI.addEvent( this.btnObj, "mouseout", this.close.bindAsEventListener(this) );
//		UI.addEvent( this.btnObj, "mouseover", this.open.bindAsEventListener(this) );
	}
}
UI.SelectObj.prototype = {
	open : function(){
		if( this.openInit ){ this.openInit(); }
		closeSelectAll();		
		this.isOpen = true;		
		this.obj.style.display = "block";
		if( this.openComplete ){ this.openComplete(); }
	},
	close : function(){
		if( this.closeInit ){ this.closeInit(); }
		this.isOpen = false;
		this.obj.style.display = "none";
		if( this.closeComplete ){ this.closeComplete(); }
	},
	condClose : function(event){
		var event = event? event : this.event; 
		var element = event.srcElement || event.target; 

		while( element ){
			if( element.idx || (element.id && element.id.indexOf(this.obj ) != -1)){
				return;
			}else{
				element = element.parentNode;
			}
		}	
		this.close();
	}, 
	toogle:function(e){
		if( this.toogleInit ){ this.toogleInit(e); }
		if(this.isOpen)	this.close();
		else this.open();
		if( this.toogleComplete ){ this.toogleComplete(e); }
		UI.stopEvent(e);
	}
}

function closeSelectAll(){
	var len=UI.SelectObject.length;
	for(var num =0; num<len; num++){
		try{ UI.SelectObject[num].close(); }catch (e){}
	}
}


UI.Select=function(id,skin){
	this.skin={
		topbox:'border:1px solid #cdcdcd;font-size:12px;font-family:AppleGothic,Dotum;color:#454545;background-color:#fff;cursor:pointer;text-align:left;line-height:20px;text-indent:5px;',
		subbox:'border:1px solid #cdcdcd;font-size:12px;font-family:AppleGothic,Dotum;color:#666;background-color:#fff;margin-top:-1px;text-align:left;',
		default_txt:'color:#666;background-color:#fff;padding-left:5px;cursor:pointer;',
		selected_txt:'color:#FFF;background-color:#697FE6;padding-left:5px;cursor:pointer;',
		arrow:'http://fn.daum-img.net/image/estate/2008/direct/budong_blit_01.gif',
		width:150,
		padding:3,
		sub_height:20,
		max_option:10,
		trg_obj:null,
		selectEvent:null,
		selfClick:false
	};
	Object.extend(this.skin,skin);

	if (this.skin.width != "auto"){
		this.skin.width=parseInt(this.skin.width)+"px";
		this.skin.topbox += ';width:'+this.skin.width;
	}
	this.input=UI.$(id);
	this.id=id;
	this.list=[];
	this.isOpen=false;
	this.isOver=false;
	this.sIndex=UI.$(id).selectedIndex;
	this.selectedIndex=UI.$(id).selectedIndex;
	this.value='';
	this.print();
};

UI.Select.prototype={
	close:function(){},
	open:function(){},
	toogle:function(e){
		if( this.selectObj.isOpen == true ){
			var obj = UI.$("UISelFocus_"+this.id);
			if( obj ){
				obj.style.display = "block";
				obj.focus();
				obj.style.display = "none";
			}
		}
		var thisClassName=this.objSub.getElementsByTagName('DIV')[this.sIndex].className.replace("default_txt","selected_txt");
		this.objSub.getElementsByTagName('DIV')[this.sIndex].className=thisClassName;
	},
	blur:function(){
		var topSelectClassName=UI.$('UISelectSel_'+this.id).className.replace("selected_txt","default_txt");
		UI.$('UISelectSel_'+this.id).className=topSelectClassName;
	},
	focus:function(){
		if(this.isopen) return;
		var topSelectClassName=UI.$('UISelectSel_'+this.id).className.replace("default_txt","selected_txt");
		UI.$('UISelectSel_'+this.id).className=topSelectClassName;
	},
	subOver:function(e){
		this.el=UI.getEl(e)
		UI.$('UISelectSub_'+this.id).getElementsByTagName('DIV')[this.sIndex].className='default_txt';
		this.el.className='selected_txt';
	},
	subOut:function(e){
		this.el=UI.getEl(e);
		this.el.className='default_txt';
	},
	subClick:function(e){
		this.el=UI.getEl(e);
		var sIndex=this.el.index;
		this.value=this.list[sIndex].value;
		UI.$('UISelectSel_'+this.id).innerHTML=this.list[sIndex].text;
		if( this.skin.selectEvent == null ){
			UI.$(this.id).value=this.list[sIndex].value;
		} else {
			try { this.skin.selectEvent( this.list[sIndex].value ); } catch (e) {}
		}
		//this.close();
		UI.$('UISelectSub_'+this.id).style.display = "none";

		UI.stopEvent(e);
		if( this.skin.selfClick == true || sIndex!=this.sIndex ){
			this.sIndex=sIndex;
			if(this.input.onchange) { this.input.onchange.call(this);}
		}
		this.sIndex=sIndex;
	},
	subChecked:function(el){
		var obj=UI.$('UISelectSubInner_'+this.id).childNodes;
		var cnt=obj.length;
		var listAry=new Array();
		for (var i=0; i<cnt ; i++){
			if (obj[i].className.indexOf("check_true") > -1){
				listAry.push(obj[i].lastChild.nodeValue);
			}
		}
		if (el != null && listAry.length==0){
			el.className=el.className.replace("check_false","check_true");
			return false;
		}
		var value=listAry.join(",");
		var widthLen= value.length - Math.round(value.replace(/[가-힣]/gi,"").length/2) +1.5;
		if (widthLen < 13) widthLen=13;

		UI.$('UISelectSel_'+this.id).innerHTML=value;
		UI.$('UISelectTop_'+this.id).style.width=UI.$('UISelectSubInner_'+this.id).style.width=widthLen+"em";
	},
	subUnChecked:function(){
		var obj=UI.$('UISelectSub_'+this.id).childNodes;
		for (var n=obj.length-1; n>=0 ; n--){
			if (obj[n].className.indexOf("check_true") > -1){
				obj[n].className=obj[n].className.replace("check_true","check_false");
			}
		}
	},
	print:function(){
		var id=this.id;
		var opt=this.input.options;
		var sb=new UI.StringBuffer();
		var bt=UI.getBrowser();
		var autoWidth=0;
		var isCheckboxItem=false;
		for(var i=0,cnt=opt.length; i<cnt; i++)
		{
			// 기본값
			// 체크박스
			var checkAttr=opt[i].getAttribute("checked");
			var checkDiv="";
			var className='default_txt';
			if (checkAttr != undefined){
				if (checkAttr=="true"){
					className += ' check_true';
				} else{
					className += ' check_false';
				}
				checkDiv='<span class="checkbox"></span>';
				isCheckboxItem=true;
			}
			this.list[i]={text:opt[i].text,value:opt[i].value,check:checkAttr};
			if (autoWidth < opt[i].text.length){
				autoWidth=checkDiv+opt[i].text.length ;
			}
			var selectedFocusObj = "";
			if( opt.sIndex == i ){
				selectedFocusObj = '<input type="input" id="UISelFocus_'+id+'" style="display:none">';
			}
			
			sb.append('<div class="'+className+'" style="line-height:'+this.skin.sub_height+'px;height:'+this.skin.sub_height+'px">'+checkDiv+opt[i].text+selectedFocusObj+'</div>');
		}
		

//				<div style="position:absolute;right:0;top:0">'+this.skin.arrow+'</div>\
		this.value=this.list[0].value;
		var tempStyle='<style type="text/css">div.default_txt{'+this.skin.default_txt+'} div.selected_txt{'+this.skin.selected_txt+'} div.check_on{color:#FF0000;} div.check_off{color:#00FF00;} #UISelFocus_'+id+'{width:1px;height:1px;border:0px; } </style>';
		var s='\
			<div id="UISelectTop_'+id+'" style="position:relative;text-align:left;'+this.skin.topbox+'">\
				<div id="UISelectSel_'+id+'">'+this.list[this.sIndex].text+'</div>\
			</div>\
			<div id="UISelectSub_'+id+'" style="display:none;position:absolute;"><span id="UISelectSubInner_'+id+'" style="display:block;width:'+this.skin.width+';'+this.skin.subbox+'">'+sb.toString()+'</span></div>';

		if ( this.skin.trg_obj == "appendChild" ){
			var parent = UI.$(this.id).parentNode;
			var inner = $C("DIV");
			parent.appendChild( inner  );
			this.input.style.display='none';
			inner.innerHTML = tempStyle + s;
		} else if (this.skin.trg_obj != null)	{
			this.skin.trg_obj.innerHTML=tempStyle
			this.input.style.display='none';
			this.skin.trg_obj.innerHTML += s;
		} else {
			doc.write(tempStyle);
			this.input.style.display='none';
			doc.write(s);
		}



		if(cnt>this.skin.max_option) {
			var sub=UI.$('UISelectSubInner_'+this.id);
			sub.style.height=this.skin.max_option * this.skin.sub_height + "px";
			sub.style.overflowY="auto";
			sub.style.overflowX="hidden";
		}

		var self=this;
		this.objTop = UI.$('UISelectTop_'+id);
		this.objSub = UI.$('UISelectSub_'+id);
		this.selectObj = new UI.SelectObj( this.objSub, this.objTop );
		this.selectObj.openComplete = this.open.bindAsEventListener(this);
		this.selectObj.toogleComplete = this.toogle.bindAsEventListener(this);
		if( bt.ie == true ){
			this.objSub.style.marginTop = "-1px";
		}

		var sub=this.objSub.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) });
		}

		this.objSub.style.display="block";
		this.autoSize=this.objSub.offsetWidth;
		if (this.skin.width=="auto"){
			this.objSub.style.width = "200px";
		}

		if( this.skin.arrow != "" ){
			this.objTop.style.backgroundColor = "#FFF";
			this.objTop.style.backgroundImage = "url("+this.skin.arrow + ")";
			this.objTop.style.backgroundRepeat = "no-repeat";
			this.objTop.style.backgroundPosition = "right top" ;
		}	
		this.objSub.style.display="none";

		if (isCheckboxItem==true){
			this.subChecked();
		}
		UI.SelectObject.push( this );
		
	}
};


/* ActiveX */

// Daum Flash
function daumActiveX(obj,div){
	// generate html code
	// for ie obejct
	var html='<object ';
	if (!obj.id && !obj.name){
		var r=Math.round(Math.random()*100);
		//html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
		html += 'id="daumActiveXObject'+r+'"" ';
	} else {
		if (obj.id) html += 'id="'+obj.id+'" ';
		else html += 'id="'+obj.name+'" ';
		/*if (obj.name) html += 'name="'+obj.name+'" ';
		else html += 'name="'+obj.id+'" ';
		*/
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.classid) html += 'classid="'+obj.classid+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
	// append events
	for (var i in obj.events){
		if (obj.events[i]){
			html += obj.events[i][0]+'="'+obj.events[i][1]+'" ';
		}
	}
	// end of object tag
	html += '>\n';
	// append params
	for (var i in obj.param){
		html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
	}

	// for ns embed
	html += '<embed ';
	if (!obj.id && !obj.name){
		var r=Math.round(Math.random()*100);
		//html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
		html += 'name="daumActiveXObject'+r+'" ';
	} else {
		//if (obj.id) html += 'id="'+obj.id+'" ';
		if (obj.name) html += 'name="'+obj.name+'" ';
	}
	if (obj.type) html += 'type="'+obj.type+'" ';
	if (obj.width) html += 'width="'+obj.width+'" ';
	if (obj.height) html += 'height="'+obj.height+'" ';
	// append params
	for (var i in obj.param){
		if (obj.param[i]){
			if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
				var _src=obj.param[i][1];
			}
			html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
		}
	}
	html += '></embed>\n';
	html += '</object>';

	var isIE=(doc.all)?true:false;
	if (isIE){
		doc.getElementById(div).innerHTML=html;
	} else if (obj.type=='application/x-shockwave-flash' || obj.classid.toLowerCase()=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
		// ie activex flash
		doc.getElementById(div).innerHTML=html;
	} else if (navigator.platform.indexOf('Win')>=0 && obj.classid.toLowerCase()=='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'){
		// Windows Media Player - windows platform
		doc.getElementById(div).innerHTML=html;
	}
}


//
function daumFlash(src,width,height,div){
	var obj=new Object();
	obj.type='application/x-shockwave-flash';
	obj.classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,64,0';
	obj.wmode='transparent'; // transparent
	obj.width=width;
	obj.height=height;

	var param=[
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],
		['bgcolor','#FFFFFF'],
		['allowScriptAccess','always'],
		['pluginspage','http://www.macromedia.com/go/getflashplayer'],
	];
	obj.param=param;
	/* event handle
	var events=[['onmouseover','test1()'],['onmouseout','test2()'],];
	obj.events=events;
	*/
	daumActiveX(obj,div);
}

function DaumFlash(src,fv,width,height,div,id ){
	var obj=new Object();
	obj.type='application/x-shockwave-flash';
	obj.classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,64,0';
	obj.width=width;
	obj.height=height;
	if (id != undefined){
		obj.id=id;
		obj.name=id;
	}
	var param=[
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','transparent'],//transparent
		['allowScriptAccess','always'],
		['bgcolor','#FFFFFF'],
		['showLiveConnect','true'],
		['FlashVars',fv]
	];
	obj.param=param;
	daumActiveX(obj,div);
}

function DaumFlashWindow(src,fv,width,height,div,id ){
	var obj=new Object();
	obj.type='application/x-shockwave-flash';
	obj.classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	obj.codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,64,0';
	obj.width=width;
	obj.height=height;
	if (id != undefined){
		obj.id=id;
		obj.name=id;
	}
	var param=[
		['movie',src],
		['src',src],
		['quality','high'],
		['wmode','window'],//transparent
		['allowScriptAccess','always'],
		['bgcolor','#FFFFFF'],
		['showLiveConnect','true'],
		['FlashVars',fv]
	];
	obj.param=param;
	daumActiveX(obj,div);
}


/* GNB common */
function chDivSize(id,width,height){
	if (width != undefined){
		UI.$(id).style.width=width+"px";
	}
	if (height != undefined){
		UI.$(id).style.height=height+"px";
	}
}
/* (suggest) */
function estateSuggestInit(){
	var suggestOption={
		cookie:{
			name:"estateSuggest",
			domain:["estate.daum.net"]
		},
		ui:{
			itemtext:"매물",
			padding:4
		},
		ajax:new FN.Ajax({url:"/estate_nsuggest"}),
		input:doc.getElementById('query1'),
		frame:doc.getElementById('SugFrame'),
		box:doc.getElementById('SugResult'),
		arrow:doc.getElementById('SugMark'),
		list:doc.getElementById('SugList'),
		infoOn:doc.getElementById('SugInfoOn'),
		infoOff:doc.getElementById('SugInfoOff'),
		footer:doc.getElementById('SugLink'),
		onBT:doc.getElementById('BTon'),
		offBT:doc.getElementById('BToff'),
		closeBT:doc.getElementById('BTclose')
	}
	var AutoStock=new Suggest(suggestOption,GoSearch,FormatSuggestList);
}
function GoSearch(){
	doc.getElementById('query1').value=doc.getElementById('query1').code;
	searchsubmit();
}
function FormatSuggestList(li,keyVal,itemVal) {
	itemVal.match(/(.*)\|(.*)/);
	li.dataName=RegExp.$1;
	li.dataCode=RegExp.$2;
	return highlightCheck(keyVal,li.dataName);
}
function highlightCheck(inputText,suggestText) {
	var rtStr="";
	var _str=suggestText.replace(/ /g,"");
	var _userKeyword=inputText.replace(/ /g,"");
	_userKeyword=_userKeyword.toLowerCase();
	if(_userKeyword==_str.substring(0,_userKeyword.length)){
		rtStr="<b>";
		for (var i=0,j=0; j<inputText.length; i++) {
			if (suggestText.substring(i,i+1)!=" ") j++;
			rtStr += suggestText.substring(i,i+1);
		}
		rtStr += "</b>" + suggestText.substring(i,suggestText.length);
	}else{
		rtStr += suggestText;
	}
	return rtStr;
}
/* 광고관련 */
function hideAD(){
	var adElem=top.ad;
	adElem.style.display="none";
}

/* 검색 관련 */
var defaultWord="동명 and 단지명";
//defaultWordUrl = "http://realestate.daum.net/search/total/?query=%EC%95%84%ED%8C%8C%ED%8A%B8%EC%A0%84%EC%84%B8&tab=total";
//
function search4EstateInit( query4EUCKR ){
	try {
		
		var obj = doc.getElementById('query1');
 
		obj.setAttribute("autocomplete","off");
		if( obj.value == "" ){
			obj.value = defaultWord;
			obj.className += " noQ";
		} else {
		}
		/*
		var qVal = "";
		if( qVal != "" ){
			obj.value = qVal;
		} else {
			obj.className += " noQ";
		}
		*/
	//	UI.addEvent( obj, "keydown", inputSearchQuery.bindAsEventListener(this) ); ## 주석 처리 후 배포 submit이 몇번 일어 나는듯.
		UI.addEvent( document, "mousedown", setSelBox.bindAsEventListener(this) );
		UI.addEvent( document, "keydown", setFocusQBox.bindAsEventListener(this) );
	} catch (exception) {}

	// click log
	if( query4EUCKR == null || query4EUCKR == "undefined" ){
		query4EUCKR = "";
	}
	init("ES", query4EUCKR, "-1", "@@@");

	//setSearchType(1);
}

function getNavigatorType(){
	if(navigator.appName == "Microsoft Internet Explorer") return 1;
	else if(navigator.appName == "Netscape") return 2;
	else return 0;
}

// 
function convEUCKR2UTF8( value ) { 
    var utfStr = ''; 
    for(var i=0; i < value.length; i++) { 
        if (value.charCodeAt(i) > 128) { 
            utfStr += '&#'+value.charCodeAt(i)+';'; 
        } else { 
            utfStr += value.substr(i,1); 
        } 
    } 
    return utfStr;
} 

function setSearchType(type){
	doc.getElementById('searchType').value=type;
	doc.getElementById('s_type'+type).className="radio_on";
	if (type==1){
		doc.getElementById('s_type2').className="radio";
	} else {
		doc.getElementById('s_type1').className="radio";
	}
}
function getSearchCheck(form){
	return true;
}
function doSearchQ(type,word) {
	var inform=doc.search;
	var temp = doc.location.href;
	_debug( inform );
	inform.action="http://realestate.daum.net/search/"+inform.tab.value+"/";//http://search.estate.daum.net/searchEstateMainAction.do"; // http://realestate.daum.net
	inform.method="get";

	var inputBox=doc.getElementById('query1');
	inputBox.value = UI.trim( inputBox.value );

	var inputWord=inputBox.value; //encodeURI,encodeURIComponent,escape
	if(inputWord=="" ) {
		alert("검색어를 입력하세요.");
		clickSearch();
		inputBox.focus();
		return false;
	} else if( inputWord == defaultWord ){
		if ( defaultWordUrl != undefined && defaultWordUrl != "" ){
			top.location.href=defaultWordUrl;
			return false;
		} else {
//			inputBox.className = inputBox.className.replace("noQ","");
			inputBox.value = defaultWordQuery;
		}
	}
	inputWord = encodeURIComponent( inputWord );
	return true;
}

function clickSearch() {
	var qInput=doc.getElementById('query1');
	if( qInput.value == defaultWord ) {
		qInput.className = qInput.className.replace("noQ","");
		qInput.value="";
	}
}
function searchsubmit() {
	//gLink(null,'SEE','1','1'); 2008-02-13 요청으로 삭제(주석처리) by 최진우
//	try{ console.log(2); }catch(e){}
 
	if(doSearchQ() ) doc.search.submit();
}
function inputSearchQuery(event){
	var e = UI.getE( event );
	if( e.keyCode == 13 ){
		searchsubmit();
	}
	return false;
}

/* click log */
var sec; var kw; var ks; var sss; var uco=0; var uda2;
var URL="http://log.search.daum.net/cgi-bin/";
var etlImg= null;

function openWin(u1,u2)
{
try{
 etlImg = new Image();
 var url=u1+"&uco="+(++uco)+u2;
 etlImg.src=url;
 uda2=null;
}
 catch (e)
 {
	 //alert(e.message);
 }
 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)
{
 try{console.log( "link : " + o + ", " + a + ", "+ r + ", " + p );}catch (e){}
 var scope="&ss="+sss+"&as=";
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"","","");
 return openWin(u1,u2);
}
function gExtraLink(o,a,ext)
{
 try{console.log( "extra : " + o + ", " + a + ", "+ ext );}catch (e){}
 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);
}

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);
}
function gCRExtraLink(u,a,ext)
{
 var scope="&ss="+sss+"&as=";
 var u1=cU1(a,scope,"","",ext); var u2=cU3(u,"","","");
 return openWin(u1,u2);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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 gSetKW(v) {kw=v;}
/* click log */


/** 
	자동 키반응 검색
*/
function getNavigatorType(){
	if(navigator.appName == "Microsoft Internet Explorer")
		return 1;  
	else if(navigator.appName == "Netscape")
		return 2;	
	else 
		return 0;
}
function setSelBox(event){
	var _event;
	switch (getNavigatorType()) {
		case 1 : // IE
			_event = window.event;
			node = _event.srcElement;
			nodeName = _event.srcElement.className;
			break;
		case 2 : // Netscape
			_event = event;
			node = _event.target;
			nodeName = _event.target.className;
			break;
		default :
			nodeName = "None"; 
			break;
	}	

	//try{
	//	doc.getElementById("hFrame").contentWindow.eventHandlerBody(event);
	//}catch(e){}
}
function setFocusQBox(event){
	var textbox;
	var _event;
	try{
		textbox = doc.search.query;
	}catch (e){
		return false;
	}
	switch(getNavigatorType()){
		case 1 : // IE
			_event = window.event;
			node = _event.srcElement;
			nodeName = _event.srcElement.nodeName;
			break;
		case 2 : // Netscape
			_event = event;
			node = _event.target;
			nodeName = _event.target.nodeName;
			break;
		default :
			nodeName = "None"; 
			break;
	}
	key = _event.keyCode;
	if(!(nodeName=="INPUT"||nodeName=="SELECT"||nodeName=="TEXTAREA"||(_event.ctrlKey&&key!=86))){
		if(key==8 || (key>32&&key<41) || (key!=21&&key<32) || _event.altKey || key==91 || key==92 || _event.metaKey){
		}else if(key==32){ 
			if(_event.shiftKey){
				textbox.focus();
				textbox.style.imeMode ="active";
				textbox.select();
				_event.returnValue=false;
			}
		}else if(key == 21){
			scrollTo(0,0);
			textbox.focus();
			textbox.style.imeMode ="active";
			textbox.select();
			_event.returnValue=false;
		}else if(node!=textbox){
			scrollTo(0,0);
			textbox.focus();
			textbox.style.imeMode ="inactive";
			textbox.select();
		}
	}
}


/* sub gnb mouse event */
function SubOver(m) {m.className=m.className + " on";}
function SubOut(m) {m.className=m.className.replace(" on","");}


function popup(url,name,option){
/*
①.width:창 가로길이 지정 [no,yes(생김)]
②.height:창 세로길이 지정 [no,yes(생김)]
③.toolbar:단축도구창 유무지정 [no,yes(생김)]
④.menubar:메뉴창 유무지정 [no,yes(생김)]
⑤.location!!:주소창 유무지정 [no,yes(생김)]
⑦.scorllbars:스크롤바 지정 [no,yes(생김)]
⑧.status:아래 상태바창 유무지정 [no,yes(생김)]
⑨.resizable:창변형 유무지정 [no,yes(생김)]
⑩.fullscreen:전체화면 유무지정 [no,yes(생김]
⑪.channelmode=yes:앞&뒤로,창최소화.닫기등을 설정(F11번 키랑 같음)
⑫.left=0,top=0:창을 고정시킨다.왼쪽 구석에 고정
*/
	
	var opt=new Array();
	for(var property in option){
		opt.push(property+"="+option[property]);
	}
	var popWin=window.open(url,name,opt.join(","));
	return popWin;
}
// 단지지정업소 안내
function popupCompInfo (){
	var popCompInfo = popup('http://realestate.daum.net/popup/agentProgramIntro.daum?nil_profile=estatetop&nil_menu=danji','danjiinfopop',{width:800,height:580,scrollbars:'no'});
	popCompInfo.focus();
}
function popupCalcSize(){
	var popCalc = popup('http://realestate.daum.net/html/calculateSize.html','calculateSizePop',{width:420,height:290,scrollbars:'no'});
	popCalc.focus();
}
function popupTaxRateSize(){
	var popTaxRate = popup('/html/taxRateTable.html','taxRateTable',{width:730,height:600,scrollbars:'no'});
	popTaxRate.focus();
}

var Estate={};

//제휴사별 매물관 랜덤출력
Estate.CpList=function(){

	this.cpList=[];
	this.cpList.push({nil:0,name:"닥터아파트",imgSrc:"http://fn.daum-img.net/image/estate/2008/direct/budong_mark_05.gif",className:"cpImg bp_y0",href:"http://drapt.realestate.daum.net/"});
	this.cpList.push({nil:1,name:"부동산써브",imgSrc:"http://fn.daum-img.net/image/estate/2008/direct/budong_mark_03.gif",className:"cpImg bp_y200",href:"http://serve.realestate.daum.net/default.asp"});
	this.cpList.push({nil:2,name:"스피드뱅크",imgSrc:"http://fn.daum-img.net/image/estate/2008/direct/budong_mark_02.gif",className:"cpImg bp_y250",href:"http://speedbank.realestate.daum.net/"});
	this.cpList.push({nil:3,name:"부동산뱅크",imgSrc:"http://fn.daum-img.net/image/estate/2008/direct/budong_mark_04.gif",className:"cpImg bp_y100",href:"http://neonet.realestate.daum.net/main.neo"});
	this.cpList.push({nil:4,name:"조인스랜드",imgSrc:"http://fn.daum-img.net/image/estate/2008/direct/budong_mark_01.gif",className:"cpImg bp_y50",href:"http://joinsland.realestate.daum.net/"});

	this.write();
}
Estate.CpList.prototype={
	write:function(){
		var url = location.href;
		var cname = "";
		if( url.indexOf( "MaemulTop.daum" ) > -1 ){cname = "PCES";}
		else {cname="Z5ES";}

		var liClass=["fl_le","fl_ri","fl_le","fl_ri","fl_le"];
		//var nil=["","","","","",""];
		var nil=["?nil_profile=estatetop&nil_menu=drapt","?nil_profile=estatetop&nil_menu=serve","?nil_profile=estatetop&nil_menu=speedbank","?nil_profile=estatetop&nil_menu=neonet","?nil_profile=estatetop&nil_menu=joinsland"];
		var randNum=this.getRandNum(0,4);

		for(var num =0; num<randNum.length; num++){
			var thisNum=randNum[num];
			var nilTag=nil[ this.cpList[thisNum].nil ];
			var row="<li class='"+liClass[num]+"'><img src='"+this.cpList[thisNum].imgSrc+"' alt='"+this.cpList[thisNum].name+"'><a target='_blank' href='"+this.cpList[thisNum].href+nilTag+"' onclick='gLink(null, \""+cname+"\", \""+(this.cpList[thisNum].nil+1)+"\", \"1\");'>"+this.cpList[thisNum].name+"</a></li>";//
			doc.write(row);
		}
	},
	getRandNum:function(min,max){
		var randList=new Array(0,1,2,3,4);
		randList.sort(function(){return Math.random()*2-1;});
		return randList;
	}
}

var FN={_browser:null};
FN.$=function(s) { return doc.getElementById(s) };
FN.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);
};

FN.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);
			}
		}
	}
};


/**
*	Click Logger
*	@param	ServiceCategory
*	@param	Data
*	... (확장가능)
*
*	사용법
*	  ex) clickLogger([sc],[c1],[c2],[c3],...);
*	증권,종목코드 035720
*	  ex) clickLogger("1","035720");
*/
function clickLogger(){
	var tag='';
	try
	{
		var ref=doc.referrer;
		var loc=doc.location;

		var cntArg=arguments.length;
		var sc=arguments[0];
		/*
		sc :
		부동산단지 2
		부동산지역 5

		c :
		부동산지역(지역페이지)
			c1=매물타입코드(A1, A2 ...)
			c2=지역코드

		부동산단지(단지페이지)
			c1=매물타입코드(A1, A2 ...)
			c2=면적그룹코드(*, S, M, L)
			c3=단지코드(단지 아이디)
		*/
		//var rootUrl="http://log.finance.daum.net"; 이전버전
		var rootUrl = "http://log.finance.daum.net";
		tag="<img name='clickLog' id='clockLog' style='display:none' src=" + "'" +  rootUrl + "/click?";
		tag += "sc=" + sc + "&";
		for (var n=1; n<cntArg ; n++) {
			tag += "c"+n+"=" + arguments[n] + "&";
		}
		tag += "ref=" + encodeURIComponent(ref) + "&loc=" + encodeURIComponent(loc) + "'" ;
		tag += "width='0' height='0'>";
	}
	catch (e) {}
	doc.write( tag );
}

// 페이지 네비 마우스 이벤트
function mOverPaging(obj){ obj.style.color="#FFF"; obj.style.backgroundColor="#4C77EB";obj.style.borderColor="#406BDD"; }
function mOutPaging(obj){  obj.style.color="#333"; obj.style.backgroundColor="";obj.style.borderColor="#DBDBDB";}


var naviItem=function(id,options){
	this.li=UI.$(id).getElementsByTagName("LI");
	this.selObj=null;
	this.selValue=null;
	this.selUlId=id;
	this.options={
		defaultIndex:null
	}
	Object.extend(this.options,options);
	this.init();
}
naviItem.prototype={
	init:function(){
		for(var n=0; n<this.li.length; n++){
			var obj=this.li[n];
			obj.index=n;

			if(this.options.defaultIndex != null && this.options.defaultIndex==n){
//				this.selValue=obj.getAttribute("value");
				this.selObj=obj;
				this.selObj.className="on";
			} else {
				obj.className="off";
			}
		}
	},
	select:function(obj, value){
		if(this.selObj != null && this.selObj != obj){
			this.selObj.className="off";
		}
		this.selValue=value;
		this.selObj=obj;
		this.selObj.className="on";
		this.index=obj.index;
		areanaviHandel.selectOption(this);
	},
	unselect:function(){
		if(this.selObj != null ){
			this.selObj.className="off";
		}
		this.selValue=null;
		this.selObj=null;
	},
	remove:function(){
		this.unselect();
		UI.$(this.selUlId).innerHTML="<li>선택하세요</li>";
	}
}
dynamicScript =new UI.DynamicScript('','UTF-8'); //DynamicScript 객체생성
var EstAreaNavi=function(saleObj,cateObj,depth1Obj,depth2Obj,depth3Obj,depth4Obj, naviType ){
	this.saleObj=saleObj; // 거래구분
	this.cateObj=cateObj; // 매물종류
	this.depth1Obj=depth1Obj; // 시/구
	this.depth2Obj=depth2Obj; // 구/시/군
	this.depth3Obj=depth3Obj; // 읍/면/동
	this.depth4Obj=depth4Obj; // 단지
	this.danjiBox = UI.$("NaviDanjiBox");
	this.naviType = UI.$(naviType);
}
EstAreaNavi.prototype={
	selectOption:function(naviItemObj){
		var id=naviItemObj.selUlId;
		var value=naviItemObj.selValue;
		var obj=UI.$(id);
		var url=null;
		
		
    	if(obj==undefined || value==undefined || value=="") return false;
    	
    	var naviType = UI.$("navi_opt_type").value;
    	var param = (naviType=="area"?"areacode":"stationcode");
    	
    	
		switch(id){
		case "Areanavi_saletype":
			if(value=="R"){
				this.cateObj.li[7].style.display="none"; // 재개발
				this.cateObj.li[12].style.display="none"; // 상가주택
				if(this.cateObj.index==7 || this.cateObj.index==12){
					this.cateObj.unselect();
					this.cateObj.select(this.cateObj.li[0],"A1");
				}
			} else {
				this.cateObj.li[7].style.display="block"; // 재개발
				this.cateObj.li[12].style.display="block"; // 상가주택
			}

			if( this.depth1Obj.selValue && this.depth2Obj.selValue && this.depth3Obj.selValue){
				url="http://realestate.daum.net/maemul/common/subdanji.daum?" + param + "="+this.depth3Obj.selValue+"&mcatecode="+this.cateObj.selValue+"&function=searchDanjiList";
			}

			break;
		case "Areanavi_catecode":
			if( this.depth1Obj.selValue && this.depth2Obj.selValue && this.depth3Obj.selValue ){
				url="http://realestate.daum.net/maemul/common/subdanji.daum?" + param + "="+this.depth3Obj.selValue+"&mcatecode="+this.cateObj.selValue+"&function=searchDanjiList";
			}
			
			// 단지군+재개발 : 비단지 / 단지박스 보임 : 안보임 
			if( this.danjiBox ){
				if( this.cateObj.index>=0 && this.cateObj.index <= 7 ){ this.danjiBox.style.display = "block"; } 
				else { this.danjiBox.style.display = "none"; }
			}
			break;
		case "Areanavi_si": //시도/ 지역
			this.depth2Obj.remove();this.depth3Obj.remove();this.depth4Obj.remove();
			if( naviType == "area"){
				url="http://realestate.daum.net/maemul/common/subarea.daum?" + param + "="+value+"&function=searchAreaListGu";
			}else{
				url="http://realestate.daum.net/common/childSubway.daum?subwayCode="+value+"&function=searchAreaListGu";
			}
			break;
		case "Areanavi_gu": // 구/시/군 / 호선
			this.depth3Obj.remove();this.depth4Obj.remove();
			if( naviType == "area"){
				url="http://realestate.daum.net/maemul/common/subarea.daum?" + param + "="+value+"&function=searchAreaListDong";
			}else{
				url="http://realestate.daum.net/common/childSubway.daum?subwayCode="+value+"&function=searchAreaListDong";
			}
			break;
		case "Areanavi_dong": // 읍/면/동 지하철역
			url="http://realestate.daum.net/maemul/common/subdanji.daum?" + param + "="+value+"&mcatecode="+this.cateObj.selValue+"&function=searchDanjiList";
			this.srcObj=this.depth3Obj;
			this.trgObj=UI.$(this.depth4Obj.selUlId);
			break;
		}
		if (url != null){
			dynamicScript.call(url);
		}
	},
	moveUrl:function(){
		var url=null;
		if(this.depth4Obj.selValue==null){
			if( this.naviType.value == "area"){
				url="http://realestate.daum.net/maemul/area/_areacode_/_catecode_/_extcatecode_/_saletype_/summary";
			}else{
				url="http://realestate.daum.net/maemul/subway/_areacode_/_catecode_/_extcatecode_/_saletype_/*/summary";
			}

			if(this.saleObj.selValue){
				url=url.replace(/(_saletype_)/gi,this.saleObj.selValue);
			}
			if( this.cateObj.selValue){
				url=url.replace(/(_catecode_)/gi,this.cateObj.selValue);
			}
			if( this.cateObj.selValue=="A1"){
				url=url.replace(/(_extcatecode_)/gi,"A1A3A4");
			} else {
				url=url.replace(/(_extcatecode_)/gi,this.cateObj.selValue);
			}
			if (this.depth3Obj.selValue){
				url=url.replace(/(_areacode_)/gi,this.depth3Obj.selValue); // 읍/면/동
			} else if (this.depth2Obj.selValue){
				url=url.replace(/(_areacode_)/gi,this.depth2Obj.selValue); // 구/시/군
			} else if (this.depth1Obj.selValue){
				url=url.replace(/(_areacode_)/gi,this.depth1Obj.selValue); // 시/구
			}
			if(url.indexOf("_areacode_") > -1){
				alert("지역 또는 단지를 선택해주세요");
				return false;
			} else {
				top.location.href=url;
			}
		} else {
			if( this.cateObj.index == 7 ){
				url="http://realestate.daum.net/maemul/zone/_danjiid_/summary";
			} else {
				if( this.naviType.value == "area"){
					url="http://realestate.daum.net/maemul/danji/_danjiid_/_extcatecode_/_saletype_/summary";
				}else{
					url="http://realestate.daum.net/maemul/subway/_areacode_/danji/_danjiid_/_extcatecode_/_saletype_/summary";
				}
			}

			if(this.saleObj.selValue){
				url=url.replace(/(_saletype_)/gi,this.saleObj.selValue);
			}
			if (this.depth4Obj.selValue){
				url=url.replace(/(_danjiid_)/gi,this.depth4Obj.selValue); // 단지
			}

			if( this.cateObj.selValue=="A1"){
				url=url.replace(/(_extcatecode_)/gi,"A1A3A4");
			} else {
				url=url.replace(/(_extcatecode_)/gi,this.cateObj.selValue);
			}

			if( this.naviType.value == "subway"){
				if (this.depth3Obj.selValue){
					url=url.replace(/(_areacode_)/gi,this.depth3Obj.selValue); // 읍/면/동
				}
			}
			
			if(url.indexOf("_danjiid_") > -1){
				alert("지역 또는 단지를 선택해주세요");
				return false;
			} else {
				top.location.href=url;
			}
		}
	}
}
//var naviStep=null;
function searchAreaListGu(data ){ makeNaviList(data, "gu" ); }
function searchAreaListDong(data ){ makeNaviList(data, "dong" ); }
function searchDanjiList(data){ makeNaviList(data, "danji"); }
function makeNaviList(data, naviStep){
	if(naviStep==null ) return false;
	var listHtml="";
	var trgObj=UI.$("Areanavi_"+naviStep);
	var naviName="navi_"+naviStep;
 
	for (var n=0; n<data.length; n++){
		if (trgObj.id=="Areanavi_danji"){
			listHtml += '<li onmousedown="'+naviName+'.select(this, \''+data[n].danjiid+'\');" >'+data[n].danjiname+'</li>';
		} else {
			var code = "";
			var name = "";
			
			if( UI.$('navi_opt_type').value == "area"){
				code = data[n].areacode;
				name = data[n].areaname;
			}else{
				if( naviStep == "gu"){ // 
					code = data[n].linecode;
					name = data[n].linename;
				}else{
					code = data[n].stationcode;
					name = data[n].stationname;
				}
			}
			listHtml += '<li onmousedown="'+naviName+'.select(this, \''+ code +'\');" >'+ name +'</li>';
		}
	}
 
	if (data.length==0){
		listHtml += '<li>정보가 없습니다</li>';
	}
	
	trgObj.innerHTML=listHtml;
	// ie6 응답 속도 느림 - 제거 (지혜님 20090824)
	//dummyUrlCall('easyNavi');	
}


var RdoNaviType = function(tab1, tab2, navicatecode, navigu, navidong){
	this.tab1 = this.curTab = UI.$(tab1);
	this.tab2 = UI.$(tab2);
	this.navigu = navigu; 
	this.navidong = navidong;
	this.navicatecode = navicatecode; 
	
	this.cateList = [{code:"A1", name: "아파트"}, {code:"A2", name: "아파트 분양권"}, {code:"A3", name: "재건축"}, {code:"A4", name: "주상복합"},{code:"A5", name: "주상복합 분양권"},  {code:"A6", name: "오피스텔"},  {code:"A7", name: "오피스텔 분양권"}];
	this.etcCateList = [{code:"B1", name:"재개발"}, {code:"C1", name: "원룸"}, {code:"C2", name: "단독/다가구"}, {code:"C3", name: "연립/다세대/빌라"},              {code:"C4", name: "전원주택"},{code:"C5", name: "사무실"}, {code:"C6", name: "빌딩/건물"},{code:"C7", name: "상가건물"},{code:"C8", name: "상가점포"},{code:"C9", name: "상가주택"},{code:"CA", name: "공장/창고"},{code:"CB", name: "숙박/콘도/펜션"},{code:"CC", name: "토지/임야"},{code:"E1", name: "기타"}];
	this.subwayList = [{code:"1100000", name: "수도권"}, {code:"1500000", name:"광주"}, {code:"1700000", name: "대구"}, {code:"1300000", name: "대전"}, {code:"1600000", name: "부산"}];
	this.areaList = [{code:"1100000", name:"서울시"}, {code:"1200000", name: "강원"}, {code:"1300000", name: "대전시"}, {code:"1310000", name: "충남"}, {code:"1360000", name: "충북"}, {code:"1400000", name: "인천시"}, {code:"1410000", name: "경기"}, {code:"1500000", name: "광주시"}, {code:"1510000", name: "전남"}, {code:"1600000", name: "부산시"},{code:"1620000", name: "경남"}, {code:"1680000", name: "울산시"}, {code:"1690000", name: "제주"}, {code:"1700000", name: "대구시"}, {code:"1710000", name: "경북"}];
}

RdoNaviType.prototype = {
	click : function(obj){
		if( obj == this.curTab ) return; 
		
		this.navigu.remove();
		this.navidong.remove();
		
		if( this.tab2 == obj){
			this.tab1.className = "navi_opt tab1";
			this.tab2.className = "navi_opt tab2 on";
			UI.$("navi_opt_type").value = "subway";
			UI.$("est_search_dep1").innerHTML = "지역";
			UI.$("est_search_dep2").innerHTML = "호선";
			UI.$("est_search_dep3").innerHTML = "지하철역";
			var sub = ""; 
			for( var i=0; i<this.subwayList.length ; i++){
				sub += "<li onkeydown='navi_si.select(this, \""+ this.subwayList[i].code +"\");' onmousedown='navi_si.select(this, \""+ this.subwayList[i].code +"\");'>"+this.subwayList[i].name+"</li>";
			}
			
			UI.$('Areanavi_si').innerHTML = sub;
			var cate = ""; 
			UI.$('Areanavi_catecode').innerHTML =""; 
			for( var i=0; i<this.cateList.length ; i++){
				cate += "<li onkeydown='navi_catecode.select(this, \""+ this.cateList[i].code +"\");' onmousedown='navi_catecode.select(this, \""+ this.cateList[i].code +"\");'>"+this.cateList[i].name+"</li>";
			}
			UI.$('Areanavi_catecode').innerHTML = cate;
			this.navicatecode.init();
		}else{
			this.tab1.className = "navi_opt tab1 on";
			this.tab2.className = "navi_opt tab2";
			UI.$("navi_opt_type").value = "area";
			UI.$("est_search_dep1").innerHTML = "시/도";
			UI.$("est_search_dep2").innerHTML = "구/시/군";
			UI.$("est_search_dep3").innerHTML = "읍/면/동";
			
			var area = ""; 
			for( var i=0; i<this.areaList.length ; i++){
				area += "<li onkeydown='navi_si.select(this, \""+ this.areaList[i].code +"\");' onmousedown='navi_si.select(this, \""+ this.areaList[i].code +"\");'>"+this.areaList[i].name+"</li>";
			}
			UI.$('Areanavi_si').innerHTML = area;
			UI.$('Areanavi_catecode').innerHTML ="";
			var cate = ""; 
			var allList = this.cateList.concat(this.etcCateList);
			for( var i=0; i<allList.length ; i++){
				cate += "<li onkeydown='navi_catecode.select(this, \""+ allList[i].code +"\");' onmousedown='navi_catecode.select(this, \""+ allList[i].code +"\");'>"+allList[i].name+"</li>";
			}
			UI.$('Areanavi_catecode').innerHTML = cate;
			this.navicatecode.init();
		}	
		this.curTab  = obj;
	}
}

var dummyUrlCall = function(dummyName, id){
	if( id ){
		if( UI.getStyle(UI.$(id), 'display') != "none"){ 
			if(document.getElementById("frameGbgBg")){
				document.getElementById("frameGbgBg").src = "http://realestate.daum.net/clickDummy/" + dummyName;
			}
		}	
	}else{
		if(UI.$("frameGbgBg")){
			UI.$("frameGbgBg").src = "http://realestate.daum.net/clickDummy/" + dummyName;
		}
	}
}

// 브라우져별 객체얻기 - 예외적인 경우임
var getExternalObject=function(id){
	if (window.document[id]) {
		return window.document[id];
	}
	
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (doc.embeds && doc.embeds[id])
			return doc.embeds[id];
	} else {
		return doc.getElementById(id);
	}
}
// JSON 전달함수
function setViewMode(mode ){
	try	{
 
		getExternalObject("FlashEstMap").setViewMode(mode); 
		var parent = UI.$("mapFlashBgA")||UI.$("mapFlashBgB")||UI.$("mapFlashBgC")||UI.$("mapFlashBgAll");
		if( parent ){
			switch( mode ){
			case "count": parent.style.backgroundPosition = "0px 0px";
				return gLink(null, "ZFES", "1", "8");
				break;
			case "rate": parent.style.backgroundPosition = "0px -22px";
				return gLink(null, "ZFES", "2", "8");
				break;
			case "price": parent.style.backgroundPosition = "0px -44px";
				return gLink(null, "ZFES", "3", "8");
				break;
			}
		}
		
	} catch (e) {
		//alert(e.message);
	}
}
function setViewModeBtn(mode ){
	try	{
		var parent = UI.$("mapFlashBgA")||UI.$("mapFlashBgB")||UI.$("mapFlashBgC")||UI.$("mapFlashBgAll");
		if( parent ){
			switch( mode ){
			case "count": parent.style.backgroundPosition = "0px 0px";
				return gLink(null, "ZFES", "1", "8");
				break;
			case "rate": parent.style.backgroundPosition = "0px -22px";
				return gLink(null, "ZFES", "2", "8");
				break;
			case "price": parent.style.backgroundPosition = "0px -44px";
				return gLink(null, "ZFES", "3", "8");
				break;
			}
		}
		
	} catch (e) {
		//alert(e.message);
	}
}

function setDataJSON(data){ getExternalObject("FlashEstMap").setDataJSON(data); }
// 지도
function flashMap(vars,id){
	var varsStr="";
	for (var property in vars){
		varsStr += "&"+property+"="+encodeURI(vars[property]);
	}
	DaumFlash("http://fn.daum-img.net/flash/estate/2009/map/map_"+vars.thisAreacode+".swf?ver=20080710",varsStr,"546","314",id,"FlashEstMap");
}

function resizeFrame( id ){ var frame = UI.$( id ); }
function resizeImg(obj,options){
	var ratio={
		width:options.width/obj.clientWidth,
		height:options.height/obj.clientHeight
	}
	if(ratio.width > ratio.height){
		obj.style.height=options.height + "px";
	} else {
		obj.style.width=options.width + "px";
	}
}

// 하단 검색창에 입력시 처리
function syncSearchQuery( bform ){
	var form = doc.search;
	form.query.value = bform.query.value;
	searchsubmit();
}
// 플래시지 지도 단지보기 팝업시
function iframeDanjiView( url ){ dummyIframePV( "iframeHiddenDanji", "/clickDummy/danjiinfo4Flash" ); }
function iframeNaviView( url ){ dummyIframePV( "iframeHiddenNavi", "/clickDummy/naviData4Flash" ); }
function iframeSiseView( url ){ dummyIframePV( "iframeHiddenSise", "/clickDummy/siseData4Flash" ); }
function dummyIframePV( id, url ){
	var obj = UI.$(id);
	if( obj ){
		obj.src = url;
	}
}

// 뉴스, 커뮤니티 우측영역 및 관련내용 뿌리기
// 제휴사, 가이아 우측 날개 데이터 뿌리기
function writeWingList( dataset, _options ){
	var options = {
		len : 30
	};
	Object.extend( options, _options );
	for ( var i in dataset ){
		var title = UI.length( dataset[i].title, options.len, ".." );
		var url = dataset[i].url;
		var classname = "";
		if ( dataset[i].bold && dataset[i].bold==true){
			classname += "fw_b ";			
		}
		doc.write("<li><a href='"+url+"' class='"+classname+"'>"+title+"</a></li>");
	}
}

function writeWingIssue( dataset, _options ){
	var options = {
		len : 20
	}
	Object.extend( options, _options );

	var title = UI.length( dataset.title, options.len, "..");
	var pic = "";
	try	{
		if( dataset.pic && dataset.pic!= "" ){ pic = dataset.pic; }
	}catch (e){ pic = "http://fn.daum-img.net/image/estate/2008/dummy/dummyissueimg.gif"; }
	var html = '<a href="'+dataset.url+'" class="black"><img src="'+dataset.pic+'" width="64" height="43" class="thumbImg fl_le" ></a><div class="title"><img src="http://fn.daum-img.net/image/estate/2008/maemulSise/icoIssueTitle.gif" alt="이슈" ><a href="'+dataset.url+'" class="black"><strong>'+title+'</strong></a></div>';

	doc.write( html );
}

var WingContents = function( _dataset ){
	this.dataset = _dataset;
};
WingContents.prototype = {
	list : function( _dataset, _options ){
		var options = {
			len : 30,
			param : {}
		};
		Object.extend( options, _options );
		if( !_dataset ) return;
		var cnt = _dataset.length;
	 
		if( options.count && options.count != "undefined" && options.count<cnt ){
			cnt = options.count
		}
		
		// nil tag 적용
		var paramTemplate = "";
		var num = 0;
		for( var property in options.param ){
			paramTemplate += "&amp;" + property+ "="+options.param[property];
		}

		for ( var i=0; i<cnt; i++ ){			
			var url = _dataset[i].url;
			var mode = null;
			var title = UI.length( _dataset[i].title, options.len, ".." );
			if( options.mode && options.mode == "newsView" ){
				mode = "news";
				title = UI.length( _dataset[i].title2, options.len, ".." );
			} else {
				mode = "debate";
			}
			// nil tag
			
			var param = paramTemplate.replace("$NUM", i+1 );
			if( param != "" ){
				url = url.replace(/(&amp;|&)?nil_[a-z0-9]+=[a-z0-9]+(&amp;|&)?/gi,"");
				url += param;
			} else if(options.nil && options.nil != 'undefined'){
				url = url.replace(/nil_[a-z0-9]+=[a-z0-9]+&?/gi,"");
				url += options.nil+(i+1);
			}
			var classname = "";
			if ( ( _dataset[i].bold && _dataset[i].bold==true ) ) {
				classname += "fw_b ";			
			}
			doc.write("<li><a href='"+url+"' class='"+classname+"' title=\""+_dataset[i].title.replace("\"", "&quot;") +"\">"+title+"</a></li>");
		}
	},
	issue : function( _dataset, _options ){
		var options = {
			len : 20
		}
		Object.extend( options, _options );

		var title = UI.length( _dataset.title, options.len, "..");
		var pic = "";
		try	{
			if(_dataset.pic == ""){
				pic = "http://fn.daum-img.net/image/estate/2008/dummy/dummyissueimg.gif";
			}else{ 
				pic = _dataset.pic;
			}
		}catch (e){ pic = "http://fn.daum-img.net/image/estate/2008/dummy/dummyissueimg.gif";}

		var html = '<a href="'+_dataset.url+options.nil+'" class="black"><img src="'+pic+'" width="64" height="43" class="thumbImg fl_le" ></a><div class="title"><img src="http://fn.daum-img.net/image/estate/2008/maemulSise/icoIssueTitle.gif" alt="이슈" ><a href="'+_dataset.url+options.nil+'" class="black"><strong>'+title+'</strong></a></div>';
		doc.write( html );
	},
	
	newsIssue : function( _dataset, _options ){
		var options = {	len : 38 }
		Object.extend( options, _options );

		var title = UI.length( _dataset.title, options.len, "..");
		var pic = "";
		try	{
			if(_dataset.pic == ""){
				pic = "http://fn.daum-img.net/image/estate/2008/dummy/dummyissueimg.gif";
			}else{ 
				pic = _dataset.pic;
			}
		}catch (e){ pic = "http://fn.daum-img.net/image/estate/2008/dummy/dummyissueimg.gif";}
		
		var html = '<a href="'+_dataset.url+options.nil+'"class="thumb"><img src="'+pic+'" width="58" height="38" /></a><a href="'+_dataset.url+options.nil+'" class="issueDesc"><strong>'+title+'</strong></a>';
		doc.write( html );
	},
	
	debateIssue : function(_dataset, _options ){
		var options = {	len : 20 }
		Object.extend( options, _options );

		var title = UI.length( _dataset.title, options.len, "..");
		var html = '<a href="'+ _dataset.url+options.nil+'" class="issueDesc"><strong>'+ title +'</strong></a>';
		doc.write( html );		
	}, 
	
	getNilLink : function( item ,type, _nil_item ){
		var _nil = null;
		if( type == null || type ==""){
			type = "sub";
		}	
		if(location.host.indexOf("news")>-1) {	// news sub 
			_nil = 'nil_news' + type + 'right';
		}else if(location.host.indexOf("bunyang")>-1) {
			_nil = 'nil_bunyang' + type + 'right';
		} else {		// community sub
			_nil = 'nil_communitysubright';
		}
		switch( item ) {
		case "debateList" : nil_item = "debate"; break;
		case "newsList" : nil_item = "news"; break;
		case "debateIssue" : nil_item = "debatissue"; break;
		case "newsIssue" : nil_item = "newsissue"; break;
		default : 
			nil_item = _nil_item;break;
		}
		
		return "&amp;nil_profile=estatetop&amp;"+_nil+"="+nil_item;
	},
	//--- 주요 뉴스 ---------------
	
	// 부동산
	getTopNews : function(item, tab, opt){ //getTopNews('list', 'estate', {nil_item:'estatenews'})
		try{
			var options = {	type : 'sub', len:30, nil_item:'' }
			Object.extend( options, opt )
			
			var _nil = this.getNilLink( item, options.type, options.nil_item );
			if( item == "list"){
				var ds = this.dataset.newsTab; 
				this.list( ds[tab] , {len:options.len, nil:_nil, count:options.count } )
			}else{ //issue
				var ds = this.dataset.newsTabIssue; 
				this.newsIssue( ds[tab] , {len:options.len, nil:_nil } )
			}
		}catch(e){}
	}, 
	//---// 주요 뉴스 ---------------
	
	//--- 베스트 토론 ---------------
	getBestDebate : function(item, tab, opt){
		try{
			var options = {	type : 'sub', len:30, nil_item:'' }
			Object.extend( options, opt )
			
			var _nil = this.getNilLink( item, options.type, options.nil_item );
			if( item == "list"){
				var ds = this.dataset.debateTab; 
				this.list( ds[tab] , {len:options.len, nil:_nil, count:options.count } )
			}else{ //issue
				var ds = this.dataset.debateTabIssue; 
				this.debateIssue( ds[tab] , {len:options.len, nil:_nil } )
			}
		}catch(e){}
	}, 
	//--- 베스트 토론 ---------------
	
	
	// 재태크 컬럼 --------------------
	getTechList : function( opt ){
		var _opt = {len : 30, type:'sub'};
		Object.extend( _opt, opt );
		this.list( this.dataset.tech, opt );
	},	
	// 재태크 컬럼 --------------------
	
	// 베스트 상담사례 -------------------- 
	getBestCounselList : function( opt ){
		var _opt = {len : 5, type:'sub'};
		Object.extend( _opt, opt );
		this.list( this.dataset.qna, opt ); // qna로 변경예정
	},
	getCounselList : function( menu, opt ){
		var _opt = {len : 30, type:'sub'};
		Object.extend( _opt, opt );
		this.list( this.dataset.qna, opt ); // 삭제 예정
	},	
	// 베스트 상담사례 --------------------
	
	getQuizText : function(){ doc.write( UI.length( this.dataset.quiz.text, 95, ".." ) ); },

	// 분양 및 커뮤니티 사용 
	getDebateList : function(opt){
		var _opt = {len : 30, type:'sub'};
		Object.extend( _opt, opt );
		
		var _nil = this.getNilLink('debateList', _opt.type);
		this.list( this.dataset.debate, {len:_opt.len, nil:_nil} );
	},
	getNewsList : function(opt){
		var _opt = {len : 30, type:'sub'};
		Object.extend( _opt, opt );
		var _nil = this.getNilLink('newsList', _opt.type);
		this.list( this.dataset.news, {len:_opt.len, nil:_nil } );
	},
	getDebateIssue : function(opt){
		var _opt = {len : 34, type:'sub'};
		Object.extend( _opt, opt );
		var _nil = this.getNilLink('debateIssue', _opt.type);
		this.issue( this.dataset.issue.debate, {len:_opt.len, nil:_nil} );
	},
	getNewsfIssue : function(opt){
		var _opt = {len : 34, type:'sub'};
		Object.extend( _opt, opt );
		var _nil = this.getNilLink('newsIssue', _opt.type);
		this.issue( this.dataset.issue.news, {len:_opt.len, nil:_nil} );
	},

	getNoticeList : function( mode ){
		this.list( this.dataset.notice, {len:30} );
	},
	
	//분양뉴스
	getByNewsList : function(){
		//var _nil = "&amp;nil_profile=estatetop&amp;"+_nil+"="+nil_item;
		this.list( this.dataset.byNews,  {len:30} );
	},
	
	//테마로찾는 매물
	getThemeList : function(){
		//var _nil = "&amp;nil_profile=estatetop&amp;"+_nil+"="+nil_item;
		this.list( this.dataset.theme,  {len:30} );
	},
	//분양 커뮤니티 : 상담
	getCommQnaList : function(){
		this.list( this.dataset.qna, {len:30} );
	}, 	
	//분양 커뮤니티 : 노하우
	getCommKnowhowList : function(){
		this.list( this.dataset.knowhow, {len:30} );
	}, 	
	getQuizDate : function(){
		var date = "0월 0일";
		try{ date = Number( this.dataset.quiz.date.substr(4,2) ) +"월 " +  Number( this.dataset.quiz.date.substr(6,2) ) + "일"; } catch (e) {}
		doc.write( date );
	},
	getQuizUrl : function(){ return this.dataset.quiz.url ; },
	getJoinsIssue : function(){ 
		var html = '';
		for ( var i in this.dataset.joinsIssue ){
			var obj = this.dataset.joinsIssue[i];
			
			var regExp = /nKey=([0-9]+)/;
			regExp.exec(obj.url);
			var nKey = RegExp.$1;
		
			html += '<li id="joinsIssue_hot_'+nKey+'" class="sub"><a href="'+obj.url+'" title="'+obj.title+'">'+UI.length( obj.title, 16, ".." )+'</a></li>';
		}
		doc.write( html );
	}
};


function getExtendTargetLink( areacode ){
	var tempAreacode = areacode;
	switch( areacode ){
		case "2900100": tempAreacode = "2410314"; break; // 고양시
		case "2900110": tempAreacode = "2420010"; break; // 부천시
		case "2900120": tempAreacode = "2425020"; break; // 안산시
		case "2900130": tempAreacode = "2430010"; break; // 안양시
		case "2900140": tempAreacode = "2440040"; break; // 수원시
		case "2900150": tempAreacode = "2446711"; break; // 용인시
		case "2900160": tempAreacode = "2461140"; break; // 성남시
	}
	return tempAreacode;
}

function getExtendArea( areacode ){
	var tempAreacode = areacode;
	switch( areacode.toString() ){
		// 고양시
		case "2410314": case "2411310": case "2412010": tempAreacode = "2900100"; break;
		// 부천시
		case "2420010": case "2421150": case "2422040": tempAreacode = "2900110"; break;
		// 안산시
		case "2425020": case "2426040": tempAreacode = "2900120"; break;
		// 안양시
		case "2430010": case "2431050": tempAreacode = "2900130"; break;
		// 수원시
		case "2440040": case "2440050": case "2441100": case "2442280": tempAreacode = "2900140"; break;
		// 용인시
		case "2446711": case "2448110": case "2449010": tempAreacode = "2900150"; break;
		// 성남시
		case "2461140": case "2462080": case "2463010": tempAreacode = "2900160"; break;
	}
	return tempAreacode;
}

function openTaxCalc(asset){
	var url = "";
	var vAction = "";
	
	switch(asset) {
		// 양도세
		case "YD": vAction = "/calc/Calc_EtcTax_YD.asp?sType=dCalc&CalcType=C02&Assets=1"; break;
		// 상속세
		case "SS": vAction = "/calc/Calc_EtcTax_SS.ASP?sType=dCalc"; break;
		// 증여세
		case "JY": vAction = "/calc/Calc_EtcTax_JY.ASP?sType=dCalc"; break;
		// 종합부동산세
		case "JB": vAction = "/calc/Calc_EtcTax_JB.ASP?sType=dCalc"; break;
		// 취득세/등록세
		case "CD": vAction = "/calc/BasicInfor.asp?SiteKey=daum&Pwd=mots-daum-20060901&sType=dCalc"; break;
		// 중개수수료 요율표
		case "TABLE": vAction = "/calc/RecommTable.asp?SiteKey=daum&Pwd=mots-daum-20060901&sType=dCalc"; break;
	}

	if(vAction != ""){
		url = "http://realestate.daum.net/sts";
		//url = "http://daum.stscenter.co.kr/B2B_Maemul";
		var frmMots = doc.getElementById("frmMots")
		if( !frmMots ){
			frmMots = $C("form");
			frmMots.method = "post";
			doc.body.appendChild( frmMots );
		}
		frmMots.action= url + vAction;
		var Win = window.open('','wMots' ,'width=680,height=550,scrollbars=yes,status=yes')
		frmMots.target = 'wMots';
		frmMots.submit();
		Win.focus();
	} else return;
}

// 콩나물 맵에서 심볼 클릭시 PV 집계용 더미파일 호출 from CongnamulMap.js > upup function
// 매물/시세, 부동산 검색에 사용
function callSymbolClickIframe(){
	// create click-log iframe 
	if(document){
		var clicklogFrame = UI.$("iframeSymbolPV");
		// 없으면 기냥 생성
		if( clicklogFrame == null ){
			clicklogFrame = $C("IFRAME");
			clicklogFrame.style.display = "none";
			clicklogFrame.id = "iframeSymbolPV";
			clicklogFrame.title = "콩나물 맵 심볼 PV집계용 iframe";
			doc.body.appendChild( clicklogFrame );
		}
		clicklogFrame.src = "http://realestate.daum.net/clickDummy/map";
	}
	
}

//################################################## TO광고 및 확장배너광고 ####################################################

function hideAD(){
	var adElem = top.ad;
	adElem.style.display="none";
}

//############### 공지사항 운영
function MenuBanner(){
	return '<a href="http://board3.finance.daum.net/gaia/do/estate/totalDanji/list?bbsId=danji&viewObj=68:69:70&pageIndex=1&nil_profile=estatetop&nil_tab=adtext1" target="new">알콩달콩 우리 동네 행복한 이야기!</a>';
} 

// ASP 페이지 내 광고영역
function getAdASP(){
	var sid = null;
	var url = location.href;
	var isTest = (url.indexOf("&test=T")>-1 )?true:false;;

	if( url.indexOf( "news.realestate.daum.net/" ) > -1 ){ sid = "00873"; } 
	else if( url.indexOf( "realestate.daum.net/mortgage/" ) > -1 ){ sid = "00875"; } 
	else if( url.indexOf( "auction.realestate.daum.net" ) > -1 ){ sid = "00874"; } 
	else if( url.indexOf( "bunyang.realestate.daum.net" ) > -1 ){ sid = "00870"; } 
	else { sid = "00874"; }// 경매가 말썽이라 -_-;;

	if( sid != null  ){
		var rand = Math.random().toString(); 
		var ordval = rand.substring(2,rand.length); 
		var clintAgent = navigator.userAgent;
		if( sid != "00870" ){ // 분양은 하지 않는다고...
			doc.writeln("<div id=\"layWiAdAsp\"><div id='ad250'><div id=\"EXTENSIBLE_BANNER_WRAP\"><div id=\"EXTENSIBLE_BANNER\"></div></div><iframe src=\"http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid="+sid+"&type=cpm&tag=iframe&mkvid=1&ord=" + ordval + "\" width=250 height=250 border=0 frameborder=0 scrolling=no marginheight=0 marginwidth=0 id=\"AMS_250exp\"></iframe></div></div>");
		} else {
			doc.writeln("<div id=\"EXTENSIBLE_BANNER_WRAP\"><div id=\"EXTENSIBLE_BANNER\"></div></div><iframe src=\"http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid="+sid+"&type=cpm&tag=iframe&mkvid=1&ord=" + ordval + "\" width=250 height=250 border=0 frameborder=0 scrolling=no marginheight=0 marginwidth=0 id=AMS_250exp></iframe>");
		}
	}
}

//########################################  서제스트 ###########################################################################

String.prototype.trim = function(){ 
	return this.replace(/(^\s*)|(\s*$)/gi, ""); 
} 
function getCookie(s){
	var tmp=doc.cookie.split('; ');
	for (var i=0; i<tmp.length;i++){
		var c_name = tmp[i].split('=');
		if (c_name[0]==s) return c_name[1];
	}
	return false;
}
function setCookie(_name,_value,_day,_domain){
	var expireDate = new Date(Number(new Date())+Number(_day)*86400000);
	var ckText = _name+'='+_value+';expires='+expireDate.toGMTString()+';path=/;';
	if(_domain) ckText += "domain="+_domain+";";
	//alert(doc.cookie);
	doc.cookie =ckText;
	//doc.cookie ="STOCKCODE="+escape("036030")+";domain=stock_dev.daum.net";
}
function getStyle(obj,styleText){
	var temp = styleText.split("-");
	var templen = temp.length;
	if(templen > 1) {
		styleText = 	temp[0];
		for(var n=1; n<templen; ++n) {
			styleText += temp[n].substr(0,1).toUpperCase() + temp[n].substr(1);
		}
	}

	if(obj.currentStyle)
		var css = obj.currentStyle;
	else
		var css = doc.defaultView.getComputedStyle(obj, null);
	value = css ? css[styleText] : null;
	return (value == null || value == undefined) ? "" : value;
}
function setStyle(obj,styles){
	var styleArr = styles.split(";");
	var styleCnt = styleArr.length;
	for(var i=0; i<styleCnt; ++i) {
		var styleItem = styleArr[i].split(":");
		styleItem[1] = styleArr[i].substr(styleItem[0].length+1);
		styleItem[0] = styleItem[0].trim();
		switch(styleItem[0]) {
			case 'float' :
				if(obj.style.styleFloat != undefined) 
					obj.style.styleFloat = styleItem[1];
				else 
					obj.style.cssFloat = styleItem[1];
				break;
			default :
				if(styleItem[0].length>0 && styleItem[1].length>0) {
					var temp = styleItem[0].split("-");
					var templen = temp.length;
					if(templen > 1) {
						styleItem[0] = 	temp[0];
						for(var n=1; n<templen; ++n) {
							styleItem[0] += temp[n].substr(0,1).toUpperCase() + temp[n].substr(1);
						}
					}
					obj.style[styleItem[0]] = styleItem[1];	
				}
				break;
		}
	}
}
//event add
function AddEvent(element, name, func){
	if (element.addEventListener) {
		element.addEventListener(name, func, false);
	}
	else if (element.attachEvent) {
		element.attachEvent('on' + name, func);
	}
}
function RemoveEvent(element, name, func){
	if (element.addEventListener) {
		element.removeEventListener(name, func, false);
	}
	else if (element.attachEvent) {
		element.detachEvent('on' + name, func);
	}
}
function StopEvent(event) {
	var e=event || window.event;
	if(e.preventDefault) {e.preventDefault(); e.stopPropagation(); }
	else {e.returnValue = false; e.cancelBubble = true;}
};
/* list over/out */
function highlight(obj, isover, color){
	if(color == undefined) color = "#EFF1FF";
	if(!obj.oldColor) obj.oldColor = getStyle(obj,"background-color");
	obj.style.backgroundColor = (isover) ? color : obj.oldColor;
}
/* javascript call */
function callsrc(id,url,type) {
	var obj = $(id);
	var parent;
	if(obj) {
		parent = obj.parentNode;
		parent.removeChild(obj);
	}
	else {
		parent = doc.getElementsByTagName('head')[0];
	}
	
	obj = $C('script');
	var cashTime = new Date() - Date.UTC(2008,5,0);
	if(type && type == "day") cashTime = Math.floor(cashTime/86400000);
	
	var param = (url.indexOf('?')<0) ? '?':'&';
	param += "d="+ cashTime;
 
	obj.src = url + param;
	obj.id = id;
	obj.type = "text/javascript";
	parent.appendChild(obj);
}
//input 초기값삭제 & 기본style로 변경
function resetInputStyle(el) {
	if (!el.isFocus) {
		el.value = "";
		el.style.color = "#333";
		el.style.fontWeight = "normal";
		el.style.fontSize = "12px";
		el.style.fontFamily = "굴림,gulim";
		el.isFocus = true;
		el.focus();
	}
}

/* suggest */
var sug = {}
sug.children = [];
sug.cur = null; //call시 현재 sug.exec 객체

sug.cookie = {
	name : "estateSuggest",
	domain : ["realestate.daum.net","maemul.realestate.daum.net","neo.realestate.daum.net","danjiboard.realestate.daum.net","news.realestate.daum.net","auction.realestate.daum.net","bunyang.realestate.daum.net","board.realestate.daum.net","qna.finance.daum.net","event.finance.daum.net"]
}

sug.$ = $;
sug.$C = $C; 
sug.setCookie = setCookie; //setCookie(_name,_value,_day,_domain)
sug.getCookie = getCookie; //getCookie(s)
sug.setStyle = setStyle; //setStyle(obj,styles)
sug.addEvent = UI.addEvent; //AddEvent(element, name, func)
sug.stopEvent = UI.stopEvent; //StopEvent(event)
sug.highlight = highlight; //highlight(obj,isOver,color) <- mouseout일때는 color값 필요없음
sug.resetInputStyle = resetInputStyle; //input에 들어있는 text style reset
sug.callsrc = callsrc;
sug.isSuggestOn = (sug.getCookie("estateSuggest")=="off") ? false : true;
sug.on = function() {
	sug.isSuggestOn = true;
	for(var i=0,cnt=sug.children.length;i<cnt;++i) {
		sug.children[i].input.autocomplete = "off";
	}
	sug.close();
	for(var i in this.cookie.domain) sug.setCookie(sug.cookie.name,"on",365,sug.cookie.domain[i]);
}
sug.off = function() {
	sug.isSuggestOn = false;
	for(var i=0,cnt=sug.children.length;i<cnt;++i) {
		sug.children[i].input.autocomplete = "on";
	}
	sug.close();
	for(var i in this.cookie.domain) sug.setCookie(sug.cookie.name,"off",365,sug.cookie.domain[i]);
}
sug.setList = function(data) {
	sug.cur.setList(data);
}
sug.close = function() {
	for(var i=0,cnt=sug.children.length;i<cnt;++i) {
		sug.children[i].closeBox();
	}
}
sug.autoSelect = function() {
	if(sug.cur.listCnt > 0) sug.cur.selectItem();
}
//input validate function (서비스마다 각각 설정)
sug.validate = function(val) {
	//if(val.length == 0 || (!isNaN(val) && val.length < 4)) return false;
	if(val.length == 0) return false;
	return true;
}

//결과값이 없을경우  (서비스마다 각각 설정)
sug.noResult = function() {
	return '<p style="padding:10px;line-height:18px">해당 단어로 시작하는 정보가 없습니다.</p>';
}
sug.info = function() {
	var html = '<p style="padding:4px 0;font:11px/15px 돋움,dotum">';
	if(sug.isSuggestOn) html += '현재 <b style="color:#5471AA">검색어 서제스트</b>를 사용하고 있습니다.';
	else html += '<b style="color:#5471AA">검색어 서제스트</b>를 사용해 보세요. <a href="javascript:;" onclick="sug.on()" style="color:#EB6F00;text-decoration:underline">기능켜기</a>';
	html += '<br>검색어 입력시 적합한 키워드를 제시합니다.</p>';
	return html;
}
sug.getFooter = function(isInfoShow) {
	var html ='<span style="float:right;text-align:right;padding-right:10px;">' +
						'	<a href="http://blog.daum.net/daumfinance/5594457" target="_blank">서제스트란?</a>' +
						'	';
	if(isInfoShow) html += '<span style="margin:0 4px">|</span> <a href="javascript:;" onclick="sug.close()">닫기</a>';
	else html += '<a href="javascript:;" onclick="sug.off()">기능끄기</a>';
	html += '</span>';
	return html;
}

// suggest
function estateSearch(id) {
	var el = $(id);
	var code = el.code;
	if(code) window.location.href="http://realestate.daum.net/search/total/?query="+encodeURIComponent( code );
	else {
		if(doSearchQ()) doc.search.submit();
	}
}
sug.exec = function(inputId,btnId,btnFunc,boxId) {
	sug.children.push(this);
	this.maxHeight = 122;
	this.isInfoShow = false;
	this.isListShow = false;
	this.listCnt = 0;
	this.curIndex = -1;	
	this.timer = null;
	
	this.input = sug.$(inputId);
	this.btn = sug.$(btnId);
	this.btnFunc = btnFunc;
	if(boxId) this.box = sug.$(boxId);
	else {
		this.box = sug.$C('div');
		sug.setStyle(this.box,"top:"+(this.input.offsetTop+this.input.offsetHeight)+"px;left:"+this.input.offsetLeft+"px");
		//doc.title = this.input.offsetLeft;
		this.input.offsetParent.style.zIndex=97-sug.children.length*4;
		this.input.offsetParent.appendChild(this.box);
	}
	sug.setStyle(this.box,"display:none;position:absolute;z-index:"+(98-sug.children.length*4)+";text-align:left;width:"+this.input.offsetWidth+"px;");
	this.render();
}
sug.exec.prototype = {
	render : function() {
		this.input.setAttribute("autocomplete","off");
		this.input.maxLength = "100"; //호호 종목은 글자가 길지 않으니... 우선 이렇게 하자... padding-right주는것도 방법 -이하영-
		this.defValue = this.input.value;
		
		var w = this.input.offsetWidth;//this.box.offsetWidth;
	
		this.bk = sug.$C('iframe'); this.bk.frameBorder = 0;
		sug.setStyle(this.bk,"position:absolute;background-color:#fff;width:"+w+"px;top:0;left:0;z-index:"+(99-sug.children.length*4));//height:146px;
		
		this.body = sug.$C('div');
		sug.setStyle(this.body,"position:absolute;width:"+(w-2)+"px;border:1px solid #8C95D6;z-index:"+(100-sug.children.length*4));
		
		this.list = sug.$C('ul'); this.list.className = "scroll";
		sug.setStyle(this.list,"width:"+(w-2)+"px;overflow-y:auto;overflow-x:hidden");
		this.body.appendChild(this.list);
		
		this.footer = sug.$C('div');
		sug.setStyle(this.footer,"float:left;background-color:#F4F6FB;height:14px;padding:7px 0px 3px 0px;font:11px 돋움,dotum;letter-spacing:-1px;color:#C2CFF0;width:100%;");
		
		this.icon = sug.$C('div');
		sug.setStyle(this.icon,"background-image:url(http://fn.daum-img.net/image/finance/plaza/2008/stock/common/ico_sugest.gif);background-repeat:no-repeat;width:7px;height:4px;position:absolute;top:"+(this.input.offsetTop+9)+"px;left:"+(this.input.offsetLeft+w-16)+"px;cursor:pointer;font-size:0");
		this.input.offsetParent.appendChild(this.icon);
		
		/*this.resortBtn = sug.$C('a'); this.resortBtn.href="javascript:;"; this.resortBtn.innerHTML = '끝단어 더보기'; sug.setStyle(this.resortBtn,"float:left");
		this.footer.appendChild(this.resortBtn);
		sug.addEvent(this.resortBtn,"click",this.resort.bind(this));*/
		this.footer.innerHTML = sug.getFooter(this.isInfoShow);
		this.body.appendChild(this.footer);
		
		this.box.appendChild(this.bk);
		this.box.appendChild(this.body);
		
		sug.addEvent(this.input,"keydown",this.keyIn.bindAsEventListener(this));
		sug.addEvent(this.input,"focus",this.focusInput.bindAsEventListener(this));
		//sug.addEvent(this.input,"focus",this.resetInputStyle.bindAsEventListener(this));
		sug.addEvent(this.input,"mousedown",this.clickInput.bindAsEventListener(this));
		sug.addEvent(document,"mousedown",this.closeBox.bindAsEventListener(this));
		sug.addEvent(this.icon,"mousedown",this.showInfo.bind(this));
		sug.addEvent(this.icon,"mousedown",sug.stopEvent); 
		sug.addEvent(this.body,"mousedown",sug.stopEvent); 
		sug.addEvent(this.btn,"mousedown",sug.stopEvent); 
		sug.addEvent(this.btn,"click",this.selectItem.bind(this));
	},
	showInfo : function() {
		if(!this.isInfoShow) {
			sug.close();
			this.isInfoShow = true;
			this.iconChange(this.isInfoShow);
			this.footer.innerHTML = sug.getFooter(this.isInfoShow);
			this.setList(null);
		}
		else {
			this.closeInfo();
		}
	},
	closeInfo : function() {
		if(this.isInfoShow) {
			this.isInfoShow = false;
			this.iconChange(this.isInfoShow);
			this.footer.innerHTML = sug.getFooter(this.isInfoShow);
			this.box.style.display = "none";
		}
	},
	keyIn : function(event) { //key control
		if(!sug.isSuggestOn)  return;

		var e=event || window.event;
		if((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 65 && e.keyCode <= 90) || (e.keyCode >= 96 && e.keyCode <= 105) || e.keyCode == 229 || e.keyCode == 8 || e.keyCode == 46) { //48~57:숫자, 65~90:문자, 96~105:숫자키패드, 229:한글, 8:백스페이스, 46 : delete
			if(!this.timer) {
				this.checkChange.bind(this);
				this.timer = window.setInterval(this.checkChange.bind(this),100);	
			}
		}
		else if(e.keyCode == 38 || e.keyCode == 40) { 
			if(this.listCnt > 0) {
				if(e.keyCode == 38) { //up key
					if(this.curIndex > 0) {
						this.curIndex--;
						var li = this.list.childNodes[this.curIndex];
						//if(li.offsetTop + li.offsetHeight <= this.list.scrollTop) this.list.scrollTop -= li.offsetHeight;
						if(li.offsetTop <= this.list.scrollTop) this.list.scrollTop = li.offsetTop;
					}
					else { //curIndex이 0인 경우 박스를 닫는다.
						this.closeBox();
					}
				} 
				else { //down key
					if(this.curIndex < this.listCnt-1) this.curIndex++;
					var li = this.list.childNodes[this.curIndex];
					//if(li.offsetTop >= this.list.offsetHeight + this.list.scrollTop) this.list.scrollTop += li.offsetHeight; //ff에서 border값 때문에 계산이 안맞아서 -3해줌
					if(li.offsetTop +li.offsetHeight >= this.list.offsetHeight + this.list.scrollTop) this.list.scrollTop = (li.offsetTop +li.offsetHeight-this.list.offsetHeight); //ff에서 border값 때문에 계산이 안맞아서 -3해줌
					this.showList(); //닫혀있으면 다시 열어준다.
				}
				//highlight
				for(var i=0; i<this.listCnt; ++i) this.list.childNodes[i].onmouseout();
				if(this.curIndex >= 0 && this.curIndex < this.listCnt) this.list.childNodes[this.curIndex].onmouseover(); 
			}
		}
		else if(e.keyCode == 13) {//enter key
			this.selectItem();
			return false;
		}
	},
	checkChange : function() { //check input value
		if(this.input.oldValue == this.input.value) return; //변화가 없으면 무시
		
		this.input.code = ""; //변화가 있으면 지워줌.
		this.input.oldValue = this.input.value; 
		this.getData();
	},
	focusInput : function() { //mousedown시 show/hide
		//초기값 (ex.종목명 or 코드) 일때는 pass해야 하지만, 검색결과가 뿌려진 경우에는????
		if(this.defValue == this.input.value) {
			//this.input.value = "";
			//this.input.isFocus = true;
			//sug.resetInputStyle(this.input);
		}
		sug.cur = this; //focus가 가면 sug.cur 세팅
	},
	clickInput : function() { //mousedown시 show/hide
		//초기값 (ex.종목명 or 코드) 일때는 pass해야 하지만, 검색결과가 뿌려진 경우에는????
		if(!sug.isSuggestOn) return;
		if(this.defValue == this.input.value) return;
		if(!this.isListShow) this.getData(); //필요할까??
		else this.closeList();
	},
	getData : function() {	
		var invalue = this.input.value;
		if(!sug.validate(invalue)) {
			this.removeList();
			return;
		}

		invalue = invalue.replace(/ /gi, "" ); 
		if( isASP() == true || isEUCKR() == true ){
			// euckr
			sug.callsrc('sugJs','http://suggest.finance.daum.net/estate_nsuggest?mod=js&func=sug.setList&q='+invalue)
		} else {
			sug.callsrc('sugJs','http://suggest.finance.daum.net/estate_nsuggest?mod=js&func=sug.setList&encoding=utf_in_out&q='+encodeURIComponent(invalue))
		}
	},
	setList : function(data) {
		sug.cur = this;  //setList 해도 sug.cur 세팅
		while(this.list.firstChild) this.list.removeChild(this.list.firstChild);
		if(!data) {
			this.showInfoList();
		}
		else {
			var items = data.items;
			var r_items = data.r_items;
			var itemCnt = items.length;
			var r_itemCnt = r_items.length;		
			if(itemCnt + r_itemCnt > 0) {
				this.listCnt = itemCnt + r_itemCnt;	
				var keyVal = data.rq;
				var i, j;
				for(i=0;i<itemCnt;++i) {
					this.makeItemList(i, keyVal, items[i]);
				}
				for(j=0;j<r_itemCnt;++i,++j) {
					this.makeItemList(i, keyVal, r_items[j]);
				}
			}
			else {
				this.listCnt = 0;
				this.makeItemList(0);
			}	
		}	
		this.showList();
		this.list.style.height = "auto";
		var listHeight = this.list.offsetHeight;
		var realHeight = (listHeight > this.maxHeight) ? this.maxHeight : listHeight;
		this.list.style.height = realHeight + "px";
		this.box.style.height = this.bk.style.height = (this.body.offsetHeight) + "px";
		this.curIndex = -1;
		this.list.scrollTop = 0;
	},
	showInfoList : function() { //<li>생성
		var li = $C('li');
		setStyle(li,"position:static;float:none;line-height:14px;padding:3px 10px 1px;height:auto");
		li.innerHTML = sug.info();
		this.list.appendChild(li);
	},
	makeItemList : function(i, keyVal, itemVal) { //<li>생성
		var li = $C('li');
		li.idx = i;
		//setStyle(li,"letter-spacing:0;width:100%;height:22px;line-height:22px;overflow:hidden");

		if(!keyVal && !itemVal) {
			setStyle(li,"position:static;float:none;height:auto");
			li.innerHTML = sug.noResult();			
		}
		else {
			//setStyle(li,"position:static;float:none;height:20px;line-height:14px;padding:3px 0 1px 10px;white-space:nowrap;overflow:hidden");
			setStyle(li,"position:static;float:none;line-height:14px;padding:4px 10px 6px;height:auto;cursor:pointer;");
			li.innerHTML = this.formatEstateItemList(li,keyVal,itemVal);		
			li.onmouseover = function() {sug.highlight(this,true,"#efefef")}; 
			li.onmouseout = function() {sug.highlight(this,false)}; 
			li.onmousedown = this.selectItemOne.bind(this,i)
		}
		this.list.appendChild(li);
	},/*
	formatItemList : function(li,keyVal,itemVal) {
		//동의어 들어있는지 확인		
		if(itemVal.indexOf("(=")>=0) itemVal.match(/(.*)\(=(.*)\)\(([A-Za-z0-9]{6})\)/);
		else itemVal.match(/(.*)(.*)\(([A-Za-z0-9]{6})\)/);
		li.dataName = RegExp.$1;
		li.dataName1 = RegExp.$2;
		li.dataCode = RegExp.$3;
		
		var html;
		var exp = new RegExp("("+keyVal.replace(/(\(|\))/gi,"\\$1")+")",'gi');
		html = li.dataName.replace(exp,"<span style=\"color:#FF5F00\">$1</span>");
		if(li.dataName1.length > 0) html += "(="+li.dataName1.replace(exp,"<span style=\"color:#FF5F00\">$1</span>")+")";
		html += "<span class=\"num\" style=\"color:#999\"> (" + li.dataCode.replace(exp,"<span style=\"color:#FF5F00\">$1</span>") +")</span>";
		return html;

	},*/
	/*

*/
	formatEstateItemList : function( li, keyVal, itemVal ){
		var itemAry = itemVal.split("|");

		li.dataName = itemVal;//RegExp.$1;
		li.dataName1 = "";
		li.dataCode = itemVal;//RegExp.$3;
		
		var html;
		var exp = new RegExp("("+keyVal.replace(/(\(|\))/gi,"\\$1")+")",'gi');
		html = this.highlightCheck( li.dataName );
		html = this.highlightrCheck( html );
		//html = li.dataName.replace(exp,"<span style=\"color:#FF5F00\">$1</span>");
		//if(li.dataName1.length > 0) html += "(="+li.dataName1.replace(exp,"<span style=\"color:#FF5F00\">$1</span>")+")";
		//html += "<span class=\"num\" style=\"color:#999\"> (" + li.dataCode.replace(exp,"<span style=\"color:#FF5F00\">$1</span>") +")</span>";
		return html;
	},
	highlightCheck : function(str) {
		var revertQuery = this.input.value.replace(/ /gi, "");
		var rtStr = "";
		var _str = str.replace(/ /gi, "");
		var _userKeyword = revertQuery.replace(/ /gi, "");
		_userKeyword = _userKeyword.toLowerCase();
		if(_userKeyword == _str.substring(0, _userKeyword.length)){
			rtStr = "<font color='#eb550c'>";
			for (var i=0,j=0; j<revertQuery.length; i++) {
				if (str.substring(i, i+1)!=" ") j++;
				rtStr += str.substring(i, i+1);
			}
			rtStr += "</font>" + str.substring(i, str.length);
		}else{
			rtStr += str;
		}
		return rtStr;
	},
	highlightrCheck : function (str) {
		var revertQuery = this.input.value.replace(/ /gi, "");
		var rtStr = "";
		var _str = str.replace(/ /gi, "");
		var _userKeyword = revertQuery.replace(/ /gi, "");
		_userKeyword = _userKeyword.toLowerCase();
		if (_userKeyword == _str.substring(_str.length - _userKeyword.length)) {
			for (var i=0,j=0; j<_str.length - _userKeyword.length; i++) {
				if (str.substring(i, i+1)!=" ") j++;
				rtStr += str.substring(i, i+1);
			}
			rtStr += "<font color='#eb550c'>";

			for (var k=i,l=0; l<_userKeyword.length; k++) {
				if (str.substring(k, k+1)!=" ") l++;
				rtStr += str.substring(k, k+1);
			}
			rtStr += "</font>";
		}else{
			rtStr += str;
		}
		return rtStr;
	},
	showList : function() { //show ul & addevent
		if(!this.isListShow) {
			this.box.style.display = "block";
			this.list.style.display = "block";
			//this.footer.style.display = "block";
			
			//this.offBT.style.display = "";
			//this.closeBT.style.display = "none";
			//this.body.style.display = "block";
			//this.bk.style.display = "block";
			this.isListShow = true;
		}
	},
	closeList : function() { //hide ul & removeevent & timer remove
		if(this.timer) {
			window.clearInterval(this.timer);
			this.timer = null; //해줘야함
			//this.input.oldValue = "";
			this.input.oldValue = this.input.value;
		}
		this.curIndex = -1;
		if(this.isListShow) {
			//this.bk.style.display = "none";
			//this.list.style.display = "none";
			this.isListShow = false;
		}
	},
	removeList : function() { //remove ul
		this.listCnt = 0;
		this.closeBox();
	},
	closeBox : function() {
		this.box.style.display = "none";
		this.closeInfo();
		this.closeList();
	},
	iconChange : function(isOn) {
		this.icon.style.backgroundPosition=(isOn)?"0 bottom":"0 0";
	},
	selectItem : function() {
		if (!this.isListShow) {
			if (typeof(this.btnFunc) == "function") 
				this.btnFunc();
			return;
		}		
		if(this.curIndex >= 0 && this.curIndex < this.listCnt) { //선택항목이 있는 경우
			this.selectItemOne(-1);
		}
		else {
			this.selectItemAuto();
		}
	},
	selectItemOne : function(idx) { //mousedown or enter click시 호출 -> StockInsert & CloseStockList
		if(idx >= 0) this.curIndex = idx;
		var li = this.list.childNodes[this.curIndex];
		this.input.value = li.dataName;
		this.input.code = li.dataCode;
		this.removeList();
		if(typeof(this.btnFunc) == "function") this.btnFunc();
	},
	selectItemAuto : function() { //enter key
		//아래 항목에 1개만 있으면 선택할필요없이 바로 code값 넣어주기
		/*
		if(this.listCnt == 1) {
			var li = this.list.firstChild;
			this.input.value = li.dataName;
			this.input.code = li.dataCode;
		}
		else
		*/
		{
		//아래 항목에서 존재하는게 있으면 선택할필요없이 바로 code값 넣어주기 && 우선주  아닌게 1개인지 체크
			var equalItem = null;
			var noPrefer = [];
			var cnt = this.listCnt;
			for(i=0;i<cnt;++i) {
				var li = this.list.childNodes[i];
				if(this.input.value == li.dataName || this.input.value == li.dataCode) {
					equalItem = li;
					break;
				}
				if(li.dataCode.substring(5)=="0") noPrefer.push(li);
			}
			
			if(equalItem || noPrefer.length == 1) {
				var target = equalItem || noPrefer[0];
				this.input.value = target.dataName;
				this.input.code = target.dataCode;				
			}
		}
		if(this.input.code && this.input.value.length>0) { //백스페이스 등으로 값을 없에는 경우, code값은 남아 있으므로 함께 check해줌
			this.removeList();
		}
		if(typeof(this.btnFunc) == "function") this.btnFunc();
	}
}

function isASP(){
	var flag = true;
	var url = location.href;
	// asp 페이지가 아닌 도메인을 구분
	if( ( url.indexOf( "http://realestate.daum.net/mortgage/" ) == -1 && url.indexOf( "http://realestate.daum.net/" ) == 0 ) 
		|| url.indexOf( "http://maemul.realestate.daum.net/" ) == 0 
		|| url.indexOf( "http://neo.realestate.daum.net/" ) == 0 
		|| url.indexOf( "http://event.finance.daum.net/" ) == 0 
		|| url.indexOf( "http://danjiboard.realestate.daum.net/" ) == 0 
		|| url.indexOf( "http://board.realestate.daum.net/" ) == 0 
		|| url.indexOf( "http://qna.finance.daum.net/" ) == 0 ){
		flag = false;
	} 
	return flag;
}
function isEUCKR(){
	var flag = false;
	var url = location.href;
	/*
	if( url.indexOf("http://qna.finance.daum.net/") == 0 ){
		flag = true;
	}
	*/
}
function goPage( url ){top.location.href = url;}

/*------------이벤트용-------------------*/
// 2009.07 아이콘 모으기 이벤트 
function eventIconClick(){
	var check = UI.$('eventChecksum').value;
 	url = "http://gold.estate.daum.net/collect/pickItem.daum?checksum=" + check;
 	UI.$("ICON_DD").style.display = "none";
 	var doc = popup(url, "_CollectEvent",{width:480, height:460, scrollbars:"no", resizable:"no" , status:"no", location:"no", menubar:"no" });
 	doc.focus();
}

var popupEvent = null;
function checkIconPoint(){
	try
	{
		UI.$("ICON_DD").style.display = "none";
		//return;
		
		// 탑에서는 둥둥이 보이지 않도록 하기
		try{
			if( requestUri != null){
		 		if(requestUri.indexOf('/EstateHome.daum') != -1 ){
					return;
				}
			}
		}catch(e){}
		
		if( !UI.$("eventChecksum") ||  UI.$("eventChecksum") == null ){
			if( getCookie("estateIcon") == "off" ) { return false; }
		}
		
		if( UI.$("eventChecksum") && UI.$("eventChecksum").value == ""){
		 	if( getCookie("estateIcon") == "off" ) { return false; }
		}
		
		if( UI.$("ICON_DD") != null  ){
			var iconDiv = UI.$("ICON_DD");
			iconDiv.className = "ddIcon";
			iconDiv.id = "ICON_DD";

			// 로그인 또는 설정이 안된경우 둥둥아이콘//http://fn.daum-img.net/image/estate/event/20080808/icon_search.gif
			/*
			if( iconPoint == 0 ){
				iconDiv.innerHTML = "<img src='http://fn.daum-img.net/image/estate/event/20080808/icon2_1.gif' onclick='popupPromotionInit();'><br><img src='http://fn.daum-img.net/image/estate/event/20080808/icn_close.gif' class='close' onclick='closePromotionIcon();'>";
			} else if( iconPoint == -1 ){
				iconDiv.innerHTML = "<img src='http://fn.daum-img.net/image/estate/event/20080808/icon2_1.gif' onclick='popupPromotion();'><br><img src='http://fn.daum-img.net/image/estate/event/20080808/icn_close.gif' class='close' onclick='closePromotionIcon();'>";
			// 설정이후는 금액아이콘
			} else if( iconPoint > 0 ){
				var url = location.href;
				url = encodeURIComponent( url );
				iconDiv.innerHTML = "<img src='http://fn.daum-img.net/image/estate/event/20080808/icon_"+iconPoint+".gif' onclick='popupPromotion(encodeUrl);'><br><img src='http://fn.daum-img.net/image/estate/event/20080808/icn_close.gif' class='close' onclick='closePromotionIcon();'>";
			}
			*/
			
			//iconDiv.innerHTML = "<a href='#' onclick='popup(\"http://gold.estate.daum.net/html/quizEvent.html\", \"_IconEvent\",{width:480, height:480, scrollbars:\"no\", resizable:\"no\" , status:\"no\", location:\"no\", menubar:\"no\" });return false;'><img src='http://fn.daum-img.net/image/estate/2008/direct/090812_75x75.gif'  width='75' height='75'></a><br><img src='http://fn.daum-img.net/image/estate/event/20080808/icn_close.gif' class='close' onclick='closePromotionIcon();' >";
			
			
			
			if( UI.$("eventChecksum") &&  UI.$("eventChecksum").value != ""){
			 	iconDiv.innerHTML = "<a href='#' onclick='eventIconClick();return false;'><img src='http://fn.daum-img.net/image/estate/2009/banner/icon_apart.gif'  width='75' height='75'></a><br><img src='http://fn.daum-img.net/image/estate/event/20080808/icn_close.gif' class='close' onclick='closePromotionIcon();' >";
			}else{
				iconDiv.innerHTML = "<a href='#' onclick='popup(\"http://gold.estate.daum.net/html/collectEvent.html\", \"_CollectEvent\",{width:480, height:460, scrollbars:\"no\", resizable:\"no\" , status:\"no\", location:\"no\", menubar:\"no\" });return false;'><img src='http://fn.daum-img.net/image/estate/2009/banner/1026_03.gif'  width='75' height='75'></a><br><img src='http://fn.daum-img.net/image/estate/event/20080808/icn_close.gif' class='close' onclick='closePromotionIcon();' >";
			}
 
			if( iconDiv.innerHTML != "" ){
				if( document.location.href.indexOf("/news") != -1){
					iconDiv.style.left = "643px";
					iconDiv.style.top = "50px";
				}else if( document.location.href.indexOf("/maemul/") != -1){
					iconDiv.style.left = "690px";
					iconDiv.style.top = "271px";			
				}else{
					iconDiv.style.left = "652px";
					iconDiv.style.top = "202px";
					
				}
				iconDiv.style.display = "block";
			}
		}
 
	} catch (e)	{
	//alert(e.message);	
	}
}
function closePromotionIcon( type ){
	try
	{
		var obj = UI.$("ICON_DD");
		if( type != "click" &&  confirm( "이 이미지가 24시간 동안 안 보이길 원하세요?" ) ){
			for(var i in sug.cookie.domain) setCookie("estateIcon","off",1,sug.cookie.domain[i]);
		}
		obj.style.display = "none";	
	} catch (e)	{}
}
function popupPromotion(encodeUrl){
	var link = "http://event.finance.daum.net/getpoint.daum?url="+encodeUrl;
	var name = "estatePromotion";
	try{
		popupEvent.close();	
	}catch (e){}

	var option = { scrollbars:"no",status:"no",width:"650",height:"510" };
	popupEvent = popup( link, name, option );
	popupEvent.focus();
	closePromotionIcon("click");
}
function popupPromotionSetup(){
	try{
		popupEvent.close();	
	}catch (e){}
	var option = { scrollbars:"no",status:"no",width:"650",height:"370" };
	popupEvent = popup("http://event.finance.daum.net/getpoint.daum",name,option);
	popupEvent.focus();
}
function popupPromotionInit(){
	popupPromotionOnStep( 1, 1 );
}
function popupPromotionState(){
	try{
		popupEvent.close();	
	}catch (e){}
	var option = { scrollbars:"no",status:"no",width:"650",height:"370" };
	popupEvent = popup("http://event.finance.daum.net/getpoint.daum",name,option);
	popupEvent.focus();
}
function popupPromotionClick(){
	popupPromotionOnStep( 2, 1 );
}
function popupPromotionBrand(){
	//popupPromotionOnStep( 2, 3 );
	var name = "estatePromotion";
	var option = { scrollbars:"yes",status:"no",width:"667",height:"510" };
	try{
		popupEvent.close();	
	}catch (e){}
	popupEvent = popup("http://event.finance.daum.net/brand.daum",name,option);
	popupEvent.focus();
	closePromotionIcon("click");
}

function popupPromotionOnStep( group, seq ){
	group = group.toString();
	seq = seq.toString();

	var name = "estatePromotion";
	var url = "";
	var option = "";

	switch( group ){
	case "1":
		option = {width:450,height:340,scrollbars:'no',status:"no"};
		switch( seq ){
		case "1":
			url = "popup1_1.html";
			break;
		case "2":
			url = "popup1_2.html";
			break;
		case "3_1":
			url = "popup1_3.html";
			break;
		case "3_2":
			url = "popup1_3_type2.html";
			break;
		case "4_1":
			url = "popup1_4.html";
			break;
		case "4_2":
			url = "popup1_4_type2.html";
			break;
		case "5":
			url = "popup1_5.html";
			break;
		}
		break;
	case "2":
		option = {width:650,height:370,scrollbars:'no',status:"no"};
		switch( seq ){
		case "1":
			url = "popup2_1.html";
			break;
		case "2":
			url = "popup2_2.html";
			break;
		case "3":
			url = "popup2_3.html";
			option.scrollbars = "yes";
			option.width = "667px";
			option.height = "600px";
			break;
		case "4":
			url = "popup2_4.html";
			option.scrollbars = "yes";
			option.width = "667px";
			option.height = "600px";
			break;
		}
		break;
	}
	try{
		popupEvent.close();	
	}catch (e){}
	popupEvent = popup("http://event.finance.daum.net/vm/estate/080903/html/"+url,name,option);
	popupEvent.focus();
	closePromotionIcon("click");

}

function importManagerJS() {
	//jsfile = "http://fn.daum-img.net/js/estate/2008/manager.js";
	//jsfile = "http://realestate.daum.net/js/manager.js";
	jsfile = "http://fn.daum-img.net/xml/estate/manage.js";
	doc.write('<scr'+'ipt type="text/javascript" charset="utf-8" src="'+jsfile+'"></'+'script>');
}
importManagerJS();

var SimpleSwitcher = function( listId, btnPrevId, btnNextId, options ){
    this.listGroup = UI.$( listId );
    this.btnPrev = UI.$( btnPrevId );
    this.btnNext = UI.$( btnNextId );
    this.prevIndexObj = null;
    this.selectedObj = null;
    this.length = null;
    this.onComplete = function(){}
    this.options = {
        defaultIndex : 0,
        loop : true,
        childTag : "LI"
    }
    Object.extend( this.options, options );
    this.init();
};

SimpleSwitcher.prototype = {
    init : function(){
        this.index = this.options.defaultIndex;
        this.list = this.listGroup.getElementsByTagName( this.options.childTag );
        this.length = this.list.length;
        this.list[ this.index ].style.display = "block";
        this.prevIndexObj = this.list[ this.index ];
        this.selectedObj = this.list[ this.index ];
        
        UI.addEvent( this.btnPrev, "mousedown", this.move.bind(this,"prev") ); //bindAsEventListener
        UI.addEvent( this.btnNext, "mousedown", this.move.bind(this,"next") );
    },
    move : function( type ){
        if( this.prevIndexObj != null ){
            this.prevIndexObj.style.display = "none";
        }   
        switch( type ){
        case "prev":
            this.index--;
            if( this.index < 0 ){
                if( this.options.loop == true ){
                    this.index = this.length-1;
                } else {
                    this.index = 0;
                }
            }
            break;
        case "next":
            this.index++;
            if( this.index >= this.length ){
                if( this.options.loop == true ){
                    this.index = 0;
                } else {
                    this.index = this.length-1;
                }
            }
            break;
        }
        this.show();
    },
    show :function(){
        this.list[ this.index ].style.display = "block";
        this.selectedObj = this.list[ this.index ];
        this.onComplete();
        this.prevIndexObj = this.list[ this.index ];
    }
};

var TopWeeklyBest = function( type, callUrl, viewListId, riseListId, option ){
    this.data = {};
    this.type = type;
    this.url = callUrl;
    this.viewList = UI.$(viewListId);
    this.riseList = UI.$(riseListId);
    this.callMode = "ajax";
    this.count = 5;
	this.initUrl = null;
    this.paramView = {}; // nil태그용 param
    this.paramRise = {}; // nil태그용 param

    Object.extend( this, option );
};
TopWeeklyBest.prototype = {
    show : function( param, type ){
		var url = this.url;
		if( this.initUrl != null ){
			url = this.initUrl;
			this.initUrl = null;
		}
        switch( this.callMode  ){
            case "call":
                try{console.log( url+"?"+param );}catch (e){}
                dynamicScript.call( url+"?"+param );
                break;
            case "ajax":
            default :
                // 선택된 광역지역 지역코드
                var ajax = new FN.Ajax( {url:url} );
                ajax.options.onComplete = this.reponse.bind(this);
                if( param ){
                    ajax.options.param = param;
                }
                ajax.send();
        }
    },
    reponse : function ( res ){
        var data = eval("("+res.responseText+")" );//{viewBest:[{type:"viewBest", danjiid:"1755", areaName:"노원구 중계동", danjiName:"주공5단지"}, {type:"viewBest", danjiid:"9850", areaName:"금천구 시흥동", danjiName:"벽산5단지"}, {type:"viewBest", danjiid:"2418", areaName:"송파구 문정동", danjiName:"훼밀리"}, {type:"viewBest", danjiid:"4608", areaName:"노원구 상계동", danjiName:"주공6단지"}, {type:"viewBest", danjiid:"4571", areaName:"노원구 상계동", danjiName:"주공16단지"}, {type:"viewBest", danjiid:"28590", areaName:"송파구 잠실동", danjiName:"잠실주공2단지"}, {type:"viewBest", danjiid:"25938", areaName:"송파구 잠실동", danjiName:"트리지움"}],riseBest:[{type:"riseBest", danjiid:"30566", areaName:"강남구 삼성동", danjiName:" AID차관 1단지"}, {type:"riseBest", danjiid:"1762", areaName:"강동구 상일동", danjiName:"고덕주공5단지"}, {type:"riseBest", danjiid:"1748", areaName:"강동구 둔촌동", danjiName:"둔촌주공4단지"}, {type:"riseBest", danjiid:"1770", areaName:"강동구 상일동", danjiName:"고덕주공6단지"}, {type:"riseBest", danjiid:"1678", areaName:"강동구 둔촌동", danjiName:"둔촌주공1단지"}, {type:"riseBest", danjiid:"1749", areaName:"강동구 상일동", danjiName:"고덕주공4단지"}, {type:"riseBest", danjiid:"4753", areaName:"강남구 개포동", danjiName:"주공1단지"}]};
        this.rander( data );
    },
    paramMerge : function ( param ){
        // nil tag 적용
        var paramTemplate = "";
        try
        {
            for( var property in param ){
                paramTemplate += "&amp;" + property+ "="+param[property];
            }
        }catch (e){}
        return paramTemplate;
    },
    rander : function( data ){
        var html = "";
        // param template 2type
        var paramViewTemplate = this.paramMerge( this.paramView );
        var paramRiseTemplate = this.paramMerge( this.paramRise );

        // view best
        for ( var i=0; i<data.viewBest.length; i++ ){
            if( i>= this.count  ) continue;
            var row = data.viewBest[i];
            var n=i+1;
//			<li class="n1"><a class="fw_b" title="imf와 3번의 부동산투기" href="http://board.realestate.daum.net/gaia/do/estate/totalDebate/read?&amp;bbsId=freeboard&amp;articleId=12525&amp;pageIndex=1&amp;nil_profile=estatetop&amp;nil_newssubright=debate1">imf와 3번의 부..</a><span class="order dn">0.77%</span></li>

            var classText = "n" + n ;

            var extcatecodes = row.mcatecode;
            if( extcatecodes == "A1" || extcatecodes == "A3" || extcatecodes == "A4" ){
            	extcatecodes = "A1A3A4"
            }
            var weight = '<span class="fl_ri gray_b1 weight '+this.getIconName(row.weight)+'">'+row.weight+'</span>';
            var rankchange = "";
            if( row.rankchange == 0){
            	rankchange = '<span class="order stay">&nbsp;</span>';
            }else{
            	rankchange = '<span class="order ' + this.getIconNameV2(row.rankchange)+'">'+Math.abs(row.rankchange)+'</span>';
            }
            if( row.newyn == "Y" ){
                rankchange = '<span class="order new"></span>';
            }
			// nil
            var param = paramViewTemplate.replace("$NUM", i+1 );
            if( param != "" ){
			    param = "?"+param;
            }
 
            if( this.type == "danji" ){
                var danjiName = row.danjiname;
 
                if( (UI.length( row.areaname ) + UI.length( danjiName )) >  18 ){
                    danjiName = UI.length( danjiName, 18-UI.length( row.areaname ), ".." );
                }

                html += '<li class="'+classText+'"><a href="http://realestate.daum.net/maemul/danji/'+row.danjiid+ '/' + extcatecodes + '/S/summary'+param+'" class="link" title="'+row.danjiname+'" onclick=\'return gLink(null, "PDES", "'+(i+1)+'", "2");\'>'+row.areaname + ' ' + danjiName+'</a>'+rankchange+'</li>';
            } else if( this.type == "area" ){
                html += '<li class="'+classText+'"><span class="bestnum no'+n+'"></span><a href="http://realestate.daum.net/maemul/area/'+row.areacode+'/'+row.mcatecode+'/'+extcatecodes+'/S/summary'+param+'" class="link" onclick=\'return gLink(null, "P2ES", "'+(i+1)+'", "2");\'>'+row.areaname+'</a>'+rankchange+'</li>';
            }
        }
        if( data.viewBest.length == 0 ){
           var typeKr = (this.type=="area")?"지역이":"단지가";
           html += '<li class="nodata"><span class="txt">많이 본 '+typeKr+' 없습니다</span></li>';
        }
        this.viewList.innerHTML= html;

        // rise best
        html = "";
        for ( var i=0; i<data.riseBest.length; i++ ){
            if( i>= this.count ) continue;

            var row = data.riseBest[i];
            var n=i+1;
            var classText = "n" + n ;
            
            var extcatecodes = row.mcatecode;
            if( extcatecodes == "A1" || extcatecodes == "A3" || extcatecodes == "A4" ){
            	extcatecodes = "A1A3A4"
            }
            
            var weight = '<span class="order '+this.getIconNameV2(row.weight)+'">'+row.weight+'%</span>';
			// nil
            var param = paramRiseTemplate.replace("$NUM", i+1 );
            if( param != "" ){
                param = "?"+param;
            }
            if( this.type == "danji" ){
                var danjiName = row.danjiname;
                if( (UI.length( row.areaname ) + UI.length( danjiName )) >  18 ){
                    danjiName = UI.length( danjiName, 18-UI.length( row.areaname), ".." );
                }
                html += '<li class="'+classText+'"><a href="http://realestate.daum.net/maemul/danji/'+row.danjiid+'/'+ extcatecodes + '/S/summary'+param+'" class="link" title="'+row.danjiname+'" onclick=\'return gLink(null, "PDES", "'+(i+1)+'", "2");\'>'+row.areaname + ' ' + danjiName+'</a>'+weight+'</li>';
            } else if( this.type == "area" ){
                html += '<li class="'+classText+'"><span class="bestnum no'+n+'"></span><a href="http://realestate.daum.net/maemul/area/'+row.areacode+'/'+row.mcatecode+'/'+extcatecodes+'/S/summary'+param+'" class="link" onclick=\'return gLink(null, "P2ES", "'+(i+1)+'", "3");\'>'+row.areaname+'</a>'+weight+'</li>';
            }
        }
        if( data.riseBest.length == 0 ){
           var typeKr = (this.type=="area")?"지역이":"단지가";
           html += '<li class="nodata"><span class="txt">매매가 상승 '+typeKr+' 없습니다</span></li>';
        }
        this.riseList.innerHTML= html;

    },
    getIconName : function( weight ){
        var className = "";
        if( weight > 0 ){
            className = "icnUp";
        } else if( weight < 0 ){
            className = "icnDown";
        } else {
            className = "icnStay";
        }
        return className;
    },
    getIconNameV2 : function( weight ){
        var className = "";
        if( weight > 0 ){
            className = "up";
        } else if( weight < 0 ){
            className = "dn";
        } else {
            className = "stay";
        }
        return className;
    }

};

var TopBestLocal = function( type, callUrl, viewListId, option ){
    this.data = {};
    this.type = type;
    this.url = callUrl;
    this.viewList = UI.$(viewListId);
    this.callMode = "ajax";
    this.count = 5;
	this.initUrl = null;
    this.paramView = {}; // nil태그용 param

    Object.extend( this, option );
};
TopBestLocal.prototype = {
    show : function( param, type ){
		var url = this.url;
		if( this.initUrl != null ){
			url = this.initUrl;
			this.initUrl = null;
		}
        switch( this.callMode  ){
            case "call":
                try{console.log( url+"?"+param );}catch (e){}
                dynamicScript.call( url+"?"+param );
                break;
            case "ajax":
            default :
                // 선택된 광역지역 지역코드
                var ajax = new FN.Ajax( {url:url} );
                ajax.options.onComplete = this.reponse.bind(this);
                if( param ){
                    ajax.options.param = param;
                }
                ajax.send();
        }
    },
    reponse : function ( res ){
        var data = eval("("+res.responseText+")" );//{viewBest:[{type:"viewBest", danjiid:"1755", areaName:"노원구 중계동", danjiName:"주공5단지"}, {type:"viewBest", danjiid:"9850", areaName:"금천구 시흥동", danjiName:"벽산5단지"}, {type:"viewBest", danjiid:"2418", areaName:"송파구 문정동", danjiName:"훼밀리"}, {type:"viewBest", danjiid:"4608", areaName:"노원구 상계동", danjiName:"주공6단지"}, {type:"viewBest", danjiid:"4571", areaName:"노원구 상계동", danjiName:"주공16단지"}, {type:"viewBest", danjiid:"28590", areaName:"송파구 잠실동", danjiName:"잠실주공2단지"}, {type:"viewBest", danjiid:"25938", areaName:"송파구 잠실동", danjiName:"트리지움"}],riseBest:[{type:"riseBest", danjiid:"30566", areaName:"강남구 삼성동", danjiName:" AID차관 1단지"}, {type:"riseBest", danjiid:"1762", areaName:"강동구 상일동", danjiName:"고덕주공5단지"}, {type:"riseBest", danjiid:"1748", areaName:"강동구 둔촌동", danjiName:"둔촌주공4단지"}, {type:"riseBest", danjiid:"1770", areaName:"강동구 상일동", danjiName:"고덕주공6단지"}, {type:"riseBest", danjiid:"1678", areaName:"강동구 둔촌동", danjiName:"둔촌주공1단지"}, {type:"riseBest", danjiid:"1749", areaName:"강동구 상일동", danjiName:"고덕주공4단지"}, {type:"riseBest", danjiid:"4753", areaName:"강남구 개포동", danjiName:"주공1단지"}]};
        this.rander( data );
    },
    paramMerge : function ( param ){
        // nil tag 적용
        var paramTemplate = "";
        try
        {
            for( var property in param ){
                paramTemplate += "&amp;" + property+ "="+param[property];
            }
        }catch (e){}
        return paramTemplate;
    },
    rander : function( data ){
        var html = "";

        var paramViewTemplate = this.paramMerge( this.paramView );

        // view best
        for ( var i=0; i<data.viewBest.length; i++ ){
            if( i>= this.count  ) continue;
            var row = data.viewBest[i];
            var n=i+1;
            var classText = "";
            if ( i==data.viewBest.length-1 || i==this.count-1){
                classText = "last";
            }
            var extcatecodes = row.mcatecode;
            if( extcatecodes == "A1" ) extcatecodes = "A1A3A4";
            var weight = '<span class="fl_ri gray_b1 weight '+this.getIconName(row.weight)+'">'+row.weight+'</span>';
            var rankchange = '<span class="fl_ri gray_b1 weight '+this.getIconNameV2(row.rankchange)+'">'+Math.abs(row.rankchange)+'</span>';
            if( row.newyn == "Y" ){
                rankchange = '<span class="fl_ri gray_b1 weight icnNewV2"></span>';
            }
			// nil
            var param = paramViewTemplate.replace("$NUM", i+1 );
            if( param != "" ){
			    param = "?"+param;
            }
            html+='<li class="clearfix '+classText+'"><span class="bestnum no'+n+'"></span><a href="http://realestate.daum.net/maemul/area/'+row.areacode+'/'+row.mcatecode+'/'+extcatecodes+'/S/*/*/*/summary'+param+'?nil_profile=estatetop&nil_estatetop=bestarea'+ parseInt(i+1, 10)+'" class="link" onclick=\'return gLink(null, "P2ES", "'+(i+1)+'", "2");\'>'+row.areaname+'</a>'+rankchange+'</li>';
        }
        if( data.viewBest.length == 0 ){
           var typeKr = (this.type=="area")?"지역이":"단지가";
           html += '<li class="nodata"><span class="txt">많이 본 '+typeKr+' 없습니다</span></li>';
        }
        this.viewList.innerHTML= html;
    },
    getIconName : function( weight ){
        var className = "";
        if( weight > 0 ){
            className = "icnUp";
        } else if( weight < 0 ){
            className = "icnDown";
        } else {
            className = "icnStay";
        }
        return className;
    },
    getIconNameV2 : function( weight ){
        var className = "";
        if( weight > 0 ){
            className = "icnUpV2";
        } else if( weight < 0 ){
            className = "icnDownV2";
        } else {
            className = "icnStayV2";
        }
        return className;
    }

};

function consoleLog( msg ){
	try{console.log( msg );	}catch (e){}
}

function showNewIcon(id){
	try {
		var obj = UI.$("tab_newIcon");
		obj.style.display = "none"; 
		var li = UI.$(id).getElementsByTagName("li");
 
		for( var i=li.length-1;i>=0;i--){
			if( li[i].className.indexOf("comm") > -1 ){
				if( UI.getStyle(li[i], 'display') != "none"){
					obj.style.top =  (UI.$("CON_TOP").offsetHeight + 98)+ 'px';
					obj.style.left = (li[i].offsetLeft+55)+"px";
				 
					obj.style.display = "block";
				}	
		   }
		}
 
	} catch(e){
		//alert(e.message);	
	}
}

// 플래시 네비 v3
function flashTopNavi(){
	var url = location.href;
	var param = "";
	if( url.indexOf("http://realestate.daum.net/maemul/") > -1 ){
		param = "mapTab=price";
	}
	DaumFlash("http://fn.daum-img.net/flash/estate/2009/top/nav3th2009Aug26.swf",param,713,317,"layFla");
}

/* 확장광고용 */
function AmsFlash(f,w,h,options){
	var param={	id:"UIswf_"+f,quality:'high',bgcolor:'#ffffff',allowScriptAccess:'always',allowFullScreen:'true'}
	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>';
	if(param.containerId) {
		doc.getElementById(param.containerId).innerHTML = s;
	} else {
		doc.write(s);
	}
	return s;
};

function wingAd(type) {
	try{
	var secid="";
	var rand = Math.random().toString(); 
	var ordval = rand.substring(2,rand.length);
	
	if( type == "top" )secid="00869";
	else if( type == "maemul" )secid="00876";
	else if( type == "news" )secid="00873";
	else if( type == "community" )secid="00877";
	else if( type == "search" )secid="00878";
	if( secid=="") return;
	
	document.writeln("<div id=\"EXTENSIBLE_BANNER_WRAP\"><div id=\"EXTENSIBLE_BANNER\"></div></div><iframe src=\"http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid=" +secid+ "&type=cpm&tag=iframe&mkvid=1&ord=" + ordval + "\" width=250 height=250 frameborder=0 scrolling=no marginheight=0 marginwidth=0 id=\"AMS_250exp\" title=\"\"></iframe>");
	}catch(e){}
}


/* getBanner 중 case 250 참고 */
function getBanner(size, type) {
	var rand = Math.random().toString(); 
	var ordval = rand.substring(2,rand.length); 
	var clintAgent = navigator.userAgent;
	var couple_ordval = ordval;
	var banner = new UI.StringBuffer();
	switch(size) {
		case 250 : {			
			banner.append('<div id="EXTENSIBLE_BANNER_WRAP"><div id="EXTENSIBLE_BANNER"></div></div>');
			//banner.append('<iframe src="http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid=03L13&type=cpm&tag=iframe&mkvid=1&ord='+ordval+'" width="250" height="250" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowTransparency="true" id="AMS_250exp" title="배너 영역"></iframe>');
			//위의 경로를 호출 할때 return 되는 경과는 ad.html 과 같다.
			banner.append('<iframe src="ad.html" width="250" height="250" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowTransparency="true" id="AMS_250exp" title="배너 영역"></iframe>');
			banner.append('<div id="TAKEOVER"><script src="http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid=03L16&type=cpm&tag=javascript&mkvid=1&ord='+couple_ordval+'" type="text/javascript"></script></div>');
			break;
		}
		case 300 : {
			banner.append('<iframe src="http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid=03L14&type=cpm&tag=iframe&mkvid=1&ord='+ordval+'" width="300" height="250" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowTransparency="true" id="movie_AMS3" title="배너 영역"></iframe>');
			banner.append('<div id="TAKEOVER"><script src="http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&secid=03L17&type=cpm&tag=javascript&mkvid=1&ord='+couple_ordval+'" type="text/javascript"></script></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/cgi-bin/adcgi?corpid=46&secid=03L21&type=cpm&tag=iframe&mkvid=1&ord=" + ordval + "\" width=200 height=39 border=0 frameborder=0 scrolling=no marginheight=0 marginwidth=0 id=movie_AMS></iframe>");
			}
			banner.append('</div>');
			break;
		}
		case "countdown" : {
			banner.append("<iframe src=\"http://amsv2.daum.net/cgi-bin/adcgi?corpid=46&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=movie_AMS></iframe>");
			break
		}		 
		default : {break;}
	}
	if(type=="return") {
		return banner.toString();
	} else {
		doc.writeln(banner.toString());
	}
}
// FF에서는 flash를 감싸고 있는 element의 style 속성이 바뀌면 플래시가 reload 됩니다. 천승희님과 상의 후 영화에선는 그냥 reload 되더라도 확장이 되는 방향으로 결정했습니다.
function extBannerOver() {
	try	{ doc.getElementById('EXTENSIBLE_BANNER').style.overflow = 'visible'; UI.$("header").style.position="static"; } catch (e){}
}
function extBannerOut() {
	try	{ doc.getElementById('EXTENSIBLE_BANNER').style.overflow = 'hidden'; UI.$("header").style.position="relative"; } catch (e){}	
}

function displayHelpMore( type ){
	switch( type ){
	case "show":
		UI.show("HelpText");break;
	case "hide":
		UI.hide("HelpText");break;
	}
}

/* png24 이미지 파일을 웹에서 투명하게 변경하는 스크립트 */
function setPNG24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bPNG24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    
    return '';
}




UI.Radio2009 = function(name)
{
	try{
		this.img_on = "http://fn.daum-img.net/image/estate/2008/maemulSise/icoRadioOn.gif";
		this.img_off = "http://fn.daum-img.net/image/estate/2008/maemulSise/icoRadioOff.gif";
		this.radio = {};
		this.checked_id = "";
 
		var ra = null,img=null;
		var cid = "";

		for(var i=0; i<doc.getElementsByName(name).length; i++)
		{
			ra = doc.getElementsByName(name)[i];
			 
			cid =ra.id;
			img=ra.parentNode.insertBefore(doc.createElement('img'), ra);
 			img.src = this.img_off;
			if(ra.checked){
				img.src = this.img_on;
				this.checked_id = cid;
			}
 
			img.cid = cid;
			var label = null;
			 
			if( ra.parentNode.getElementsByTagName("label")[i]){
				label = ra.parentNode.getElementsByTagName("label")[i];
			}else{
				label = ra.parentNode.getElementsByTagName("label")[0];
			}

			if( ra.onclick ){
				UI.addEvent(img, 'click', ra.onclick);
				UI.addEvent(label, 'click', ra.onclick);
			}
			
			UI.addEvent(img, 'click', this.select.bind(this, cid));
 			UI.addEvent(label, 'click',this.select.bind(this, cid));
		 
			//label.onclick = ra.onclick;	
			ra.style.display="none";
			this.radio[cid] = {ra:ra, img:img, lbl:label};
		}
	}catch(e){
		//alert('a :' + e.message);
	}
};
UI.Radio2009.prototype={
	select : function(cid) {
		try{
			var inp = this.radio[cid].ra; 
				
			this.radio[cid].img.src = this.img_on;
			this.radio[cid].ra.checked=true;
 
			if(this.checked_id!=""){
				this.radio[this.checked_id].lbl.className = "";
			}	
			this.radio[cid].lbl.className = "on";
			 
			if(this.checked_id && this.checked_id!=cid) this.radio[this.checked_id].img.src = this.img_off;
			this.checked_id=cid;
		}catch(e){
			//alert(e.message);
		}
	},
	showValue : function() {
		return this.radio[this.checked_id].ra.value;
	}
};
 

/*	listId : ul id,
maxCount : 1page 
prevBtId, nextBtId : button id
listTag :  
*/
UI.Paging = function(listId,maxCount,prevBtId,nextBtId,listTag, isInline) {
this.el = document.getElementById(listId);
this.tag = (listTag) ? listTag : 'li';
this.maxCount = maxCount;
this.isInline = isInline; 
this.prevBt = (prevBtId) ? document.getElementById(prevBtId) : null;
this.nextBt = (nextBtId) ? document.getElementById(nextBtId) : null;
if(this.prevBt) AddEvent(this.prevBt,"click",this.prev.bind(this));
if(this.nextBt) AddEvent(this.nextBt,"click",this.next.bind(this));
this.init();

}

UI.Paging.prototype = {
init : function() {
	this.list = this.el.getElementsByTagName(this.tag);
	this.totalCount = this.list.length;
	this.totalPage = Math.ceil(this.totalCount/this.maxCount);
	this.needPaging = (this.totalCount > this.maxCount);
	if(!this.needPaging) {
		if(this.prevBt) this.prevBt.style.display = "none";
		if(this.nextBt) this.nextBt.style.display = "none";
	}
	else {
		if(this.prevBt) this.prevBt.style.display = "";
		if(this.nextBt) this.nextBt.style.display = "";
	}
	this.curPage = 1;
	this.exec(1);
},
prev : function() {
	this.exec(--this.curPage);
},
next : function() {
	this.exec(++this.curPage);
},
exec : function(n) {
	if(n<=0)  this.curPage = this.totalPage;
	else if(n>this.totalPage)  this.curPage = 1;

	var min = this.maxCount*(this.curPage-1), max = this.maxCount*this.curPage;
	for(var i=0;i<this.totalCount;++i) {
		if(min <= i && i < max){
			if( this.isInline ){
				this.list[i].style.display = "inline-block";
			}else{
				this.list[i].style.display = "block";
			}
		}	
		else this.list[i].style.display = "none";
	}
}
}
 

function calcPeung(inVal){
	try{
		var outVal = Math.floor(inVal * 0.3025 * 10) / 10 ;
		var result = UI.addComma( outVal ) + '평';
		return result;
		
	}catch(e){}
}

var rBanner130 = function(){
	try{
		var div = document.createElement('div');
		UI.$('CONTENTS').appendChild(div);
		div.id = "RIGHT_SPACE_BANNER";
		var top = "12px";
		var loc = document.location.href; 
		
		if( loc.indexOf('/EstateHome.daum') != -1 ){
			 top = "0px";
		}else if( loc.indexOf('maemul/MaemulTop.daum') != -1 ){
			 top = "12px";
		}else if( document.location.href.indexOf('/maemul/') != -1 ){
			 top = "36px";
		}
		div.style.top = top;
		
		var rand = Math.random().toString();  
		var ordval = rand.substring(2,rand.length);  
		var clintAgent = navigator.userAgent;
		  
		var _string = "<iframe src=\"http://amsv2.daum.net/ad/adview?secid=00888\" width=130 height=250 border=0 frameborder=0 scrolling=no marginheight=0 marginwidth=0 id=estate_AMS></iframe>";
		div.innerHTML = _string; 
	}catch(e){
 
	}
}
UI.addEvent(window, 'load', rBanner130);
 


