//Reference to in-window chatPanel manager 
var chatPanelWindowMgr;
// starting chat with user
function startChatWithUser(userJid) {
/*
	if (canChat()) {
		if (top.imframe.is.b == "ie") {
			return top.imframe.roster.openChat(userJid);
		} else {
			return top.imframe.roster.openChatFromWS(userJid);
		}
	}
	return;
*/
	//alert("jwchat.js (inwindowchat.js) startChatWithUser(userJid: '"+userJid+"')");
	if ( top.mainframe.chatPanelWindowMgr ) {
		chatPanelWindowMgr = top.mainframe.chatPanelWindowMgr;

		//MATCHES jschatPanelWindowMgr.getChatPanel()
		if ( userJid.indexOf('@') != -1 ) {
			userJid = userJid.substring(0, userJid.indexOf('@'));
		}
		
		//chatPanelWindowMgr.showChatPanel(userJid);
		//chatPanelWindowMgr.showChatPanelUsingMD5(userJid);
		//chatPanelWindowMgr.appendTextToAndShowChatPanelUsingMD5(userJid, '','','');
		chatPanelWindowMgr.showChatPanelMD5(userJid);
		
	}

}

// adding Sparc user
function addSparcUser(userJid) {}

// person can chat
//	LOOK HERE: should probably be made a meaningful function
function canChat() {
	/*
	if (top.imframe) {
		if (!(top.imframe.statusLed.src == top.imframe.unavailableLed.src)) {
			return true;
		}
	}
	return false;
	*/
	/*
		CREATE index.iframe.currentjquery.html function isConnected()
		CHANGE jsjac_simpleclient.js to have specific calls for connected, disconnected, connecting
		return chatPanelWindowMgr.isConnected();
	*/
	return true;
}

// shows Sparc roster with contacts
function showChatRoster() {}

// hides chat button when viewing persons information
function hideChatButton() {}

// gets possibility to chat when roster is initialized
// hides chat for not working and unsupported browsers
function isChatableRoster() {
	return true;
}

// returns existence of chat user
function existChatUser(jid){ }
