/****************************************************
* @version : 0.1
* @date : 2008.07.02
* @organization : Daum Communications UI Dev.
****************************************************/
//Object member extend
Object.extend = function(dest, source, overwrite){
	var overwrite = overwrite || true;

	for(var property in source){
		if(dest[property] == undefined || overwrite){
			dest[property] = source[property];
		}
	}			
}
Object.extend(Object, {
	toJSON : function(_obj){
		var ret = new String.Buffer();
		ret.append("{");
		
		for(var p in _obj){
			var _type = typeof(_obj[p]);
			
			ret.append("\"" + p + "\": ");
			
			if(_type == "object"){
				ret.append(Object.toJSON(_obj[p]));
			}else if(_type == "function"){
				ret.append(_obj[p].toString().removeCR());
			}else{						 
				if(_type == "number"){
					ret.append(_obj[p]);
				}else{
					ret.append("\"" + _obj[p] + "\"");
				}
			}
			ret.append(", ");
		}
		ret.removeLast();		
		ret.append("}");
		
		return ret.evaluate();
	}
});
//String member extend
Object.extend(String.prototype, {
	isString : true,
	px : function(){
		return this + "px";
	},	
	addslashes : function(){
		return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
	},
	trim : function () {
		return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
	},
	replaceAll : function(findStr, newStr){
		try{
			return this.replace(new RegExp(findStr, "gi"), newStr);
		}catch(e){
			var tmpStr = this;
			while(tmpStr.indexOf(findStr) != -1){
				tmpStr = tmpStr.replace(findStr, newStr);
			}
			
			return tmpStr;
		}		
	},
	removeCR : function(){
		var ret = this;		
		return ret.replaceAll("\n", " ").replaceAll("\r", "");
	},	
	toInt : function(l){
		var l = l || 10;
		return parseInt(this, l);
	},
	toFloat : function(l){
		var l = l || 10;
		return parseFloat(this, l);
	},
	toString : function(){
		return this;
	},	
	empty : function(){
		return (this.length == 0)
	},	
	startWith : function(s){
		return this.substring(0, s.length) == s;
	},	
	endWith : function(s){		
		return this.substring(this.length - s.length) == s;
	},
	byteLength : function(){		
		var _byte = 0;
		for(var i=0,len=this.length;i<len;i++){
			var val = escape(this.charAt(i)).length;
			if(val>3) _byte++;
			_byte++;
		}
		
		return _byte;
	},
	cutString : function(limit, suffix){		
		var suffix = suffix || "";
		var _limit = limit - suffix.length;
		var _byte = 0;
		var _str = new String.Buffer();
		for(var i=0,len=this.length;i<len;i++){			
			if(_limit>0) _str.append(this.charAt(i));			
			var val = escape(this.charAt(i)).length;
			if(val>3){ _byte++; _limit--; }
			_byte++; _limit--;
		}
		_str.append(suffix);
		
		return (limit >= _byte) ? this : _str.evaluate(); 
	},
	cutPixel : function(_px, suffix){
		if(!daum.documentLoaded) return false;
		
		var suffix = suffix || "";		
		document.body.appendChild(daum.HTMLPrototype);			
		daum.HTMLPrototype.innerHTML = suffix;
		var suffixLen = daum.HTMLPrototype.offsetWidth;
		_px -= suffixLen;
		daum.HTMLPrototype.innerHTML = "";
		var _str = new String.Buffer();
		for(var i=0,len=this.length;i<len;i++){			
			daum.HTMLPrototype.innerHTML += this.charAt(i);
			if(_px > daum.HTMLPrototype.offsetWidth){			
				_str.append(this.charAt(i));
			}else{
				_str.append(suffix);
				break;
			}
		}
		daum.HTMLFragment.appendChild(daum.HTMLPrototype);
		
		return _str.evaluate();				
	},
	
	_escape : function(flag){
		var s1=["&amp;","&#39;","&quot;","&lt;","&gt;"];
		var s2=["&","'","\"","<",">"];
		var s3 = [];		
		var ret = this;
		if(flag) { s3=s1;s1=s2;s2=s3; }
		for(var i=0,len=s1.length;i<len;i++){
			ret = ret.replace(new RegExp(s1[i], "g"), s2[i]);
		}
		
		return ret;
	},
	
	escapeHTML : function(){
		return this._escape(true);
	},
	
	toHTML : function(){
		return this._escape(false);
	}
});
//Array member extend
Array.from = function(unarray){	
	if(!unarray) return [];
	if(unarray.isArray) return unarray;
	
	var ret = [];
	for(var i=0,len=unarray.length; i<len; i++){
		ret.push(unarray[i]);
	}
	
	return ret;
}
Object.extend(Array.prototype, {
	isArray : true,	
	each : function(func){		
		for(var i=0,len=this.length; i<len; i++){
			func(this[i]);
		}
	},
	clone : function(){
		var clone = [];
			
		for(var i=0; i<this.length; i++){
			clone[i] = this[i];
		}
			
		return clone;
	},
	deepClone : function(){
		var clone = [];

		for(var i=0,len=this.length; i<len; i++){
			if (this[i].constructor == this.constructor) {
				clone[i] = this[i].deepClone();
			}
			else if(typeof(this[i]) == 'object'){
				if(typeof(this[i].valueOf()) == 'object'){
					clone[i] = this[i].constructor();
	
					for (var p in this[i]) {
						clone[i][p] = this[i][p];
					}
				}else{
					clone[i] = this[i].constructor(this[i].valueOf());
				}
			}else{
				clone[i] = this[i];
			}
		}

		return clone;
	},
	compact : function(){
		var ret = [];
		for(var i=0,len=this.length; i<len; i++){
			if(!(this[i] == null || typeof(this[i]) == "undefined")) ret.push(this[i]);
		}
		
		return ret;
	},	
	indexOf : function(_find){
		for(var i=this.length; i>-1; i--){
			if(this[i] === _find) return i;
		}
		
		return -1;
	},	
	size : function(){		
		return this.compact(this).length;
	},	
	toJSON : function(){
		var ret = new String.Buffer();
		ret.append("[");
		
		for(var i=0,len=this.length; i<len; i++){
			var _type = typeof(this[i]);
			if(_type == "object"){
				if(this[i].toJSON){
					ret.append(this[i].toJSON());
				}else{
					ret.append(Object.toJSON(this[i]));
				}
			}else if(_type == "function"){
				ret.append(this[i].toString().removeCR());
			}else if(_type == "string"){
				ret.append("\"" + this[i] + "\"");
			}else if(_type == "number"){
				ret.append(this[i]);
			}
			if(i < len-1) ret.append(", ");
		}
		
		ret.append("]");
		
		return ret.evaluate();
	},	
	uniq : function(){
		var ret = [];
		for(var i=0,len=this.length; i<len; i++){
			if(ret.indexOf(this[i]) == -1) ret.push(this[i]);
		}
		
		return ret;
	}
});
//Number member extend
Object.extend(Number.prototype, {
	isNumber : true,
	px : function(){
		return this + "px";
	},	
	toString : function(cipher){
		var cipher = cipher || 0;		
		var ret = "" + this;
		if(cipher < ret.length) return ret;
		
		while(ret.length < cipher){
			ret = "0"+ret;
		}
		
		return ret;
	},
	
	toInt : function(l){
		var l = l || 10;
		return parseInt(this, l);
	},
	toFloat : function(l){
		var l = l || 10;
		return parseFloat(this, l);
	}
});
//String Buffer
String.Buffer = function(){
	this.buffer = [];
	this.bufferLength = 0;
};
String.Buffer.prototype = {
	append : function(string){
		this.bufferLength = this.buffer.push(string);		
	},
	
	removeLast : function(){
		this.buffer.splice(this.bufferLength - 1, 1);
	},
	
	evaluate : function(delimeter){
		var delimeter = delimeter || "";
		return this.buffer.join(delimeter);
	}
};
//Function util extend
Object.extend(Function.prototype, {
	bind : function(){
		var __method = this, args = Array.from(arguments), object = args.shift();		
		return function(){
	    	return __method.apply(object, args.concat(Array.from(arguments)));
		}
	},
	
	bindAsEventListener : function(object){
		var __method = this;
		return function(event){
			return __method.call(object, event || window.event);
		}
	},
	
	timeout : function(ms, _object){
		var func = (_object) ? this.bind(_object) : this;		
		return window.setTimeout(func, ms);
	},
	
	interval : function(ms, _object){
		var func = (_object) ? this.bind(_object) : this;
		return window.setInterval(func, ms);
	},
	
	callBack : function(){
		var that = this, args = Array.from(arguments), func = args.shift();

		return function(){
			args = args.concat(Array.from(arguments));

			that(args);
			func(args);
		}
	},
	
	callFore : function(){
		var that = this, args = Array.from(arguments), func = args.shift();

		return function(){
			args = args.concat(Array.from(arguments));

			func(args);
			that(args);
		}
	}
});
//Date member extend
Object.extend(Date.prototype, {
	toJSON : function(){
	}
});

