var mino={};

mino.debuging=1; //use mino debug. (0=not use.)
mino.debugView=1;

if(mino.debuging) {
	mino.debugMessage=new Array();
}

// navigator type
if(navigator.appName.match(/Explorer/)) mino.isIE=1; //Internet Exporer
else mino.isIE=0; // or.. FF

// element return
function $(str) {
	return(document.getElementById(str));
}

function $T(str) {
	return(document.getElementsByTagName(str));
}

if(!mino.isIE) {
	HTMLElement.prototype.$T=function(str) {
		return this.getElementsByTagName(str);
	}
}


function $N(str) {
	return(document.getElementsByName(str));
}

//trim
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/gi, "");
} 

// screen
mino.screen={}

function _mino_chkscr() {
	if(mino.isIE) {

		try {
			mino.screen.width=document.body.offsetWidth;
			mino.screen.height=document.body.offsetHeight;
		} catch (e){
			setTimeout("_mino_chkscr()",1000);
		}
	} else {
		try {
			mino.screen.width=self.innerWidth;
			mino.screen.height=self.innerHeight;
		} catch (e)	{
			setTimeout("_mino_chkscr()",1000);
		}
	}

	if(!mino.screen.height) setTimeout("_mino_chkscr()",1000);
}

_mino_chkscr();

//firefox innerText fix;
if(!mino.isIE) {
	if (typeof HTMLElement != "undefined" && typeof HTMLElement.prototype.__defineGetter__ != "undefined") {
		HTMLElement.prototype.__defineGetter__("innerText", function () {
			if (this.textContent) { return(this.textContent)   }    
			else{var r=this.ownerDocument.createRange(); r.selectNodeContents(this);return r.toString();}
		});  
		HTMLElement.prototype.__defineSetter__("innerText", function (sText) {    

			if  (sText.textContent)  {this.innerHTML=sText.textContent; }
			else {
//				this.innerHTML = sText.replace(/\&/g, "&").replace(/ /g, ">");
				this.innerHTML = sText.replace(/\&/g, "&");
			}

		});
	}
}

/*
mino Class Request

coded by : hanulis (hanulis@docircle.com)
date : 2006. 12. 8

about : AJAX Request function
usege : (object) mino.Request(url,params,method,callback[,param1,param2,...])

		param1, param2, ... 등등은 Request후 callback function에 넘겨줄 인자들을 받는다./
		callback function에서는 req(xml original), json, params(array)를 넘겨받는다.

*/
mino.request={};


mino.request=function(url,method,params,callback) {

	var args=arguments;

	this.params = (params == null) ? null : params;

	this.callbackMethod=(callback==null) ? null : callback;
	this.method=(method==null) ? "GET" : method;
	this.url=(url==null) ? null : url;
	this.params=(params==null) ? null : params;
	this.callbackParams=new Array();
	this.trycount=1;

	this.waitingTime=10*1000;

	var argsLength=args.length;

	if(argsLength>4) {
		for(_p=4;_p<argsLength;_p++) {
			this.callbackParams.push(args[_p]);
		}
	}

	this.send();

}

