
$XX = function(a) {
	return typeof a == 'object' ? a : document.getElementById(a);
}

if (!Ua) {
	var Ua = {
		version: "20090213001",
		included : new Object(),
		listeners: new Object(),
		initialize: function() {
			Ua.Browser.check();
			this.include("/js/uacommon.js");
			this.include("/js/uatools.js");
			this.include("/js/ualogs.js");
			this.include("/js/player/swfobject.js");
			
			window.onload = this.onload;
		},
		include: function(src) {
			var t = new Date();
			if (!this.included[src]) {
				this.included[src] = "included";
				var str = '<scr'+'ipt type="text/javascript" src="'  + src + '?'+ Ua.version +'"></scr'+'ipt>';
				document.writeln(str);
			}
		},
		onload: function() {
			for (var ls in Ua.listeners) {
				if (typeof Ua.listeners[ls] == "function") {
					Ua.listeners[ls]();
				}
			}
		},
		addEventListener: function(name, func) {
			if (!this.listeners[name]) {
				if (typeof func == "function") {
					this.listeners[name] = func;
				}
				else {
					alert(func + 'Àº(´Â) ÇÔ¼ö°¡ ¾Æ´Õ´Ï´Ù.');
				}
			}
			else
				alert('Áßº¹  µî·Ï: ' + name);
		},
		Browser: {
			isXP: navigator.userAgent.indexOf('Windows NT 5.1') > 0,	// XP is true
			IE: !!(window.attachEvent && !window.opera),
			IEVer: 0,
			check: function() {	// Check browser & version
			    var agent = window.navigator.userAgent;
			    var ie = agent.indexOf( "MSIE " );
			    if (ie > 0)
			       this.IEVer = parseInt(agent.substring(ie+5, agent.indexOf(".", ie)));
			}
		},
		goTop: function() {
			if (document.documentElement && document.documentElement.scrollTop) {
				document.documentElement.scrollTop = 0;
			}
			else if (document.body) {
				document.body.scrollTop = 0;
			}
		},
		go: function(y) {
			if (document.documentElement) {
				document.documentElement.scrollTop = y;
			}
			else if (document.body) {
				document.body.scrollTop = y;
			}
		},
		_getY: function() {
			return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
		},
		_getWindowScroll: function(w) {
			var T, L, W, H;
			w = w || window;
			with (w.document) {
				if (w.document.documentElement && documentElement.scrollTop) {
					T = documentElement.scrollTop;
					L = documentElement.scrollLeft;
				} 
				else if (w.document.body) {
					T = body.scrollTop;
					L = body.scrollLeft;
				}
				
				if (w.innerWidth) {
					W = w.innerWidth;
					H = w.innerHeight;
				} 
				else if (w.document.documentElement && documentElement.clientWidth) {
					W = documentElement.clientWidth;
					H = documentElement.clientHeight;
				} 
				else {
					W = body.offsetWidth;
					H = body.offsetHeight
				}
			}
			return { top: T, left: L, width: W, height: H };
		},
		_rect: function(obj, e) {
			var x = 0, y = 0, w = 0, h = 0;
			if (typeof obj == 'string')
				obj = document.getElementById(obj);
			w = obj.offsetWidth || obj.clientWidth;
			h = obj.offsetHeight || obj.clientHeight;

			x += obj.offsetLeft;
			y += obj.offsetTop - obj.scrollTop;
			
			if (e) {
				x += e.x;
				y += e.y;
			}
			return {x: x, y: y, w: w, h: h};
		},
		_rect2: function(obj, e) {
			var x = 0, y = 0, w = 0, h = 0;
			if (typeof obj == 'string')
				obj = document.getElementById(obj);
			w = obj.offsetWidth;
			h = obj.offsetHeight;

			while (obj) {
				x += obj.offsetLeft;
				y += obj.offsetTop - obj.scrollTop;
				obj = obj.offsetParent;
			}
			
			if (e) {
				x += e.x;
				y += e.y;
			}
			return {x: x, y: y, w: w, h: h};
		},
		
		/**
		 * HTML ¹®¼­ ³»¿¡ µð¹ö±× Á¤º¸¸¦ Ç¥½Ã ÇÑ´Ù.
		 * 
		 * @param obj text message
		 * @param obj object
		 * 
		 * obj°¡ objectÀÏ °æ¿ì ´ÙÀ½°ú °°Àº property parameter¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
		 * 		width		: with of message box, default '100%' 
		 * 		height		: height of message box, default '20px'
		 * 		isInsert	: trueÀÌ¸é message¸¦ message boxÀÇ ¾ÕÂÊ¿¡ Ãß°¡ ÇÑ´Ù.
		 * 		isAppend	: trueÀÌ¸é meeeage¸¦ message boxÀÇ µÞÂÊ¿¡ Ãß°¡ ÇÑ´Ù.
		 * 		isText		: trueÀÌ¸é innerText¿¡ Ãß°¡ ÇÑ´Ù.
		 * 		pos			: message box°¡ display µÉ ÁÂÇ¥¸¦ ÁöÁ¤ ÇÑ´Ù.
		 * 		msg			: message
		 * 
		 * »ç¿ë ¿¹)
		 * 		Ua.debug({
		 * 			width: 200,
		 * 			height: 200,
		 * 			isInsert: true,
		 * 			isText : true,
		 * 			position : { x: 50, y: 100 },
		 * 			msg: 'Hello, debuger'
		 * 		});
		 * 			
		 */
	  	debugX: function(obj) {	// µð¹ö±ë ¸Þ¼¼Áö Ãâ·Â
			this.debug(obj + '<br/>');
		},
	  	debug: function(obj) {	// µð¹ö±ë ¸Þ¼¼Áö Ãâ·Â
			if (!obj)
				return;

			if (typeof obj != 'object') {
				obj = {
					msg: obj,
					isAppend: true
				};
			}
			
			var ie6 = window.navigator.userAgent.indexOf("MSIE 6") != -1;
			var oDiv = document.getElementById('debugXXXX');
			if (!oDiv) {
				oDiv = document.createElement("DIV");
				oDiv.id = 'debugXXXX';

				oDiv.style.display = 'block';
				oDiv.style.backgroundColor = '#800000';
				oDiv.style.color = 'white';
				if (ie6)
					oDiv.style.position = 'absolute';
				else
					oDiv.style.position = 'fixed';
				
				oDiv.style.zIndex = 99999;
				oDiv.style.left = '0px';
				oDiv.style.top = '0px';
				oDiv.style.width = obj.width || '300px'
				oDiv.style.height = obj.height || '100%';
				oDiv.style.overflowY = 'auto';
				oDiv.title = '´õºí Å¬¸¯ÇÏ¸é ³»¿ëÀÌ Áö¿öÁý´Ï´Ù.';
				oDiv.ondblclick = function() {
					this.innerHTML = '';
				};

				document.body.appendChild(oDiv);

				var position = obj.position || {x: 0, y: 0};
				if (ie6) {
					var p = this.cumulativeScrollOffset(document.body);
					position.y += p.y;
				}
				this.show(oDiv, position);
			}

			var txt = '';
			
			if (obj.isInsert) {
				txt = obj.msg + oDiv.innerHTML;
			}
			else if (obj.isAppend) {
				txt = oDiv.innerHTML + obj.msg;
			}
			else {
				txt = obj.msg;
			}
				
			if (obj.isText) {
				oDiv.innerText = txt;
			}
			else {
				oDiv.innerHTML = txt;
			}
			
			var oTxt = document.createElement('TEXT');
			oDiv.appendChild(oTxt);
			oTxt.scrollIntoView();
			oDiv.removeChild(oTxt);
		},
		hideDebug: function() {
			var oDiv = document.getElementById('debug');
			if (oDiv)
				document.body.removeChild(oDiv);
		},
		strlen: function(str) {			// ÇÑ±Û ¹®ÀÚ¿­ ±æÀÌ °è»ê
			return (str.length+(escape(str)+"%u").match(/%u/g).length-1);
		},
		substr: function(str, size) {	// ÇÑ±Û ¹®ÀÚ¿­ ÀÚ¸£±â
			var len = this.strlen(str);
			var s = escape(str);
			var x = "";
			var n = 0;
			for (var i = 0; i < s.length; ) {
				if (s.charAt(i) == '%' && s.charAt(i+1) == 'u') {
					if (n + 2 > size) {
						//Ua.debug(n);
						break;
					}
					
					x += unescape(s.substr(i, 6));
					i += 6;
					n += 2;
				}
				else if (s.charAt(i) == '%') {
					x += unescape(s.substr(i, 3));
					i += 3;
					n++;
				}
				else {
					x += s.charAt(i);
					i++;
					n++;
				}
				
				if (n >= size)
					break;
			}
			
			return x;
		},
		toggle: function(id) {
			var obj = $(id);
			if (obj.style.display == "none")
				obj.style.display = "block";
			else
				obj.style.display = "none";
			return obj.style.display == "block";
		},
		show: function(obj, e) {
			if (typeof obj == 'string') {
				obj = document.getElementById(obj);
			}
			if (obj) {
				obj.style.display = "block";
				
				if (e) {
					obj.style.left = e.x + "px";
					obj.style.top = e.y + "px";
				}
			}
		},
		showY: function(obj, y) {
			if (typeof obj == 'string')
				obj = document.getElementById(obj);
			
			if (obj) {
				obj.style.display = "block";
				obj.style.top = y + "px";
			}
		},
		hide: function(obj) {
			if (typeof obj == 'string')
				obj = document.getElementById(obj);
			if (obj)
				obj.style.display = "none";
		},
		// IE, ChromiumÀº window.event¸¦ »ç¿ëÇÏ°í, 
		// Netscape´Â È£ÃâÇÒ ¶§ event °´Ã¼¸¦ ³Ñ°ÜÁà¾ß ÇÑ´Ù. onclick="Ua.getEvent(event)"
		// µû¶ó¼­ ºê¶ó¿ìÀú¿¡ »ó°ü ¾øÀÌ °øÅëÀ¸·Î »ç¿ëÇÏ·Á¸é onclick="Ua.getEvent(event)" Ã³·³ ³Ñ°Ü ¹Þ¾Æ¾ß ÇÑ´Ù.
		getEvent: function(aEvent) {
			return aEvent || window.event;
		},
		getSrcElement: function(aEvent) {
			if (aEvent)
				return aEvent.srcElement || aEvent.target;
			return null;
		},
		getOffset: function(oP, oC) {	// ÀÚ½ÄÀÇ offset + ºÎ¸ðÀÇ offset
			if (typeof oP == 'string')
				oP = document.getElementById(oP);
			if (typeof oC == 'string')
				oC = document.getElementById(oC);
			
			var x = oC.offsetLeft;
			var y = oC.offsetTop;
			
			if (Ua.Browser.IE && Ua.Browser.IEVer < 8) {
				x += oP.offsetLeft;
				y += oP.offsetTop;
			}
			
			return {x: x, y: y}
		},
		cumulativeOffset: function(element) {
		    var valueT = 0, valueL = 0;
		    do {
		      valueT += element.offsetTop  || 0;
		      valueL += element.offsetLeft || 0;
		      element = element.offsetParent;
		    } while (element);
		    return {x: valueL, y: valueT};
		},
		cumulativeScrollOffset: function(element) {
			    var valueT = 0, valueL = 0;
			    do {
			      valueT += element.scrollTop  || 0;
			      valueL += element.scrollLeft || 0;
			      element = element.parentNode;
			    } while (element);
			    return {x: valueL, y: valueT};
		 },
		 makeFlash: function(Url,Width,Height){
			  document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + Width + "\" height=\"" + Height + "\">");
			  document.writeln("<param name=\"movie\" value=\"" + Url + "\">");
			  document.writeln("<param name=\"quality\" value=\"high\">");
			  document.writeln("<param name=\"wmode\" value=\"transparent\">");
			  document.writeln("<embed src=\"" + Url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + Width + "\"  height=\"" + Height + "\">");
			  document.writeln("</object>");
		},
		addComma: function(v) {
			v = "" + v;
			var s = v.replace(/,/g,"").reverse();
			var t = "";
			for (var i = 0; i < s.length; i += 3) {
				if (t)
					t += ",";
				t += s.substr(i, 3);
			}
			return t.reverse();
		},
		copy: function(inElement) {
			//window.clipboardData.setData('text',inElement.value);
			//return;
			/*
			alert(inElement.createTextRange);
			if (inElement.createTextRange) {
				var range = inElement.createTextRange();
				if (range)
					range.execCommand('Copy');
			}
			else*/ /*{
				var flashcopier = 'flashcopier';
				if(!document.getElementById(flashcopier)) {
					var divholder = document.createElement('div');
					divholder.id = flashcopier;
					document.body.appendChild(divholder);
				}
				document.getElementById(flashcopier).innerHTML = '';
		    
				var divinfo = '<embed src="/js/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
				document.getElementById(flashcopier).innerHTML = divinfo;
				alert(divinfo);
			}
			*/
		},
		opacity: function(s, val) {
			if ( navigator.appName.indexOf("Explorer") != -1 ) {
				$XX(s).style.filter="Alpha(opacity=" + val + ")";
			} else {
				$XX(s).style.opacity= val/100;
			}
		}
	}

	Ua.initialize();
}