var daum = {
    documentLoaded : false,
    
    initHTMLPrototype : function(){    	  	
    	try{
	    	if(!this.HTMLFragment){
	    		this.HTMLFragment = document.createDocumentFragment();
	    		this.HTMLPrototype = document.createElement("div");
	    		this.HTML_Stack = document.createElement("div");
	    	}    	
		
			this.HTMLPrototype.id = "daum_html_prototype";
			this.HTML_Stack.id = "daum_html_stack";	
			
			this.HTMLFragment.appendChild(this.HTMLPrototype);
			this.HTMLFragment.appendChild(this.HTML_Stack);
			
			this.HTMLPrototype.style.position = "absolute";
			this.HTMLPrototype.style.top = "-10000px";
			this.HTMLPrototype.style.left = "-10000px";
					
			this.HTML_Stack.style.position = "absolute";
			this.HTML_Stack.style.top = "-10000px";
			this.HTML_Stack.style.left = "-10000px";
			with(this.HTML_Stack.style){
				position = "absolute";
				top = "-10000px";
				left = "-10000px";
			}
		}catch(e){}
				
		if(this.HTMLPrototype){
			this.initHTMLPrototype = function(){};
		}
	},
	
    $A : Array.from,
    
    $ : function(obj){
		return (obj.isString) ? document.getElementById(obj) : obj;  
	},	
	
	$d : function(element){
		return new daum.HTML(element);
	},
	
	parseQuery : function(){
		var r={}, t=[];
		var a=location.search.substr(1).split('&');
		for(i=0;i<a.length;i++){t=a[i].split("=");r[t[0]] = t[1];}
		this.url_parameter = r;
		return r;
	},
	
	getParam : function(_name){
		if(!this.url_parameter) this.parseQuery();
		
		return this.url_parameter[_name] || null;		
	},
	
	random : function(min, max){
		return Math.floor(Math.random() * (max - min + 1) + min);
	},
	
	return_false : function(){
		return false;
	},
	
	activeX : function(obj,div){
		var _html = new String.Buffer();
		_html.append('<object ');
		var _id = "daumActiveXObject" + Math.round(Math.random()*100);
		obj.id = obj.id || _id;
		obj.name = obj.name || _id;
		 
		_html.append('id="' + obj.id + '" name="' + obj.name + '" ');

		if(obj.type) _html.append('type="'+obj.type+'" ');
		if(obj.classid) _html.append('classid="'+obj.classid+'" ');
		if(obj.width) _html.append('width="'+obj.width+'" ');
		if(obj.height) _html.append('height="'+obj.height+'" ');
		if(obj.codebase) _html.append('codebase="'+obj.codebase+'" ');

		for(var p in obj.events){
			if(obj.events[p]){
				_html.append(obj.events[p][0]+'="'+obj.events[p][1]+'" ');
			}
		}
		_html.append('>\n');

		for (var p in obj.param){
			_html.append('<param name="'+obj.param[p][0]+'" value="'+obj.param[p][1]+'"/>\n');
		}

		_html.append('<embed ');
		_html.append('id="'+obj.id+'" name="'+obj.name+'" ');
		
		if (obj.type) _html.append('type="'+obj.type+'" ');
		if (obj.width) _html.append('width="'+obj.width+'" ');
		if (obj.height) _html.append('height="'+obj.height+'" ');
		
		var res_src = "";
		for (var i in obj.param){
			if (obj.param[i][0]){
				if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
					var _src = obj.param[i][1];
				}
				if (obj.param[i][0].toLowerCase()=='flashvars'){
					if (_src){
						res_src = _src + '?'+obj.param[i][1]+'" '+tmpArr[1];
					} else {
						obj.param[obj.param.length] = obj.param[i];
					}
				} else {
					_html.append(obj.param[i][0]+'="'+obj.param[i][1]+'" ');
				}
			}
		}
		_html.append('/>\n');
		_html.append('</object>');
		
		var html = _html.evaluate();
		if(_src) html.replaceAll(_src, res_src);
			
		var _panel = daum.$(div);
		if(daum.Browser.ie || (obj.type == "application/x-shockwave-flash" || obj.classid.toLowerCase()=="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000") || (daum.Browser.win && obj.classid.toLowerCase() == "clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95")){
			_panel.innerHTML = html;
		}
	},
	
	showFlash : function(src, width, height, div, vars){
		var obj = {
			"type" : 'application/x-shockwave-flash',
			"classid" : 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
			"codebase" : 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			"wmode" : 'transparent',
			"width" : width,
			"height" : height,
			"param" : [
				['movie',src],
				['src',src],
				['quality','high'],
				['wmode','transparent'],
				['bgcolor','#FFFFFF'],
				['pluginspage','http://www.macromedia.com/go/getflashplayer'],
				['allowScriptAccess','Always'] 
			]
		};
		
		if(vars){
			obj.param[obj.param.length] = ['FlashVars',vars];
		}
		
		daum.activeX(obj,div);
	},
	
	selection : function(target, flag){
		var flag = flag || false;		
		target = daum.$(target);
		
		if(!flag){
			daum.Event.addEvent(target, "selectstart", daum.return_false);
			target.style.MozUserSelect = "none";
			target.style.KhtmlUserSelect = "none";
			target.unselectable = "on";
		}else{
			daum.Event.removeEvent(target, "selectstart", daum.return_false);
			target.style.MozUserSelect = "text";
			target.style.KhtmlUserSelect = "text";
			target.unselectable = "off";
		}
	}
}