mino.request.prototype = {
	getXMLHttpRequest: function() {
		if (window.ActiveXObject) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e1) { return null; }
			}
		} else if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else {
			return null;
		}		
	},

	send: function() {
		this.req = this.getXMLHttpRequest();

		if(!this.req) alert("failed to request xmlHTTP.");

		var httpMethod = this.method ? this.method : 'GET';
		if (httpMethod != 'GET' && httpMethod != 'POST') httpMethod = 'POST';
		var httpParams = (this.params == null || this.params == '') ? null : this.params;
		var httpUrl = this.url;
		if (httpMethod == 'GET' && httpParams != null) httpUrl = httpUrl + "?" + httpParams;
		this.req.open(httpMethod, httpUrl, true);

		this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

		var request = this;

		this.requestTimer = setTimeout(function() {if(request.trycount==3) {request.req.abort();alert_layer("Process failed temporarily due to poor network connection.  Please try again...")} else {request.resend();}}, this.waitingTime);

		this.req.onreadystatechange = function() {
			request.onStateChange.call(request);
		}
		this.req.send(httpMethod == 'POST' ? httpParams : null);
	},

	resend: function() {
		this.trycount++;
		this.send();
	},

	onStateChange: function() {
		if(this.callbackMethod) this.callback(this.req,this.callbackMethod,this.callbackParams);
		else {
			if(this.req.readyState == 4) clearTimeout(this.requestTimer);
		}
		return;
	},

	callback: function (req,callbackMethod,callbackParams){
		if(req.readyState == 4){
			clearTimeout(this.requestTimer);
			if(req.status == 200){
				var t=req.responseText;

				if(t.match(/Parse error/)) {
					alert_layer("PHP error\n\n"+t);
					return;
				}

				var t=req.responseXML;
				try
				{
					var err=t.selectSingleNode("//ERRORMESSAGE").firstChild.nodeValue;
					if(err != "success") { 
						alert_layer(err);
						return;
					}
				}
				catch (e){}


//				if(t.getElementsByTagName("ERRORMESSAGE").item(0).nodeValue) {
//					alert_layer("DB Qeury ERROR\n\n"+t.getElementsByTagName("ERRORMESSAGE").item(0).nodeValue);
//					return;
//				}

				if(callbackParams) callbackMethod(req,callbackParams);
				else callbackMethod(req);
			} else {
				if(req.status=="0" || req.status=="12029" || req.status=="12030" || req.status=="12152") alert_layer("Process failed temporarily due to poor network connection.  Please try again...");
				else alert_layer('HTTP ERROR:'+req.status+'<br><br>callback Failed.');
			}
		}
	} 

}

/*
mino Class layer

coded by : hanulis (hanulis@docircle.com)
date : 2006. 12. 10

about : event class
usege : (void) mino.layer.show(obj)
		- object(layer) 를 보여준다.

		(void) mino.layer.hide(obj)
		- object(layer) 를 감춘다.

		(void) mino.layer.changeDisplay(obj)
		- object(layer)의 표시 상태(숨김/보임)를 바꾼다.
		
		(object) mino.layer.xy(obj)
		- object의 화면 "절대위치"를 return한다.
		- ex) var xy=mino.layer.xy(obj);
			  xy.x (x 위치) xy.y (y 위치)
		
		(void) mino.layer.moveSmooth(obj,x,y)
		- object를 x,y위치로 이동시킨다.
		- obj.attribute:onmovesmoothstart, onmovesmoothend
		- onmovesmoothstart: 마우스가 움직임을 시작할때 발생시킬 action.
		- onmovesmoothend: 마우스가 움직임을 종료할때 발생시킬 action.


		(void) mino.layer.moveCenter(obj)
		- object를 화면 중앙으로 이동시킨다.

		(void) mino.layer.blend(obj,to,timer);
		- object의 opacity를 to까지 smooth하게 조절한다. opacity가 변하는 시간은 timer로 정하며 1/1000s(1ms)단위.
		
		(void) mino.layer.setOpacity(obj, to);
		- object의 opacity를 to값으로 조절한다.

		(void) mino.layer.getOpacity(obj, to);
		- object의 opacity값을 가져온다.
		
		(void) mino.layer.moveMouse(obj,event);
		- object를 마우스가 클릭한 위치로 이동시킨다. (event값을 같이 넘겨줘야함)

*/
var _mino_layer_smooth_obj=null;
var _mino_layer_smooth_doing=false;

var _mino_layer_blend_obj=null;
var _mino_layer_blend_doing=false;

var _mino_layer_moveCenter_obj=null;

var _mino_layer_outOff_obj=null;
var _mino_layer_outOff_stats=true;

var _mino_layer_zoomIn_obj=null;
var _mino_layer_zoomIn_overflow;