var Try = {
  these: function() {
    var returnValue;

    for (var i = 0, length = arguments.length; i < length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) { }
    }

    return returnValue;
  }
}

var UaAjax = {
		name: 'UaAjax'
	};
	UaAjax.Request = function(config) {
		this.name 	= 'Request';
		this.method = (config.method || 'GET').toUpperCase();
		this.owner	= config.owner;
		this.url	= config.url;
		this.sync  	= !!config.sync;
		
		if (typeof config.params == 'string') {
			this.params 	= config.params;
		}
		else if (typeof config.params == 'object') {
			var p = "";
			for (var property in config.params) { 
				if (p != "")
					p += "&";
				p += property + "=" + config.params[property];
			}
			this.params = p;
		}
		
		this.callback 	= config.callback;
		this.debug		= !!config.debug;
		this.req 		= null;
		this.send();
	}

UaAjax.Request.prototype = {
		
    getTransport: function() {
	  return Try.these (
	      function() {
	    	  http = new XMLHttpRequest();
	    	  if (http.overrideMimeType){ 
	    		  http.overrideMimeType('text/xml');
			  }
	    	  return http;
	      },
	      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
	      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
	    ) || false;
	},
	send: function() {
		var httpUrl = this.url;
		
		// IE¿¡¼­ URLÀÌ °°À» °æ¿ì cache¸¦ ÀÌ¿ëÇÏ´Â ¹®Á¦¸¦ ÇØ°áÇÏ±â À§ÇØ URL¿¡ dummy¸¦ Ãß°¡ ÇÔ
		var dummy = (new Date().getTime());

		// XMLHttpRequest object
		this.req = this.getTransport();
		
		if (this.method == 'GET' && this.params) {
			httpUrl = httpUrl + "?" + this.params + "&dummy=" + dummy; 
		}
		else {
			httpUrl = httpUrl + "?" + "dummy=" + dummy; 
		}
		this.req.open(this.method, httpUrl, true);
		
		if (this.method == 'POST')
			this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');

		var request = this;
		this.req.onreadystatechange = function() {
			request.onStateChange.call(request);
		}
		this.req.send(this.method == 'POST' ? this.params : null);
	},
	onStateChange: function() {
		if(this.req.readyState == 4) {
			if(this.req.status != 200) {
				var s = "ERROR: " 
						+ this.req.statusText 
						+ "(" + this.req.status + "): " 
						+ this.url + "?" 
						+ this.params;
				
				if (this.debug) {
					Ua.debug(s);
				}
				this.req = null;
			}
			else {
				var xml = this.req.responseXML;
				if (xml && xml.parseError && xml.parseError.errorCode != 0) {
					if (this.debug) {
						Ua.debug('XML ¿À·ù: ' + xml.parseError.reason);
					}
					this.req = null;
				}
			}
			if (this.callback)
				this.callback.call(this.owner, this.req, this.target);
		}
  	}
}	

