function ServerConnector() { this.endPointDirectory = ""; this.serviceEndPoint = ""; this.endPointRequest = ""; this.endPointResponse = ""; this.requestURL = ""; this.internalCache = Array(); this.endPointDirectory = "http://"+document.URL.substring(7,document.URL.indexOf('.'))+".everyonehealthy.com/ServiceEndPoints/"; } ServerConnector.prototype.AddItem = function(name, value, allowArray, returnFunction) { RequestData = Array(); RequestData['Action'] = "ADD_ITEM"; RequestData['Format'] = "JAVASCRIPT"; RequestData['Name'] = name; RequestData['Value'] = value; RequestData['AllowArray'] = allowArray; this.Request(this.endPointDirectory+"ServerConnector.sep", RequestData, ""); this.AddInternalCache(name, value, allowArray); } ServerConnector.prototype.ClearItem = function(name, returnFunction) { RequestData = Array(); RequestData['Action'] = "CLEAR_ITEM"; RequestData['Format'] = "JAVASCRIPT"; RequestData['Name'] = name; this.Request(this.endPointDirectory+"ServerConnector.sep", RequestData, ""); this.AddInternalCache(name, value, allowArray); } ServerConnector.prototype.AddInternalCache = function(name, value, allowArray) { var exists = false; for(element in this.internalCache) if(element == name) exists = true; if(exists && allowArray == 'true') { if(this.isArray(this.internalCache[name])) { this.internalCache[name].push(value); } else { newArray = Array(); newArray.push(this.internalCache[name]); newArray.push(value); this.internalCache[name] = null; this.internalCache[name] = newArray; } } else { this.internalCache[name] = value; } } ServerConnector.prototype.CheckInternal = function(name) { var exists = false; for(element in this.internalCache) { if(element == name) { exists = true; } } return exists; } ServerConnector.prototype.CreateResponseArray = function(response){ var responseArray = Array(); var tempResponse = Array(); var tempResponse = response.split("|"); responseArray['Result'] = tempResponse[0]; responseArray['Data'] = Array(); var rowNumber = 0; for(i = 1; i < tempResponse.length - 1; i++) { if(tempResponse[i].search('^') != -1) { rowData = tempResponse[i].split("^"); responseArray['Data'][rowNumber] = Array(); for(j = 0; j < rowData.length; j++) { tempArray = ServerConnector.prototype.SplitPair(rowData[j]); responseArray['Data'][rowNumber][j] = tempArray; responseArray['Data'][rowNumber][tempArray[0]] = tempArray[1]; } rowNumber++; } else { var pairedValue = ServerConnector.prototype.SplitPair(tempResponse[i]); responseArray['Data'][pairedValue[0]] = pairedValue[1]; } } return responseArray; } ServerConnector.prototype.SplitPair = function(string) { var array = string.split("="); return array; } ServerConnector.prototype.Request = function(endPointURL, requestPacket, returnFunction, async) { if(endPointURL != "") { if(requestPacket['Action'] != null) { requestParams = "?"; requestPacket['Format'] = 'JAVASCRIPT'; for(i in requestPacket) { requestParams += i+"="+requestPacket[i]+"&"; } this.endPointRequest = requestPacket; requestURL = endPointURL+requestParams+''; var xmlhttp = false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch (E) { xmlhttp = false;}} @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {try {xmlhttp = new XMLHttpRequest();}catch (e){xmlhttp = false;}} if (!xmlhttp && window.createRequest) {try {xmlhttp = window.createRequest();} catch (e) {xmlhttp = false;}} async = (async == undefined ? true : async); xmlhttp.open("GET", requestURL, async); if(!async) { xmlhttp.send(null); return xmlhttp.responseText; } else { xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { this.endPointResponse = ServerConnector.prototype.CreateResponseArray(xmlhttp.responseText); if(returnFunction != "") eval(returnFunction+'(this)'); } } xmlhttp.send(null); } } } } ServerConnector.prototype.FetchPage = function(pageAlias, parameters) { requestPacket = parameters; requestPacket['Action'] = "FETCH_PAGE"; requestPacket['PageAlias'] = pageAlias; requestPacket['Format'] = "RAW"; return this.Request("http://www.everyonehealthy.com/ServiceEndPoints/ServerConnector.sep", requestPacket, "", false); } ServerConnector.prototype.ClearStore = function(storeName) { requestPacket = Array(); requestPacket['Action'] = "CLEAR_ITEM"; requestPacket['Name'] = storeName; requestPacket['Format'] = "RAW"; return this.Request("http://www.everyonehealthy.com/ServiceEndPoints/ServerConnector.sep", requestPacket, "", true); } ServerConnector.prototype.isArray = function(obj) { ret = false; if (obj.constructor.toString().indexOf("Array") == -1) { ret = false; } else { ret = true; } return ret; } function Timer() { this.time = 0; this.timeout = 0; this.timerID = 0; this.interval = 0; this.eventFunction = ""; } Timer.prototype.Initialise = function(timeout, interval, eventFunction) { this.timeout = timeout; this.interval = interval; this.eventFunction = eventFunction; } Timer.prototype.Start = function() { this.time = 0; clearTimeout(this.timerID); this.timerID = 0; this.timeout = this.timeout <= 0 ? 100 : this.timeout; this.interval = this.interval <= 0 ? 10 : this.interval; this.timerID = setTimeout('this.Tick', this.interval); } Timer.prototype.Tick = function() { this.time += this.interval; if(this.time >= this.timeout) { eval(this.eventFunction+"("+this+")"); this.Stop(); } } Timer.prototype.Stop = function() { clearTimeout(this.timerID); this.time = 0; } function ErrorControl() { this.Errors = Array(); this.ErrorBox = ""; } ErrorControl.prototype.HideErrorBox = function() { document.getElementById(this.ErrorBox).style.display = "none"; } ErrorControl.prototype.ShowErrors = function(ErrorList) { this.Errors = ErrorList; errorListText = ""; for(error in this.Errors) { errorListText += '
'+this.Errors[error]['Name']+'
'+this.Errors[error]['Description']+'
'; } if(this.ErrorBox == undefined) { alert(errorListText); } else { document.getElementById(this.ErrorBox).innerHTML = '

Error

There were errors detected with the information you entered. Please correct the following errors:
'+errorListText+'
'; document.getElementById(this.ErrorBox).style.display = ""; document.getElementById(this.ErrorBox).style.position = "absolute"; } }