mino.layer={
	show:function(obj) {
		if(obj) obj.style.display="";
	},

	hide:function(obj) {
		if(obj) obj.style.display="none";
	},
	
	changeDisplay:function(obj) {
		if(obj) {
			if(obj.style.display=="none") mino.layer.show(obj);
			else mino.layer.hide(obj);
		}
	},

	xy:function(obj) {

		if(document.getBoxObjectFor) { //firefox
			try {
				var tempXY=document.getBoxObjectFor(obj);
			} catch(e) {return [0,0,obj.offsetWidth,obj.offsetHeight]}

			return [tempXY.x,tempXY.y,obj.offsetWidth,obj.offsetHeight];
		} else if(obj.getBoundingClientRect) { //internet Explorer

			var tempXY=obj.getBoundingClientRect();						
			return [(tempXY.left+document.body.scrollLeft),(tempXY.top+document.body.scrollTop),obj.offsetWidth,obj.offsetHeight];
		} else return false;
	},

	moveCenter:function(obj) {
		if(mino.screen.width) {
			mino.layer.show(obj);
			if(obj.style.position!="absolute") obj.style.position="absolute";

			if(mino.isIE) {
				obj.style.top=parseInt(mino.screen.height-obj.offsetHeight)/2+parseInt(document.body.scrollTop)+"px";
				obj.style.left=parseInt(mino.screen.width-obj.offsetWidth)/2+"px";
			} else {
				obj.style.top=(mino.screen.height-obj.offsetHeight)/2+parseInt(document.body.scrollTop)+"px";;
				obj.style.left=(mino.screen.width-obj.offsetWidth)/2;
			}
			_mino_layer_moveCenter_obj=null;

		} else {
			mino.layer.hide(obj);
			_mino_layer_moveCenter_obj=obj;
			setTimeout("mino.layer.moveCenter(_mino_layer_moveCenter_obj)",100);
		}
	},

	moveSmooth:function(obj,x,y) {

		if(arguments[3]==undefined && _mino_layer_smooth_doing) {
			return;
		}
		else _mino_layer_smooth_doing=1;

		if(!_mino_layer_smooth_obj) {
			_mino_layer_smooth_obj=obj;
			if(obj.getAttribute("onmovesmoothstart")) eval(obj.getAttribute("onmovesmoothend"));
		}

		var loc=mino.layer.xy(_mino_layer_smooth_obj);

		if(x!=null) {
			if(Math.abs(Math.abs(loc[0])-Math.abs(x))<10) {
				obj.style.left=x;
				var xc=1;
			} else {
				obj.style.left=parseInt(loc[0]+(x-loc[0])/3);
			}
		} else var xc=1;

		if(y!=null) {
			if(Math.abs(Math.abs(loc[1])-Math.abs(y))<10) {
				obj.style.top=y;
				var yc=1;
			} else {
				obj.style.top=parseInt(loc[1]+(y-loc[1])/3);
			}
		} else var yc=1;

		if(xc && yc) {
			if(obj.getAttribute("onmovesmoothend")) {
				eval(obj.getAttribute("onmovesmoothend"));
			}
			_mino_layer_smooth_doing=0;
			_mino_layer_smooth_obj=null;
			return;
		}

		setTimeout('mino.layer.moveSmooth(_mino_layer_smooth_obj,'+x+','+y+',"s")',1);

	},

	blend:function(obj,to,timer) {

		if(arguments[3]==undefined && _mino_layer_blend_doing) {
			return;
		}

		if(to<0) to=0;
		else if(to>100) to=100;
		var nowOpacity=mino.layer.getOpacity(obj);

		if(!mino.isIE) nowOpacity*=100;

		if(nowOpacity==to) {
			_mino_layer_blend_doing=false;
			_mino_layer_blend_obj=null;
			return;
		}

		if(!_mino_layer_blend_obj) {
			_mino_layer_blend_obj=obj;
			if(obj.getAttribute("onblendstart")) eval(obj.getAttribute("onblendstart"));
		}
		else _mino_layer_blend_doing=1;

		if(Math.abs(to-nowOpacity)<5) {
			_mino_layer_blend_obj=null;
			_mino_layer_blend_doing=false;
			mino.layer.setOpacity(obj,to);
			if(obj.getAttribute("onblendend")) {
				eval(obj.getAttribute("onblendend"));
			}
			return;
		} else {

			mino.layer.setOpacity(obj,nowOpacity+(to-nowOpacity)/3);
		}

		setTimeout("mino.layer.blend(_mino_layer_blend_obj,"+to+","+timer+",'s')",timer);

	},

	getOpacity:function(obj) {
		if(mino.isIE) {
			try {
				var t=obj.style.filter;
				var _match=t.match(/alpha\(opacity\=(.*?)\)/i);
				if(_match[1]) return parseInt(_match[1]);
				
			} catch (e){
				return 100;
			}
		} else {
			if(obj.style.opacity) return obj.style.opacity;
			else if(obj.style.MozOpacity) return obj.style.MozOpacity*100;
			else return 1;
		}
	},

	setOpacity:function(obj,val) {

		val=parseInt(val);

		if(mino.isIE) {
			obj.style.filter="alpha(opacity="+val+")";
		} else {

			obj.style.opacity=val/100;
			obj.style.MozOpacity=val/100;
		}
	},

	moveMouse:function(obj,e) {

		var xy=mino.event.xy(e);

		if(arguments[2]) xy[0]=xy[0]+arguments[2];
		if(arguments[3]) xy[1]=xy[1]+arguments[3];

		if(obj.offsetWidth+xy[0]-parseInt(document.body.scrollLeft)>mino.screen.width) obj.style.left=mino.screen.width-obj.offsetWidth-20;
		else obj.style.left=xy[0]-10;

		if(obj.offsetHeight+xy[1]-parseInt(document.body.scrollTop)>mino.screen.height) obj.style.top=mino.screen.height-obj.offsetHeight-20+document.body.scrollTop;
		else obj.style.top=xy[1]-10;


	}, 
		
	outOff:function(obj) {
		if(_mino_layer_outOff_obj !=obj && _mino_layer_outOff_obj) {
			mino.layer.hide(_mino_layer_outOff_obj);
			_mino_layer_outOff_obj=null;
		}

		_mino_layer_outOff_obj=obj;

		mino.layer.chkoutOff();
	},

	chkoutOff:function() {

		try{
			_mino_layer_outOff_obj.onmouseover=function() {_mino_layer_outOff_stats=true;}
			_mino_layer_outOff_obj.onmouseout=function() {_mino_layer_outOff_stats=false;} 
		}catch(e) {}

		if(_mino_layer_outOff_stats==false) {
			mino.layer.hide(_mino_layer_outOff_obj);
			_mino_layer_outOff_obj=null;
			_mino_layer_outOff_stats=true;
			return;
		} else setTimeout("mino.layer.chkoutOff()",100);

	},

	zoomIn:function(obj,x,y) {

		if(!_mino_layer_zoomIn_obj) {
			if(obj.style.overflow) _mino_layer_zoomIn_overflow=obj.style.overflow;
			obj.style.overflow="hidden";
			_mino_layer_zoomIn_obj=obj;
			obj.style.tableLayout="fixed";
			if(x!=null) obj.style.width=0;
			if(y!=null) obj.style.height=0;
		}


		var _xc=0;
		var _yc=0;
	

		var objx=0;
		var objy=0;

		this.onEnterFrame=function() {

			objx=parseInt(obj.style.width);
			objy=parseInt(obj.style.height);
			//resize x

			if(x!=null && objx<x-5) {
				obj.style.width=objx+(x-parseInt(objx))/4;

			} else {
				if(x!=null) obj.style.width=x;
				_xc=1;
			}


			//resize y
			if(y!=null && objy<y-5) {
				obj.style.height=objy+(y-parseInt(objy))/4;
			} else {
				if(y!=null) obj.style.height=y;
				_yc=1;
			}

			if(_xc && _yc) {
				eval(obj.getAttribute("onzoominend"));
				if(_mino_layer_zoomIn_overflow) obj.style.overflow=_mino_layer_zoomIn_overflow;
				_mino_layer_zoomIn_obj=null;
				_xc=0;
				_yc=0;
				return;
			} else {
				setTimeout("mino.layer.zoomIn(_mino_layer_zoomIn_obj,"+x+","+y+")",10);
			}


		}

		this.onEnterFrame();

	}

}

