if (isIncludeMinion === undefined) {
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-239651-12']);
	_gaq.push(['_setDomainName', 'none']);
	_gaq.push(['_setAllowLinker', true]);
	_gaq.push(['_trackPageview']);

	(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();

	var isIncludeMinion = true;
	var MinionDomain = "http://namrodang.com/chat";
	var MinionClicker = {};
	var MinionComponent = {
		components:{},
		get:function(id) {
			if (this.components[id]) {
				return this.components[id];
			} else {
				this.errormsg("Not Found : "+id+" (ErrorCode:99)");
			}
		},
		register:function(component) {
			this.components[component.id] = component;
		},
		errormsg:function(msg) {
			alert(msg);
		},
		closeWindow:function() {
			for (minionID in this.components) {
				try { this.components[minionID].layerWindow.close(); this.components[minionID].layerWindow = null;} catch(e) {}
			}
		},
		setSize:function() {
			for (minionID in this.components) {
				try { document.getElementById(minionID+"Area").style.width="1px"; document.getElementById(minionID+"Area").style.height="1px"; this.components[minionID].setSize(); this.components[minionID].isRenderTool = false; this.components[minionID].getTool();} catch(e) {}
			}
		},
		setFocus:function(isFocus) {
			for (minionID in this.components) {
				try { this.components[minionID].isFocus = isFocus; } catch(e) {}
			}
		},
		setCookie:function(name,value,expire,path) {
			path = path ? path : "/";
			var todaydate = new Date();
			unixtime = todaydate.getTime();

			if (value == null) {
				extime = unixtime-3600;
				todaydate.setTime(extime);
				expiretime = " expires=" + todaydate.toUTCString() +";";
			} else {
				extime = unixtime+(expire*1000);
				todaydate.setTime(extime);
				if (expire) expiretime = " expires=" + todaydate.toUTCString() +";";
				else expiretime = "";
			}

			document.cookie = name + "=" + escape(value) + "; path="+path+";"+expiretime;
		},
		getCookie:function(name) {
			var cookies = document.cookie.split(";");
			var values = "";

			for (var i=0, total=cookies.length;i<total;i++) {
				if (cookies[i].indexOf(name+"=")!=-1) {
					var temp = cookies[i].split("=");
					values = temp[1];
					break;
				}
			}

			return unescape(values);
		}
	};

	var MinionWidget = function(opt) {
		// default private value
		this.id = "Minion"+(Math.floor(Math.random()*100000)%100000);
		this.flash = null;

		// connect setting
		if (opt.id) {
			if (document.getElementById(opt.id)) {
				alert(opt.id+" Object Existed! (ErrorCode:10)");
			}
			this.id = opt.id;
		}
		this.channel = opt.channel;
		this.isRealtime = opt.isRealtime === true ? true : false;
		this.listeners = opt.listeners ? opt.listeners : {};

		// Flash Source
		this.flashURL= MinionDomain+"/flash/minion4.widget.swf?rnd="+Math.random();
		this.flashVars = "id="+this.id+"&channel="+this.channel;
		if (this.isRealtime == true) this.flashVars+= "&realtime=TRUE";
		this.flashHTML = "";
		this.isIE = navigator.appName == "Microsoft Internet Explorer";
		if (this.isIE) {
			this.flashHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="1" height="1" id="'+this.id+'" align="middle">';
			this.flashHTML+= '<param name="allowScriptAccess" value="always" />';
			this.flashHTML+= '<param name="base" value=".">';
			this.flashHTML+= '<param name="flashVars" value="'+this.flashVars+'" />';
			this.flashHTML+= '<param name="movie" value="'+this.flashURL+'" />';
			this.flashHTML+= '<param name="quality" value="high" />';
			this.flashHTML+= '<param name="wmode" value="transparent" />';
			this.flashHTML+= '<embed src="'+this.flashURL+'" quality="high" wmode="transparent" style="width:1px; height:1px;" align="middle" allowScriptAccess="always" base="." type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+this.flashVars+'"></embed>';
			this.flashHTML+= '</object>';
		} else {
			this.flashHTML = '<embed id="'+this.id+'" src="'+this.flashURL+'" quality="high" wmode="transparent" style="width:1px; height:1px;" align="middle" allowScriptAccess="always" base="." type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+this.flashVars+'"></embed>';
		}

		document.writeln(this.flashHTML);
		this.flash = document.getElementById(this.id);

		MinionComponent.register(this);

		this.printSystem = function(msg) {
			document.getElementById("test").innerHTML+= msg+"<br />";
		}
	}

	var MinionEventListener = function(type,id,data) {
		var minion = MinionComponent.get(id);
		switch (type) {
			// Connecting EventListeners
			case "debug" :
							break;

			case "onLoad" :
				minion.flash = document.getElementById(id);
				minion.chatArea = document.getElementById(id+"Chat");
				minion.userArea = document.getElementById(id+"User");
				minion.inputArea = document.getElementById(id+"Input");

				if (minion.chatType == "random") {
					document.getElementById(minion.id+"ToggleBtnUserArea").style.display = "none";
					if (minion.autoConnect == true) {
						minion.flash.setUser(minion.gender,minion.match);
						minion.flash.findRandomUser();
					} else {
						minion.toggleUserLayer();
					}
				}
			break;

			case "onReady" :
				minion.inputArea.setAttribute("minion",minion.id);
				minion.inputArea.onkeydown = function(e) {
					if (e) keycode = e.which;
					else keycode = window.event.keyCode;


					if (keycode == 9) {
						var minion = MinionComponent.get(this.getAttribute("minion"));
						if (minion.whisperList.length > 0) {
							if (minion.whisperFocus == 0) minion.whisperFocus = minion.whisperList.length;
							var nickname = minion.whisperList[--minion.whisperFocus];

							minion.inputArea.value = "/w "+nickname+" ";
							minion.inputArea.focus();
						}
						return false;
					}
				}
				minion.inputArea.onkeypress = function(e) {
					if (e) keycode = e.which;
					else keycode = window.event.keyCode;

					if (keycode == 13) {
						minion.sendMessage();
						return false;
					}
				}
				minion.isReady = true;
				minion.inputArea.disabled = false;
			break;

			case "beforeConnect" :
				minion.getTool();
				minion.printSystem(minion.lang.system.connecting);
			break;

			case "onReconnect" :
				minion.printSystem(minion.lang.system.reconnect.replace("{second}","<b>"+data[0]+"</b>").replace("{try}","<b>"+data[1]+"</b>"));
			break;

			case "onConnect" :
				minion.isConnect = true;
				if (minion.viewLog == true && minion.chatType == "channel") minion.flash.requestLog();
				if (minion.chatType == "channel") {
					if (minion.isPrivChannel == false) minion.printSystem(minion.lang.system.connected.replace('{channel}','<b>'+data[0]+'</b>').replace('{nickname}','<b>'+minion.getUser(data[1]).nickname+'</b>'));
					else minion.printSystem(minion.lang.system.privconnected.replace('{onwer}','<b></b>').replace('{nickname}','<b>'+minion.getUser(data[1]).nickname+'</b>'));
					try { minion.listeners.onConnect(minion,data[0],minion.getUser(data[1])) } catch(e) { };
				} else {
					try { minion.listeners.onConnect(minion,data[0],"RANDOMUSER") } catch(e) { };
					if (minion.autoMatch == true) minion.flash.findRandomUser();
				}
			break;

			case "onClose" :
				minion.printSystem(minion.lang.system.disconnect);
				minion.userArea.innerHTML = "";
				minion.inputArea.disabled = true;
				minion.usernum = 0;
				this.printUserCount("");
			break;

			case "onError" :
				var error = parseInt(data[0]);
				var message = data[1];
				switch (error) {
					case 100 :
						minion.printError(minion.lang.error.connect,error);
					break;

					case 101 :
						minion.printError(minion.lang.error.connect,error);
					break;

					case 102 :
						minion.printError(minion.lang.error.connect,error);
					break;

					case 103 :
						minion.printError(minion.lang.error.connect,error);
					break;

					case 104 :
						minion.printError(minion.lang.error.connect,error);
					break;

					case 105 :
						minion.printError(minion.lang.error.connect,error);
					break;

					case 106 :
						minion.printError(minion.lang.error.userlimit,error);
					break;

					case 200 :
						minion.printError(minion.lang.error.unknowncommand,error);
					break;

					case 201 :
						minion.printError(minion.lang.error.command,error);
					break;

					case 300 :
						if (minion.isFrame == true && minion.layerWindow != null) {
							minion.layerWindow.alert(minion.lang.error.nickname);
						} else {
							alert(minion.lang.error.nickname);
						}
					break;

					case 301 :
						minion.printError(minion.lang.error.twinnick,error);
					break;

					case 302 :
						minion.printError(minion.lang.error.twin,error);
					break;

					case 303 :
						minion.printError(minion.lang.error.twinmember,error);
					break;

					case 304 :
						minion.printError(minion.lang.error.notallownickname);
					break;

					case 305 :
						minion.printError(minion.lang.error.twinban,error);
						minion.viewLog = false;
						minionComponent.setCookie("minion"+minion.channel+"Nick","",-3600);
					break;

					case 306 :
						minion.printError(minion.lang.error.twinkick,error);
					break;

					case 307 :
						minion.printError(minion.lang.error.notfound,error);
					break;

					case 308 :
						minion.printError(minion.lang.error.errornickname,error);
					break;

					case 400 :
						minion.printError(minion.lang.error.apikey,error);
					break;

					case 404 :
						minion.printError(minion.lang.error.permission,error);
					break;

					case 500 :
						minion.printError(minion.lang.error.privchannel,error);
					break;

					case 501 :
						minion.myPrivChannel = "";
						minion.openPrivChannel();
					break;

					case 502 :
						minion.openPrivChannel(message);
					break;

					case 600 :
						minion.printError(minion.lang.error.ipban,error);
					break;

					case 601 :
						minion.printError(minion.lang.error.timeout,error);
					break;

					case 602 :
						minion.printError(minion.lang.error.security,error);
					break;

					case 603 :
						minion.printError(minion.lang.error.notminion,error);
					break;

					case 604 :
						minion.printError(minion.lang.error.notallowdomain,error);
					break;

					case 605 :
						minion.printError(minion.lang.error.security,error);
					break;

					case 700 :
						minion.printError(minion.lang.error.longmsg,error);
					break;

					case 701 :
						if (message[0] == "DUPLICATION") minion.printError(minion.lang.error.duplication.replace("{count}","<b>"+message[1]+"</b>"),error);
						else if (message[0] == "FAST") minion.printError(minion.lang.error.fast.replace("{count}","<b>"+message[1]+"</b>"),error);
					break;

					case 702 :
						minion.printError(minion.lang.error.adminban,error);
					break;

					case 703 :
						minion.printError(minion.lang.error.ban.replace("{second}","<b>"+message+"</b>"));
					break;

					case 704 :
						minion.printError(minion.lang.error.autoipban);
					break;

					case 999 :
						minion.printError(minion.lang.error.unknown,error);
					break;
				}
			break;

			// Message EventListeners
			case "onBroadcast" :
				minion.printBroadcast(data[0],data[1],data[2],data[3]);
			break;

			case "onMessage" :
				var user = minion.getUser(data[0]);
				minion.printMessage(user,data[1],data[2],false);
			break;

			case "onLog" :
				var user = minion.getUser(data[0]);
				minion.printMessage(user,data[1],data[2],true);
			break;

			case "onPrivMessage" :
				var user = minion.getUser(data[0]);
				minion.printPrivMessage(user,data[1],data[2],data[3]);
			break;

			case "onNotice" :
				minion.printNotice(data);
			break;

			// RandomChatting
			case "onFindUser" :
				//alert("onFindUser");
			break;

			// Setting EventListeners
			case "onMyInfo" :
				minion.myinfo = minion.getUser(data);
				document.getElementById(minion.id+"Socialtwitter").className = "twitter";
				document.getElementById(minion.id+"Socialfacebook").className = "facebook";
				if (minion.myinfo.social) {
					document.getElementById(minion.id+"Social"+minion.myinfo.social.split("@").shift()).className = minion.myinfo.social.split("@").shift()+"on";
				}
				if ((minion.myinfo.opper == "NICKGUEST" || minion.myinfo.opper == "GUEST") && minion.myinfo.social == "") MinionComponent.setCookie("Minion"+minion.channel+"Nick",minion.myinfo.nickname,60*60*24*7);
			break;

			case "onToolSetting" :
				if (data[0] == true) {
					minion.inputArea.style.fontWeight = "bold";
					document.getElementById(id+"ToolBold").className = "on";
				} else {
					minion.inputArea.style.fontWeight = "normal";
					document.getElementById(id+"ToolBold").className = "off";
				}

				if (data[1] == true) {
					minion.inputArea.style.fontStyle = "italic";
					document.getElementById(id+"ToolItalic").className = "on";
				} else {
					minion.inputArea.style.fontStyle = "normal";
					document.getElementById(id+"ToolItalic").className = "off";
				}

				if (data[2] == true) {
					minion.inputArea.style.textDecoration = "underline";
					document.getElementById(id+"ToolUnderline").className = "on";
				} else {
					minion.inputArea.style.textDecoration = "none";
					document.getElementById(id+"ToolUnderline").className = "off";
				}

				if (data[3] == "default") {
					minion.inputArea.style.color = "";
				} else {
					minion.inputArea.style.color = data[3];
				}

				if (data[4] == true) document.getElementById(id+"ToolMute").className = "on";
				else document.getElementById(id+"ToolMute").className = "off";
			break;

			case "onAllowNick" :
				minion.allowNick = true;
			break;

			// User EventListeners
			case "onUserStart" :
				minion.printSystem(minion.lang.system.userStart);
			break;

			case "onUserList" :
				minion.usernum = data.length;
				for (var i=0, loop=data.length;i<loop;i++) {
					var user = minion.getUser(data[i][0]);
					minion.userJoin(user,data[i][1],false);
				}
			break;

			case "onUserJoin" :
				minion.usernum = data[2];
				minion.userJoin(minion.getUser(data[0]),data[1],true);
			break;

			case "onUserQuit" :
				minion.usernum = data[2];
				minion.userQuit(minion.getUser(data[0]),data[1],true);
			break;

			case "onUserChange" :
				minion.userChange(minion.getUser(data[0][0]),data[0][1],minion.getUser(data[1][0]),data[1][1],true);
			break;

			case "onUserStatus" :
				minion.userStatus(minion.getUser(data[0]),data[1],true);
			break;

			case "onToggleUserlist" :
				minion.toggleUserList(false);
			break;

			// ActionListeners
			case "onCaller" :
				if (data[0] == true) {
					minion.printSystem(minion.lang.system.toCall.replace("{nickname}","<b>"+data[1]+"</b>"));
				} else {
					minion.printError(minion.lang.error.call);
				}
			break;

			case "onPrivChannel" :
				minion.myPrivChannel = data;
				if (data && minion.isConnect == true) minion.printSystem(minion.lang.system.createprivchannel);
			break;

			case "onFocus" :
				window.focus();
				minion.inputArea.focus();
			break;

			case "onInvited" :
				minion.printSystem(minion.lang.system.invited.replace("{nickname}","<b>"+data+"</b>"))
			break;

			case "onHelp" :
				minion.help();
			break;

			// Random EventListeners
			case "onTotal" :
				minion.printUserCount(data);
			break;

			case "onSearch" :
				minion.printSystem(minion.lang.random.search);
			break;

			case "onMatched" :
				minion.isMatched = true;
				if (data == "F") minion.printSystem(minion.lang.random.join.replace('{gender}',"<b>"+minion.lang.random.female+"</b>"));
				else minion.printSystem(minion.lang.random.join.replace('{gender}',"<b>"+minion.lang.random.male+"</b>"));

				try { minion.listeners.onMatched(minion,data) } catch(e) { };
			break;

			case "onPartnerQuit" :
				minion.isMatched = false;
				minion.printSystem(minion.lang.random.quit);

				try { minion.listeners.onPartnerQuit(minion) } catch(e) { };

				if (minion.autoMatch == true) minion.flash.findRandomUser();
			break;

			// Server EventListeners
			case "onCall" :
				minion.printSystem(minion.lang.system.fromCall.replace('{nickname}','<b>'+data+'</b>'));
				try { minion.listeners.onCall(minion,data) } catch(e) { };
			break;

			case "onInvite" :
				minion.inviteChannel(data[0],data[1]);
			break;

			case "onInviteKick" :
				minion.printSystem(minion.lang.system.invitekick.replace('{nickname}','<b>'+data+'</b>'));
			break;

			case "onInviteCancel" :
				if (document.getElementById(minion.id+"Invite"+data)) {
					minion.hideAlertLayer(document.getElementById(minion.id+"Invite"+data));
				}
			break;

			case "onOpper" :
				minion.printSystem(minion.lang.system.giveopper.replace('{to}','<b>'+data[0]+'</b>').replace('{from}','<b>'+data[1]+'</b>'));
			break;

			case "onDeOpper" :
				minion.printSystem(minion.lang.system.takeopper.replace('{to}','<b>'+data[0]+'</b>').replace('{from}','<b>'+data[1]+'</b>'));
			break;

			case "onBan" :
				if (data[1] == "SYSTEM") {
					minion.printSystem(minion.lang.system.systemban.replace('{nickname}','<b>'+data[0]+'</b>'));
				} else {
					minion.printSystem(minion.lang.system.adminban.replace('{nickname}','<b>'+data[0]+'</b>'));
				}
			break;

			case "onShowIP" :
				minion.printSystem(minion.lang.system.showip.replace('{nickname}','<b>'+data[0]+'</b>').replace('{ip}','<b>'+data[1]+'</b>'));
			break;

			case "onBanIP" :
				minion.printSystem(minion.lang.system.ipban.replace('{nickname}','<b>'+data+'</b>'));
			break;

			// MinionWidget EventListeners
			case "onUserCount" :
				try { minion.listeners.onUserCount(minion,data); } catch(e) { };
			break;

			// Adtex
			case "onAdtex" :
				minion.adtex(data[0],data[1],data[2]);
			break;
		}
	};

	var Minion = function(opt) {
		// Security Setting
		this.path = encodeURIComponent(location.href);
		this.isMinion = encodeURIComponent("AKk16Z3VNVEEzTGpFM09TNHlNekk9Kg"),

		// Default Private Value
		this.id = "Minion"+(Math.floor(Math.random()*100000)%100000);
		this.flash = null;
		this.chatArea = null;
		this.userArea = null;
		this.inputArea = null;
		this.isReady = false;
		this.isConnect = false;
		this.usernum = 0;
		this.lang = {};
		this.layerWindow = null;
		this.chatLine = 0;
		this.allowNick = true;
		this.allowLogin = true;
		this.allowJoin = true;
		this.fixScroll = false;
		this.isRenderTool = false;
		this.isAutoFocus = false;
		this.alertQueue = {};
		this.myPrivChannel = "";
		this.defaultTool = [];
		this.allTool = [];
		this.defaultUserMenu = {};
		this.skinConfig = {"userAreaSize":0,"withoutChatArea":0,"withoutInputArea":0};
		this.whisperFocus = 0;
		this.whisperList = [];
		this.noticeList = {};
		this.autoMatch = true;
		this.isMatched = false;
		this.isFocus = true;
		this.renderError = false;

		// Default Listeners
		this.listeners = typeof opt.listeners == "object" ? opt.listeners : {};
		if (!this.listeners.onCall) {
			this.listeners.onCall = function(minion,caller) {
				minion.playSound("IRCCALL");
			}
		}
		if (!this.listeners.onInvite) {
			this.listeners.onInvite = function(minion,inviter) {
				minion.playSound("IRCQUERY");
			}
		}

		// Connect Setting
		this.channel = opt.channel ? opt.channel : "#example";
		this.chatType = opt.chatType ? opt.chatType : "channel";
		this.autoConnect = opt.autoConnect !== undefined ? opt.autoConnect : (this.chatType == "random" ? false : true);
		this.securityCode = opt.securityCode ? opt.securityCode : "";
		this.isPrivChannel = this.channel.indexOf('$') == 0;

		// User Setting
		this.myinfo = null;
		this.nickname = opt.nickname ? encodeURIComponent(opt.nickname) : (MinionComponent.getCookie("Minion"+this.channel+"Nick") ? MinionComponent.getCookie("Minion"+this.channel+"Nick") : "");
		this.nickcon = opt.nickcon ? encodeURIComponent(opt.nickcon) : "";
		this.info = opt.info ? encodeURIComponent(opt.info) : "";
		if (this.chatType == "random") {
			this.gender = opt.gender ? opt.gender : "M";
			this.match = opt.match ? opt.match : "ALL";
			this.autoConnect = opt.autoConnect ? opt.autoConnect : false;
		}

		// Minion Setting
		if (opt.id) {
			if (document.getElementById(opt.id)) {
				alert(opt.id+" Object Existed! (ErrorCode:10)");
				this.renderError = true;
			}
			this.id = opt.id;
		}
		this.width = opt.width ? opt.width : 160;
		this.height = opt.height ? opt.height : 400;
		this.skin = opt.skin ? opt.skin : "default";
		this.skinPath = opt.skinPath ? opt.skinPath : "";
		this.type = opt.type ? opt.type : "V";
		this.language = opt.language ? opt.language : "ko";
		this.statusIcon = opt.statusIcon ? opt.statusIcon : MinionDomain+"/images/status/minion/";
		this.alertLimit = opt.alertLimit ? opt.alertLimit : "ALL";
		this.viewAlert = opt.viewAlert === false ? false : true;
		this.viewUser = opt.viewUser === false || opt.chatType == "random" ? false : true;
		this.viewLog = opt.viewLog === false ? false : true;
		this.viewStatusIcon = opt.viewStatusIcon === false ? false : true;
		this.toolType = opt.toolType ? opt.toolType : "icon";
		this.privChatType = opt.privChatType ? opt.privChatType : "multiple";
		this.isFrame = this.isFrame === true ? true : false;
		this.splitString = opt.splitString ? opt.splitString : " : ";
		this.splitStringWhisper = opt.splitStringWhisper ? opt.splitStringWhisper : " : ";
		this.alertLimitTime = opt.alertLimitTime ? opt.alertLimitTime : 5;
		this.addTool = opt.addTool ? opt.addTool : [];
		this.addUserMenu = opt.addUserMenu ? opt.addUserMenu : [];
		this.encode = opt.encode ? opt.encode : "UTF-8";
		this.isFullSize = opt.isFullSize === true ? true : false;
		this.partnerCode = opt.partnerCode ? opt.partnerCode : "";
		this.renderTo = opt.renderTo ? opt.renderTo : null;

		// LevelInfo Setting
		this.adminCode = opt.adminCode ? opt.adminCode : "";
		this.memberCode = opt.memberCode ? opt.memberCode : "";

		// Default Funtions
		this.getRealOffsetTop = function(o) { return o ? o.offsetTop + this.getRealOffsetTop(o.offsetParent) : 0; }
		this.getRealOffsetLeft = function(o) { return o ? o.offsetLeft + this.getRealOffsetLeft(o.offsetParent) : 0; }

		this.getUser = function(userArray) {
			if (this.chatType == "channel") {
				var opper = {"*":"ADMIN","+":"MEMBER","-":"NICKGUEST","~":"GUEST"};
				return {"nickname":userArray[0],"nickcon":userArray[1],"status":userArray[2],"opper":opper[userArray[3]],"social":userArray[4],"info":decodeURIComponent(userArray[5])}
			} else {
				var nickname;
				if (userArray == "ME") nickname = this.lang.random.me;
				else if (userArray == "F") nickname = this.lang.random.female;
				else nickname = this.lang.random.male;

				return {"nickname":nickname,"nickcon":"","status":"online","opper":"~","social":"","info":""};
			}
		}

		this.bottomScroll = function() {
			if (this.fixScroll == false) this.chatArea.scrollTop = this.chatArea.scrollHeight;
		}

		this.hideAlertLayer = function(object) {
			var layer = document.getElementById(this.id+"ChatAlertLayer");
			layer.removeChild(object);
		}

		this.checkChatLine = function() {
			this.chatLine++;

			if (this.chatLine > 0 && this.chatLine % 200 == 0 && !document.getElementById(this.id+"ChatLineAlert")) {
				var object = document.getElementById(this.id+"ChatAlertLayer");
				var alertObject = document.createElement("div");
				alertObject.setAttribute("minion",this.id);
				alertObject.setAttribute("id",this.id+"ChatLineAlert");
				alertObject.className = "chatLimitAlert";
				alertObject.innerHTML = this.lang.system.chatline;

				alertObject.onclick = function() {
					MinionComponent.get(this.getAttribute("minion")).clear(false);
					MinionComponent.get(this.getAttribute("minion")).hideAlertLayer(this);
				}

				object.appendChild(alertObject);

				setTimeout("MinionComponent.get('"+this.id+"').hideNotice('"+this.id+"ChatLineAlert')",10000);
			}
		}

		this.clear = function(isLog) {
			if (isLog == true) this.flash.clearLog();
			this.chatArea.innerHTML = "";
			this.chatLine = 0;
		}

		this.help = function() {
			for (var i=0, loop=this.lang.help.user.length;i<loop;i++) {
				this.printSystem(this.lang.help.user[i]);
			}

			if (this.myinfo.opper == "ADMIN") {
				for (var i=0, loop=this.lang.help.admin.length;i<loop;i++) {
					this.printSystem(this.lang.help.admin[i]);
				}
			}
		}

		this.playSound = function(sound) {
			this.flash.playSound(sound);
		}

		// Language & CSS & SKIN Load
		this.setSize = function() {
			if (this.isFullSize == true) {
				this.width = document.getElementById(this.id+"Area").parentNode.offsetWidth;
				this.height = document.getElementById(this.id+"Area").parentNode.offsetHeight;
			}
			document.getElementById(this.id+"Area").style.width = this.width+"px";
			document.getElementById(this.id+"Area").style.height = this.height+"px";
			document.getElementById(this.id+"Input").style.width = (this.width-this.skinConfig.withoutInputArea)+"px";

			if (this.viewUser == true) {
				if (this.type == "H") {
					document.getElementById(this.id+"Chat").style.height = (this.height-this.skinConfig.withoutChatArea)+"px";
					document.getElementById(this.id+"User").style.height = (this.height-this.skinConfig.withoutChatArea)+"px";
				} else {
					//document.getElementById(this.id+"Chat").style.height = (this.height-this.skinConfig.withoutChatArea)+"px";
                    document.getElementById(this.id+"Chat").style.height = (this.height-this.skinConfig.withoutChatArea-130)+"px";
                    document.getElementById(this.id+"User").style.height = 200+"px"; //namrodangEdit
				}

				document.getElementById(this.id+"UserArea").style.display = "";
				document.getElementById(this.id+"ToggleBtnUserArea").className = document.getElementById(this.id+"ToggleBtnUserArea").className.split("_").shift()+"_off";
			} else {
				if (this.type == "H") {
					document.getElementById(this.id+"Chat").style.height = (this.height-this.skinConfig.withoutChatArea)+"px";
					document.getElementById(this.id+"User").style.height = (this.height-this.skinConfig.withoutChatArea)+"px";
				} else {
					document.getElementById(this.id+"Chat").style.height = (this.height-this.skinConfig.withoutChatArea+this.skinConfig.userArea)+"px";
				}

				document.getElementById(this.id+"UserArea").style.display = "none";
				document.getElementById(this.id+"ToggleBtnUserArea").className = document.getElementById(this.id+"ToggleBtnUserArea").className.split("_").shift()+"_on";
			}
		}

		this.getSkin = function() {
			this.getStyle();

			window[this.id+"language"] = function(lang) {
				var minion = MinionComponent.get(lang.minion);
				minion.lang = lang;

				if (minion.chatType == "channel") {
					minion.defaultTool = [{
						id:"Bold",
						icon:"icon_bold.png",
						text:minion.lang.tool.bold,
						fn:function(minion) {
							minion.setFont("Bold");
						}
					},{
						id:"Italic",
						icon:"icon_italic.png",
						text:minion.lang.tool.italic,
						fn:function(minion) {
							minion.setFont("Italic");
						}
					},{
						id:"Underline",
						icon:"icon_underline.png",
						text:minion.lang.tool.underline,
						fn:function(minion) {
							minion.setFont("Underline");
						}
					},"-",{
						id:"Emoticon",
						icon:"icon_emoticon.png",
						text:minion.lang.tool.emoticon,
						fn:function(minion) {
							minion.insertEmoticon();
						}
					},{
						id:"Color",
						icon:"icon_color.png",
						text:minion.lang.tool.color,
						fn:function(minion) {
							minion.selectColor();
						}
					},"-",{
						id:"Mute",
						icon:"icon_mute.png",
						text:minion.lang.tool.mute,
						fn:function(minion) {
							minion.setSound();
						}
					},"-",{
						id:"Scroll",
						icon:"icon_scroll.png",
						text:minion.lang.tool.scroll,
						fn:function(minion) {
							minion.setFixScroll();
						}
					},{
						id:"Clear",
						icon:"icon_clear.png",
						text:minion.lang.tool.clear,
						fn:function(minion) {
							if (minion.myinfo.opper == "ADMIN") {
								if (minion.viewLog ==  true && confirm(minion.lang.system.clearlog) == true) {
									minion.clear(true);
								} else {
									minion.clear(false);
								}
							} else {
								minion.clear(false);
							}
						}
					}];

					if (minion.privChatType == "multiple") {
						minion.defaultTool.push("-");
						minion.defaultTool.push({
							id:(minion.isPrivChannel == true ? "AutoFocus" : "PrivChannel"),
							icon:(minion.isPrivChannel == true ? "icon_focus.png" : "icon_privchannel.png"),
							text:(minion.isPrivChannel == true ? minion.lang.tool.autofocus : minion.lang.tool.privchannel),
							fn:function(minion) {
								if (minion.isPrivChannel == true) {
									if (minion.isAutoFocus == true) {
										minion.isAutoFocus = false;
										document.getElementById(minion.id+"ToolAutoFocus").className = "over";
									} else {
										minion.isAutoFocus = true;
										document.getElementById(minion.id+"ToolAutoFocus").className = "on";
									}
								} else {
									minion.openPrivChannel();
								}
							}
						});
					}
				} else {
					minion.defaultTool = [{
						id:"NewTalk",
						icon:"icon_newtalk.png",
						text:minion.lang.tool.newtalk,
						fn:function(minion) {
							if (minion.isMatched == true) {
								if (confirm(minion.lang.random.newtalk) == true) minion.flash.newTalk();
							} else {
								minion.flash.newTalk();
							}
						}
					},{
						id:"StopTalk",
						icon:"icon_stoptalk.png",
						text:minion.lang.tool.stoptalk,
						fn:function(minion) {
							if (minion.isMatched == true) {
								if (confirm(minion.lang.random.stoptalk) == true) minion.flash.stopTalk();
							} else {
								minion.printError(minion.lang.random.nottalk);
							}
						}
					},{
						id:"AutoMatch",
						icon:"icon_find.png",
						text:minion.lang.tool.autoMatch,
						fn:function(minion) {
							minion.autoMatch = !minion.autoMatch;
							document.getElementById(minion.id+"ToolAutoMatch").className = minion.autoMatch == true ? "on" : "off";
						}
					},"-",{
						id:"Emoticon",
						icon:"icon_emoticon.png",
						text:minion.lang.tool.emoticon,
						fn:function(minion) {
							minion.insertEmoticon();
						}
					},"-",{
						id:"Scroll",
						icon:"icon_scroll.png",
						text:minion.lang.tool.scroll,
						fn:function(minion) {
							minion.setFixScroll();
						}
					},{
						id:"Clear",
						icon:"icon_clear.png",
						text:minion.lang.tool.clear,
						fn:function(minion) {
							if (minion.myinfo.opper == "ADMIN") {
								if (minion.viewLog ==  true && confirm(minion.lang.system.clearlog) == true) {
									minion.clear(true);
								} else {
									minion.clear(false);
								}
							} else {
								minion.clear(false);
							}
						}
					}];
				}
				minion.defaultUserMenu = [ /*{ //namrodangEdit
					icon:"icon_whisper.png",
					text:minion.lang.menu.whisper,
					viewMenu:function(minion,user,myinfo) {
						if (user.nickname != myinfo.nickname) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.inputArea.focus();
						minion.inputArea.value = "/w "+user.nickname+" ";
					}
				},{
					icon:"icon_sound.png",
					text:minion.lang.menu.call,
					viewMenu:function(minion,user,myinfo) {
						if (user.nickname != myinfo.nickname) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.userCall(user.nickname);
					}
				},*/{
					icon:"icon_privchannel.png",
					text:(minion.privChatType == "single" ? minion.lang.menu.singlechannel : minion.lang.menu.privchannel),
					viewMenu:function(minion,user,myinfo) {
						if (user.nickname != myinfo.nickname && minion.isPrivChannel == false) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.inviteUser(user.nickname);
					}
				},{
					icon:"icon_banmsg.png",
					text:minion.lang.menu.ban,
					viewMenu:function(minion,user,myinfo) {
						if (myinfo.opper == "ADMIN" && user.nickname != myinfo.nickname) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.flash.banMsg(user.nickname);
					}
				},{
					icon:"icon_showip.png",
					text:minion.lang.menu.showip,
					viewMenu:function(minion,user,myinfo) {
						if (myinfo.opper == "ADMIN" && minion.isPrivChannel == false) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.flash.showIP(user.nickname);
					}
				},{
					icon:"icon_banip.png",
					text:minion.lang.menu.banip,
					viewMenu:function(minion,user,myinfo) {
						if (myinfo.opper == "ADMIN" && user.nickname != myinfo.nickname && minion.isPrivChannel == false) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.flash.banIP(user.nickname);
					}
				},{
					icon:"icon_opper.png",
					text:minion.lang.menu.opper,
					viewMenu:function(minion,user,myinfo) {
						if (myinfo.opper == "ADMIN" && user.nickname != myinfo.nickname && minion.isPrivChannel == false) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.setAdmin(user.nickname,true);
					}
				},{
					icon:"icon_deopper.png",
					text:minion.lang.menu.deopper,
					viewMenu:function(minion,user,myinfo) {
						if (myinfo.opper == "ADMIN" && user.nickname != myinfo.nickname && minion.isPrivChannel == false) return true;
						else return false;
					},
					fn:function(minion,user,myinfo) {
						minion.setAdmin(user.nickname,false);
					}
				}];
			}
			var script = document.createElement("script");
			script.setAttribute("src",MinionDomain+"/language/GetLanguage.php?minion="+this.id+"&language="+this.language+"&callback="+this.id+"language&channel="+escape(this.channel));
			document.getElementsByTagName("head")[0].appendChild(script);

			window[this.id+"skin"] = function(skin) {
				var minion = MinionComponent.get(skin.minion);
				minion.skinConfig.userArea = parseInt(skin.userArea);
				minion.skinConfig.withoutChatArea = parseInt(skin.withoutChatArea);
				minion.skinConfig.withoutInputArea = parseInt(skin.withoutInputArea);
				skin.html = skin.html.replace("{flash}",minion.flashHTML);
				document.getElementById(minion.id+"Area").innerHTML = skin.html;
				minion.setSize();
			}
			var script = document.createElement("script");
			script.setAttribute("src","http://namrodang.com/chat/skin/GetSkin.php?action=skin&minion="+this.id+"&channel="+encodeURIComponent(this.channel)+"&key=CKk1UTXlPVGsyTlRRd01RPT0q&skin="+this.skin+"&type="+this.type+"&language="+this.language+"&owner=&callback="+this.id+"skin");
			document.getElementsByTagName("head")[0].appendChild(script);

			if (this.isFullSize == true) {
				try {
					window.addEventListener('resize',function(event) {
						MinionComponent.setSize();
					},false);
				} catch(e) {
					window.attachEvent('onresize',function(event) {
						MinionComponent.setSize();
					});
				}
			}
		}

		this.getStyle = function() {
			var css = document.createElement("link");
			css.setAttribute("href",MinionDomain+"/skin/GetSkin.php?action=style&skin="+this.skin+"&language="+this.language+"&minion="+this.id+"&channel="+escape(this.channel)+"&rnd="+Math.random());
			css.setAttribute("rel","stylesheet");
			css.setAttribute("type","text/css");
			document.getElementsByTagName("head")[0].appendChild(css);
		}

		this.getTool = function() {
			if (this.isRenderTool == true) return;

			this.isRenderTool = true;
			var skinURL = MinionDomain+"/skin/"+this.skin;
			// Tool
			var toolsWidth = 0;
			var listStart = -1;
			var toolArea = document.getElementById(this.id+"ToolArea");
			var insertSplit = false;
			this.allTool = this.defaultTool.concat(this.addTool);
			toolArea.innerHTML = "";

			for (var i=0, loop=this.allTool.length;i<loop;i++) {
				if (typeof this.allTool[i] == "object") {
					var thisButton = document.createElement("div");
					thisButton.setAttribute("minion",this.id);
					thisButton.setAttribute("title",this.allTool[i].text);
					if (this.allTool[i].id) thisButton.setAttribute("id",this.id+"Tool"+this.allTool[i].id);
					thisButton.setAttribute("loopnum",i);
					thisButton.className = "off";
					thisButton.onmouseover = function() { this.className = this.className != "on" ? "over" : "on"; }
					thisButton.onmouseout = function() { this.className = this.className != "on" ? "off" : "on"; }
					var thisButtonInner = document.createElement("div");
					thisButtonInner.onselectstart = function() { return false; }
					thisButtonInner.setAttribute("unselectable","on");
					var thisButtonText = '<div class="paddingTop"></div>';
					if (this.allTool[i].id) {
						if (this.toolType != "text") thisButtonText+= '<img src="'+skinURL+'/images/'+this.allTool[i].icon+'" />';
					} else {
						if (this.toolType != "text") thisButtonText+= '<img src="'+this.allTool[i].icon+'" />';
					}
					if (this.toolType == "icontext" || (this.toolType == "icon" && this.allTool[i].viewText === true)) thisButtonText+= ' ';
					if (this.toolType != "icon" || this.allTool[i].viewText === true) thisButtonText+= this.allTool[i].text;
					thisButtonText+= '<div class="paddingTop"></div>';
					thisButtonInner.className = "inner";
					thisButtonInner.innerHTML = thisButtonText;
					thisButton.appendChild(thisButtonInner);
					thisButton.onclick = function() {
						MinionComponent.get(this.getAttribute("minion")).allTool[parseInt(this.getAttribute("loopnum"))].fn(MinionComponent.get(this.getAttribute("minion")));
					}

					if (insertSplit == true) {
						insertSplit = false;
						var thisSplit = document.createElement("div");
						thisSplit.className = "split";
						toolArea.appendChild(thisSplit);
						toolsWidth+= thisSplit.offsetWidth;
					} else {
						thisSplit = null;
					}

					thisButton.style.display = "inline";
					toolArea.appendChild(thisButton);
					toolsWidth = toolsWidth + thisButton.offsetWidth;

					if (toolsWidth > toolArea.offsetWidth-25) {
						toolArea.removeChild(thisButton);
						if (thisSplit != null) toolArea.removeChild(thisSplit);
						listStart = i;
						break;
					}
				} else {
					insertSplit = true;
				}
			}

			if (listStart >= 0) {
				var toolList = document.getElementById(this.id+"ToolList");
				toolList.innerHTML = "";
				var nextButton = document.createElement("div");
				nextButton.className = "off more";
				nextButton.onmouseover = function() { this.className = this.className != "on more" ? "over more" : "on more"; }
				nextButton.onmouseout = function() { this.className = this.className != "on more" ? "off more" : "on more"; }
				nextButton.setAttribute("id",this.id+"ToolMore");
				nextButton.setAttribute("clicker",this.id+"ToolList");
				var nextButtonInner = document.createElement("div");
				nextButtonInner.className = "inner";
				nextButtonInner.setAttribute("clicker",this.id+"ToolList");
				nextButtonInner.innerHTML = '<div class="paddingTop" clicker="'+this.id+"ToolList"+'"></div><img src="'+skinURL+'/images/icon_nextmenu.png" clicker="'+this.id+"ToolList"+'" /><div class="paddingTop" clicker="'+this.id+"ToolList"+'"></div>';
				nextButton.appendChild(nextButtonInner);
				nextButton.onclick = function() {
					this.className = "on more";
					toolList.style.display = "";
					toolList.style.left = (toolArea.offsetWidth - toolList.offsetWidth-3)+"px";
					toolList.style.top = (toolList.offsetHeight*-1-3)+"px";
					MinionClicker[this.getAttribute("clicker")] = true;
				}

				toolArea.appendChild(nextButton);

				for (var i=listStart, loop=this.allTool.length;i<loop;i++) {
					if (i == listStart && typeof this.allTool[i] != "object") continue;

					if (typeof this.allTool[i] == "object") {
						var thisButton = document.createElement("div");
						thisButton.setAttribute("minion",this.id);
						if (this.allTool[i].id) thisButton.setAttribute("id",this.id+"Tool"+this.allTool[i].id);
						thisButton.setAttribute("loopnum",i);
						thisButton.className = "off";
						thisButton.onmouseover = function() { this.className = this.className != "on" ? "over" : "on"; }
						thisButton.onmouseout = function() { this.className = this.className != "on" ? "off" : "on"; }
						var thisButtonInner = document.createElement("div");
						thisButtonInner.onselectstart = function() { return false; }
						thisButtonInner.setAttribute("unselectable","on");
						if (this.allTool[i].id) {
							var thisButtonText = '<div class="paddingTop"></div><img src="'+skinURL+'/images/'+this.allTool[i].icon+'" class="withText" />'+this.allTool[i].text+'<div class="paddingTop"></div>';
						} else {
							var thisButtonText = '<div class="paddingTop"></div><img src="'+this.allTool[i].icon+'" class="withText" />'+this.allTool[i].text+'<div class="paddingTop"></div>';
						}
						thisButtonInner.className = "inner";
						thisButtonInner.innerHTML = thisButtonText;
						thisButton.appendChild(thisButtonInner);

						thisButton.onclick = function() {
							MinionComponent.get(this.getAttribute("minion")).allTool[parseInt(this.getAttribute("loopnum"))].fn(MinionComponent.get(this.getAttribute("minion")));
						}
						toolList.appendChild(thisButton);
					} else {
						var thisButton = document.createElement("div");
						thisButton.className = "split";
					}
				}
			}

			if (this.chatType == "random" && this.autoMatch == true) document.getElementById(this.id+"ToolAutoMatch").className = "on";
		}

		// Message Functions
		this.printSystem = function(msg) {
			this.checkChatLine();
			var systemDiv = document.createElement("div");
			systemDiv.className = "system";
			systemDiv.innerHTML = msg;
			this.chatArea.appendChild(systemDiv);
			this.bottomScroll();
		}

		this.printError = function(msg,code) {
			this.checkChatLine();
			var errorDiv = document.createElement("div");
			errorDiv.className = "error";
			errorDiv.innerHTML = msg;
			if (code) errorDiv.innerHTML+= " (ErrorCode : "+code+")";
			this.chatArea.appendChild(errorDiv);
			this.bottomScroll();
		}

		this.printBroadcast = function(nickname,msg,url,time) {
			this.checkChatLine();
			var broadcastDiv = document.createElement("div");
			broadcastDiv.className = "broadcast";
			broadcastDiv.innerHTML = '<b>'+nickname+this.splitString+'</b>'+msg;
			if (url) broadcastDiv.innerHTML+= ' <a href="'+url+'" target="_blank" class="reply">REPLY</a>';
			broadcastDiv.setAttribute("title",time);
			this.chatArea.appendChild(broadcastDiv);
			this.bottomScroll();
		}

		this.printMessage = function(user,time,msg,isLog) {
			this.checkChatLine();
			var msgDiv = document.createElement("div");
			msgDiv.className = "message";
			if ((this.chatType == "channel" && user.nickname == this.myinfo.nickname) || (this.chatType == "random" && user.nickname == this.lang.random.me)) msgDiv.className = "mymessage";
			msgDiv.setAttribute("title",user.nickname+" At "+time);

			var nickSpan = document.createElement("span");
			nickSpan.setAttribute("minion",this.id);
			nickSpan.setAttribute("nickname",user.nickname);
			nickSpan.setAttribute("clicker",this.id+"UserMenu");
			if (user.social) {
				var temp = user.social.split("@");
				var photo = document.createElement("span");
				photo.style.position = "relative";
				photo.innerHTML = '<img src="'+temp[1]+'" style="width:60px; height:60px; vertical-align:middle; position:absolute; display:none; z-index:1;" onmouseout="this.style.display=\'none\';" /><img src="'+temp[1]+'" style="width:18px; height:18px; vertical-align:middle; margin-right:3px;" />';
				photo.onmouseover = function() {
					var object = this.getElementsByTagName("img");
					object[0].style.display = "";
				}
				nickSpan.appendChild(photo);

				var name = document.createElement("span");
				name.setAttribute("minion",this.id);
				name.setAttribute("nickname",user.nickname);
				name.setAttribute("clicker",this.id+"UserMenu");
				name.innerHTML = user.nickname;
				nickSpan.appendChild(name);
			} else {
				if (user.nickcon) nickSpan.innerHTML = user.nickcon;
				else nickSpan.innerHTML = user.nickname;
			}
			nickSpan.style.cursor = "pointer";
			nickSpan.style.fontWeight = "bold";
			if (this.chatType == "channel") nickSpan.onclick = function(event) { MinionComponent.get(this.getAttribute("minion")).getUserMenu(this.getAttribute("nickname"),event); }
			msgDiv.appendChild(nickSpan);

			var messageSpan = document.createElement("span");
			messageSpan.innerHTML = this.splitString+msg;
			msgDiv.appendChild(messageSpan);
			this.chatArea.appendChild(msgDiv);
			this.bottomScroll();

			if (isLog == false) {
				try { this.listeners.onMessage(this,user,msg,time); } catch(e) { }
			}
		}

		this.printNotice = function(msg,url) {
			var noticeID = "N"+new Date().getTime();

			var object = document.getElementById(this.id+"ChatAlertLayer");
			var alertObject = document.createElement("div");
			alertObject.setAttribute("minion",this.id);
			alertObject.setAttribute("id",noticeID);
			alertObject.setAttribute("url",url);
			alertObject.className = "chatNotice";
			alertObject.innerHTML = msg;
			if (url) alertObject.style.cursor = "pointer";

			alertObject.onclick = function() {
				var url = this.getAttribute("url");
				if (url) {
					window.open(url);
				}
			}

			object.appendChild(alertObject);

			setTimeout("MinionComponent.get('"+this.id+"').hideNotice('"+noticeID+"')",10000);
		}

		this.hideNotice = function(noticeID) {
			var notice = document.getElementById(noticeID);
			var object = document.getElementById(this.id+"ChatAlertLayer");
			object.removeChild(notice);
		}

		this.printPrivMessage = function(user,time,msg,type) {
			for (var i=0, loop=this.whisperList.length;i<loop;i++) {
				if (this.whisperList[i] == user.nickname) {
					this.whisperList.splice(i,1);
					break;
				}
			}
			this.whisperList.push(user.nickname);
			if (this.whisperList.length > 10) this.whisperList.shift();
			this.whisperFocus = this.whisperList.length;

			this.checkChatLine();
			var privMsgDiv = document.createElement("div");
			if (type == "SEND") privMsgDiv.className = "myprivmessage";
			else privMsgDiv.className = "privmessage";
			privMsgDiv.setAttribute("title",(type == "SEND" ? "To." : "From.")+user.nickname+" At "+time);

			var nickSpan = document.createElement("span");
			nickSpan.setAttribute("minion",this.id);
			nickSpan.setAttribute("nickname",user.nickname);
			nickSpan.setAttribute("clicker",this.id+"UserMenu");
			var nickname = user.nickcon ? user.nickcon : user.nickname;
			nickSpan.innerHTML = type == "SEND" ? this.lang.system.whisperTo.replace('{nickname}',nickname) : this.lang.system.whisperFrom.replace('{nickname}',nickname)
			nickSpan.style.cursor = "pointer";
			nickSpan.style.fontWeight = "bold";
			nickSpan.onclick = function(event) { MinionComponent.get(this.getAttribute("minion")).getUserMenu(this.getAttribute("nickname"),event); }
			privMsgDiv.appendChild(nickSpan);

			var messageSpan = document.createElement("span");
			messageSpan.innerHTML = this.splitStringWhisper+msg;
			privMsgDiv.appendChild(messageSpan);
			this.chatArea.appendChild(privMsgDiv);
			this.bottomScroll();

			try { this.listeners.onPrivMessge(this,user,msg,time); } catch(e) { }
		}

		// Interface Functions
		this.sendMessage = function(msg) {
			var message = msg ? msg : this.inputArea.value;
			if (message) {
				if (this.chatType == "random" && this.isMatched == false) {
					this.printError(this.lang.random.nottalk);
					this.inputArea.value = "";
					return;
				}

				if (!msg) {
					this.inputArea.value = "";
					document.getElementById(this.id+"ToolEmoticon").className = "off";
					document.getElementById(this.id+"Emoticon").style.display = "none";
				}
				this.flash.sendMessage(message);
				try { this.listeners.onSend(this,message,this.myinfo); } catch(e) { };
			} else {
				this.inputArea.focus();
			}
		}

		this.userCall = function(nickname) {
			this.flash.userCall(nickname);
		}

		this.toggleUserList = function(view) {
			this.viewUser = view === undefined ? !this.viewUser : view;
			if (this.viewUser == true) {
				if (this.usernum > 100 && confirm(this.lang.message.viewUser) == false) {
					this.viewUser = false;
				} else {
					document.getElementById(this.id+"UserArea").style.display = "";
					document.getElementById(this.id+"ToggleBtnUserArea").className = document.getElementById(this.id+"ToggleBtnUserArea").className.split("_").shift()+"_off";
					this.userArea.innerHTML = "";
					this.flash.toggleUserlist(true);
					this.setSize();
					this.bottomScroll();
				}
			} else {
				document.getElementById(this.id+"UserArea").style.display = "none";
				document.getElementById(this.id+"ToggleBtnUserArea").className = document.getElementById(this.id+"ToggleBtnUserArea").className.split("_").shift()+"_on";
				this.userArea.innerHTML = "";
				this.flash.toggleUserlist(false);
				this.setSize();
				this.bottomScroll();
			}
		}

		this.toggleUserLayer = function() {
			if (this.chatType == "channel") {
				var layer = document.getElementById(this.id+"UserLayer");

				if (layer.style.display == "") {
					layer.style.display = "none";
					return false;
				}

				document.getElementById(this.id+"UserLayerNickname").value = this.myinfo.nickname;
				if (this.myinfo.social) {
					var social = this.myinfo.social.split("@").shift();
					document.getElementById(this.id+"UserLayerStatusIcon").style.backgroundImage = "url("+MinionDomain+"/images/status/"+social+"/"+this.myinfo.status+".gif)";
				} else {
					document.getElementById(this.id+"UserLayerStatusIcon").style.backgroundImage = "url("+this.statusIcon+"/"+this.myinfo.status+".gif)";
				}
				document.getElementById(this.id+"UserLayerStatusIcon").setAttribute("status",this.myinfo.status);
				document.getElementById(this.id+"UserLayerStatusText").innerHTML = this.lang.status[this.myinfo.status];

				layer.style.display = "";
				layer.style.left = (layer.parentNode.offsetWidth - layer.offsetWidth)+"px";
			} else {
				var layer = document.getElementById(this.id+"RandomLayer");

				if (this.myinfo == null) this.myinfo = {"gender":this.gender,"match":this.match};

				document.getElementById(this.id+"RandomLayerGenderText").setAttribute("gender",this.myinfo.gender);
				document.getElementById(this.id+"RandomLayerGenderText").innerHTML = this.lang.random.gender[this.myinfo.gender];
				document.getElementById(this.id+"RandomLayerMatchText").setAttribute("match",this.myinfo.match);
				document.getElementById(this.id+"RandomLayerMatchText").innerHTML = this.lang.random.match[this.myinfo.match];

				layer.style.display = "";
				layer.style.left = (layer.parentNode.offsetWidth - layer.offsetWidth)+"px";
			}
		}

		this.toggleStatusList = function() {
			var list = document.getElementById(this.id+"UserLayerStatusList");
			if (list.style.display == "") {
				list.style.display = "none";
				return false;
			}
			list.innerHTML = "";
			for (statusText in this.lang.status) {
				if (statusText != "offline") {
					var thisStatus = document.createElement("div");
					thisStatus.className = "off";
					if (this.myinfo.social) {
						var social = this.myinfo.social.split("@").shift();
						thisStatus.style.backgroundImage = "url("+MinionDomain+"/images/status/"+social+"/"+statusText+".gif)";
					} else {
						thisStatus.style.backgroundImage = "url("+this.statusIcon+"/"+statusText+".gif)";
					}
					thisStatus.innerHTML = this.lang.status[statusText];
					thisStatus.setAttribute("minion",this.id);
					thisStatus.setAttribute("status",statusText);
					thisStatus.setAttribute("statusText",this.lang.status[statusText]);
					thisStatus.onmouseover = function() { this.className = "over"; }
					thisStatus.onmouseout = function() { this.className = "off"; }
					thisStatus.onclick = function() {
						var minion = MinionComponent.get(this.getAttribute("minion"));

						if (minion.myinfo.social) {
							document.getElementById(this.getAttribute("minion")+"UserLayerStatusIcon").style.backgroundImage = "url("+MinionDomain+"/images/status/"+minion.myinfo.social.split("@").shift()+"/"+this.getAttribute("status")+".gif)";
						} else {
							document.getElementById(this.getAttribute("minion")+"UserLayerStatusIcon").style.backgroundImage = "url("+MinionComponent.get(this.getAttribute("minion")).statusIcon+"/"+this.getAttribute("status")+".gif)";
						}
						document.getElementById(this.getAttribute("minion")+"UserLayerStatusIcon").setAttribute("status",this.getAttribute("status"));
						document.getElementById(this.getAttribute("minion")+"UserLayerStatusText").innerHTML = this.getAttribute("statusText");
						document.getElementById(this.getAttribute("minion")+"UserLayerStatusList").style.display = "none";
					}

					list.appendChild(thisStatus);
				}
			}

			list.style.display = "";
		}

		this.toggleGenderList = function() {
			var list = document.getElementById(this.id+"RandomLayerGenderList");
			if (list.style.display == "") {
				list.style.display = "none";
				return false;
			}
			list.innerHTML = "";
			for (genderText in this.lang.random.gender) {
				var thisGender = document.createElement("div");
				thisGender.className = "off";
				thisGender.style.paddingLeft = "5px";
				thisGender.innerHTML = this.lang.random.gender[genderText];
				thisGender.setAttribute("minion",this.id);
				thisGender.setAttribute("gender",genderText);
				thisGender.setAttribute("genderText",this.lang.random.gender[genderText]);
				thisGender.onmouseover = function() { this.className = "over"; }
				thisGender.onmouseout = function() { this.className = "off"; }
				thisGender.onclick = function() {
					var minion = MinionComponent.get(this.getAttribute("minion"));
					document.getElementById(this.getAttribute("minion")+"RandomLayerGenderText").setAttribute("gender",this.getAttribute("gender"));
					document.getElementById(this.getAttribute("minion")+"RandomLayerGenderText").innerHTML = this.getAttribute("genderText");
					document.getElementById(this.getAttribute("minion")+"RandomLayerGenderList").style.display = "none";
				}

				list.appendChild(thisGender);
			}

			list.style.display = "";
		}

		this.toggleMatchList = function() {
			var list = document.getElementById(this.id+"RandomLayerMatchList");
			if (list.style.display == "") {
				list.style.display = "none";
				return false;
			}
			list.innerHTML = "";

			for (matchText in this.lang.random.match) {
				var thisMatch = document.createElement("div");
				thisMatch.className = "off";
				thisMatch.style.paddingLeft = "5px";
				thisMatch.innerHTML = this.lang.random.match[matchText];
				thisMatch.setAttribute("minion",this.id);
				thisMatch.setAttribute("match",matchText);
				thisMatch.setAttribute("matchText",this.lang.random.match[matchText]);
				thisMatch.onmouseover = function() { this.className = "over"; }
				thisMatch.onmouseout = function() { this.className = "off"; }
				thisMatch.onclick = function() {
					var minion = MinionComponent.get(this.getAttribute("minion"));
					document.getElementById(this.getAttribute("minion")+"RandomLayerMatchText").setAttribute("match",this.getAttribute("match"));
					document.getElementById(this.getAttribute("minion")+"RandomLayerMatchText").innerHTML = this.getAttribute("matchText");
					document.getElementById(this.getAttribute("minion")+"RandomLayerMatchList").style.display = "none";
				}

				list.appendChild(thisMatch);
			}

			list.style.display = "";
		}

		this.socialLogin = function(social) {
			if (this.myinfo.social) {
				this.flash.socialLogout();
				this.toggleUserLayer();
			} else {
				if (social == "twitter") {
					var width = 600;
					var height = 600;
				} else {
					var width = 1000;
					var height = 600;
				}
				var windowLeft = (screen.width-width)/2;
				var windowTop = (screen.height-height)/2;
				windowTop = windowTop>20 ? windowTop-20 : windowTop;

				var socialWindow = window.open(MinionDomain+"/html/SocialLogin.php?social="+social+"&channel="+encodeURIComponent(this.channel),"","top="+windowTop+",left="+windowLeft+",width="+width+",height="+height+",scrollbars=0");
				if (socialWindow) {
					socialWindow.focus();
					socialWindow.onunload = function() {
						//alert(this.location.href);
					}
				} else {
					this.printError(this.lang.error.popup);
				}
			}
		}

		this.insertEmoticon = function() {
			var tool = document.getElementById(this.id+"ToolEmoticon");
			var object = document.getElementById(this.id+"Emoticon");
			var emoticonArea = document.createElement("div");
			emoticonArea.className = "scrolling";

			if (object.style.display == "") {
				tool.className = "over";
				object.style.display = "none";
			} else {
				if (object.getElementsByTagName("div").length == 0) {
					var emoticons = document.createElement("div");
					for (var i=1;i<=40;i++) {
						var emoticon = document.createElement("img");
						emoticon.src = MinionDomain+"/images/emoticon/"+i+".gif";
						emoticon.setAttribute("minion",this.id);
						emoticon.setAttribute("no",i);
						emoticon.onclick = function() {
							MinionComponent.get(this.getAttribute("minion")).inputArea.value+= "[EMO:"+this.getAttribute("no")+"]";
							MinionComponent.get(this.getAttribute("minion")).inputArea.focus();
						}
						emoticons.appendChild(emoticon);
					}
					emoticonArea.appendChild(emoticons);
					object.appendChild(emoticonArea);
				}

				tool.className = "on";
				object.style.display = "";
			}
		}

		this.selectColor = function() {
			var tool = document.getElementById(this.id+"ToolColor");
			var object = document.getElementById(this.id+"Color");
			object.innerHTML = "";
			var colorArea = document.createElement("div");

			if (object.style.display == "") {
				tool.className = "over";
				object.style.display = "none";
				delete MinionClicker[this.id+"Color"];
			} else {
				var colorbox = document.createElement("div");
				colorbox.setAttribute("minion",this.id);
				colorbox.className = "defaultbox";
				if (this.inputArea.getAttribute("color") == "") colorbox.className = "defaultbox_select";
				else colorbox.className = "defaultbox";
				colorbox.onmouseover = function() { this.className = this.className == "defaultbox_select" ? "defaultbox_select" : "defaultbox_over"; }
				colorbox.onmouseout = function() { this.className = this.className == "defaultbox_select" ? "defaultbox_select" : "defaultbox"; }
				colorbox.onclick = function() { MinionComponent.get(this.getAttribute("minion")).setColor("default"); }
				colorArea.appendChild(colorbox);
				
                //namrodangEdit
				var colors = [
                    "#222222",
                    "#880015",
                    "#ED1C24",
                    "#FF7F27",
                    "#333333",
                    "#22B14C",
                    "#00A2E8",
                    "#3F48CC",
                    "#A349A4",
                    "#000000",
                    "#0066FF",
                    "#333300",
                    "#734136",
                    "#FF6600",
                    "#663366",
                    "#990066",
                    "#993333",
                    "#003399",
                    "#006600"];
                
				for (var i=0, loop=colors.length;i<loop;i++) {
					var colorbox = document.createElement("div");
					colorbox.setAttribute("minion",this.id);
					colorbox.setAttribute("color",colors[i]);
					if (this.inputArea.getAttribute("color") == colors[i]) colorbox.className = "colorbox_select";
					else colorbox.className = "colorbox";
					colorbox.style.backgroundColor = colors[i];
					colorbox.onmouseover = function() { this.className = this.className == "colorbox_select" ? "colorbox_select" : "colorbox_over"; }
					colorbox.onmouseout = function() { this.className = this.className == "colorbox_select" ? "colorbox_select" : "colorbox"; }
					colorbox.onclick = function() { MinionComponent.get(this.getAttribute("minion")).setColor(this.getAttribute("color")); }

					colorArea.appendChild(colorbox);
				}
				tool.className = "on";
				object.style.display = "";
				object.appendChild(colorArea);
			}
		}

		this.setMyInfo = function() {
			if (this.chatType == "channel") {
				var nickname = document.getElementById(this.id+"UserLayerNickname").value;
				var status = document.getElementById(this.id+"UserLayerStatusIcon").getAttribute("status");

				if (this.myinfo.nickname != nickname) {
					this.flash.setNick(nickname);
				}
				if (this.myinfo.status != status) {
					this.flash.setStatus(status);
				}
				document.getElementById(this.id+"UserLayer").style.display = "none";
			} else {
				var gender = document.getElementById(this.id+"RandomLayerGenderText").getAttribute("gender");
				var match = document.getElementById(this.id+"RandomLayerMatchText").getAttribute("match");
				this.myinfo.gender = gender;
				this.myinfo.match = match;
				this.flash.setUser(gender,match);
				document.getElementById(this.id+"RandomLayer").style.display = "none";
			}
		}

		this.setFont = function(type) {
			this.flash.setFont(type.toLowerCase(),document.getElementById(this.id+"Tool"+type).className != "on");
		}

		this.setColor = function(color) {
			this.flash.setColor(color);
			document.getElementById(this.id+"ToolColor").className = "off";
			document.getElementById(this.id+"Color").style.display = "none";
			this.inputArea.focus();
		}

		this.setSound = function() {
			this.flash.setMute(document.getElementById(this.id+"ToolMute").className != "on");
		}

		this.setAdmin = function(nickname,opper) {
			this.flash.setAdmin(nickname,opper);
		}

		this.setFixScroll = function(type) {
			if (this.fixScroll == true) {
				this.fixScroll = false;
				document.getElementById(this.id+"ToolScroll").className = "off";
				this.bottomScroll();
			} else {
				this.fixScroll = true;
				document.getElementById(this.id+"ToolScroll").className = "on";
			}
		}

		this.inviteChannel = function(nickname,channel) {
			if (!document.getElementById(this.id+"Invite"+channel)) {
				var object = document.getElementById(this.id+"ChatAlertLayer");
				var alertObject = document.createElement("div");
				alertObject.setAttribute("minion",this.id);
				alertObject.setAttribute("id",this.id+"Invite"+channel);
				alertObject.setAttribute("channel",channel);
				alertObject.setAttribute("nickname",nickname);
				alertObject.className = "chatInviteAlert";
				alertObject.innerHTML = this.lang.system.invite.replace("{nickname}","<b>"+nickname+"</b>");

				alertObject.onclick = function() {
					MinionComponent.get(this.getAttribute("minion")).joinPrivChannel(this.getAttribute("channel"),this.getAttribute("nickname"));
				}

				object.appendChild(alertObject);

				try { this.listeners.onInvite(this,nickname); } catch(e) { }
			}
		}

		this.inviteUser = function(nickname) {
			if (this.myPrivChannel == "" || this.privChatType == "single") {
				this.openPrivChannel(nickname);
			} else {
				this.flash.inviteUser(nickname);
			}
		}

		this.joinPrivChannel = function(code,nickname) {
			if (confirm(this.lang.system.confirmprivchannel.replace('{nickname}',nickname)) == true) {
				var width = 700;
				var height = 400;
				var windowLeft = (screen.width-width)/2;
				var windowTop = (screen.height-height)/2;
				windowTop = windowTop>20 ? windowTop-20 : windowTop;

				var formObject = document.createElement("form");
				formObject.style.display = "none";
				formObject.action = MinionDomain+"/html/PrivChannel.php";
				formObject.target = code.replace('$','');
				formObject.method = "POST";

				var channel = document.createElement("input");
				channel.name = "channel";
				channel.value = this.channel;
				formObject.appendChild(channel);

				var owner = document.createElement("input");
				owner.name = "owner";
				owner.value = nickname;
				formObject.appendChild(owner);

				var nickname = document.createElement("input");
				nickname.name = "nickname";
				nickname.value = this.myinfo.nickname;
				formObject.appendChild(nickname);

				var nickcon = document.createElement("input");
				nickcon.name = "nickcon";
				nickcon.value = this.nickcon;
				formObject.appendChild(nickcon);

				var config = document.createElement("input");
				config.name = "config";
				config.value = this.skin+","+this.language+","+this.encode;
				formObject.appendChild(config);

				var privchannel = document.createElement("input");
				privchannel.name = "privchannel";
				privchannel.value = code;
				formObject.appendChild(privchannel);

				document.getElementById(this.id+"Area").appendChild(formObject);

				var privWindow = window.open(MinionDomain+"/html/Loading.php",code.replace('$',''),"top="+windowTop+",left="+windowLeft+",width="+width+",height="+height+",scrollbars=0");
				if (privWindow) {
					privWindow.focus();
					formObject.submit();
					document.getElementById(this.id+"Area").removeChild(formObject);
				} else {
					this.printError(this.lang.error.popup);
				}
			} else {
				this.flash.inviteKick(nickname,code);
			}

			this.hideAlertLayer(document.getElementById(this.id+"Invite"+code));
		}

		this.openPrivChannel = function(inviteUser) {
			var inviteUser = inviteUser ? inviteUser : "";
			if (this.myPrivChannel == "" || this.privChatType == "single") {
				var width = 700;
				var height = 400;
				var windowLeft = (screen.width-width)/2;
				var windowTop = (screen.height-height)/2;
				windowTop = windowTop>20 ? windowTop-20 : windowTop;

				var privCode = "$"+new Date().getTime();
				this.myPrivChannel = new Date().getTime();

				var formObject = document.createElement("form");
				formObject.style.display = "none";
				formObject.action = MinionDomain+"/html/PrivChannel.php";
				formObject.target = privCode.replace("$","");
				formObject.method = "POST";

				var channel = document.createElement("input");
				channel.name = "channel";
				channel.value = this.channel;
				formObject.appendChild(channel);

				var nickname = document.createElement("input");
				nickname.name = "nickname";
				nickname.value = this.myinfo.nickname;
				formObject.appendChild(nickname);

				var nickcon = document.createElement("input");
				nickcon.name = "nickcon";
				nickcon.value = this.nickcon;
				formObject.appendChild(nickcon);

				var owner = document.createElement("input");
				owner.name = "owner";
				owner.value = this.myinfo.nickname;
				formObject.appendChild(owner);

				var config = document.createElement("input");
				config.name = "config";
				config.value = this.skin+","+this.language+","+this.encode;
				formObject.appendChild(config);

				var privchannel = document.createElement("input");
				privchannel.name = "privchannel";
				privchannel.value = privCode;
				formObject.appendChild(privchannel);

				var invite = document.createElement("input");
				invite.name = "invite";
				invite.value = inviteUser;
				formObject.appendChild(invite);

				document.getElementById(this.id+"Area").appendChild(formObject);

				var privWindow = window.open(MinionDomain+"/html/Loading.php",privCode.replace("$",""),"top="+windowTop+",left="+windowLeft+",width="+width+",height="+height+",scrollbars=0");
				if (privWindow) {
					privWindow.focus();
					formObject.submit();
					document.getElementById(this.id+"Area").removeChild(formObject);
				} else {
					this.printError(this.lang.error.popup);
				}
			} else if (this.myPrivChannel.toString().indexOf('\$') == 0) {
				this.flash.setFocus(this.myPrivChannel);
			} else {
				if (this.myPrivChannel > new Date().getTime()-30000) {
					this.printError(this.lang.error.waitprivchannel);
				} else {
					this.myPrivChannel = "";
					this.openPrivChannel();
				}
			}
		}

		this.openWindow = function(url,width,height,html) {
			var windowLeft = (screen.width-width)/2;
			var windowTop = (screen.height-height)/2;
			windowTop = windowTop>20 ? windowTop-20 : windowTop;

			this.layerWindow = window.open("","LayerWindow","top="+windowTop+",left="+windowLeft+",width="+width+",height="+height+",scrollbars=0");
			this.layerWindow.document.writeln(html);
			try {
				this.layerWindow.window.addEventListener('beforeunload',function(event) {
					MinionComponent.closeWindow();
				},false);
			} catch(e) {
				this.layerWindow.window.attachEvent('onbeforeunload',function(event) {
					MinionComponent.closeWindow();
				});
			}
		}

		// User Functions
		this.userJoin = function(user,order,isAlert) {
			if (this.viewUser == true) {
				var userDiv = document.createElement("div");
				if (this.viewStatusIcon == true) {
					if (user.social) {
						var social = user.social.split("@").shift();
						userDiv.style.backgroundImage = "url("+MinionDomain+"/images/status/"+social+"/"+user.status+".gif)";
					} else {
						userDiv.style.backgroundImage = "url("+this.statusIcon+user.status+".gif)";
					}
				} else {
					userDiv.style.paddingLeft = "5px";
				}
				userDiv.setAttribute("title",user.nickname);
				userDiv.setAttribute("minion",this.id);
				userDiv.setAttribute("nickname",user.nickname);
				userDiv.setAttribute("clicker",this.id+"UserMenu");
				if (user.nickcon) {
					userDiv.innerHTML = user.nickcon;
				} else {
					userDiv.innerHTML = user.nickname;
				}

				if (user.nickname == this.myinfo.nickname) userDiv.className = "my";
				if (user.opper == "ADMIN") userDiv.innerHTML+= '<img src="'+MinionDomain+'/skin/'+this.skin+'/images/icon_admin.gif" style="margin-left:3px;" />';

				if (user.nickname != this.myinfo.nickname) {
					userDiv.onmouseover = function() { this.className = "over"; }
					userDiv.onmouseout = function() { this.className = ""; }
				}
				userDiv.onclick = function(event) { MinionComponent.get(this.getAttribute("minion")).getUserMenu(this.getAttribute("nickname"),event); }

				if (order == -1) {
					this.userArea.appendChild(userDiv);
				} else {
					this.userArea.insertBefore(userDiv,this.userArea.getElementsByTagName("div")[order]);
				}
			}

			var viewMessage = false;
			if (isAlert == true && this.viewAlert == true) {
				if (this.alertLimit == "ALL") viewMessage = true;
				if (this.alertLimit == "NICKGUEST" && (user.opper == "ADMIN" || user.opper == "MEMBER" || user.opper == "NICKGUEST")) viewMessage = true;
				if (this.alertLimit == "MEMBER" && (user.opper == "ADMIN" || user.opper == "MEMBER")) viewMessage = true;
				if (this.alertLimit == "ADMIN" && user.opper == "ADMIN") viewMessage = true;
			}

			if (viewMessage == true) {
				if (this.alertQueue[user.nickname]) {
					clearTimeout(this.alertQueue[user.nickname]);
					delete this.alertQueue[user.nickname];
				} else {
					this.printSystem(this.lang.system.userjoin.replace('{nickname}','<b>'+user.nickname+'</b>'));
				}
			}
			this.printUserCount(this.usernum);
		}

		this.userQuit = function(user,order,isAlert) {
			if (this.viewUser == true && order != -1) {
				this.userArea.removeChild(this.userArea.getElementsByTagName("div")[order]);
			}

			var viewMessage = false;
			if (isAlert == true && this.viewAlert == true) {
				if (this.alertLimit == "ALL") viewMessage = true;
				if (this.alertLimit == "NICKGUEST" && (user.opper == "ADMIN" || user.opper == "MEMBER" || user.opper == "NICKGUEST")) viewMessage = true;
				if (this.alertLimit == "MEMBER" && (user.opper == "ADMIN" || user.opper == "MEMBER")) viewMessage = true;
				if (this.alertLimit == "ADMIN" && user.opper == "ADMIN") viewMessage = true;
			}

			if (viewMessage == true) {
				if (this.alertLimitTime > 0) {
					if (this.alertQueue[user.nickname]) clearTimeout(alertQueue[user.nickname]);
					this.alertQueue[user.nickname] = setTimeout("MinionComponent.get('"+this.id+"').userQuitMessge('"+user.nickname+"')",this.alertLimitTime*1000);
				} else {
					this.printSystem(this.lang.system.userquit.replace('{nickname}','<b>'+user.nickname+'</b>'));
				}
			}

			this.printUserCount(this.usernum);
		}

		this.printUserCount = function(usernum) {
			if (usernum == "") document.getElementById(this.id+"UserCount").innerHTML == "";
			else document.getElementById(this.id+"UserCount").innerHTML = this.lang.userCount.replace('{count}',usernum);
		}

		this.userQuitMessge = function(nickname) {
			this.printSystem(this.lang.system.userquit.replace('{nickname}','<b>'+nickname+'</b>'));
			if (this.alertQueue[nickname]) delete this.alertQueue[nickname]
		}

		this.userChange = function(beforeUser,beforeOrder,afterUser,afterOrder,isAlert) {
			this.userQuit(beforeUser,beforeOrder,false);
			this.userJoin(afterUser,afterOrder,false);

			if (beforeUser.nickname != afterUser.nickname) this.printSystem(this.lang.system.usernick.replace('{nickname}','<b>'+beforeUser.nickname+'</b>').replace('{newnick}','<b>'+afterUser.nickname+'</b>'));

			if (beforeUser.opper != "ADMIN" && afterUser.opper == "ADMIN") this.printSystem(this.lang.system.opper.replace('{nickname}','<b>'+afterUser.nickname+'</b>'));
		}

		this.userStatus = function(user,order,isAlert) {
			if (this.viewUser == true && this.viewStatusIcon == true) {
				if (user.social) {
					var social = user.social.split("@").shift();
					this.userArea.getElementsByTagName("div")[order].style.backgroundImage = "url("+MinionDomain+"/images/status/"+social+"/"+user.status+".gif)";
				} else {
					this.userArea.getElementsByTagName("div")[order].style.backgroundImage = "url("+this.statusIcon+user.status+".gif)";
				}
			}

			if (isAlert == true) {
				this.printSystem(this.lang.system.status.replace('{nickname}','<b>'+user.nickname+'</b>').replace('{status}','<b>'+this.lang.status[user.status]+'</b>'));
			}
		}

		this.getUserMenu = function(nickname,event) {
			var e = event ? event : window.event;

			var userMenu = document.getElementById(this.id+"UserMenu");
			userMenu.innerHTML = "";
			var user = this.getUser(this.flash.userInfo(nickname));

			var scrollTop = Math.max(document.documentElement.scrollTop,document.body.scrollTop);
			var scrollLeft = Math.max(document.documentElement.scrollLeft,document.body.scrollLeft);

			var offsetTop = this.getRealOffsetTop(document.getElementById(this.id+"Area"));
			var offsetLeft = this.getRealOffsetLeft(document.getElementById(this.id+"Area"));
			var top = e.clientY+scrollTop-offsetTop;
			var left = e.clientX+scrollLeft-offsetLeft;

			var nickname = document.createElement("div");
			nickname.className = "nickname";
			if (user.social) {
				var social = user.social.split("@").shift();
				nickname.style.backgroundImage = "url("+MinionDomain+"/images/status/"+social+"/"+user.status+".gif)";
			} else {
				//nickname.style.backgroundImage = "url("+this.statusIcon+user.status+".gif)"; //namrodangEdit
			}
			nickname.innerHTML = user.nickname;

			userMenu.appendChild(nickname);

			for (var i=0, loop=this.defaultUserMenu.length;i<loop;i++) {
				if (this.defaultUserMenu[i].viewMenu(this,user,this.myinfo) == true) {
					var thisMenu = document.createElement("div");
					thisMenu.setAttribute("loop",i);
					thisMenu.setAttribute("minion",this.id);
					thisMenu.setAttribute("nickname",user.nickname);
					thisMenu.onmouseover = function() { this.className = "over"; }
					thisMenu.onmouseout = function() { this.className = "off"; }
					thisMenu.onclick = function() {
						var minion = MinionComponent.get(this.getAttribute("minion"));
						var user = minion.getUser(minion.flash.userInfo(this.getAttribute("nickname")));
						minion.defaultUserMenu[parseInt(this.getAttribute("loop"))].fn(minion,user,minion.myinfo);
					}
					//thisMenu.style.backgroundImage = "url("+MinionDomain+"/skin/"+this.skin+"/images/"+this.defaultUserMenu[i].icon+")"; //namrodangEdit
					thisMenu.className = "off";
					thisMenu.innerHTML = this.defaultUserMenu[i].text;

					userMenu.appendChild(thisMenu);
				}
			}

			for (var i=0, loop=this.addUserMenu.length;i<loop;i++) {
				if (this.addUserMenu[i].viewMenu(this,user,this.myinfo) == true) {
					var thisMenu = document.createElement("div");
					thisMenu.setAttribute("loop",i);
					thisMenu.setAttribute("minion",this.id);
					thisMenu.setAttribute("nickname",user.nickname);
					thisMenu.onmouseover = function() { this.className = "over"; }
					thisMenu.onmouseout = function() { this.className = "off"; }
					thisMenu.onclick = function() {
						var minion = MinionComponent.get(this.getAttribute("minion"));
						var user = minion.getUser(minion.flash.userInfo(this.getAttribute("nickname")));
						minion.addUserMenu[parseInt(this.getAttribute("loop"))].fn(minion,user,minion.myinfo);
					}
					thisMenu.style.backgroundImage = "url("+this.addUserMenu[i].icon+")";
					thisMenu.className = "off";
					thisMenu.innerHTML = this.addUserMenu[i].text;

					userMenu.appendChild(thisMenu);
				}
			}

			userMenu.style.display = "";

			if (left+userMenu.offsetWidth > this.width) {
				left = this.width-userMenu.offsetWidth-5;
			}

			if (top+userMenu.offsetHeight > this.height) {
				top = this.height-userMenu.offsetHeight-5;
			}

			userMenu.style.top = top+"px";
			userMenu.style.left = left+"px";

			MinionClicker[userMenu.getAttribute("id")] = true;
		}

		this.adtex = function(adtext,adurl,adshow) {
			var object = document.getElementById(this.id+"ChatAlertLayer");
			if (adshow == true) {
				var alertObject = document.createElement("div");
				alertObject.setAttribute("minion",this.id);
				alertObject.setAttribute("id",this.id+"Adtex");
				alertObject.setAttribute("adurl",adurl);
				alertObject.className = "adtex";
				alertObject.innerHTML = adtext;

				alertObject.onclick = function() {
					window.open(this.getAttribute("adurl"));
					MinionComponent.get(this.getAttribute("minion")).hideAlertLayer(this);
				}

				object.appendChild(alertObject);
			} else {
				this.hideAlertLayer(document.getElementById(this.id+"Adtex"));
			}
		}

		// Flash Source
		this.flashURL= this.chatType == "channel" ? MinionDomain+"/flash/minion4.channel.swf?version=4.3.0" : MinionDomain+"/flash/minion4.random.swf?version=4.3.0";
		this.flashURL+= "&rnd="+Math.random();
		this.flashVars = "xml=http%3A%2F%2Fnamrodang.com%2Fchat%2Fxml%2Fsetup.xml.php&id="+this.id+"&channel="+this.channel+"&nickname="+this.nickname+"&nickcon="+this.nickcon+"&securityCode="+this.securityCode+"&adminCode="+this.adminCode+"&memberCode="+this.memberCode+"&info="+this.info+"&path="+this.path+"&partnerCode="+this.partnerCode+"&isMinion="+this.isMinion;
		this.flashHTML = "";
		this.isIE = navigator.appName == "Microsoft Internet Explorer";
		if (this.isIE) {
			this.flashHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="1" height="1" id="'+this.id+'" align="middle">';
			this.flashHTML+= '<param name="allowScriptAccess" value="always" />';
			this.flashHTML+= '<param name="base" value=".">';
			this.flashHTML+= '<param name="flashVars" value="'+this.flashVars+'" />';
			this.flashHTML+= '<param name="movie" value="'+this.flashURL+'" />';
			this.flashHTML+= '<param name="quality" value="high" />';
			this.flashHTML+= '<param name="wmode" value="transparent" />';
			this.flashHTML+= '<embed src="'+this.flashURL+'" quality="high" wmode="transparent" style="width:1px; height:1px;" align="middle" allowScriptAccess="always" base="." type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+this.flashVars+'"></embed>';
			this.flashHTML+= '</object>';
		} else {
			this.flashHTML = '<embed id="'+this.id+'" src="'+this.flashURL+'" quality="high" wmode="transparent" style="width:1px; height:1px;" align="middle" allowScriptAccess="always" base="." type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+this.flashVars+'"></embed>';
		}

		// Minion Body
		this.MinionHTML = '<div id="'+this.id+'Area" style="width:'+this.width+'px; height:'+this.height+'px; overflow:hidden;"></div>';

		if (this.renderTo == null) {
			document.writeln(this.MinionHTML);
		} else {
			if (!document.getElementById(this.renderTo)) {
				alert("Not Found : "+this.renderTo+" Object (ErrorCode:11)");
				this.renderError = true;
			} else {
				document.getElementById(this.renderTo).innerHTML = this.MinionHTML;
			}
		}
		MinionComponent.register(this);

		if (this.renderError == false && this.isFullSize == true) {
			if (document.getElementById(this.id+"Area").parentNode.offsetHeight < 200) {
				//alert("isFullSize Property Error (ErrorCode:12)");
			}
		}

		if (this.renderError == false) this.getSkin();
	}

	try {
		document.addEventListener('click',function(event){
			var e = event ? event : window.event;
			var object = e.target ? e.target : e.srcElement;

			for (clicker in MinionClicker) {
				if (clicker != object.getAttribute("clicker")) {
					document.getElementById(clicker).style.display = "none";
					if (clicker.indexOf("ToolList") >= 0) document.getElementById(clicker.replace("ToolList","ToolMore")).className = "off more";
					delete MinionClicker[clicker];
				}
			}
		},false);

		window.addEventListener('unload',function(event) {
			MinionComponent.closeWindow();
		},false);

		window.addEventListener('blur',function(event) {
			MinionComponent.setFocus(false);
		},false);

		window.addEventListener('focus',function(event) {
			MinionComponent.setFocus(true);
		},false);
	} catch(e) {
		document.attachEvent('onclick',function(event){
			var e = event ? event : window.event;
			var object = e.target ? e.target : e.srcElement;

			for (clicker in MinionClicker) {
				if (clicker != object.getAttribute("clicker")) {
					document.getElementById(clicker).style.display = "none";
					if (clicker.indexOf("ToolList") >= 0) document.getElementById(clicker.replace("ToolList","ToolMore")).className = "off more";
					delete MinionClicker[clicker];
				}
			}
		});

		window.attachEvent('onunload',function(event) {
			MinionComponent.closeWindow();
		});

		window.attachEvent('onfocus',function(event) {
			MinionComponent.setFocus(true);
		});
	}
}