/* Event */
daum.Event = {
	observer : [],	
	eventModel : (document.addEventListener) ? "w3c" : "bubble",
	
	addEvent : function(src, type, handler, isCapture){		
		var isCapture = isCapture || false;	
		src = daum.$(src);

		var preObserver = {"src" : src,"type" : type,"handler" : handler};
		
		var flag = false;
		var asserted_index = this.observer.indexOf(preObserver);
		if(asserted_index != -1){
			flag = true;
			
			return this.observer[asserted_index];
		}
		
		if(!flag){
			asserted_index = this.observer.push({
				"src" : src,
				"type" : type,
				"handler" : handler
			}) - 1;
			
			if(this.eventModel == "w3c"){
				if(type=='mousewheel') type='DOMMouseScroll';
				src.addEventListener(type, handler, isCapture);
			}else if(this.eventModel == "bubble"){
				if(type=='DOMMouseScroll') type='mousewheel';
				src.attachEvent("on"+type, handler);
			}
			
			return this.observer[asserted_index];
		}
	},
	
	removeEvent : function(src, type, handler, isCapture){ 
		var isCapture = isCapture || false;
		src = daum.$(src);
		
		if(this.eventModel == "w3c"){
			if(type=='mousewheel') type='DOMMouseScroll';
			src.removeEventListener(type , handler, isCapture);
		}else if(this.eventModel == "bubble"){
			if(type=='DOMMouseScroll') type='mousewheel';
			src.detachEvent("on"+type, handler);
		}
		for(var i=0,len=this.observer.length; i<len; i++){
			if(this.observer[i].src == src && this.observer[i].type == type && this.observer[i].handler === handler){
				this.observer.splice(i, 1);

				break;
			}
		}
	},
	
	stopObserving : function(_observer){		
		if(_observer) this.removeEvent(_observer.src, _observer.type, _observer.handler);
	},
	
	hasObserver : function(src, type){
		var has = false;
		for(var i=0, len=this.observer.length; i<len; i++){
			if(this.observer[i].src == src && this.observer[i].type == type){
				has = true;
				break;
			}
		}
		
		return has;
	},
	
	stopEvent : function(e){
		var e = window.event || e;

		e.cancelBubble = true;
		if(e.stopPropagation) e.stopPropagation();
	},
	
	getWheel : function(e){
		var e = window.event || e;		
		var delta=0;
		if(e.wheelDelta) delta=e.wheelDelta/120;
		else if(e.detail) delta=-e.detail/3;
		return delta;
	},
	
	preventDefault : function(e){
		var e = window.event || e;
		
		e.returnValue = false;
		if(e.preventDefault) e.preventDefault();
		
		return false;		
	},
	
	GC : function(){			
		for(var i=this.observer.length-1; i>-1; i--){
			var found = false;
	  		var element = this.observer[i].src;	
	  		if(daum.Browser.ie){
	  			if(element && element["ownerDocument"]){
	  				try{
	  					if(!this.observer[i].src["offsetParent"]){
	  						found = true;
	  					}
	  				}catch(e){
	  					found = true;
	  				}
	  			}
	  		}else if(element && element.ownerDocument){
				if(!this.observer[i].src.offsetParent){
					var isBodyElement = false;
					do{
						if(element == document.body){
							isBodyElement = true;
							break;
						}
					}while(element = element.parentNode)
					
					if(!isBodyElement) found = true;
				}
	  		}	  
	    	if(found) this.stopObserving(this.observer[i]);	    		
	   	}
	}
}//daum.Event