var UaCookie = {
		createCookie: function(name, value, domain, expireSecond) {
		 	var date = new Date();
		 	date.setTime(date.getTime()+(expireSecond*1000));
		 	
		 	var strExpires = "; expires="+date.toGMTString();
		 	var strDomain = "; domain="+domain;
		 	
		 	document.cookie = name+"="+value+strExpires+strDomain+"; path=/";
		},
		createSimpleCookie: function(name, value, domain) {
		 	document.cookie = name + "=" + value + "; expires=0" + "; domain=" + domain + "; path=/";
		},
		deleteCookie: function(name, domain) {
			createCookie(name, "", domain, 0);
		},
		setCookie: function(name, value, domain, expiredays) {
			var todayDate = new Date();
			var nextDate = new Date(todayDate.getYear(), todayDate.getMonth(), todayDate.getDate() + expiredays);
			
			if ( domain=="" ) domain=".uajjang.com";
			document.cookie = name + "=" + escape(value) + "; path=/; expires=" + nextDate.toGMTString() + ";"
			                  + (domain ? "domain="+domain : "" ) + ";"
		},
		getCookie: function(name) {
			var nameOfCookie = name + "=";
			var x = 0;
			while (x <= document.cookie.length) {
				var y = (x+nameOfCookie.length);
				if (document.cookie.substring( x, y ) == nameOfCookie) {
			        if ((endOfCookie=document.cookie.indexOf( ";", y )) == -1)
			            endOfCookie = document.cookie.length;
			        return unescape(document.cookie.substring(y, endOfCookie));
				}
				x = document.cookie.indexOf(" ", x) + 1;
				if (x == 0)
					break;
			}
			return "";
		},
		getCookieX: function(name) {
			var start = document.cookie.indexOf( name + "=" );
			var len = start + name.length + 1;
			if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
			{
				return null;
			}
			
			if( start == -1 )
				return null;
			
			var end = document.cookie.indexOf( ";", len );
			
			if ( end == -1 )
				end = document.cookie.length;
			
			return unescape( document.cookie.substring( len, end ) );
		}
}

