var openLayer = null; 
var openLayer2 =[]; 

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 '';
} 
try {doc.execCommand('BackgroundImageCache', false, true);} catch(e) {}
/* 2007-07-10 from jes */
UI.Radio = 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 self=this;
	
		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;
			img.onclick = function() {
				self.select(this.cid);
				if(self.radio[this.cid].ra.onclick) self.radio[this.cid].ra.onclick();
			};
			ra.style.display="none";
			this.radio[cid] = {ra:ra, img:img};
		}
	}catch(e){
	}
};
UI.Radio.prototype={
	select : function(cid) {
		try{
			this.radio[cid].img.src = this.img_on;
			this.radio[cid].ra.checked=true;
			if(this.checked_id && this.checked_id!=cid) this.radio[this.checked_id].img.src = this.img_off;
			this.checked_id=cid;
		}catch(e){
			//alert(e.message);
		}
	},
	showValue : function() {
		return this.radio[this.checked_id].ra.value;
	}
};
 
/**
2007-09-18
*/
UI.Modal=function(url,options){
 
	this.options={
		type:'image',
		alt:'',
		loading:false,
		opacity:30,
		width:0,height:0,top:null,
		scroll:true
	};
	Object.extend(this.options, options);
	var options=this.options;

	if(!UI.$('UIModalB')) UI.Modal.print();
	UI.setOpacity(UI.$('UIModalB'), options.opacity);
	
	UI.Modal.setB();
	if(options.loading) UI.Modal.center(UI.$('UIModalL'));

	if(options.type=='image')
	{
		UI.$('UIModalF').innerHTML = '<img id="UIModalImage" src="'+url+'" alt="'+options.alt+'" />';
		if(options.loading) UI.$('UIModalImage').style.display='none';
		UI.addEvent(UI.$('UIModalImage'), 'load', UI.Modal.onload);
		UI.addEvent(UI.$('UIModalImage'), 'click', UI.Modal.reset);
	}
	else if(options.type=='iframe')
	{		
		UI.$('UIModalF').innerHTML = '<iframe name="UIModalIframe" id="UIModalIframe" src="'+url+'" '+options.status+'></iframe>';
		if(options.loading) 
		{
			UI.$('UIModalIframe').style.display='none';
			UI.addEvent(UI.$('UIModalIframe'), 'load', UI.Modal.onload);
		}
		UI.Modal.center(UI.$('UIModalF'));
	}else if( options.type == 'maemuldetail'){
		if(UI.$("clickIdx")){
			UI.$("clickIdx").value = options.dIndex; 
		}
		UI.$('UIModalF').innerHTML = UI.$("modalWindow").value;
		UI.Modal.center(UI.$('UIModalF'));
	}
	UI.Modal.self=this;
	UI.addEvent(UI.$('UIModalB'), 'click', UI.Modal.reset);

	if ( this.options.scroll == true ){
		UI.addEvent(window,'scroll', UI.Modal.onscroll);
	} else {
		UI.$("UIModalB").style.width = doc.documentElement.scrollWidth+"px";
		UI.$("UIModalB").style.height = doc.documentElement.scrollHeight+"px";
	}

	if ( this.options.top == null ){
		UI.addEvent(window,'resize', UI.Modal.onresize);
	} else {
		UI.$("UIModalF").style.top = parseInt(this.options.top)+"px";
		UI.addEvent(window,'resize', UI.Modal.centerH );
	}
};
UI.Modal.self={};
UI.Modal.onload=function(){
	UI.$('UIModalL').style.display='none';
	var pos=UI.getScroll();
	UI.Modal.center(UI.$('UIModalF'));	
	if(UI.Modal.self.options.type=='image')
	{
		UI.$('UIModalImage').style.display='block';
		UI.resizeImage(UI.$('UIModalImage'),pos.width,pos.height);	
	}
	else 
	{
		UI.$('UIModalIframe').style.display='block';
	}
	UI.Modal.center(UI.$('UIModalF'));
};
UI.Modal.print=function(){
	var d=doc.createElement('div');
	var s='';
	s+='<div id="UIModalB" style="z-index:99998;width:100%;height:100%;position:absolute;display:none;background-color:#000;"></div>';
	s+='<div id="UIModalF" style="z-index:99999;position:absolute;display:none;"></div>';
	s+='<div id="UIModalL" style="z-index:99999;display:none;position:absolute;border:2px solid gray;">로딩중..</div>';
	d.innerHTML=s;
	doc.getElementsByTagName('body')[0].appendChild(d);		
};
UI.Modal.setB=function(){
	var w=UI.$('UIModalB');
	var pos=UI.getScroll();
	//w.style.top=pos.top+'px';
	w.style.top = "0px";
	w.style.left=pos.left+'px';
	if(doc.all)
	{
		w.style.width=pos.width+'px';
		w.style.height=pos.height+'px';
	}
	w.style.display='block'	
};
UI.Modal.center=function(el){
	el.style.display='block';
	var pos=UI.getScroll();
	el.style.left=pos.width/2-el.offsetWidth/2+pos.left+'px';
	el.style.top=pos.height/2-el.offsetHeight/2+pos.top+'px';
	UI.$("UIModalB").style.width = doc.documentElement.scrollWidth+"px";
	UI.$("UIModalB").style.height = doc.documentElement.scrollHeight+"px";
};
UI.Modal.centerH=function(){
	var el = UI.$("UIModalF");
	el.style.display='block';
	var pos=UI.getScroll();
	el.style.left=pos.width/2-el.offsetWidth/2+pos.left+'px';
	UI.$("UIModalB").style.width = doc.documentElement.scrollWidth+"px";
	UI.$("UIModalB").style.height = doc.documentElement.scrollHeight+"px";
}
UI.Modal.reset=function(){
	UI.Modal.self=null;
	UI.$('UIModalF').innerHTML='';
	UI.$('UIModalB').style.display='none';
	UI.$('UIModalF').style.display='none';
	UI.$('UIModalL').style.display='none';
	UI.delEvent(window,'resize',UI.Modal.onresize);
	UI.delEvent(window,'scroll',UI.Modal.onscroll);
};
UI.Modal.onresize=function(){
	var pos=UI.getScroll();
	if(UI.Modal.self.options.type=='image') UI.resizeImage(UI.$('UIModalImage'),pos.width,pos.height);
	UI.Modal.center(UI.$('UIModalF'));
	UI.Modal.setB();
};

UI.Modal.onscroll=function(){
	UI.Modal.onresize();
};


UI.resizeImage=function(img,w,h){
	var t = new Image();
	t.src=img.src;	
	if(t.width==0 || t.height==0) return;
	if(t.width>w || t.height >h)
	{
		img.width=w;img.height=h;
		if((t.width/w) > (t.height/h) )	img.height=Math.round(t.height * (w / t.width));
		else img.width = Math.round(t.width *  (h / t.height));
	}
	else
	{
		img.width=t.width;
		img.height=t.height;
	}
	if(img.width==0 || img.height==0) setTimeout(function(){UI.resizeImage(img,w,h)},500);
};

UI.makeLiElement = function ( listArray, options ){
	this.options = {
		className : null,
		effectClassName : null,
		effectClassDefault : null,
		effectClassSelected : null,
		defaultValue : null,
		onClick : null,
		onOver : null,
		onOut : null
	}
	Object.extend( this.options, options );
	
	var liBefore = '<li';
	var liAfter = '</li>';

	// className
	var classNameTemp = new Array();

	if ( this.options.className != null ){
		classNameTemp.push( this.options.className );
	}
	if ( this.options.effectClassName != null ){
		var temp = this.options.effectClassName.split("||"); // [ default || selected ]
		if ( temp.length >= 2 ){
			this.options.effectClassDefault = temp[0];
			this.options.effectClassSelected = temp[1];
		} else {
			this.options.effectClassDefault = temp;
			this.options.effectClassSelected = temp;
		}
		classNameTemp.push( "[CLASS_NAME]" );
	}
	if ( classNameTemp.length > 0 ){
		liBefore += ' class="'+classNameTemp.join(" ")+'"';
	}
	// onclick
	if ( this.options.onClick != null ){	liBefore += ' onclick="'+this.options.onClick+'"';		}
	// onmouseover
	if ( this.options.onOver != null ){		liBefore += ' onmouseover="'+this.options.onOver+'"';	}
	// onmouseout
	if ( this.options.onOut != null ){		liBefore += ' onmouseout="'+this.options.onOut+'"';		}

	liBefore += '>';

	var cnt = listArray.length;
	for ( var n=0; n<cnt ; n++ ){
		var row = liBefore + listArray[n] + liAfter;
		if ( this.options.effectClassName != null ){
			var thisClassName = this.options.effectClassDefault;
			if ( this.options.defaultValue != null && this.options.defaultValue == listArray[n] ){
				thisClassName = this.options.effectClassSelected;
			}
			row = row.replace("[CLASS_NAME]", thisClassName );
		}
		doc.write( row );
	}
}