daum.Browser = {
	ua : navigator.userAgent.toLowerCase(),
	offset : { width : 0, height:0 },
	init : function(){
		this.ie = this.ua.indexOf("msie") != -1;
		this.ie_sv1 = this.ua.indexOf("sv1") != -1;
		this.ie_sv2 = this.ua.indexOf("sv2") != -1;
		this.ie6 = this.ua.indexOf("msie 6") != -1;
		this.ie7 = this.ua.indexOf("msie 7") != -1;
		this.ie8 = this.ua.indexOf("msie 8") != -1;
		this.ff = this.ua.indexOf("firefox") != -1 && this.ua.indexOf("navigator") == -1;
		this.ff2 = this.ff && this.ua.indexOf("firefox/2.") != -1;
		this.ff3 = this.ff && this.ua.indexOf("firefox/3.") != -1;
		this.sf = this.ua.indexOf("safari") != -1;
		this.op = this.ua.indexOf("opera") != -1;
		this.ns = this.ua.indexOf("netscape") != -1 || (this.ua.indexOf("firefox") != -1 && this.ua.indexOf("navigator") != -1);
		this.gecko = this.ua.indexOf("gecko") != -1;
		this.infopath = this.ua.indexOf("infopath") != -1;
		this.etc = this.gecko && this.ff && this.ns;

		this.win = this.ua.indexOf("win") != -1; 
			this.vista = this.ua.indexOf("nt 6") != -1; this.xp = this.ua.indexOf("nt 5.1") != -1; this.w2k = this.ua.indexOf("nt 5.0") != -1; this.w98 = this.ua.indexOf("windows 98") != -1;
		this.mac = this.ua.indexOf("mac") != -1;
		this.unix = !(this.win || this.mac);		
		
		this.versioning();
		this.setOffset();
		
		return;
	},
	
	versioning : function(){
		if(this.ie){						
			if(this.ie8){				
				this.ie7 = this.ie6 = this.ie_sv2 = this.ie_sv1 = false;
			}
			if(this.ie7){
				this.ie6 = this.ie_sv2 = this.ie_sv1 = false;
			}			
		}
		if(this.ff){
			if(this.ff3) this.ff2 = false;
		}
	},
	
	setOffset : function(){
		if(this.ie_sv1)	{ this.offset.width = 10; this.offset.height = (this.infopath) ? 58 : 29; }
		else if(this.ie7) { this.offset.width = 10; this.offset.height = 81; }	
		else if(this.etc) { this.offset.width = (this.mac) ? 0 : 6; this.offset.height = (this.mac) ? 68 : 54; } 
		else if(this.ff2) { this.offset.width = (this.mac) ? 0 : 6; this.offset.height = (this.mac) ? 18 : (this.infopath) ? 54 : 49; }
		else if(this.ff3) { this.offset.width = (this.mac) ? 0 : 8; this.offset.height = (this.mac) ? 68 : (this.infopath) ? 85 : 75; }
		else if(this.sf) { this.offset.width = (this.mac) ? 0 : 4; this.offset.height = (this.mac) ? 23 : 27; }
		else if(this.ns) { this.offset.width = (this.mac) ? 0 : 6; this.offset.height = (this.mac) ? 18 : 54; }
		else if(this.op) { this.offset.width = (this.mac) ? 0 : 9; this.offset.height = (this.mac) ? 36 : 49; }
	},
			
	resizePop : function(_w, _h){
		_w += this.offset.width;
		_h += this.offset.height;

		window.resizeTo(_w, _h);
	},
		
	getWindowSize : function(){
		var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 1003 ;
		var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 650;		
		
		return { "width" : windowWidth - 2, "height" : windowHeight - 2 }
	},
	
	popup : function(url, w, h, _options){
		var options = {
			"name" : "daumPopup",
			"scroll" : false,
			"resize" : false,
			"status" : false		
		}		
		Object.extend(options, _options || {}, true);		

		return window.open(url,options.name,"width="+w+",height="+h+",status="+options.status+",resizable="+options.resize+",scrollbars="+options.scroll);
	},

	setCookie : function(name,value,expires){
		var d = new Date();	var day="";
		if(expires){
			d.setDate(d.getDate()+expires);
			day = "expires="+d.toGMTString()+";";
		}
		document.cookie = name+"="+escape(value)+"; path=/;"+day;
	},
	
	getCookie : function(name){
		name += "=";
		cookie = document.cookie + ";";
		start = cookie.indexOf(name);
		if (start != -1){
			end = cookie.indexOf(";",start);
			return unescape(cookie.substring(start + name.length, end));
		}
		return;
	},
	
	delCookie : function(name){
		document.cookie = name + "=;expires=Fri, 31 Dec 1987 23:59:59 GMT;";
	}	
}; //daum.Broswer
daum.Browser.init();
daum.Template = function(template){
	this.template = template;	
};
daum.Template.prototype = {
	evaluate : function(data){
		var result = this.template;
		for(var p in data){
			result = result.replaceAll("#{"+p+"}", data[p]);			
		}
		
		return result;
	},
	
	toElement : function(data){
		if(!daum.HTMLPrototype) daum.initHTMLPrototype();
		
		daum.HTMLPrototype.innerHTML = this.evaluate(data);
		
		var element = daum.HTMLPrototype.firstChild;
		
		while(element.nodeType != 1) element = element.nextSibling;
		
		daum.HTML_Stack.appendChild(element);
		
		return element;
	}
};
daum.Element = {
	getElementsByClassName : function(_element, className){
		var _all = daum.$(_element).getElementsByTagName("*");
		var element = [];	
		for(var i=0,len=_all.length; i<len; i++){
			if(this.hasClassName(_all[i], className)) element.push(_all[i]);
		}
		return (element.length > 0) ? element : null;
	},
	
	hasClassName : function(_element, className){
		return (_element.className.indexOf(className) != -1);
	},
	
	addClassName : function(_element, className){
		if(_element.className.trim() == ""){
			_element.className = className;
		}else{
			_element.className += (" " + className);
		}
	},
	
	removeClassName : function(_element, className){
		var _classNames = _element.className;
		if(_classNames.length > 0){
			_classNames = _classNames.replaceAll(className, "");
		}
		
		_element.className = _classNames;
	},
	
	setLeft : function(_element, _left){
		_element.style.left = _left.px();
	},

	setTop : function(_element, _top){
		_element.style.top = _top.px();
	},
		
	setPosition : function(_element, _left, _top){
		this.setTop(_element, _top);
		this.setLeft(_element, _left);
	},
	
	setWidth : function(_element, _width){
		_element.style.width = _width.px();
	},
	
	setHeight : function(_element, _height){
		_element.style.height = _height.px();
	},
	
	setSize : function(_element, _width, _height){
		this.setWidth(_element, _width);
		this.setHeight(_element, _height);
	},
	
	setWidthByOffset : function(_element, _offsetWidth){
		this.setWidth(_element, _element.style.width.toInt() + _offsetWidth);		
	},
	
	setHeightByOffset : function(_element, _offsetHeight){
		this.setHeight(_element, _element.style.height.toInt() + _offsetHeight);		
	},
	
	setSizeByOffset : function(_element, _offsetWidth, _offsetHeight){
		this.setWidthByOffset(_element, _offsetWidth);
		this.setHeightByOffset(_element, _offsetHeight);
	}, 
	
	setLeftByOffset : function(_element, _offsetLeft){
		this.setLeft(_element, _element.style.left.toInt() + _offsetLeft);
	},
	
	setTopByOffset : function(_element, _offsetTop){
		this.setTop(_element, _element.style.top.toInt() + _offsetTop);
	},
	
	setPositionByOffset : function(_element, _offsetLeft, _offsetTop){
		this.setLeftByOffset(_element, _offsetLeft);
		this.setTopByOffset(_element, _offsetTop);
	},
	
	show : function(_element){
		daum.$(_element).style.display = "";
	},
	
	hide : function(_element){
		daum.$(_element).style.display = "none";
	},
	
	setStyle : function(_element, cssProperty, cssValue){
		daum.$(_element).style[cssProperty] = cssValue;
	},
	
	getStyle : function(_element, cssProperty, mozCssProperty){   	
   		var mozCssProperty = mozCssProperty || cssProperty
   		
   		return (_element.currentStyle) ? _element.currentStyle[cssProperty] : document.defaultView.getComputedStyle(_element, null).getPropertyValue(mozCssProperty);  
	},
	
	getNext : function(_element){
		var next = _element.nextSibling;
		while(next.nodeType != 1) next = next.nextSibling;
		
		return next;
	},
	
	getPrev : function(_element){
		var prev = _element.previousSibling;
		while(prev.nodeType != 1) prev = prev.previousSibling;
		
		return prev;
	},
	
	getParent : function(_element){
		return _element.parentNode;
	},
	
	getFirstChild : function(_element){
		var fchild = _element.firstChild;
		while(fchild.nodeType != 1) fchild = fchild.nextSibling;
		
		return fchild;
	},
	
	getCoords : function(_element){
		var element = this.$(_element);		
		var w = element.offsetWidth;
		var h = element.offsetHeight;
		
		var coords = { "left" : 0, "top" : 0, "right" : 0, "bottom" : 0 };
		
		while(element){
			coords.left += element.offsetLeft;
			coords.top += element.offsetTop;	
			element = element.offsetParent;			
		}
		
		coords.right = coords.left + w;
		coords.bottom = coords.top + h;
	
		return coords;
	},
	
	show : function(_e){
		_e.style.display = "";
	},	
	hide : function(_e){
		_e.style.display = "none";
	},
	
	posHide : function(_e){
		this.setPosition(_e, -10000, -10000);
	},
	
	setOpacity : function(_e, op){		
		_e.style.filter="alpha(opacity="+op*100+")";
		_e.style.opacity=op;
		_e.style.MozOpacity=op;
		_e.style.KhtmlOpacity=op;
	},
	
	setCssText : function(_e, _csstext){
		if(daum.Browser.ie){
			_e.style.cssText = _csstext;
		}else{
			_e.setAttribute("style", _csstext);
		}
	},
	
	_cleanNode : function(el){
	    var child = el.firstChild;
	    while (child){
	        var nextNode = child.nextSibling;
	        if (child.nodeType == 3 && !/\S/.test(child.nodeValue)){
	            el.removeChild(child);
	        }
	        child = nextNode;
	    }
	    return el;
	},
	
	setPngOpacity : function(_e, src){
		if(daum.Browser.ie6){
			_e.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + src + "\", sizingMethod=\"image\")";
			if(_e.tagName.toLowerCase() == "img"){ //img tag
				_e.src = "about:blank";
			}
		}else{
			if(_e.tagName.toLowerCase() != "img") _e.style.background = "url(" + src + ") no-repeat";
			
		}
	}
};

daum.HTML = function(element){
	this.element = daum.$(element);
	
	for(var p in this){
		if(typeof(this[p]) == "function"){
			this[p] = this[p].bind(this, this.element);
		}
	}
}
Object.extend(daum.HTML.prototype, daum.Element);

//init daum Core
(function(){
	if(!window.$) window.$ = daum.$;	
	if(!window.$d) window.$d = daum.$d;
	if(!window.$A) window.$A = daum.$A;

	Object.extend(daum, daum.Event);
	Object.extend(daum, daum.Browser);
	Object.extend(daum, daum.Element);
	
	daum.initHTMLPrototype();
	daum.parseQuery();

	daum.Event.GC.interval(60000, daum.Event);
	
	daum.Event.addEvent(window, "load", function(){
		daum.documentLoaded = true;
	});
	
	return true;
})();