/****************************************************
* @version : 0.1
* @date : 2007.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"){
				if(_obj[p].isArray){
					ret.append(_obj[p].toJSON());
				}else{
					ret.append(Object.toJSON(_obj[p]));
				}				
			}else if(_type == "function"){
				ret.append(_obj[p].toString().removeCR());
			}else{						 
				if(_type == "number" || _type == "boolean"){
					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.endWith("px")) ? this : 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;
	}
});
//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]);
		}
	},
		
	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);
	},	
	
	formatForDmaps : function(format){
		var num = this;
		var i,c,f,comma,symbol='',sign='',decimals='',integers='';
		var fInt,fDec,nInt,nDec,len=0,cnt=0;
		if(num<0) sign='-';
		num+='';
		if(sign) n=n.replace('-','');
		format=(format)? format+'':'#,##0.00';
		if(format.indexOf(',')>=0) comma=',';
		if(format.indexOf('$')>=0) symbol='$';
		else if(format.indexOf('%')>=0)	symbol='%';
		s=format.split('.');
		fInt=((s[0]==''||s[0]==null||s[0]=='undefinded')? '':s[0]);
		fInt=fInt.split('').reverse().join('');
		fDec=(s[1]==''||s[1]==null||s[1]=='undefinded')? '':s[1];
		s=num.split('.');
		nInt=((s[0]==''||s[0]==null||s[0]=='undefinded')? '':s[0]);
		nInt=nInt.split('').reverse().join('');;
		nDec=(s[1]==''||s[1]==null||s[1]=='undefinded')? '':s[1];
		if (nInt) len=nInt.length;
		if (fInt.length>len) len=fInt.length;
		for(i=0;i<len;i++){
		c=nInt.charAt(i);
		f=fInt.charAt(i);
		cnt++;
		if (cnt==4 && comma && (c||f=='0')) integers+=comma;
		if(f=='0' && !c) integers+='0';
		else if(c) integers+=c;
		if (cnt==4) cnt=1;
		}
		if(fDec) len=fDec.length;
		for(i=0;i<len;i++){
		c=nDec.charAt(i);
		f=fDec.charAt(i);
		if(f=='0' && !c) decimals+='0';
		else if((f=='#' || f=='0') && c) decimals+=c;
		}
		f=((integers+'').split('').reverse().join(''))+((decimals)? '.'+decimals:'');
		if(symbol=='%') f+=symbol;
		else f=symbol+f;
		
		return sign+f;
	}
});
//String Buffer
String.Buffer = function(){
	this.buffer = [];
	this.bufferLength = 0;
};
String.Buffer.prototype = {
	append : function(){
		for(var i=0,len=arguments.length; i<len; i++){
			this.bufferLength = this.buffer.push(arguments[i]);
		}		
	},
	
	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 _hnd = (_object) ? this.bind(_object) : this;
		return window.setTimeout(_hnd, ms);
	},
	
	interval : function(ms, _object){
		var _hnd = (_object) ? this.bind(_object) : this;		
		return window.setInterval(_hnd, ms);
	} 
});

var daum = {    
    version : "0.5 alpha",
    copyright : "Daum Communications, UI Dev. all rights reserved",
    references : "",    
    
    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.HTMLPrototype.style.position = this.HTML_Stack.style.position = "absolute";
			this.HTMLPrototype.style.top = this.HTML_Stack.style.top = "-10000px";
			this.HTMLPrototype.style.left = this.HTML_Stack.style.left = "-10000px";
			
			this.HTMLFragment.appendChild(this.HTMLPrototype);
			this.HTMLFragment.appendChild(this.HTML_Stack);
		}catch(e){}
				
		if(this.HTMLPrototype){
			this.initHTMLPrototype = function(){};
		}
	},
	
    $A : Array.from,
    
    $ : function(obj){
		return (obj.isString) ? document.getElementById(obj) : obj;  
	},	
	
	getCoords : function(_element, isAbsolute){
		var element = this.$(_element);
		var absolute = (isAbsolute) ? false : true;
		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;
	},
	
	parseQuery : function(str){
		var r={}, t=[];
		var str = str || location.search.substr(1); 
		var a = str.split('&');
		for(i=0;i<a.length;i++){t=a[i].split("=");r[t[0]] = t[1];}
		
		if(!arguments[0]) this.url_parameter = r;
		return r;
	},
	
	return_false : function(){ return false; },	
	
	activeX : function(obj,div){
		// generate html code
		// for ie obejct
		var html = '<object ';
		if (!obj.id && !obj.name){
			var r = Math.round(Math.random()*100);
			html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
		} else {
			if (obj.id) html += 'id="'+obj.id+'" ';
			else html += 'id="'+obj.name+'" ';
			if (obj.name) html += 'name="'+obj.name+'" ';
			else html += 'name="'+obj.id+'" ';
		}
		if (obj.type) html += 'type="'+obj.type+'" ';
		if (obj.classid) html += 'classid="'+obj.classid+'" ';
		if (obj.width) html += 'width="'+obj.width+'" ';
		if (obj.height) html += 'height="'+obj.height+'" ';
		if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
		// append events
		for (var i in obj.events){
			if (obj.events[i]){
				html += obj.events[i][0]+'="'+obj.events[i][1]+'" ';
			}
		}
		// end of object tag
		html += '>\n';
		// append params
		for (var i in obj.param){
			html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
		}
	
		// for ns embed
		html += '<embed ';
		if (!obj.id && !obj.name){
			var r = Math.round(Math.random()*100);
			html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
		} else {
			if (obj.id) html += 'id="'+obj.id+'" ';
			if (obj.name) html += 'name="'+obj.name+'" ';
		}
		if (obj.type) html += 'type="'+obj.type+'" ';
		if (obj.width) html += 'width="'+obj.width+'" ';
		if (obj.height) html += 'height="'+obj.height+'" ';
		// append params
		for (var i in obj.param){
			if (obj.param[i][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){
						var tmpArr = html.split('src="'+_src+'"');
						html = tmpArr[0]+' src="'+_src+'?'+obj.param[i][1]+'" '+tmpArr[1];
					} else {
						obj.param[obj.param.length] = obj.param[i];
					}
				} else {
					html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
				}
			}
		}
		html += '/>\n';
		html += '</object>';
	
		var isIE = (document.all)?true:false;
		if (isIE){
			daum.$(div).innerHTML = html;
		} else if (obj.type=='application/x-shockwave-flash' || obj.classid.toLowerCase()=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
			daum.$(div).innerHTML = html;
		} else if (navigator.platform.indexOf('Win')>=0 && obj.classid.toLowerCase()=='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'){
			daum.$(div).innerHTML = html;
		}				
	},
	
	showFlash : function(src,width,height,div,options){
		var obj = new Object();
		obj.type = 'application/x-shockwave-flash';
		obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
		obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
		obj.wmode = (options.wmode?options.wmode:'transparent');
		obj.width = width;
		obj.height = height;
	
		var param = [
			['movie',src],
			['src',src],
			['quality', (options.quality?options.quality:'high')],
			['wmode',(options.wmode?options.wmode:'transparent')],
			['bgcolor',(options.bgcolor?options.bgcolor:'#FFFFFF')],
			['pluginspage',(options.pluginspace?options.pluginspace:'http://www.macromedia.com/go/getflashplayer')],
			['allowScriptAccess',(options.allowScriptAccess?options.allowScriptAccess:'Always')],
		];
		if(options.vars){
			param[param.length] = ['FlashVars',options.vars];
		}
		obj.param = param;
		daum.activeX(obj,div);
	},
	
	selection : function(target, flag){
		var flag = flag || false;		
		target = daum.$(target);
		
		if(!flag){
			daum.addEvent(target, "selectstart", daum.return_false);
			target.style.MozUserSelect = "none";
			target.style.KhtmlUserSelect = "none";
			target.unselectable = "on";
		}else{
			daum.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){		
		if(isCapture == null) var isCapture = false;	
		src = daum.$(src);
		
		type = type.toLowerCase();
		if(type == 'mousewheel' || type == 'dommousescroll') {
			if(daum.Browser.ie || daum.Browser.op || daum.Browser.sf) {
				type = "mousewheel";
			} else {
				type = "DOMMouseScroll";
			}
		}
	
		var flag = false;
		var asserted_index = null;
		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){				
				flag = true;
				asserted_index = i;
				
				return this.observer[asserted_index];
				break;
			}
		}
		
		if(!flag){
			asserted_index = this.observer.push({
				"src" : src,
				"type" : type,
				"handler" : handler
			});
			if(this.eventModel == "w3c"){
				src.addEventListener(type, handler, isCapture);
			}else if(this.eventModel == "bubble"){
				src.attachEvent("on"+type, handler);
			}
			
			return this.observer[asserted_index-1];
		}
	},
	
	removeEvent : function(src, type, handler, isCapture){ 
		if(isCapture == null) var isCapture = false;
		src = daum.$(src);
		
		type = type.toLowerCase();
		if(type == 'mousewheel' || type == 'dommousescroll') {
			if(daum.Browser.ie || daum.Browser.op || daum.Browser.sf) {
				type = "mousewheel";
			} else {
				type = "DOMMouseScroll";
			}
		}
		
		if(this.eventModel == "w3c"){ 
			src.removeEventListener(type , handler, isCapture);
		}else if(this.eventModel == "bubble"){
			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();
		
		return false;
	},
	
	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);
		
		return;		
	},
		
	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);
	}
}; //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;
	}
};
//Template Preset
daum.Template.imgButton = '<img src="#{src}" width="#{width}" height="#{height}" alt="#{alt}" style="cursor:pointer;border:0 none;" />';
daum.Template.linkButton = '<a href="#{href}" style="#{style}">#{text}</a>';

daum.Element = {
	getElementsByClassName : function(_e, className){
		var _all = daum.$(_e).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(_e, className){
		return (_e.className.indexOf(className) != -1);
	},
	
	addClassName : function(_e, className){
		if(_e.className.trim() == ""){
			_e.className = className;
		}else{
			_e.className += (" " + className);
		}
	},
	
	removeClassName : function(_e, className){
		var _classNames = _e.className;
		if(_classNames.length > 0){
			_classNames = _classNames.replaceAll(className, "");
		}
		
		_e.className = _classNames;
	},
	
	setLeft : function(_e, _left){
		_e.style.left = _left.px();
	},

	setTop : function(_e, _top){
		_e.style.top = _top.px();
	},
		
	setPosition : function(_e, _top, _left){
		_e.style.top = _top.px(); _e.style.left = _left.px();
	},
	
	setWidth : function(_e, _width){
		_e.style.width = _width.px();
	},
	
	setHeight : function(_e, _height){
		_e.style.height = _height.px();
	},
	
	setSize : function(_e, _width, _height){
		_e.style.width = _width.px(); _e.style.height = _height.px();		
	},
	
	getStyle : function(_e, cssProperty, mozCssProperty){   	
   		var mozCssProperty = mozCssProperty || cssProperty
   		
   		if(_e.currentStyle)
		   	return _e.currentStyle[cssProperty];
		else
			return document.defaultView.getComputedStyle(_e, null).getPropertyValue(mozCssProperty);
	},
	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\")";
			_e.style.background = "0 none";
			if(_e.tagName.toLowerCase() == "img"){ //img tag
				_e.src = "about:blank";
			}
		}else{
			_e.style.background = "url(" + src + ") no-repeat";
		}
	}
};

//init daum Core
(function(){
	if(!window.$) window.$ = daum.$;	

	Object.extend(daum, daum.Event);
	Object.extend(daum, daum.Browser);
	Object.extend(daum, daum.Element);		
	
	daum.initHTMLPrototype();
	
	daum.ua = daum.Browser;

	return true;
})();

daum.Ajax = function(_options){
	this.options = {
		url : "",
		method : "GET",
		async : true,
		timeout : 5000,
		paramString : "",
		encoding : "euc-kr",
		onsuccess : function(){},
		onfailure : function(){},
		onloading : function(){},
		ontimeout : function(){}
	}
	Object.extend(this.options, _options || {});
	
	this.init();		
}
daum.Ajax.prototype = {
	init : function(){
		if(window.XMLHttpRequest){
			this.XHR = new XMLHttpRequest();
		}else if(window.ActiveXObject){		
			try{
				this.XHR = new ActiveXObject("Msxml2.XMLHTTP");			
			}catch(e){
				try{
					this.XHR = new ActiveXObject("Microsoft.XMLHTTP");				
				}catch(e){				
					this.XHR = null;
				}
			}
		}		
		
		if(!this.XHR) return false;
	},
	
	request : function(url, options){
		this.setOptions(options);
		var url = url || this.options.url;
				
		this.open(url);
	},
	
	open : function(url){
		this.XHR.open(this.options.method, url, this.options.async);		
		
		this.XHR.onreadystatechange = this.stateHandle.bindAsEventListener(this);
		
		this.options.timer = this.abort.timeout(this.options.timeout, this);

		this.XHR.setRequestHeader("charset", this.options.encoding);
		if(this.options.method.toUpperCase() == "POST"){
			this.XHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			this.XHR.send(this.options.paramString)
			if(!this.options.async) this.stateHandle();
		}else{
			this.XHR.send(null);
			if(!this.options.async) this.stateHandle();
		}
	},
	
	abort : function(){
		if(this.XHR){
			this.XHR.abort();
			this.callTimeout();
		}
	},
	
	stateHandle : function(e){
		switch(this.XHR.readyState){
			case 4:
				window.clearTimeout(this.options.timer);
				this.options.timer = null;
				
				if(this.XHR.status == 200 || this.XHR.status == 304){
					this.callSuccess();
				}else if(this.XHR.status >= 400){
					this.callFailure();
				}
				
				break;
				
			case 1:
				this.callLoading();
				
				break;			
		}			
	},
	
	callSuccess : function(){
		this.options.onsuccess(this.XHR);		
	},
	callFailure : function(){
		this.options.onfailure(this.XHR);		
	},
	callLoading : function(){
		this.options.onloading(this.XHR);		
	},
	callTimeout : function(){
		this.options.ontimeout(this.XHR);
	},
	setOptions : function(options){
		Object.extend(this.options, options || {});
	}
};


var log_seq = 0;
function log() {	
	if(!window.p) return;
	
	if(arguments){
		var msg = log_seq + " - ";
		
		for(var i=0; i < arguments.length; ++i) {
			if(i == 0) {
				msg += arguments[i];
			} else {
				msg += " , " + arguments[i];
			}
		}
		
		p.value += msg + "\n";
		
		log_seq++;
	}
}
/* Addition for Daum Maps */
daum.Element.initPos = function(_e){ _e.style.top = "0px"; _e.style.left = "0px"; }