EstAreaSort = function( id ){
	this.con = UI.$( id ); // 제목 컨테이너
	this.sub = null; // 리스트 컨테이너
	var tempDiv = this.con.getElementsByTagName("div");

	//for ( var num in tempDiv ){
	for ( var num =0; num <= tempDiv.length; num++){
		if ( tempDiv[num].className == undefined ){continue;}
		if ( tempDiv[num].className.indexOf( "areaSortList") > -1 ){this.sub = tempDiv[num];break;}
	}
	UI.addEvent( this.con, 'click', this.titleClick.bind(this) );
	UI.addEvent( document, "mousedown", this.selfClose.bindAsEventListener(this) );

};
EstAreaSort.prototype = {
	titleClick : function(){
		if ( UI.getStyle( this.sub, "display" ) == "none" ){this.open();} 
		else {this.close();}
	},
	setSubDisplay : function( value ){this.sub.style.display = value;},
	close : function(){this.sub.style.display = "none";	},
	selfClose : function( event ){
		var e=event || window.event; var el=e.target || e.srcElement;
		if ( el.className.indexOf( "areaSort" ) == -1 )	{this.sub.style.display = "none";}
	},
	open : function(){this.sub.style.display = "block";}
}
function thisSwfMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {return window[movieName];}
	else {return document[movieName];}
}
/*************************************** 통합페이지 지도 프레임 컴트롤 ********************************************************/
var mapFrameControl = function(menutype){
	this.mapCon = UI.$("mapCon");
	this.mapListWarp = UI.$("mapListWarp");
	this.mapAreaWarp = UI.$("mapAreaWarp");
	this.mapHandleV = UI.$("mapHandleV");
	this.mapHandleH = UI.$("mapHandleH");
	this.menuType = menutype; 
 
	this.status = {
		isExtendList:false, // [true/false] 2단계
		heightLevel:0 // [-1,0,1] 3단계
	}
	this.defaultClassname = this.mapCon.className;
	this.resize();
	
	//if( this.mapHandleV ) UI.addEvent(this.mapHandleV, "click", this.mapFrameHandleClick.bindAsEventListener(this) );
	if( this.mapHandleH ) UI.addEvent(this.mapHandleH, "click", this.mapFrameHandleClick.bindAsEventListener(this) );
}
mapFrameControl.prototype = {
	mapFrameHandleClick : function(event){
		var e=event || window.event; var el=e.target || e.srcElement;
		if( el == this.mapHandleV ){
			this.setExtendList();
		} else if( el == this.mapHandleH ){
			if( this.status.heightLevel == 0 ) this.status.heightLevel = 1;
			else this.status.heightLevel = 0;
			this.resize();
		}
		
	},
	
	mapChnaged : function( type, menuType ){
		this.status.heightLevel = type; 
		this.menuType = menuType; 
		this.resize();
	},
	 
	setExtendList : function( mode ){
		try{
		if( this.status.isExtendList == true || mode != "list" ) {
			this.status.isExtendList = false;
			if(UI.$("mapParent")){
				UI.$("mapParent").style.display = "block";
			}
		} else {
			setViewMode('count');// 플래시 지도가 있으면 단지수로 플래시 셋팅
			this.status.isExtendList = true;
			if(UI.$("mapParent")){
				UI.$("mapParent").style.display = "none";
			}
		}
		var cntTitle = UI.$("listCountTitle"); 
		
		if( this.status.isExtendList  == true){
			cntTitle.className ="listTitle extendTitle";
			cntTitle.getElementsByTagName('a')[0].innerHTML = "지도와 함께보기"
		}else{
			cntTitle.className ="listTitle";
			cntTitle.getElementsByTagName('a')[0].innerHTML = "리스트 보기"
		}
		
		this.resize();
		dummyUrlCall('toggleMap');	
		}catch(e){
			console.debug(e.message);
		}
	},
	resize : function(){
		try{
		var classname = []; // classname에 올수 있는 내용 = [ extendList, extendHeight, reduceHeight ]
		// 좌우폭 2단계
		if( this.status.isExtendList == true ) {
			classname.push("extendList");
		}
		// 상하높이 3단계
		if( this.status.heightLevel == -1 ) classname.push("reduceHeight");
		else if( this.status.heightLevel == 1 ) classname.push("extendHeight");
		if( this.defaultClassname ) classname.push( this.defaultClassname );
		this.mapCon.className = classname.join(" ");
 
		var wmap = doc.getElementById("mapAreaWrap"); 
		var height = parseInt( UI.getStyle( wmap, "height" ) );
 
		var ifr = doc.getElementById("mapif").contentWindow; 
		if( ifr.dmap){
			if(this.status.heightLevel == 1){
				UI.$("mapIframe").style.height = "533px";
				ifr.dmap.main.reSetPanelSize(755,533);
				if( ifr.infowindow ){
					ifr.infowindow.hide();
				}
				if( UI.$("tabNewIcon") ){
					var top = parseInt(UI.getStyle(UI.$("tabNewIcon"), "top"), 10) ; 
					UI.$("tabNewIcon").style.top = top + 170 + 'px'; 
				}
			}else{
				UI.$("mapIframe").style.height = "364px";
				ifr.dmap.main.reSetPanelSize(755,364);
				if( ifr.infowindow ){
					ifr.infowindow.hide();
				}
				if( UI.$("tabNewIcon") ){
					var top = parseInt(UI.getStyle(UI.$("tabNewIcon"), "top"), 10) ; 
					UI.$("tabNewIcon").style.top = top - 170 + 'px'; 
				}
			}
			// 지역별 - 커뮤니티 new
			try{ showNewIcon('PageTabDanji'); }catch(e){}
		}
 
		}catch(e){
			//console.debug(e.message);
		}
	}
}

 
/*************************************** 매물시세탑 주간 Best단지 ********************************************************/
var EstBestSwitcher = function( listId, btnPrevId, btnNextId, viewListId, riseListId, options ){
	this.listGroup = UI.$( listId );
	this.btnPrev = UI.$( btnPrevId );
	this.btnNext = UI.$( btnNextId );
	this.viewList = UI.$( viewListId );
	this.riseList = UI.$( riseListId );

	this.prevIndexObj = null;
	this.length = null;
	
	this.options = {
		defaultIndex : 0,
		loop : true,
		childTag : "LI"
	}
	
	Object.extend( this.options, options );

	this.init();
	
}
EstBestSwitcher.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 ];
		
		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.prevIndexObj = this.list[ this.index ];
		
		// 선택된 광역지역 지역코드
		var areacode = this.list[ this.index ].id.replace("area_","");
		
		var ajax = new FN.Ajax( {url:"/maemul/MaemulTopWeeklyBest.daum"} );
		ajax.options.onComplete = this.reponse.bind(this);
		ajax.options.param = "areacode="+areacode;
		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단지"}]};
			//
		var html = "";

		// view best
		for ( var i=0; i<data.viewBest.length; i++ ){
			if( i>= 5 ) continue;

			var row = data.viewBest[i];
			var n=i+1;
			var classText = "";
			if ( i==data.viewBest.length-1){
				classText = " class='last'";
			}
			var danjiName = row.danjiname;
			if( (UI.length( row.areaname ) + UI.length( danjiName )) >  24 ){
				danjiName = UI.length( danjiName, 24-UI.length( row.areaname ), ".." );
			}
			var weight = '<span class="fl_ri gray_b1 weight '+this.getIconName(row.weight)+'">'+row.weight+'</span>';
			html += '<li'+classText+'><span class="bestnum no'+n+'"></span><a href="/maemul/area/'+row.areacode+'/'+row.mcatecode+'/'+row.mcatecode+'/S/summary" class="fs_small blue area">['+row.areaname+']</a> <a href="/maemul/danji/'+row.danjiid+'/'+row.mcatecode+'/S/summary" class="link" title="'+row.danjiname+'">'+danjiName+'</a>'+weight+'</li>';
		}
		this.viewList.innerHTML= html;

		// rise best
		html = "";
		for ( var i=0; i<data.riseBest.length; i++ ){
			if( i>= 5 ) continue;

			var row = data.riseBest[i];
			var n=i+1;
			var classText = "";
			if ( i==data.riseBest.length-1){
				classText = " class='last'";
			}
			var danjiName = row.danjiname;
			if( (UI.length( row.areaname ) + UI.length( danjiName )) >  22 ){
				danjiName = UI.length( danjiName, 22-UI.length( row.areaname), ".." );
			}
			var weight = '<span class="fl_ri gray_b1 weight '+this.getIconName(row.weight)+'">'+row.weight+'%</span>';
			html += '<li'+classText+'><span class="bestnum no'+n+'"></span><a href="/maemul/area/'+row.areacode+'/'+row.mcatecode+'/'+row.mcatecode+'/S/summary" class="fs_small blue area">['+row.areaname+']</a> <a href="/maemul/danji/'+row.danjiid+'/'+row.mcatecode+'/S/summary" class="link" title="'+row.danjiname+'">'+danjiName+'</a>'+weight+'</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;
	}
}



/************************** 매물정보/단지정보 테마검색 ****************************/
var themeAction = function(curTheme){
	this.curTheme = curTheme;
}