/*
mino Class form

coded by : hanulis (hanulis@docircle.com)
date : 2006. 12. 12

about : form parsing
usege : 

*/
mino.form={
	ajaxSubmit:function(f) {
		var act=f.getAttribute("action");
		var callback=f.getAttribute("callback");
		var method=f.getAttribute("method");

		var elements=f.elements;
		
		var q="";

		for(i in elements) {
			q+=elements[i].getAttribute("name")+"="+elements[i].value;
			if(elements[i+1]) q+="&";
		}

		new mino.request(action,method,q,callback);

	}
}

/*
mino Class event

coded by : hanulis (hanulis@docircle.com)
date : 2006. 12. 11

about : event class
usege : (bool) mino.event.add(obj,event,callback function)
		- object에 event가 발생할 경우 실행할 function을 정의한다.

		(bool) mino.event.del(obj,event,callback function)
		- object에 걸려있는 event를 삭제한다.

		(object) mino.event.src(obj)
		- event를 발생한 객체를 리턴한다.

		(void) mino.event.cancel()
		- event를 cancel시킨다.

*/
mino.event={
	add:function(obj, evt, callback) {
		if(obj.addEventListener) { //not internet explorer
			return obj.addEventListener(evt,callback,false);
		} else if(obj.attachEvent) { //internet explorer
			return obj.attachEvent("on"+evt,callback);
		}

	},

	del:function(obj, evt, callback) {
		if(obj.removeEventListener) { //not internet explorer
			return obj.removeEventListener(evt,callback,false);
		} else if(obj.detachEvent) { //internet explorer
			return obj.detachEvent("on"+evt,callback);
		}
	},

	src:function(evt) {
		if(mino.isIE) { //is internet explorer?
			return evt.srcElement;
		} else { //or..
			return evt.target;
		}
	},
	
	cancel:function(e) {
		if(!mino.isIE) { //firefox

			e.cancelBubble=true;
			e.stopPropagation(); 
//			e.preventBubble=true;
//			e.getPreventDefault();
//			e.initMouseEvent();
//			e.stopPropagation();
//			e.preventDefault();
			e.stopPropagation(); 

			return false;
		} else { //ie
			e.cancelBubble=true;
			e.returnValue=false;
			return false;
		}
	},

	xy:function(e) {
		return [e.clientX+document.body.scrollLeft,e.clientY+document.body.scrollTop];
	}
}

