function LL_WEBCOMPONENT_CHAT(strName) {
	this.strName = strName;
	this.intWidth = 0;
	this.intHeight = 0;
	this.objParent = null;
	this.objChild = null;
	this.arrListener = new Array();
	this.strResetUrl = "";
	this.strFrameName = "";
	this.strShowKey = "";
}

LL_WEBCOMPONENT_CHAT.prototype.setResetUrl = function(strUrl) {
	this.strResetUrl = strUrl;
}

LL_WEBCOMPONENT_CHAT.prototype.setArrListener = function(arrListener) {
	this.arrListener = arrListener;
}

LL_WEBCOMPONENT_CHAT.prototype.setParent = function(objParent) {
	this.objParent = objParent;
	this.objParent.setChild(this);
}

LL_WEBCOMPONENT_CHAT.prototype.setChild = function(objChild) {
	this.objChild = objChild;
}

LL_WEBCOMPONENT_CHAT.prototype.reloadChat = function(sKey) {
	if(sKey) {
		this.strShowKey = sKey;
	}
	if(document.getElementById(this.strFrameName)) {
		var objUrl = new DHL.NET.URL(this.strResetUrl);
		objUrl.removeAttribute('reset');
		objUrl.setAttribute('skey', this.strShowKey);
		document.getElementById(this.strFrameName).src = objUrl.toString();
	}
}

LL_WEBCOMPONENT_CHAT.prototype.changeSize = function(intWidth, intHeight) {
	this.intWidth = intWidth;
	this.intHeight = intHeight;

	if(document.getElementById(this.strFrameName)) {
		document.getElementById(this.strFrameName).style.width = intWidth + 'px';
		document.getElementById(this.strFrameName).style.height = intHeight + 'px';
	}
	
	if(document.getElementById("tblChatContainer" + this.strFrameName)) {
		document.getElementById("tblChatContainer" + this.strFrameName).style.width = intWidth + 'px';
		document.getElementById("tblChatContainer" + this.strFrameName).style.height = intHeight + 'px';
	}
	
	if(document.getElementById("tChatCgiIrc")) {
		document.getElementById("tChatCgiIrc").style.width = (intWidth-4) + 'px';
		document.getElementById("tChatCgiIrc").style.height = (intHeight-1) + 'px';
	}

	if(document.getElementById("div" + this.strFrameName)) {
		document.getElementById("div" + this.strFrameName).style.width = intWidth + 'px';
		document.getElementById("div" + this.strFrameName).style.height = intHeight + 'px';
	}

	if(document.getElementById("tChatCgiIrc")) {
		document.getElementById("tChatCgiIrc").style.border="0";
		document.getElementById("tChatCgiIrc").frameborder = "0";
		document.getElementById("tChatCgiIrc").style.margin="0";
		document.getElementById("tChatCgiIrc").style.padding="0";
	}

	try {
		if(this.objChild) {
			this.objChild.changeSize(intWidth, intHeight);
		}
	}
	catch(exception) {
	}
}

LL_WEBCOMPONENT_CHAT.prototype.onConnectVideo = function() {
	try {
		if(this.objChild) {
			this.objChild.onConnectVideo();
		}
		else {
			this.connectChat();
		}
	}
	catch(exception) {
	}
}

LL_WEBCOMPONENT_CHAT.prototype.connectChat = function() {
	if(typeof tChatCgiIrc != 'undefined') {
		tChatCgiIrc.connect();
	}
}

LL_WEBCOMPONENT_CHAT.prototype.onConnectChat = function() {
	this.notifyListener('onCgiIrcConnect');
}

LL_WEBCOMPONENT_CHAT.prototype.notifyListener = function(strEvent) {
	try {
		if(this.objParent) {
			this.objParent.notifyListener(strEvent);
		}
		else {
			if(this.arrListener[strEvent]) {
				for(var intI = 0; intI < this.arrListener[strEvent].length; intI++) {
					eval(this.arrListener[strEvent][intI] + "();");
				}
			}
		}
	}
	catch(exception) {
	}
}

LL_WEBCOMPONENT_CHAT.prototype.setFrameName = function(strName) {
	this.strFrameName = strName;
}

LL_WEBCOMPONENT_CHAT.prototype.setSize = function(intWidth, intHeight) {
	this.intWidth = intWidth;
	this.intHeight = intHeight;
}

LL_WEBCOMPONENT_CHAT.prototype.resetNick = function() {
	try {
		if(this.objChild) {
			this.objChild.resetNick();
		}
		else {
			var objUrl = new DHL.NET.URL(this.strResetUrl);
			objUrl.setAttribute('w', this.intWidth);
			objUrl.setAttribute('h', this.intHeight);
			document.location.replace(objUrl.toString());
		}
	}
	catch(exception) {
	}
}

LL_WEBCOMPONENT_CHAT.prototype.disconnectChat = function() {
	try {
		if(document.getElementById(this.strFrameName)) {
			document.getElementById(this.strFrameName).src = "about:blank";
		}	
	}
	catch(exception) {}
}

LL_WEBCOMPONENT_CHAT.prototype.applyParentSize = function() {
	try {
		if(this.objParent) {
			this.objParent.applyParentSize();
		}
		else {
			this.changeSize(this.intWidth, this.intHeight);
		}
	}
	catch(exception) {
	}
}

LL_WEBCOMPONENT_CHAT.prototype.changeChatUrl = function (objUrl) {
	if(this.objChild) {
		this.objChild.changeChatUrl(objUrl);
	}
	else {
		document.location.replace(objUrl);
	}
}

LL_WEBCOMPONENT_CHAT.prototype.hideChat = function() {
	if(this.objChild) {
		this.objChild.hideChat();
	}
	else {
		if(document.getElementById("tChatCgiIrc")) {
			document.getElementById("tChatCgiIrc").style.width = "0px";
			document.getElementById("tChatCgiIrc").style.height = "0px";
		}
		if(document.getElementById("tblChatLoading")) {
			document.getElementById("tblChatLoading").style.display="block";
		}
		if(document.getElementById("tblChatForm")) {
			document.getElementById("tblChatForm").style.position = "absolute";
			document.getElementById("tblChatForm").style.width = "1px";
			document.getElementById("tblChatForm").style.height = "1px";
			document.getElementById("tblChatForm").style.visibility = "hidden";
		}
	}
}

LL_WEBCOMPONENT_CHAT.prototype.showChat = function() {
	if(this.objChild) {
		this.objChild.showChat();
	}
	else {
		if(document.getElementById("tChatCgiIrc")) {
			document.getElementById("tChatCgiIrc").style.width = (this.intWidth-4) + "px";
			document.getElementById("tChatCgiIrc").style.height = (this.intHeight-1) + "px";
		}
		if(document.getElementById("tblChatLoading")) {
			document.getElementById("tblChatLoading").style.display="none";
		}
		if(document.getElementById("tblChatForm")) {
			document.getElementById("tblChatForm").style.position = "relative";
			document.getElementById("tblChatForm").style.width = (this.intWidth-4) + "px";
			document.getElementById("tblChatForm").style.height = (this.intHeight-1) + "px";
			document.getElementById("tblChatForm").style.visibility = "visible";
		}
	}
}