themeAction.prototype = {
	setBackground : function(_obj,_url){
		if(_url){_obj.style.backgroundImage ="url("+_url+")";}else _obj.style.backgroundImage ="none";
	}, 
	
	setBgPosition : function(_obj,al,vl){
		_obj.style.backgroundPosition = al+"px "+vl+"px";
	},
	
	setClassNameByObj : function(_obj,_name){
		_obj.className = _name; 
	}, 
	
	setClassNameById : function(_obj,_name, thisObj, posX, posY, _type){
		if( _type =="out"){
			if( this.curTheme == _obj){
					return false;
			}
		}
		UI.$(_obj).className = _name;
		this.setBgPosition(thisObj, posX, posY); 	
	},
	
	setDisplayNone : function(_obj){
		UI.$(_obj).style.display= "none"; 
	},
	 
	setDisplay : function(_obj,_display){
		UI.$(_obj).style.display= _display; 
	},

	setEmClassNameById : function(_obj, _thisObj, _name, _type){
		if( _type =="out"){
			if( this.curTheme == _obj){
					return false;
			}
		}
		this.setClassNameByObj(_thisObj, _name);
	}	
} 

var modalSlideShow;

var ModalSilde=function(picNum,options){
	this.options={
		opacity:30,
		width:0,
		height:0,
		top:null,
		scroll:true,
		totcount : 0,
		page : 1
	};
	Object.extend(this.options, options);
	var options=this.options;

	if(!UI.$('UIModalB')) ModalSilde.print();
	UI.setOpacity(UI.$('UIModalB'), options.opacity);
	ModalSilde.setB();
 
	if( options.type == 'maemuldetail'){
		if(UI.$("clickIdx")){
			UI.$("clickIdx").value = options.dIndex; 
		}
		UI.$('UIModalF').innerHTML = UI.$("modalWindow").value;
		UI.addEvent(UI.$('UIModalB'), 'click', ModalSilde.reset);

	}else{
		var innerStr = '<iframe name="UIModalIframe" id="UIModalIframe" allowtransparency="true" src="/html/ModalBgFrame.html" '+options.status+' ></iframe>';
		innerStr = innerStr + "<div id='mSildeImgBox'><table width='100%' height='100%'><tr><td id='SlideView'><img id='UIModalImage' src='" + slideShow.listdata[comm.page][comm.index].pic + "' alt=''/></td></tr></table></div>";
		UI.$('UIModalF').innerHTML = innerStr;

		UI.addEvent(UI.$('UIModalB'), 'click', ModalSilde.reset);
		UI.addEvent(UI.$('UIModalF'), 'click', ModalSilde.reset);
		UI.addEvent(UI.$('mSildeImgBox'), 'click', ModalSilde.reset);
	}

	ModalSilde.center(UI.$('UIModalF'));
	ModalSilde.self=this;

	
 
	if ( this.options.scroll == true ){
		UI.addEvent(window,'scroll', ModalSilde.onscroll);
	} else {
		UI.$("UIModalB").style.width = doc.documentElement.scrollWidth+"px";
		UI.$("UIModalB").style.height = doc.documentElement.scrollHeight+"px";
	}

	if ( this.options.top == null ){
		UI.addEvent(window,'resize', ModalSilde.onresize);
	} else {
		UI.$("UIModalF").style.top = parseInt(this.options.top)+"px";
		UI.addEvent(window,'resize', ModalSilde.centerH );
	}
 
	//UI.setOpacity(UI.$('mSildeTopBarBg'), 65);
	if(UI.$("FLASH_BANNER")){
		UI.$("FLASH_BANNER").style.display = "none";
	}	 
};
ModalSilde.self={};
ModalSilde.onload=function(){
	ModalSilde.center(UI.$('UIModalF'));	
	//UI.resizeImageSlide(UI.$('UIModalImage'),736,552);
};
ModalSilde.print=function(){
	var d=doc.createElement('div');
	var s='';
	s+='<div id="UIModalB" style="z-index:99998;width:100%;height:100%;position:absolute;display:none;background-color:#000;"></div>';
	s+='<div id="UIModalF" style="z-index:99999;position:absolute;display:none;"></div>';
	s+='<div id="UIModalL" style="z-index:99999;display:none;position:absolute;border:2px solid gray;">로딩중..</div>';
	d.innerHTML=s;
	doc.getElementsByTagName('body')[0].appendChild(d);		
};
ModalSilde.setB=function(){
	var w=UI.$('UIModalB');
	var pos=UI.getScroll();
	w.style.top=pos.top+'px';
	w.style.left=pos.left+'px';
	if(doc.all)
	{
		w.style.width=pos.width+'px';
		w.style.height=pos.height+'px';
	}
	w.style.display='block'	
};
ModalSilde.center=function(el){
	el.style.display='block';
	var pos=UI.getScroll();
	el.style.left=pos.width/2-el.offsetWidth/2+pos.left+'px';
	el.style.top=pos.height/2-el.offsetHeight/2+pos.top+20+'px';
	UI.$("UIModalB").style.width = doc.documentElement.scrollWidth+"px";
	UI.$("UIModalB").style.height = doc.documentElement.scrollHeight+"px";
};
ModalSilde.centerH=function(){
	var el = UI.$("UIModalF");
	el.style.display='block';
	var pos=UI.getScroll();
	el.style.left=pos.width/2-el.offsetWidth/2+pos.left+'px';
	UI.$("UIModalB").style.width = doc.documentElement.scrollWidth+"px";
	UI.$("UIModalB").style.height = doc.documentElement.scrollHeight+"px";
}
ModalSilde.reset=function(){
	if(UI.$("FLASH_BANNER")){
		UI.$("FLASH_BANNER").style.display = "block";
	}	 
	ModalSilde.self=null;
	UI.$('UIModalF').innerHTML='';
	UI.$('UIModalB').style.display='none';
	UI.$('UIModalF').style.display='none';
	UI.$('UIModalL').style.display='none';
	UI.delEvent(window,'resize',ModalSilde.onresize);
	UI.delEvent(window,'scroll',ModalSilde.onscroll);
};
ModalSilde.onresize=function(){
	//UI.resizeImageSlide(UI.$('UIModalImage'),736,552);
	ModalSilde.center(UI.$('UIModalF'));
	ModalSilde.setB();
};
ModalSilde.onscroll=function(){
	ModalSilde.onresize();
};
/*************************************** 사진 슬라이드 ********************************************************/
var comm; 
var slideShow;
var SlideShow = function( listdata, objId, options ){
	this.view = UI.$(objId.view);
	this.list = UI.$(objId.list);

	this.counter = UI.$(objId.counter);
	this.desc = UI.$(objId.desc);
	this.table = UI.$(objId.table);			// 단지 사진 이미지 테이블
	this.listdata = listdata;
	this.item = [];
	this.autoHandle = null;
	
	// 기본옵션
	this.options = {
		stepWidth : 78, // width of step
		stepPerPage : 8, 
		defaultIndex :0,
		pageLoop : true,
		noImg : "http://fn.daum-img.net/image/estate/2008/direct/no_image.gif",
		noThumb : "http://fn.daum-img.net/image/estate/2008/direct/no_image_s.gif",
		clicklog : null,
		clicklogPart : null
	}
	Object.extend( this.options, options );

	// 기본 스타일설정
	this.list.style.position = "relative";
	// create click-log iframe 
	this.clicklogFrame = $C("IFRAME");
	this.clicklogFrame.style.display = "none";
	this.list.appendChild( this.clicklogFrame );
	// 데이터 설정
	var cnt = this.listdata.length;
	this.itemLen = this.listdata.length;
	
	for ( var i=0; i<cnt; i++ ){
		var li = $C("LI");
		if(i == 0)
			li.className = "on";

		var div = $C("DIV");div.className = "brd";
		li.appendChild( div );
		if( i<this.itemLen && this.listdata[i] && this.listdata[i].html ){ //html인 경우
			div.innerHTML = this.listdata[i].html;
		} else { //기본은 썸네일 이미지
			var img = $C("IMG");
			if( i<this.itemLen ){
				img.src=this.listdata[i].thumb||this.options.noThumb;
			} else {
				img.src=this.options.noThumb;
			}
			img.className="thumb";			
			UI.addEvent( img, "click", this.selectItem.bindAsEventListener(this, i) );
			UI.addEvent( img, "error", this.error.bindAsEventListener( this ) );
			//UI.addEvent( img, "mouseover", this.itemMouseOver.bindAsEventListener(this,i));
			//UI.addEvent( img, "mouseout", this.itemMouseOut.bindAsEventListener(this,i));
			div.appendChild( img );			
		}		
		var span = $C("SPAN");
		span.className = "fs_small";
		
		var apname_tmp ="";
		if(this.listdata[i].apname){
			if(this.listdata[i].apname.length > 5){
				apname_tmp = this.listdata[i].apname.slice(0,5)+"..";
			}
			else{
				apname_tmp = this.listdata[i].apname;
			}
		}		
		if(this.listdata[i].dong) 
			span.innerHTML = "<ul><li class='thumbTitle ff_dotum ls_m1'>"+apname_tmp+"</li><li class='thumbDong ff_dotum ls_m1'>"+String(this.listdata[i].dong).slice(0,6)+"</li></ul>";
		else
			span.innerHTML = "<ul><li class='thumbTitle ff_dotum ls_m1'>"+apname_tmp+"</li></ul>";
		
		
		li.appendChild( span );
		
		this.list.appendChild( li );
		this.item.push( li );
	}

	if( this.options.defaultIndex<0 ) {this.options.defaultIndex=0;} else if( this.options.defaultIndex>=this.itemLen ){this.options.defaultIndex=this.itemLen-1;}
	// 기본값
	this.timer = null;
	this.index = this.options.defaultIndex;
	this.totalPage = Math.ceil( this.itemLen / this.options.stepPerPage );
	this.cursor = Math.floor( this.index / this.options.stepPerPage ) * this.options.stepPerPage;
	this.curX = 0;
	this.trgX = this.options.stepWidth*this.cursor*-1;
	this.list.style.width = this.item.length * this.options.stepWidth + "px";
		
	// data
	if( this.itemLen > 0 ) {
		this.isInit = true;
		this.selectAction();
		this.isInit = false;
		return true;
	} else {
		return false;
	}
	
}

