
/**
 * msgconfig.js
 * Created on 5 Jan 2007
 *
 * Alex Little (OCI)
 * 
 * License info: http://kmi.open.ac.uk/technologies/msg/developer/licenses/ 
 */


function configAPI(){
	this.msg_jabberurl = "http://msg.open.ac.uk/buddyxml";
	this.msg_host = "msg.open.ac.uk";
	this.msg_jabberui = "http://msg.open.ac.uk/msg";
	this.imgroot = "http://msg.open.ac.uk/MSGClientAPI/images/";
	
	this.enable_popup_notifications = false;
	this.enable_text_notifications = false;
	
	this.stateText = new Array();
	this.stateText['online'] = "Online";
	this.stateText['away'] = "Away";
	this.stateText['dnd'] = "Do not disturb";
	this.stateText['offline'] = "Offline";
	
	this.maxLoginAttempts = 3;
	
	this.peekTimeoutNoInterrupt = 5000;
    this.peekTimeoutInterrupt = 30000;

	this.checkLoginTimeout = 2000;
	
	//settings for the counters
	this.global_online_url = null;
	this.global_online_counter_id = null;
	this.global_counter_id = null;
	this.global_total_url = null;
	this.personal_online_url = null;
	this.personal_online_counter_id = null;
	this.personal_counter_id = null;
	this.global_online_refresh_rate = 5000;
	this.personal_online_refresh_rate = 2000;
	
	this.user_sessions_url = null;
	
	this.clientWindowName = "MSGClientWindow";
	this.clientWindowProps = "width=500,height=400,scrollbars=yes,resizable=yes";
	this.str_clickToChat = " - click to chat";
	this.str_oneMessageUnread = "1 new MSG message";
	this.str_messagesUnread = " new MSG messages";
	this.str_popupBlocked = "MSG tried to open as a popup window, but you have blocked popups.\n\n You can unblock popups via the 'Tools... (Internet) Options...' menu in your browser.";
	this.str_mapUpdateLocationNotes = "";
	this.str_popupRead = "read";
	this.str_popupClose = "close";

}

function MSGService(){
	/* properties */
	this.jData = null;
	this.curr_id = null;
	this.curr_state = null;
	
	/* methods */
	this.checkLogin = checkLogin;
	this.updatePresenceIcon = updatePresenceIcon;
	this.launchClick = launchClick;
	this.peek = peek;
	this.initStates = initStates;
	this.loginUser = loginUser;
	
	this.mapUsersSetStates = userSetStates;
	this.disconnected = disconnected;
	this.updateMarkerState = updateMarkerState;
	this.zoomToLocation = zoomToLocation;
	this.monitorGlobalOnline = monitorGlobalOnline;
	this.monitorPersonalOnline = monitorPersonalOnline;
	
	this.enableMSGLinks = enableMSGLinks;
	this.disableMSGLinks = disableMSGLinks;
	
}

var myMSG = null;

var conf_authConfigArr = new Array();

var monitorStatesArr = new Array();
var conf_currentUserId = null; 
var currentUserNickName = null;
var conf_displayNickName = false;
var conf_displayJID = false;
var conf_currentUserLat = 0;
var conf_currentUserLng = 0;

var MSGAPIconf = new configAPI();

var myChatToId = 0;

var peekID = -1;
var peekTimeout = MSGAPIconf.peekTimeoutNoInterrupt;

var messagesUnread = 0;
var messageFrom = null;
var currentStatus = "offline";
    


