

chatWindowManager = function() {
	
	
	this.init=function(ContainerId)
	{
		this.chatContainer=document.getElementById("chatContainer");
	}
	
	this.checkWindowExists=function(windowTagId)
	{
		if (windowTagId=="") return false;
		if (document.getElementById(windowTagId)) return true;
		return false;
	};
	
	this.checkMSGSTagExists=function(windowTagId)
	{
		if (document.getElementById("MSGS_" + windowTagId)) return true;
		return false;		
	}
	
	this.createNewChatWindow=function(windowTagId,userId)
	{
		// Create The DIV Tag
		if (windowTagId!="" && windowTagId!=null)
		{
			newDIV=document.createElement("div");
			
			newDIV.setAttribute("id",windowTagId);
			//newDIV.setAttribute("style","border: 1px solid #000000;");
			this.chatContainer.appendChild(newDIV);
		}
		
	};
	
	
	
	this.removeChatWindow=function(windowTagId,userId)
	{
		if (this.checkWindowExists(windowTagId))
		{
			divWin=document.getElementById(windowTagId);
			this.chatContainer.removeChild(divWin);
		}
	};
	
	
	
	
	this.refreshMSGs=function(windowId,msgHTML)
	{
		if (this.checkMSGSTagExists(windowId))
		{
			chatMSGS=document.getElementById("MSGS_" + windowId);
			chatMSGS.innerHTML=msgHTML;
			chatMSGS.scrollTop=chatMSGS.scrollHeight;
		}	
		else
		{
			//alert("MSGS Tag not found:" + "MSGS_" + windowId);
		}
		//alert("refreshMSGS for Window " + windowId + " with" + msgHTML);
	};

	
	
	
	
	this.setChatWindowHTML=function(windowId,msgHTML)
	{
		if (this.checkWindowExists(windowId))
		{
			chatWindow=document.getElementById(windowId);
			chatWindow.innerHTML=msgHTML;
			
			
			test=document.getElementById('popup' + windowId);
			if (test)
			{
				popupObjchatPopup_1 = new Draggable('popup' + windowId,{handle: 'popupHandle' + windowId});
			}
			else
			{
				//alert("PopupTag dragable not found:" + 'popup' + windowId);
			}
			
			
		}
		
		//alert("setChatWindowHTML for Window " + windowId + " with" + msgHTML);
	};
	
	
	this.closeAllWindows=function()
	{
		this.chatContainer.innerHTML="";
		// Alle Tags durchlauifen und lioeschen
	};	
	
};