SlideShow.prototype = {
	prevStep : function(){if( this.itemLen > 0){this.unselectAction();this.index--;this.selectAction();}},
	nextStep : function(){

		if( this.itemLen > 0){this.unselectAction();this.index++;this.selectAction();}
	},
	prevPage : function(){if( this.itemLen > 0){this.cursor -= this.options.stepPerPage;if( this.options.pageLoop == false && this.cursor<0){this.cursor=0;}this.checkCursor( this.cursor );}},
	nextPage : function(){if( this.itemLen > 0){this.cursor += this.options.stepPerPage;if( this.options.pageLoop == false && this.cursor>=this.itemLen){this.cursor=(this.totalPage-1)*this.options.stepPerPage;}this.checkCursor( this.cursor );}},
	selectItem : function( event, num ){if( this.options.clicklog != null && this.options.clicklogPart != null ){gLink( null, this.options.clicklog, num, this.options.clicklogPart);}this.unselectAction();this.index = num;this.selectAction();	},
	unselectAction : function(){this.item[this.index].className = "";},
	selectAction : function(){
		this.checkCursor();
		this.item[this.index].className = "on";
		// 슬라이드 액션
		if( this.isInit == false && this.listdata[this.index].href ){// 링크연결이 있는경우
			top.location.href=this.listdata[this.index].href;
		} else if ( this.isInit == false && this.listdata[this.index].viewModal ) {// 모달
			new ModalSilde(this.listdata[this.index].pic, {opacity:70, type:'maemuldetail', dIndex:this.index});
			this.detailEvent();
		} else if ( this.view ) {// 이미지링크인 경우
			this.view.src = this.listdata[this.index].pic||this.options.noImg;
		} 
		// 슬라이드 설명
		if( this.desc ){
			var text = "<span class='desc'>"+this.listdata[this.index].desc+"</span> ";
			var name = this.listdata[this.index].name;
			var date = this.listdata[this.index].date;
			if( name && name != "" ){
				text += "<span class='name'>"+name+"</span>";
			}
			if( date && date != "" ){
				if( name && name != "" ){
					text += "<span class='bar'> | </span>";
				}
				text += "<span class='date'>"+date+"</span>";
			}
			this.desc.innerHTML = text;
		}
		// clicklog
		if( this.isInit == false ){
			if( this.autoHandle == null || ( this.autoHandle.options.mode != "slow" && this.autoHandle.options.mode != "fast" ) ){
				this.callDummy();
			}
		}
	},
 
	detailEvent : function(){
		var curidx = Math.floor(UI.$("clickIdx").value%8) ;
		var _totIndex = parseInt(UI.$("clickIdx").value, 10); 
		var _nowPage = Math.floor(_totIndex/8) + parseInt(1) ;
		var _totpage = Math.floor(this.options.comm_counter/8) + 1;
	
		comm = new SlideCommon({listPage:this.options.comm_listPage,listIndex:parseInt(curidx,10)+1,counter:this.options.comm_counter, 
			defaultIndex:1, stepPerPage:8, photoIndex:_totIndex,  totPage:_totpage, nowPage:_nowPage });
		photoviewer = new SlidePhotoViewer( "" , {danjiId:"", view:"SlideView",prevLayer:"prevLayer", nextLayer:"nextLayer", parentLayer:"ParentDIV"});
		slideShow  = new imageSlideNavigation( picdata, photoviewer, {danjiId:"",list:"SlideList"},{clicklog:"X3ES", clicklogPart:"5"});
		autoSlide = new AutoSlideOption( {handle:photoviewer, mode:document.autoSlideForm.slideMode.value} );
		
		_radio = new UI.Radio2009("slideMode"); 
	},
	
	checkCursor : function( cursor ){
		if( this.index >= this.itemLen ) {
			this.index = 0;
			this.cursor = Math.floor( this.index / this.options.stepPerPage ) * this.options.stepPerPage;
		} else if( this.index < 0 ) {
			this.index = this.itemLen-1;
			this.cursor = Math.floor( this.index / this.options.stepPerPage ) * this.options.stepPerPage;
		}
					
		if( cursor == undefined || cursor == null ){//기본
			this.cursor = Math.floor( this.index / this.options.stepPerPage ) * this.options.stepPerPage;
		} else {// 임의의 cursor 설정
			this.cursor = cursor;
			if( this.cursor < 0 ){
				this.cursor = Math.floor( (this.itemLen-1) / this.options.stepPerPage ) * this.options.stepPerPage;
			} else if ( this.cursor >= this.itemLen) {
				this.cursor = 0;
			}
		}
		this.trgX = this.options.stepWidth*this.cursor*-1;
		this.curX = this.list.offsetLeft;
		var self = this;
		if( this.trgX != this.curX ){
			clearInterval( this.timer );
			this.timer = setInterval( this.enterFrame.bind(this), 10 );
		}
		this.setCounter();
	},
	callDummy : function(){
		this.clicklogFrame.src = "http://realestate.daum.net/clickDummy/photoview";
	},
	setCounter : function(){
		if( this.counter ){
			this.counter.innerHTML = "<strong class='fs_small'> 단지사진</strong> (<strong>"+(parseInt(this.index)+1)+"</strong>/"+this.itemLen+")";
		}
	},	
	enterFrame : function(){
		if( this.trgX != this.list.offsetLeft ){
			this.curX += 0.3*(this.trgX  - this.curX );
			this.list.style.left = Math.round(this.curX)  + "px";
		} else {
			clearInterval( this.timer );
		}
	},
	error : function( event ){
		var e=event || window.event; var el=e.target || e.srcElement;
		el.src = this.options.noThumb;
	},	
	itemMouseOver : function (event,num){
		if(this.index != num)
			this.item[num].className ="over";
	},
	itemMouseOut : function (event,num){
		if(this.index != num)
			this.item[num].className ="";
	}
}
/***********************************************************************************************************************/

/***************************SlidePhotoViewer****************************/
UI.getPosition=function(el) { 
	var left=0,top=0; 
	while(el) { 
		left+=el.offsetLeft || 0; top+=el.offsetTop || 0; el=el.offsetParent; 
	} 
	
	return {'x': left, 'y': top} 
};

var SlideCommon = function(base){
	this.base ={
		listPage : 0, //list 페이지에 서의 페이지 번호
		listIndex : 0, // 현재 페이지에서의 인덱스 번호
		photoIndex : 0, // 전체 이미지 내에서의 인덱스 
		setpPerPage : 8,
		counter : 0,
		defaultIndex : 0,
		totPage : 0, // 전체 페이지 갯수
		nowPage : 1 // 현재 페이지 번호
	}
	Object.extend( this.base, base );

	this.index = this.base.listIndex-1;
 
	this.totcount = base.counter;
	this.page = this.base.nowPage;
	this.totIndex = this.base.photoIndex-1; 
	this.totpage = this.base.totPage;
	this.stepPerPage  = this.base.stepPerPage;
	
	//console.debug('listIndex=' +this.base.listIndex,'index='+ this.index, 'curpage=' + this.page, 'totIndex='+this.totIndex, 'totpage='+ this.totpage);
	this.first = false;
	this.last = false;
}