/*
mino Class error

coded by : hanulis (hanulis@docircle.com)
date : 2006. 12. 11

about : error parsing
usege : (bool) mino.debug.add(msg,url,line)
		- script가 오류가 있을때, 해당 오류를 (array) mino.debugMessage에 저장한다.
		
		(string) mino.debug.print()
		- mino.debugMessage에 저장된 오류 메세지를 alert로 띄운다.

		* mino.debug=1 (사용)
			- mino.debug_add()가 onerror이벤트에 종속된다.
			- mino.debug_print()가 onload이벤트에 종속된다.

*/
mino.debug={
	add:function(msg,url,line) {
		var err="SCRIPT ERROR :\n";
		err+="url: "+url+"\n";
		err+="line: "+line+"\n";
		err+="msg: "+msg+"\n";
		mino.debugMessage.push(err);

		if(mino.debugView) alert(mino.debugMessage.toString());
		return true;
	},

	print:function() {
		if(mino.debugMessage.length>0 && mino.debugView) {
			alert(mino.debugMessage.toString());
		}
	}
}

if(mino.debuging) {
	window.onerror=mino.debug.add;
	mino.event.add(window,"load",mino.debug.print);
}


// Drag and Drop
/*
mino Class DragDrop

coded by : hanulis (hanulis@docircle.com)
date : 2007. 3. 7

about : Drag and Drop
usege : 
		1. drag할 object를 등록한다.
		mino.dragdrop.addDrag(object, thread, drag parent, drag action, move limit("parent","x","y",null) )
		ex> mino.dragdrop.addDrag($('d1'),1,null,null,"parent");

		2. drop할수 있는 dropzone으로 만들 object를 등록한다.

		mino.dragdrop.addDropzone(object, thread, over action, out action, drop action)
		ex> mino.dragdrop.addDropzone($('dp'),1,"$('dp').style.backgroundColor='#eeeeee'","$('dp').style.backgroundColor=''",null);


*/

//chk dropzone interval val

var dropzone=new Array();
var dragobj=new Array();

var draging_obj;
var draging_child;

var _chk_dropzone=false;
var _chk_dragobj=false;
var _virtualObj=null;

var _now_dropzone;

_virtualObj=document.createElement("DIV");
_virtualObj.style.border="2px dotted #cccccc";
_virtualObj.style.clear="both";

//_virtualObj.style.position="relative";
//_virtualObj.style.backgroundColor="$fff";
_virtualObj.style.display="none";
_virtualObj.setAttribute("_VIRTUALOBJ_","1");
if(document.body) document.body.appendChild(_virtualObj);

var _drag_direction=null;
var _b_direction=0;

var _init_var1;
var _init_var2;