var UaNotice = function(config) {
	this.config = {};
	for (var c in config) {
		this.config[c] = config[c];
	}

	// ´Ý±â ¹öÆ°°ú ¸Þ¼¼ÁöÀÇ À§Ä¡ 'top', 'bottom'
	this.config.position = this.config.position || 'bottom';
	this.element = null;
	this.cookieName = config.id;
	this.config.background = this.config.background || '#d4d4d4;';
	
	if (this.config.allowHide === undefined) {
		this.config.allowHide = true;
	}
}

UaNotice.prototype = {
		
	showEx: function() {
		if (UaCookie.getCookie(this.cookieName))
			return;

		this.element = document.getElementById(this.config.id);
		if (this.element) {
			this.element.style.display = 'block';
			this.element.style.top = this.config.top + "px";
			this.element.style.left = this.config.left + "px";
		}
	},
		
	show: function() {
		
		if (UaCookie.getCookie(this.cookieName))
			return;
		
		this.element = document.getElementById(this.config.id);
		if (this.element) {
			
			this.element.style.display = 'block';
			this.element.style.top = this.config.top + "px";
			this.element.style.left = this.config.left + "px";
			this.element.style.background = this.config.background;
			if (this.config.border) {
				this.element.style.border = this.config.border;
			}

			var oDivOuter = document.createElement('DIV');
			oDivOuter.style.width = this.config.width + 'px';
			oDivOuter.style.background = this.config.background;
			oDivOuter.style.height = '20px';
			
			// -------------------------------------------------------------------------------
			if (this.config.allowHide) {
				var oDiv = document.createElement('DIV');
				oDiv.style.styleFloat = 'left';
				oDiv.style.width = (this.config.width - 50) + 'px';
				oDiv.style.height = '16px';
				oDiv.style.textAlign = 'left';
				oDiv.style.color = '#6a6a6a';
				oDiv.style.marginLeft = '10px';
	
				var oInput = document.createElement('INPUT');
				var oNotice = this;
				oInput.onclick = function() {
					UaCookie.setCookie(oNotice.cookieName, true, oNotice.config.domain, 1);
				}
				oInput.type = 'checkbox';
				oInput.style.cursor = 'pointer';
				
				var oText = document.createElement("TEXT");
				oText.innerText = '¿À´ÃÀº ´õ ÀÌ»ó º¸ÀÌÁö ¾ÊÀ½';
				
				oDiv.appendChild(oText);
				oDiv.appendChild(oInput);
	
				oDivOuter.appendChild(oDiv);
			}

			// -------------------------------------------------------------------------------
			var oDiv = document.createElement('DIV');
			oDiv.style.styleFloat = 'right';
			oDiv.style.lineHeight = '10px';
			
			var oImg = new Image();
			oImg.src = "/images/btn/close_s.gif";
			oImg.style.paddingTop = '2px';
			oImg.style.paddingRight = '10px';
			oImg.style.verticalAlign = 'middle';
			oImg.style.cursor = 'pointer';
			oImg.alt = '´Ý±â';
			
			var oNotice = this;
			oImg.onclick = function() {
				oNotice.element.style.display = 'none';
				//UaMain.playerTalk.stop();
			}
			oDiv.appendChild(oImg);
			
			oDivOuter.appendChild(oDiv);
			
			if (this.config.position == 'top') {
				this.element.insertBefore(oDivOuter, this.element.firstChild);
			}
			else {
				this.element.appendChild(oDivOuter);
			}
		}
	},
	hide: function() {
		if (this.element) {
			this.element.style.display = 'none';
		}
	},
	checkCookie: function() {
		return UaCookie.getCookie(this.cookieName);
	},
	toggle: function(oElement) {
		if (oElement.checked) {
			UaCookie.setCookie(this.cookieName, true, this.config.domain, 1);
		}
		else {
			UaCookie.setCookie(this.cookieName, '', this.config.domain, 1);
		}
	}
}