var SlidePhotoViewer = function( viewdata,objId )
{
	try{
		this.isInit = false;
		this.view = UI.$(objId.view);
		this.viewdata = [];
		this.prevLayer = UI.$(objId.prevLayer);
		this.nextLayer = UI.$(objId.nextLayer);
		this._parentView = UI.$(objId.parentLayer);
		//this._parentView.layerName = objId.parentLayer; 
		this.danjiId = objId.danjiId; 
		that = this;
		
		// 기본옵션
		this.options = {
			pageLoop : true,
			noImg : "http://fn.daum-img.net/image/estate/2008/direct/no_image.gif"	
		}	

		this.clicklogFrame = $C("IFRAME");
		this.clicklogFrame.style.display = "none";
		UI.$("SlideViewClickLog").appendChild( this.clicklogFrame );

		this._bind_event(); 
	}catch(e){}
}
SlidePhotoViewer.prototype = {
	prevStep : function(){
		if( comm.index > 0){
			this.unselectAction();
			comm.index--;
			comm.totIndex--; 
			this.selectAction();
		}else{
			if( comm.page != 1){
				comm.page--; 
				comm.index = 7;
				comm.totIndex--; 
				slideShow.selectAction();
			}
		}
	},
	
	nextStep : function(){
		try{
			if(comm.page <= comm.totpage){
				if( comm.index < 7 ){
					this.unselectAction();
					comm.index++; 
					comm.totIndex++; 
					this.selectAction();
				}else{ // comm.index = 7
					comm.index =0; 
					comm.page++; 
					comm.totIndex++;
					slideShow.selectAction();
				}
			}
		}catch(e){}
	} ,
	selectItem : function( event, num ){},
	unselectAction : function(){slideShow.unselectAction();	},
	selectAction : function(idx){
		try{
 
			if( idx != null || idx != undefined ){
				comm.index = idx; 
			}
			if(this.viewdata[comm.page][comm.index]){
				var lItem = this.viewdata[comm.page][comm.index];
				this.view.removeAttribute('width');
				this.view.removeAttribute('height');
				this.view.src = lItem.pic;
				 
				this.view.onload = function(){
					UI.resizeImageSlide(this.view, 680, 500);
				}.bind(this);	
				
				
				if( UI.$('docBoard')){
					UI.$("curImageIdx").innerHTML = ((comm.page-1)*comm.stepPerPage) + (comm.index+1);
					UI.$('docBoard').className = "docBoard";
					if( lItem.type == "G"){
					    var str='<p>'+
						        '<a class="tit"  target="_boardView" href="http://danjiboard.realestate.daum.net/gaia/do/estate/totalDanji/read?&viewObj=68%3A69%3A70&bbsId=danji&nil_gnb=danji&nil_profile=estatetop&articleId='+ lItem.docid +'&pageIndex=1">'+ lItem.doctitle +'</a>' +
						        '<span class="writeinfo">'+ lItem.daumname +'</span><span class="vline"> | </span> <span class="writeinfo">'+ lItem.docdate +'</span>' +
						        '</p>';
	 
					    UI.$('docBoard').innerHTML = str; 
					}else{
					    var str='<p>'+
						        '<span class="tit td_under">'+ lItem.category +'</span>' +
						        '</p>';
					    UI.$('docBoard').innerHTML = str; 					
					} 
				}	
				if(slideShow){
					slideShow.moveSelectItem(comm.index);
 					slideShow.commUpdate(); 
				}
				
			}else{
				this.view.parentNode.innerHTML ="<div class='noImage'><p>단지사진이 없습니다.</p><p>직접 사진을 등록해 주세요!</p>	<span><a href=''><img src='http://fn.daum-img.net/image/estate/2008/direct/btn_photoregist.gif'></a></span></div><img id='SlideView' height='500' width='680' src='http://fn.daum-img.net/image/estate/2008/direct/no_image.gif'/>";
			}		
			 
			if( this.isInit == true){
				if( this.autoHandle == null || ( this.autoHandle.options.mode != "slow" && this.autoHandle.options.mode != "fast" ) ){
					this.callDummy();
				}
			}	
			this.isInit = true;
		}catch(e){
			return;
		}
	},
	
	callDummy : function(){
		this.clicklogFrame.src = "http://realestate.daum.net/clickDummy/photoview";
	},

	_bind_event : function(){
		UI.addEvent(this._parentView, 'mousemove', this.chkCursor.bind(this._parentView));
		UI.addEvent(this._parentView, 'mouseenter', this.chkCursor.bind(this._parentView));
		UI.addEvent(this._parentView, 'click', this.click.bind(this));
	},

	click : function(){
		
		if( this._parentView.curType == "prev"){
			if( comm.page!=1 || (comm.page==1 && comm.index!=0) ){
				this.prevStep();
				return gLink(null, 'X3ES', '1', '4');
			}			
		}else{
			if( comm.page != comm.totpage || (comm.page == comm.totpage && comm.index != this.viewdata[comm.page].length-1) ){
				this.nextStep();
				return gLink(null, 'X3ES', '2', '4');
			}			
		}
		
	}, 
 
	chkCursor : function(event){
		try{
 
			var event = event || window.event;
			var element = event.srcElement || event.target;
			
 			var pos = UI.getPosition(UI.$("ParentDIV")) ;
			var path = "http://fn.daum-img.net/image/estate/2008/maemulSise/";
			var current;
			
			if(this.clientWidth/2 <= (event.clientX - pos.x) ){
				current = (comm.last == true? "btn_next_ie_no.cur.ico" : "btn_next_ie.cur.ico");
				this.curType = "next";
			}else{
				current = (comm.first == true? "btn_prev_ie_no.cur.ico" : "btn_prev_ie.cur.ico");
				this.curType = "prev";
			}
 
			this.strCurType = current;
			if(this.strPreCurType && this.strCurType ){
				if( this.strPreCurType == this.strCurType ){ return; }
			}
 		
			this.style.cursor = "url(" + path+current+ "), pointer";
			this.strPreCurType = this.strCurType; 
			this.curStyle = this.style.cursor;
		}catch(e){
			//alert(e.message);
		}
	}
}

var AutoSlideOption = function( options ){
	try{
		this.options = {
			handle : null,
			mode : "stop",
			speed : [2500, 1000]
		}
		Object.extend( this.options, options );
		this.options.handle.autoHandle = this;
		this.timer = null;
		this.exec( this.options.mode );
	}catch(e){}
}
var _radio;
AutoSlideOption.prototype = {
	exec : function( mode ){
	try{
		this.options.mode = mode;
		if( this.timer != null){
			this.stop();
		}	
		switch( mode ){
			case "stop":
				_radio.select('slideMode1');
				break;
			case "slow":
				this.timer = setInterval( this.play.bind(this), this.options.speed[0] );
				_radio.select('slideMode2');
				break;
			case "fast":
				this.timer = setInterval( this.play.bind(this), this.options.speed[1] );
				_radio.select('slideMode3');
				break;
		}
	}catch(e){}
	},
	play : function(){
		//console.debug(comm.page, comm.totpage, comm.index, comm.totcount, comm.totIndex);
		if( (comm.page == comm.totpage && comm.index == (comm.totcount % comm.stepPerPage)-1 ) || (comm.totIndex == comm.totcount-1)){
			this.stop('play'); 
		}else{
			
			this.options.handle.nextStep();
		}	
	}, 
	stop : function(type){
		clearInterval( this.timer );
		this.timer = null;
		if( type ){
			_radio.select('slideMode1');
		}	
	}
}

/***************************SlideNavigation****************************/
var imageSlideNavigation = function(listdata, viewer, objId, options ){
	try{
		this.list = UI.$(objId.list);
		this.info = UI.$(objId.info);
		this.title = UI.$(objId.danjititle);
		this.listdata = [];	
		this.item = [];
		this.autoHandle = null;	
		this.viewer = viewer; 
		this.danjiId = objId.danjiId;
		that = this;
	
		// 기본옵션
		this.options = {
			stepWidth : 78, // width of step
 			defaultIndex :0,
			pageLoop : false,
			noThumb : "http://fn.daum-img.net/image/estate/2008/direct/no_image_s.gif",
			clicklog : null,
			clicklogPart : null
		}	
		Object.extend( this.options, options );
			
		// 기본 스타일설정
		this.list.style.position = "relative";
		this.list.style.left = 0;
 
		if( listdata ){
			//if( comm.page==1 ){
				if( listdata.length > 8){
					var tp = 2; 
					var tmp = new Array(tp);
					var tt = 1;
					tmp[tt] = [];

					for( var i=0; i<listdata.length; i++){
						tmp[tt].push(listdata[i]);
						if( i!=0 && i%8 == 7){
							tt += 1;
							tmp[tt] = [];
						}
					}
			 
					for( var i=1; i<= tmp.length ; i++){
						if( tmp[i]  && tmp[i].length>0 ){
							this.listdata[i] = tmp[i];
						}	
					}
					
					this.rendering();
					this.commUpdate();
							 			
				}else{
					this.listdata[comm.page] = listdata;
					this.rendering();
					this.commUpdate(); 
				}
		}else{
			this.selectAction();
		}
		this.timer = null;
	}catch(e){}
}