mino.dragdrop={

	addDrag:function(obj,thread,dragParent,dragEvent) {
//		if(_virtualObj==null) mino.dragdrop.makeVirtualObj();

		if(!obj) return;

		obj.style.cursor="move";
		obj.setAttribute("_dt_",thread);

		if(dragParent) obj.setAttribute("_dp_",dragParent);
		if(dragEvent) obj.setAttribute("_de_",dragEvent);

		mino.event.add(obj,"mousedown",mino.dragdrop.initDrag);
		mino.event.add(obj,"mouseup",mino.dragdrop.stopDrag);

		if(dragParent) mino.event.add($(dragParent),"mouseup",mino.dragdrop.stopDrag);

		if(!dragobj[thread]) dragobj[thread]=new Array();

		var tc=dragobj[thread].length; //thread count
		if(dragParent) dragobj[thread][tc]=$(dragParent);
		else dragobj[thread][tc]=obj;
		
	},

	initmove:function() {
		mino.dragdrop.chkZone(_now_dropzone.getAttribute("_dt_"));
		mino.dragdrop.chkObj(_now_dropzone.getAttribute("_dt_"));

	},

	initDrag:function(e) {

		var obj=mino.event.src(e);
	
		if(obj.getAttribute("onclick") || (obj.tagName!="IMG" && obj.getAttribute("href")) || obj.tagName=="INPUT" || obj.tagName=="TEXTAREA") return;
		else if(obj.parentNode.getAttribute("onclick") || (obj.parentNode.tagName!="IMG" && obj.parentNode.getAttribute("href")) || obj.parentNode.tagName=="INPUT" || obj.parentNode.tagName=="TEXTAREA") return;

		if(!obj.getAttribute("_dt_")) {
			while(obj) {
				obj=obj.parentNode;
				if(obj.getAttribute("_dt_")) {
					break;
				}
			}
		}

			// ignore drag event
		// ie
		document.body.ondragstart=function() {return false;}
		document.body.onselectstart=function() {return false;}
		document.body.ondrag=function() {return false;}
		// ff
		document.body.style.MozUserFocus="ignore";
		document.body.style.MozUserInput="disabled";
		document.body.style.MozUserSelect="none";

		var objTag=obj.tagName;

		draging_child=obj;

		//if drag-parent(ex:table) is been, draging_obj is drag-parent.
		if(obj.getAttribute("_dp_")) draging_obj=$(obj.getAttribute("_dp_"));
		else draging_obj=obj;

		try {
			eval(obj.getAttribute("_de_")); //execute drag event.
		} catch(e) {}



		draging_obj.style.position="absolute";

		draging_obj.style.left=e.clientX-(draging_child.offsetWidth/2)+document.body.scrollLeft;
		draging_obj.style.top=e.clientY-(draging_child.offsetHeight/2)+document.body.scrollTop;


		var thread=obj.getAttribute("_dt_");
		draging_obj.setAttribute("_dt_",thread);

		if(dropzone[obj.getAttribute("_dt_")]) {

			//virtual object view
			_virtualObj.style.display="";
			_virtualObj.style.width=draging_obj.offsetWidth;
			_virtualObj.style.height=draging_obj.offsetHeight;
			if(draging_obj.style.styleFloat || draging_obj.style.cssFloat) {
				_virtualObj.style.clear="";
				_virtualObj.style.cssFloat="left";
				_virtualObj.style.styleFloat="left";
			}

			draging_obj.parentNode.insertBefore(_virtualObj,draging_obj);
			mino.event.add(_virtualObj,"mousemove",mino.dragdrop.move);
			mino.event.add(_virtualObj,"mouseup",mino.dragdrop.stopDrag);

		}

		mino.event.add(draging_obj,"mousemove",mino.dragdrop.move);
		mino.event.add(document,"mousemove",mino.dragdrop.move);


		_now_dropzone=draging_obj.parentNode;
//		mino.dragdrop.chkZone(draging_obj.getAttribute("_dt_"));
//		if(!_chk_dropzone) {
//			_chk_dropzone=setInterval("mino.dragdrop.chkZone("+_now_dropzone.getAttribute("_dt_")+")",100);
//		}
//		if(!_chk_dragobj) {
//			_chk_dragobj=setInterval("mino.dragdrop.chkObj("+_now_dropzone.getAttribute("_dt_")+")",10);
//		}

		mino.event.add(document,"mousemove",mino.dragdrop.initmove);



	},

	chkZone:function(thread) {
		var xy=mino.layer.xy(draging_obj);
		try {
			var zc=dropzone[thread].length;
		} catch(e) {return;}

		var zxy;
//		debug(zc);
		for(i=0;i<zc;i++) {
			zxy=mino.layer.xy(dropzone[thread][i]);
			if(_drag_direction=="m") {
				if(xy[0]>zxy[0] && xy[0]<zxy[0]+zxy[2] && xy[1]>zxy[1] && xy[1]<zxy[1]+zxy[3]) {
	//				debug("find-zone");
					if(_now_dropzone && dropzone[thread][i] != _now_dropzone) {
						try {
							if(_now_dropzone.getAttribute("_oua_")) eval(_now_dropzone.getAttribute("_oua_"));
							if(dropzone[thread][i].getAttribute("_oa_")) eval(dropzone[thread][i].getAttribute("_oa_"));
							_now_dropzone=dropzone[thread][i];
						} catch(e) {}
					return;
					}
				}
			} else {
				if(xy[0]+xy[2]>zxy[0] && xy[0]+xy[2]<zxy[0]+zxy[2] && xy[1]>zxy[1] && xy[1]<zxy[1]+zxy[3]) {
	//				debug("find-zone");
					if(_now_dropzone && dropzone[thread][i] != _now_dropzone) {
						try {
							if(_now_dropzone.getAttribute("_oua_")) eval(_now_dropzone.getAttribute("_oua_"));
							if(dropzone[thread][i].getAttribute("_oa_")) eval(dropzone[thread][i].getAttribute("_oa_"));
							_now_dropzone=dropzone[thread][i];
						} catch(e) {}
					return;
					}
				}
			}
		}

		if(_now_dropzone) {
			try {
				if(_now_dropzone.getAttribute("_oua_")) eval(_now_dropzone.getAttribute("_oua_"));
			} catch(e) {}
		}

	},

	chkObj:function(thread) {

		var xy=mino.layer.xy(draging_obj);
		try {
			var zc=dragobj[thread].length;
		} catch(e) {return;}

		var zxy;

		if(!_now_dropzone.childNodes.length) {
			_now_dropzone.appendChild(_virtualObj);
		}

		for(i=0;i<zc;i++) {
			zxy=mino.layer.xy(dragobj[thread][i]);
			if(_drag_direction=="m") {			
				if(xy[0]>zxy[0] && xy[0]<zxy[0]+zxy[2] && xy[1]>zxy[1] && xy[1]<zxy[1]+zxy[3]) {
					_virtualObj.style.display="";
	//				if(_now_dropzone) _now_dropzone.insertBefore(_virtualObj,dragobj[thread][i]);

					try {
						if(dragobj[thread][i].previousSibling==_virtualObj) {
							if(dragobj[thread][i].nextSibling) _now_dropzone.insertBefore(_virtualObj,dragobj[thread][i].nextSibling);
							else _now_dropzone.appendChild(_virtualObj);
						}
						else _now_dropzone.insertBefore(_virtualObj,dragobj[thread][i]);
					} catch(e) {}

					return;
				}
			} else {
				if(xy[0]+xy[2]>zxy[0] && xy[0]+xy[2]<zxy[0]+zxy[2] && xy[1]>zxy[1] && xy[1]<zxy[1]+zxy[3]) {
					_virtualObj.style.display="";
	//				if(_now_dropzone) _now_dropzone.insertBefore(_virtualObj,dragobj[thread][i]);

					try {
						if(dragobj[thread][i].previousSibling==_virtualObj) {
							if(dragobj[thread][i].nextSibling) _now_dropzone.insertBefore(_virtualObj,dragobj[thread][i].nextSibling);
							else _now_dropzone.appendChild(_virtualObj);
						}
						else _now_dropzone.insertBefore(_virtualObj,dragobj[thread][i]);
					} catch(e) {}

					return;
				}
			}
		}

		if(_virtualObj.parentNode!=_now_dropzone) _now_dropzone.appendChild(_virtualObj);

	},

	move:function(e) {
		if(!draging_obj) return false;
		if(_b_direction) {
			if(e.clientX-_b_direction<0) _drag_direction="m";
			else if(e.clientX-_b_direction>0) _drag_direction="p";

			_b_direction=e.clientX;
		} else {
			_b_direction=e.clientX;
		}

		draging_obj.style.left=e.clientX-(draging_child.offsetWidth/2)+document.body.scrollLeft;
		draging_obj.style.top=e.clientY-(draging_child.offsetHeight/2)+document.body.scrollTop;;

	},


	stopDrag:function(e) {
		if(!draging_obj) return false;
//		debug(_virtualObj.parentNode.getAttribute("_dt_"));
		try {
			var mouseOutAction=_virtualObj.parentNode.getAttribute("_oua_");
			mouseOutAction.replace(/this/g,"_virtualObj.parentNode");
			eval(mouseOutAction);
		} catch(e) {}

		mino.event.del(document,"mousemove",mino.dragdrop.initmove);

		_chk_dropzone=false;
		_chk_dragobj=false;

		//re-fresh drag event
		//ie
		document.body.ondragstart=function() {return true;}
		document.body.onselectstart=function() {return true;}
		document.body.ondrag=function() {return true;}
		//ff

		document.body.style.MozUserFocus="";
		document.body.style.MozUserInput="";
		document.body.style.MozUserSelect="";


		mino.event.del(draging_obj,"mousemove",mino.dragdrop.move);
		mino.event.del(document,"mousemove",mino.dragdrop.move);
		mino.event.del(_virtualObj,"mouseup",mino.dragdrop.stopDrag);
		mino.event.del(_virtualObj,"mousemove",mino.dragdrop.move);


		//if thread dropzone is been, position style set to normal. 
		if(dropzone[(draging_obj.getAttribute("_dt_"))]) {
			draging_obj.style.position="";

			//replace obj <-> virtual obj
			_virtualObj.parentNode.replaceChild(draging_obj,_virtualObj);
			_virtualObj.style.cssFloat="";
			_virtualObj.style.styleFloat="";
		}

		try {

			if(_now_dropzone.getAttribute("_da_")) {
				var dropAction=_now_dropzone.getAttribute("_da_");
				dropAction=dropAction.replace(/this/g,"_now_dropzone");

				eval(dropAction);
			}
		} catch(e) {}

		draging_obj=false;
		draging_child=false;


	},


	addDropzone:function(obj, thread, overAction, outAction, dropAction) {
		if(!dropzone[thread]) dropzone[thread]=new Array();

		obj.setAttribute("_dt_",thread);

		if(overAction) obj.setAttribute("_oa_",overAction);
		if(outAction) obj.setAttribute("_oua_",outAction);
		if(dropAction) obj.setAttribute("_da_",dropAction);

		var tc=dropzone[thread].length; //thread count
		dropzone[thread][tc]=obj;

	}

}