var SelectBox = {
		addList: function(n, source, target) {
			var newOpt = document.createElement("OPTION");
			newOpt.text = source.options[n].text;	
			newOpt.value = source.options[n].value;

			if (target.options.length == 0) {
				target.add(newOpt);
			}
			else {
				var inserted = false;
				for (var i = 0; i < target.options.length; i++) {
					if (target.options[i].value > newOpt.value) {
						target.add(newOpt, i);
						inserted = true;
						break;
					}	
				}
				if (!inserted) {
					target.add(newOpt);
				}
			}
			source.remove(n);
		},
	    moveOption: function(source, target) {
			for (var i = 0; i < source.options.length; i++) {
				if (source.options[i].selected) {
					this.addList(i, source, target);
					i--;
				}
			}
	    },
		swap: function(options, i1, i2) {
			var x = options[i1];
			if (i2 == null)
				i2 = options.length - 1;
			options.remove(i1);
			options.add(x, i2);
		},
		up: function(s) {
			var i = s.selectedIndex;
			if (i <= 0)
				return;
			this.swap(s.options, i, i-1);
		},
		down: function(s) {
			var i = s.selectedIndex;
			if (i >= s.options.length - 1)
				return;
			this.swap(s.options, i, i+1);
		},
		top: function(s) {
			var i = s.selectedIndex;
			if (i <= 0)
				return;
			this.swap(s.options, i, 0);
		},
		bottom: function(s) {
			var i = s.selectedIndex;
			if (i >= s.options.length - 1)
				return;
			this.swap(s.options, i);
		}
	}