imageSlideNavigation.prototype = {
	createElement : function(){
		try{
			this.list.innerHTML =""; 	
			this.item = [];
			
			var cnt = this.listdata[comm.page].length;
			for ( var i=0; i < cnt; i++ ){
				var li = $C("LI");
				if( comm.index == i){
					li.className = "on";
				}
				var div = $C("DIV");
				div.className = "brd";
				li.appendChild( div );
				
				if( i< comm.stepPerPage && this.listdata[comm.page][i] && this.listdata[comm.page][i].html ){ //html인 경우
					div.innerHTML = this.listdata[comm.page][i].html;
				} else { //기본은 썸네일 이미지
					var img = $C("IMG");
					if( i<comm.stepPerPage ){
						img.src=this.listdata[comm.page][i].thumb||this.options.noThumb;
					} else {
						img.src=this.options.noThumb;				
					}
					img.className="thumb";			
					
					UI.addEvent( img, "click", this.selectItem.bindAsEventListener(this, i) );
					UI.addEvent( img, "error", this.error.bindAsEventListener( this ) );
					div.appendChild( img );			
				}
				this.list.appendChild( li );
				this.item.push( li );
			}	
		}catch(e){}
	},
	unselectAction : function(){this.item[comm.index].className = ""; },
	selectActionExtend : function(){this.item[comm.index].className = "on";}, 
	selectItem : function( event, num ){
 		if(this.options.clicklog != null && this.options.clicklogPart != null ){
			gLink( null, this.options.clicklog, num, this.options.clicklogPart);
		}
		this.unselectAction();
		comm.index = num;
		comm.totIndex = ((comm.page-1)*8) + num;
		this.selectActionExtend();
		
		//하단 상세보기
		photoviewer.selectAction(num); 
	},
	
	moveSelectItem : function(idx){
		this.unselectAction();
		comm.index = idx;
		comm.totIndex = ((comm.page-1)*8) + idx;
		this.selectActionExtend();
	},

	commUpdate : function(){
		try{
		comm.first = false; comm.last = false;
		if( comm.page == 1 && comm.index == 0 ){
			comm.first = true;
		}
		if( comm.totpage == comm.page){
			if( comm.totcount%comm.stepPerPage == 0){
				if(comm.index == 7){
					comm.last = true;
				}
			}else if( comm.index == (comm.totcount%comm.stepPerPage)-1 ){
				comm.last = true; 
			}
		}	
		}catch(e){}
	}, 
	
	getData : function(type){
	try{
 
		if( type == "prev"){
			if( comm.page != 1){
				this.unselectAction();
 
				comm.page--; 
				comm.index = 7; 
				if(!!this.listdata[comm.page]){
					this.createElement();
					this.viewer.selectAction(comm.index);
					this.btnStatusChange(); 
				}else{
					this.selectAction(); 
				}
			}
		}else{
			if( comm.page < comm.totpage ){
 				this.unselectAction();
 				comm.page++;
 				comm.index = 0; 
				if(!!this.listdata[comm.page]){
					this.createElement();
					this.viewer.selectAction(comm.index);
					this.btnStatusChange();
				}else{
					this.selectAction(); 
				}
			}
		}
		}catch(e){}
	}, 

	selectAction : function(){
		try{
			if(!this.listdata[comm.page] ){
				if(this.viewer != null || this.viewer != undefined){
	 				var slideAjax = new FN.Ajax({url:"/maemul/Danji-photoList.daum?screenId=danjiPhotoView&danjiId="+this.danjiId + "&page=" + comm.page +"&count=" + comm.stepPerPage, onComplete:this.onDataLoadComplete});		
					slideAjax.send();
				}
			}else{
				this.rendering(); 
			}
		}catch(e){}
	},

 	onDataLoadComplete : function (res) {
		try{
			var data = eval("("+res.responseText+")" );
			that.listdata[comm.page] = data;
			that.rendering(); 
		}catch(e){}
	},
	
	rendering : function(){
		// 상단 슬라이드 그리기
		this.createElement();
		this.viewer.viewdata[comm.page] = this.listdata[comm.page];  
		
		this.viewer.selectAction(comm.index);
		this.btnStatusChange();		
	}, 
	
	btnStatusChange : function(){
		var prev = UI.$('btnPrevPage'); 
		var next = UI.$('btnNextPage');
		
		if(comm.page==1){
			prev.className = "prevPage disabled";
		}else{
			prev.className = "prevPage";
		}
		if(comm.page == comm.totpage){
			next.className = "nextPage disabled";
		}else{
			next.className = "nextPage";	
		}
	}, 
 
	enterFrame : function(){
		if( this.trgX != this.list.offsetLeft ){
			this.curX += 0.3*(this.trgX  - this.curX );
			this.list.style.left = Math.round(this.curX)  + "px";
		} else {
			clearInterval( this.timer );
		}
	},
	error : function( event ){
		var e=event || window.event; var el=e.target || e.srcElement;
		el.src = this.options.noThumb;
	}
}

/***********************************************************************************************************************/

/* 단지의 사진 탭 슬라이드 */ 

/* slideshow 용 modal */
UI.resizeImageSlide=function(img,w,h){
	if(img) {
		if(img.width==0 || img.height==0) return;

		if(img.width > w || img.height > h) {

			if((img.width - w) > (img.height - h)) {
				if(img.width > w) {
					img.width = w;
				}
			} else {
				if(img.height > h) {
					img.height = h;
				}
			}
		}
	}
};


 
/* 우측 날개 버튼 클릭시 리스트 롤링 */
var ListRolling = function(objId,count,opt){
	this.objId = objId; 
	this.count = count;
	this.options = {
		defaultIndex : 0 
	}
	Object.extend( this.options, opt );
	this.item = [];
	this.index = 0;
	this.init();    
}	
ListRolling.prototype = {
	init : function(){
		for( var i=0; i<this.count; i++){
		//	console.log(this.objId+(i+1))
			this.item.push(UI.$(this.objId+(i+1)));
			this.item[i].style.display = "none";
		}
		this.index = this.options.defaultIndex;
		this.setBlockItem(this.index);		
	}, 
	prev : function(){this.setNoneItem(this.index);	this.index = (this.index==0? this.count-1:this.index-1);this.setBlockItem(this.index);}, 
	next : function(){this.setNoneItem(this.index);	this.index = (this.index == this.count-1? 0:this.index+1);	this.setBlockItem(this.index);},
	setBlockItem : function(idx){try{this.item[idx].style.display = "block";}catch(e){}}, 
	setNoneItem : function(idx){try{this.item[idx].style.display = "none";}catch(e){}}
} 
 
function clickOn(id, thisObj){
	var obj = UI.$(id).getElementsByTagName('a'); 
	for( var i=0; i< obj.length; i++){
		obj[i].className = "item"; 
	}
	thisObj.className ="item on"; 
	return false;
}


/***** top GNB 지역/매매/아파트 선택 *****/
var topGnbNavi = function(viewId, listId, opt){
	this.curIdx = 0; 
	this.viewId = viewId; 
	this.listId = listId; 

	this.options = {}
	Object.extend( this.options, opt); 
	that2 = this;
	this._bind_event();
}
topGnbNavi.prototype = {
	_bind_event : function(){
		for( var i=1; i<= 3; i++){
			var obj = UI.$(this.viewId + i); 
			obj.idx = i;
			UI.addEvent(obj, 'click', this._clickNavi.bind(obj)); 

			var objLi =  UI.$(this.listId +i).getElementsByTagName("li"); 

			for( var j=0; j<objLi.length; j++){
				UI.addEvent(objLi[j], 'mouseover',this._over.bind(objLi[j])); 
				UI.addEvent(objLi[j], 'mouseout', this._out.bind(objLi[j])); 
				UI.addEvent(objLi[j], 'click', this._itemClick.bind(objLi[j])); 
			}
		}
		UI.addEvent(document, 'click', this._noNaviClick.bind(obj)); 
	},
	
	_clickNavi : function(){
		if( that2.curIdx != 0){
			var tmpIdx = that2.curIdx; 
			that2._none( UI.$(that2.viewId + that2.curIdx), that2.curIdx);
			if( tmpIdx == this.idx ){	
				return; 
			}
		}
		if( this.idx != that2.curIdx ){
			this.className = "on"; 
			that2._block( this, this.idx); 
		}else{
			that2._none( this, this.idx); 
		}
	}, 

	_block : function(obj, idx){
		if( openLayer2 ){
			for( var i=0; i< openLayer2.length; i++){
				openLayer2[i].style.display = "none";
			}
		}
		/*
		var cateObj = UI.$(this.listId + idx).getElementsByTagName('li'); 
		for( var i=0; i<cateObj.length; i++){
			if( cateObj[i].getAttribute("value") == obj.getAttribute("value")){
				cateObj[i].className = "on"; 
				break;
			}
		}
		*/
		openLayer = {"idx":idx, "obj":UI.$(this.listId  + idx)}; 
		UI.$(this.listId  + idx).style.display = "block"; 
		obj.className = "case tab" + idx + "_on"; 
		obj.getElementsByTagName('span')[0].className = "on";
	 
		that2.curIdx = idx;
	},

	_none : function(obj, idx){
		try{
		if(UI.$(this.listId  + idx)){
			UI.$(this.listId  + idx).style.display = "none"; 
	
			obj.className = "case tab" + idx ; 
			obj.getElementsByTagName('span')[0].className = ""; 
			that2.curIdx = 0;
			openLayer = ""; 
		}else{
			return;
		}
		}catch(e){}
	}, 

	_noNaviClick : function(event){
		try{
		var event = event? event : this.event; 
		var element = event.srcElement || event.target; 
 
		while( element && element.tagName != "BODY"){
			if( (element.idx || ( element.id.indexOf(that2.listId ) != -1)) ){
				return;
			}else{
				element = element.parentNode;
			}
		}
		that2._none( UI.$(that2.viewId + that2.curIdx), that2.curIdx);
		}catch(e){}
	}, 
	_over : function(){
		if( this.className != "grayline"){
			this.className = "on"; 
		}
	},

	_out : function(){
		if( this.className != "grayline"){
			this.className = ""; 
		}
	}, 

	_itemClick : function(){
		if( this.className != "grayline"){
			//alert(this.getAttribute('value'));
		}else{
			return false;
		}
	}
}