// Element
/*
mino Class Element

coded by : hanulis (hanulis@docircle.com)
date : 2007. 3. 9

about : Element class
usege : 

*/

mino.element={
	show:function(tag) {
		var t=document.getElementsByTagName(tag);
		for(i=0;i<t.length;i++) {
			t[i].style.display="";
			t[i].style.visibility="visible";
		}
	},

	hide:function(tag) {
		var t=document.getElementsByTagName(tag);
		for(i=0;i<t.length;i++) {
			t[i].style.display="none";
			t[i].style.visibility="hidden";
		}
	}
}

// Image
/*



*/

mino.image={
	resize:function(obj,x,y) {
		var _x=obj.width;

		if(_x>x) obj.width=x;

		var _y=obj.height;

		if(_y>y) obj.height=y;
	}

}

// XML
/*


*/

mino.xml={
	nodeValue:function(obj,nodename) {
		return obj.selectSingleNode(nodename).firstChild.nodeValue;
	},
	
	parseArray:function(obj) {

		obj=obj.childNodes;

		var cn=obj.length;

		var r=new Array();

		var nn;
		var nv;
	
		if(mino.isIE) {

			for(_i_=0;_i_<cn;_i_++) {
				nn=obj[_i_].nodeName;
				nv=obj[_i_].firstChild.nodeValue;
				
				r[(nn)]=nv;
				r[_i_]=nv;
			}
		} else {

			for(_i_=0;_i_<cn;_i_++) {
				try
				{
					nn=obj[_i_].nodeName;
					nv=obj[_i_].firstChild.nodeValue;
					if(nn != "#text") {
						r[(nn)]=nv;
						r[_i_]=nv;
					}
				
				}
				catch (e) {continue;}
			}

		}

		return r;
	}
}

// after processing
//mino.event.add(window,"load",_mino_chkscr);