var XMLData = function(id) {
	this.id = id;
	this.xmlObject = document.getElementById(this.id);
};

XMLData.prototype = {
	getText: function(node) {
		var oItem = this.xmlObject.XMLDocument.selectSingleNode(node);
		if (oItem)
			return oItem.text;
		return '';
	},
	getNodes: function(node) {
		return this.xmlObject.XMLDocument.selectNodes(node);
	},
	addNode: function(name, text) {
		var root = this.xmlObject.documentElement;
		var element = this.xmlObject.XMLDocument.createElement(name);
		element.text = text;
		root.appendChild(element);
	},
	addCData: function(name, cdata) {
		var root = this.xmlObject.documentElement;
		var element = this.xmlObject.XMLDocument.createElement(name);
		var cdataElem = this.xmlObject.XMLDocument.createCDATASection(cdata);
		element.appendChild(cdataElem);
		root.appendChild(element);
	},
	updateNode: function(name, text) {
		var element = this.xmlObject.XMLDocument.selectSingleNode(name);
		element.text = text;
	},
	updateCData: function(name, text) {
		var element = this.xmlObject.XMLDocument.selectSingleNode(name);
		var cdata = element.firstChild;
		if (!cdata) {
			cdata = this.xmlObject.XMLDocument.createCDATASection(text);
			element.appendChild(cdata);
		}
		else 
			cdata.text = text;
	},
	toString: function() {
		return this.xmlObject.XMLDocument.xml;
	}
};