function tabNaviNone(object){
	if(object){
		UI.$("topNavi" + object.idx).getElementsByTagName('span')[0].className = "";
		UI.$("topNavi" + object.idx).className = "case tab" + object.idx ;
		object.obj.style.display = "none"; 
		 
		openLayer = null; 
	}else{
		return;
	}
}
/***** top GNB 지역/매매/아파트 선택 *****/

UI.Select2009=function(id,skin){
    this.skin={
        topbox:'border:1px solid #4a51bb;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 #4a51bb;font-size:12px;font-family:AppleGothic,Dotum;color:#666;background-color:#fff;margin-top:-1px;text-align:left;',
        default_txt:'color:#2f3b77;background-color:#fff;padding-left:5px;cursor:pointer;float:left;margin-right:10px;',
        selected_txt:'color:#2f3b77;background-color:#e3ecfc;padding-left:5px;cursor:pointer;float:left;margin-right:10px;',
        arrow:'http://fn.daum-img.net/image/estate/2008/maemulSise/new_detail/bl_sales_more.gif',
        width:150,
        padding:3,
        sub_height:20,
        max_option:8,
        trg_obj:null,
        selectEvent:null,
        selfClick:true,
		titleLink: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();
};
function defaultClick( id ){
    var obj = UI.$( id );	
    UI.stopEvent();
	obj.onchange.call( obj );
}
UI.Select2009.prototype={
    close:function(){
    	if(UI.$("btn_" + this.id)){
			UI.$("btn_" + this.id).style.display = "none";
		}	
	},
    open:function(){
    	if(UI.$("btn_" + this.id)){
			UI.$("btn_" + this.id).style.display = "block";
		}	
	},
    toogle:function(e){
		if( openLayer != null){
			tabNaviNone(openLayer);      	
		}
        if( this.selectObj.isOpen == true ){
            var obj = UI.$("UISelFocus_"+this.id);
            if( obj ){
                obj.style.display = "block";
                obj.focus();
                obj.style.display = "none";
            }
        }
        openLayer2.push(UI.$('UISelectSub_'+this.id));
        if( UI.$("btn_" + this.id) ){
        	openLayer2.push(UI.$("btn_" + this.id));
        }	 
        var thisClassName=this.objSub.getElementsByTagName('li')[this.sIndex].className.replace("default_txt","selected_txt");
        this.objSub.getElementsByTagName('li')[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){
		try{
			this.el=UI.getEl(e)
			UI.$('UISelectSub_'+this.id).getElementsByTagName('li')[this.sIndex].className='default_txt';
			this.el.className='selected_txt';
		}catch(e){
		//console.debug(e.message);
		}
    },
    subOut:function(e){
        this.el=UI.getEl(e);
        this.el.className='default_txt';
    },
    subClick:function(e){
    	try{
	        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();
	        if(UI.$("btn_" + this.id)){
	        	UI.$("btn_" + this.id).style.display = "none";
	        } 
	        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;
        }catch(e){
       		//alert(e.message);
        }
    },
    
    print:function(){
		try{
			var id=this.id;
			var opt=this.input.options;
			var sb=new UI.StringBuffer();
			var bt=UI.getBrowser();
			var autoWidth=0;
	 
			for(var i=0,cnt=opt.length; i<cnt; i++)
			{
				var className='default_txt';
	 
				this.list[i]={text:opt[i].text,value:opt[i].value};
				if (autoWidth < opt[i].text.length){
					autoWidth= opt[i].text.length ;
				}
				var selectedFocusObj = "";
				if( opt.sIndex == i ){
					selectedFocusObj = '<input type="input" id="UISelFocus_'+id+'" style="display:none">';
				}
				
				var st = "line-height:"+this.skin.sub_height+"px;height:"+this.skin.sub_height+"px;";
				if( i%this.skin.column == this.skin.column-1  ){
					st = st + "margin-right:0;"; 
				}
				 
				sb.append('<li class="'+className+'" style="' + st + '">'+opt[i].text+selectedFocusObj+'</li>');
			}
			
			if(this.list[0]){
				this.value=this.list[0].value;
			}	
			var tempStyle='<style type="text/css">li.default_txt{'+this.skin.default_txt+'} li.selected_txt{'+this.skin.selected_txt+'} #UISelFocus_'+id+'{width:1px;height:1px;border:0px;} </style>';
			if(this.list[this.sIndex]){
				var titleText = this.list[this.sIndex].text;
				if( this.skin.titleLink == true ){
					titleText = '<a href="#" onclick="defaultClick(\''+this.id+'\');return false;">'+this.list[this.sIndex].text+'</a>';
				}
			}	
			var cname = ""; 
			
			if( '$menuType' == "subway"){
				cname = "swselBlock" + this.skin.mlevel + "_" + this.skin.column;
			}else{
				cname = "selBlock" + this.skin.mlevel + "_" + this.skin.column;
			}
			
			var s ="";
			if( id=="selBlock" || id=="selComp"){
				s='\
				<div id="UISelectTop_'+id+'" style="position:relative;text-align:left;'+this.skin.topbox+'">\
					<div id="UISelectSel_'+id+'">'+titleText+'</div>\
				</div>\
				<div id="UISelectSub_'+id+'" class="UISelectSub_navi" style="display:none;position:absolute;"><ul id="UISelectSubInner_'+id+'" class="'+cname+'" style="display:block;'+this.skin.subbox+'">'+sb.toString()+'</ul></div>';

			}else{
				s='\
				<div id="UISelectTop_'+id+'" style="position:relative;text-align:left;'+this.skin.topbox+'">\
					<div id="UISelectSel_'+id+'">'+titleText+'</div><img id="btn_'+id+'"  class="btnGogo" style="display:none" src="http://fn.daum-img.net/image/estate/2008/maemulSise/new_detail/bt_sales_goto.gif" />\
				</div>\
				<div id="UISelectSub_'+id+'" class="UISelectSub_navi" style="display:none;position:absolute;"><ul id="UISelectSubInner_'+id+'" class="'+cname+'" style="display:block;'+this.skin.subbox+'">'+sb.toString()+'</ul></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 {
				document.write(tempStyle);
				this.input.style.display='none';
				document.write(s);
			}

			if( this.skin.max_option * this.skin.column < cnt ){
				var sub=UI.$('UISelectSubInner_'+this.id);
				sub.style.height = this.skin.max_option * this.skin.sub_height + "px";
				var cn = 'scroll_'; 
				if( '$menuType' == "subway"){
					cn = 'swscroll_';
				} 
				sub.className = sub.className + ' '+ cn +  this.skin.mlevel + "_" +  this.skin.column;  
				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.closeComplete = this.close.bindAsEventListener(this);
			this.selectObj.toogleComplete = this.toogle.bindAsEventListener(this);
			if( bt.ie == true ){
				this.objSub.style.marginTop = "-1px";
			}

			// 바로 가기 이벤트 걸기 
			if(UI.$("btn_" + this.id)){
				UI.addEvent(UI.$("btn_" + this.id), 'click', function(){
	 		        this.value=this.list[this.sIndex].value;
			        UI.$('UISelectSel_'+this.id).innerHTML=this.list[this.sIndex].text;
			        if( this.skin.selectEvent == null ){
			            UI.$(this.id).value=this.list[this.sIndex].value;
			        } else {
			            try { this.skin.selectEvent( this.list[this.sIndex].value ); } catch (e) {}
			        }
			        UI.$('UISelectSub_'+this.id).style.display = "none";
				}.bind(this));
			}			
			var sub=this.objSub.getElementsByTagName('li');
			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";
	 
			UI.SelectObject.push( this );
		}catch(e){
			//console.debug(e.message);
		}
    }
};


var SelectBox = function(ele, list, options){
	try{
		this.list = list;
		this.element ;
		this.elementId=""; 
		  
		if( typeof(ele) == "string"){
			this.element = UI.$(ele);
			this.elementId = ele;
		}else{
			return;
			//this.element = ele;
			//this.elementId = ele.id;
		}

		this.options = {
			maxLength : 8 , 
			background : '#e3ecfc', 
			titleMessage : '선택해 주세요', 
			isButton : 'N', 
			goUrl : {}, 
			blit : 'http://fn.daum-img.net/image/estate/2008/direct/budong_blit_94.gif', 
			level : 1,
			column : 1, 
			classType : 'area', 
			bold :'N'
		}
 
		Object.extend(this.options, options);
		this.createList();
	}catch(e){
		alert('err:' + e.message);
	}
}

SelectBox.prototype = {
	createList : function(){
		this.defaultText = this.createElement('span');
		this.element.appendChild(this.defaultText);
		this.defaultText.innerHTML = this.options.defaultText;
 
 		if( this.options.bold == "Y"){
 			this.defaultText.className = "defaultText bold arrow";
 		}else{
 			this.defaultText.className = "defaultText arrow";
 		}
 		
		 

		if( this.options.isButton == "Y"){
			this.button = this.createElement("img");
			this.element.appendChild(this.button);
			this.button.className = "btnGoto"; 
			this.button.src = "http://fn.daum-img.net/image/estate/2008/maemulSise/new_detail/bt_sales_goto.gif"; 
			UI.addEvent( this.button, 'click', this._buttonClick.bind(this));
		}

		this.outerBox = this.createElement('div');
		this.element.appendChild(this.outerBox);
		this.outerBox.className = "outerBox";
//		this.outerBox.style.width = this.options.width + 'px';
		
		this.ul = this.createElement('ul');
		this.outerBox.appendChild(this.ul);
		
		this._setBoxList();
		this._bind_event();
	}, 

	_buttonClick : function(){
		document.location.href = this.options.goUrl; 
	}, 

	_bind_event : function(){
		UI.addEvent( this.defaultText, 'click', this._toggle.bind(this, this.outerBox));
		UI.addEvent( document, 'click', this._close.bind(this));
	}, 

	_toggle : function(obj){
		if( this.defaultText.style.cursor == "default"){
			return;
		}
		if( obj.style.display == "block"){
			obj.style.display = "none";
			if( this.options.isButton == "Y"){
				this.button.style.display = "none"; 
				this.defaultText.style.background = "url(" + this.options.blit + ") no-repeat scroll right 5px"; 
			}
 		}else{
			obj.style.display = "block";
			if( this.options.isButton == "Y"){
				this.button.style.display = "block"; 
				this.defaultText.style.background = "none"; 
			}
		}
		
	},
	
	_setBoxList : function(optionsList, sIdx){
		var optionsList = this.list;
		var sIdx = this.options.defaultIndex;
 
 		if( this.ul.childNodes.length > 0){
			this.remove();
		}		
 
		if( optionsList.length <= 0){
			if( this.options.depth=="3" && this.options.level == "3"){
				var txt = ( this.options.defaultText=="단지"?"가":"이");
				var li = this.add({value:'', text:this.options.defaultText + txt + " 없습니다."});

				var cn = "box_" + this.options.classType + "_" + this.options.level + "_0"; 
				this.ul.className = cn;
				this.ul.style.height = "auto";
			}else{
				this.defaultText.style.cursor = "default";
				this.defaultText.setAttribute('title', this.options.titleMessage);
			}
		}else{
			for(var i=0;i<optionsList.length;++i) {
				var li = this.add(optionsList[i]);
				if( this.options.column == 1){
					li.style.marginRight = "0";
				}else{
					if( i%this.options.column == this.options.column-1){
						li.style.marginRight = "0";
					}
				}	
				if( optionsList.length < this.options.maxLength ){

					//li.style.width = this.options.width + 'px';
				} 
				if(i==sIdx) {
					this.value = optionsList[i].value;
					this.defaultText.innerHTML = optionsList[i].text;
					if(li){
						this.setBg(li);
					}
				}
			}
			var cn = "box_" + this.options.classType + "_" + this.options.level + "_" + this.options.column; 

			//option의 갯수가 maxLength개 이상일 경우 스크롤바 생성 - 추가
 			if( this.options.maxLength * this.options.column < optionsList.length  ){
				this.ul.className = cn + " " + cn+"_scroll" + " scroll";
				this.ul.style.height =  (this.options.maxLength * 21)+ 'px';
			}else{
				this.ul.className = cn;
				this.ul.style.height = "auto";
			}		
		}		
	}, 
	
	createElement : function(tag, opts){
		var obj = document.createElement(tag);
		var options = {
		}
		Object.extend(options, opts);
		if(options.id){
			obj.id = options.id;
		}	
		return obj;
	}, 

  	add : function(obj){
		var idx = this.ul.childNodes.length;
		var li = this.createElement('li');
		li.id = this.elementId + "=li" + idx;
		li.idx = idx;
		li.innerHTML = li.text = obj.text;
		li.tag = obj.value;
 
		this.ul.appendChild(li);
		if( obj.value != ""){
			UI.addEvent(li, 'mouseover', function(){
	 			this.mouseOver(li);
			}.bind(this));

			UI.addEvent(li, 'click', function(){
				this.click(li);
			}.bind(this));
		}

		return li;
	}, 
	
	remove : function(idx){
		var len = this.ul.childNodes.length;
		for( var idx=len-1; idx >= 0 ; idx--){
 			this.ul.removeChild(this.ul.childNodes[idx]);
		}
		this.ul.innerHTML = "";
	},

	setBg : function(obj){
		var cnt = this.ul.childNodes.length;
		for(var i=0;i<cnt;++i) {
			this.bgColor(this.ul.childNodes[i],'transparent');
		}
		this.bgColor(obj,this.options.background);
	}, 
 
	mouseOver : function(li){
 		//curLi = li; 
		this.setBg(li);
	}, 
 
	click : function(obj){
		//this.defaultText.innerHTML = obj.innerHTML;
		//this.selectedIndex = obj.idx;
		//this.value = obj.tag;
		//this._toggle(this.outerBox);
		document.location.href = obj.tag;
 
	},

	bgColor : function(obj, color){
		try{
		obj.style.backgroundColor = color;
		}catch(e){}
	},
 
	_close : function(event){
		try{
			var e = event ? event : window.event;
			var element = e.target || e.srcElement;
			while(element && element.tagName != "BODY"){
 				if( element == this.defaultText || element == this.ul){
					return;
				}
				element = element.parentNode; 
			}

			if( this.outerBox){
				this.outerBox.style.display = "none";
				if( this.options.isButton == "Y"){
					this.button.style.display = "none";
					this.defaultText.style.background = "url(" + this.options.blit + ") no-repeat right 5px"; 
				}
			}
		}catch(e){
			alert(e.message);
		}
	}
}

var CateBox = function(eid, list, options){
	this.element = eid;
	this.list = list;
	this.options = {
		maxLength : 8 , 
		background : '#e3ecfc', 
		titleMessage : '선택해 주세요', 
		blit : 'http://fn.daum-img.net/image/estate/2008/direct/budong_blit_94.gif', 
		level : 1,
		column : 1, 
		classType : 'area', 
		bold :'N'			
	}
	Object.extend(this.options, options); 
	this.init();
}

CateBox.prototype = {
	init : function(){
		try{
	    	var newlist = [];
	    	var totList = this.list.length;
	
	    	var divValue = totList% this.options.column;
	    	var maxLoop = 0; 
	    	if( divValue == 0){
	    		 maxLoop = totList/this.options.column;
	    	}else{
	    		 maxLoop = Math.floor(totList/this.options.column)+1;
	    	}
	
	    	for( var i=0; i<maxLoop; i++){
	    		newlist.push({value:this.list[i].value, text:this.list[i].text, tag:this.list[i].value});
	    		if( this.options.column >= 2){
	    			if( this.list[maxLoop+i]){
	    				newlist.push({value:this.list[maxLoop+i].value, text:this.list[maxLoop+i].text, tag:this.list[maxLoop+i].value});
	    			}	
	    		} 
	    		if( this.options.column == "3"){
	    			if( this.list[(maxLoop*2)+i]){
	    				newlist.push({value:this.list[(maxLoop*2)+i].value, text:this.list[(maxLoop*2)+i].text, tag:this.list[(maxLoop*2)+i].value});
	    			}	
	    		}
	    	}
	    	var opt_index=0; 
	    	for( var i=0 ; i< newlist.length; i++){
	    		var str = "";
	    		if( this.options.classType == "area"){
		    		if( this.options.level == "3"){ // 단지 
		    			var path = ""; 		
		    		 	if( this.options.cateGroupType=="B"){
		    				path = "zone/" + newlist[i].value;
		    		 	}else{
		    				path = "danji/" + newlist[i].value + "/" + this.options.extCatecodes+"/" + this.options.saletype;
		    		 	}			
		    		    str="/maemul/" + path + "/summary";
		    		}else{
		    			str="/maemul/area/" + newlist[i].value + "/" +this.options.mcatecode + "/" + this.options.extCatecodes+"/" + this.options.saletype + "/summary";
		    		}
	    		}else{
	    			str="/maemul/subway/" + this.options.subwayCode + "/danji/" + newlist[i].value + "/" + this.options.extCatecodes+"/" + this.options.saletype + "/summary";
	    		}
	    		var nil = (this.options.level >=3? 'danji' : (parseInt(this.options.level,10)+1) + 'depth');
	    		if( newlist[i].tag == this.options.curCode){
	    			opt_index = i+1; 
	    		}
	    		str += '?nil_profile=estatetop&nil_maemul=' + nil; 
	    		newlist[i].value = str;
	    	}

	    	var _isButton ="N";
	    	var _goUrl = "";
 
			if( this.options.level <= this.options.depth-2 ){
				_isButton = "Y"; 
				_goUrl = "/maemul/area/" + this.options.curCode + "/" + this.options.mcatecode + "/" + this.options.extCatecodes + "/" + this.options.saletype +"/summary"; 
			}	
			
	    	new SelectBox(this.element, newlist, {depth:this.options.depth, width:198, level:this.options.level, column:this.options.column, bold:this.options.bold, classType:this.options.classType, defaultIndex:opt_index-1, defaultText:this.options.defaultText, isButton:_isButton, goUrl:_goUrl, maxLength:this.options.maxLength, titleMessage:this.options.titleMessage})
	    	newlist =[];
		}catch(e){
			console.debug(e.message);
		}
	}	
}