var UaAudioManager = {
		audio: null,

		// audio °´Ã¼ Ãß°¡
		put: function(id, audio) {
			if (!this.audio)
				this.audio = {};

			var a = this.audio[id];
			if (!a)
				a = audio;

			this.audio[id] = a;

			return a;
		},

		get: function(id) {
			if (!this.audio)
				this.audio = {};

			return this.audio[id];
		},

		remove: function(id) {
			if (!this.audio)
				this.audio = {};

			var a = this.audio[id];
			delete this.audio[id];

			return a;
		},

		checkStatus: function(id) {
			if (this.audio) {
				var a = this.audio[id];
				if (a) {
					if (a.player.playState == 10) {
					}
				}
			}
		}
	};

var UaAudioX = function(id, container, width, height) {
	this.id = id;
	this.width = width;
	this.height = height;
	this.container = container;
	this.player = document.getElementById(id);
	
	if (!this.player) {
		this.player = document.createElement('OBJECT');
		this.player.id = this.id;
		this.player.classid = 'CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6';
		this.player.uiMode = 'mini';
		this.player.settings.autoStart = false;
		this.player.settings.volume = 100;
		this.player.style.width = width;
		this.player.style.height = height;

		if (container != null) {
			if (typeof container == 'string')
				container = document.getElementById(container);

			if (container)
				container.appendChild(this.player);
			else
				document.body.appendChild(this.player);
		}
		else
			document.body.appendChild(this.player);
		
		UaAudioManager.put(id, this);
	}
};

UaAudioX.prototype.play = function() {
	if (this.player)
		this.player.controls.play();
};
UaAudioX.prototype.stop = function() {
	if (this.player)
		this.player.controls.stop();
};
UaAudioX.prototype.pause = function() {
	if (this.player)
		this.player.controls.pause();
};
UaAudioX.prototype.file = function(url) {
	if (this.player)
		this.player.URL = url;
};
UaAudioX.prototype.volume = function(vol) {
	if (this.player)
		this.player.settings.volume = vol;
};
UaAudioX.prototype.mute = function(isMute) {
	if (this.player)
		this.player.settings.mute = isMute;
};
UaAudioX.prototype.toString = function() {
	if (this.player)
		return this.player.outerHTML;
	return '<object id="' + this.id + '"></object>';
};



//Tab button Á¤º¸¸¦ ´ãÀ» Object
var UaPageTab = function(owner, id, view, callback) {
	this.owner = owner;
	this.id = id;
	this.isOn = false;
	this.image = $XX(id);
	this.view = $XX(view);
	this.callback = callback;
	
	this.image.onclick = function() {
		owner.display(id);
	}
}

//Tab conrainer
var UaPageTabContainer = function(owner) {
	this.owner = owner;
	this.tabs = {};
	this.defaultTab = null;
}

//Tab Ãß°¡
UaPageTabContainer.prototype.add = function(id, view, callback) {
	this.tabs[id] = new UaPageTab(this, id, view, callback);
}
//Tab get
UaPageTabContainer.prototype.get = function(id) {
	id = id || this.defaultTab;
	return this.tabs[id];
}
//Tab »èÁ¦
UaPageTabContainer.prototype.remove = function(id) {
	delete this.tabs[id];
}
//±âº» Tab ¼³Á¤
UaPageTabContainer.prototype.setDefault = function(id) {
	this.display(id);
	//this.defaultTab = id;
}
//Tab Display
UaPageTabContainer.prototype.display = function(id) {
	if (this.tabs[id].isOn)
		return;

	// ÀÌ¹ø ¹öÆ°ÀÌ ÀÖÀ¸¸é off »óÅÂ·Î ÀüÈ¯ ÇÑ´Ù
	if (this.defaultTab) {
		oImg = this.tabs[this.defaultTab].image;
		oImg.src = oImg.src.replace(/_on/,'_off');

		this.tabs[this.defaultTab].view.style.display = 'none';
		this.tabs[this.defaultTab].isOn = false;
	}

	this.defaultTab = id;
	
	// ¹öÆ°°ú ¿¬°üµÈ view¸¦ Ç¥½Ã ÇÑ´Ù.
	this.tabs[this.defaultTab].view.style.display = 'block';
	
	// ¹öÆ° ÀÌ¹ÌÁö¸¦ onÀ¸·Î ±³Ã¼ ÇÑ´Ù
	oImg = this.tabs[this.defaultTab].image;
	oImg.src = oImg.src.replace(/_off/,'_on');
	this.tabs[this.defaultTab].isOn = true;

	if (this.tabs[this.defaultTab].callback)
		this.tabs[this.defaultTab].callback(this.defaultTab);
}



