var icApplicationUrl = "https://secure.logmeinrescue.com/"; var ICLoader = null; // Default websessionID length var webSessionIdLength = 24; function RescueInstantChatLoader() { var msp = null; var mspcounter = 0; var windtitle = ""; var windblinkingvar = null; // Start InstantChat Preloader this.Start = function() { // Reload page with rescuewebsesisonid if (window.location.hash.length == webSessionIdLength + 1) { if ((window.location + "").indexOf("rescuewebsessionid") == -1) { var separator = "?"; if (window.location.search.length != 0) separator = "&"; window.location = removeBookmark(window.location + "") + separator + "rescuewebsessionid=" + window.location.hash.replace("#", ""); return; } else { window.location = (window.location + "").replace("rescuewebsessionid", "rescuewebsession2id"); return; } } ICLoader = this; // Check the obligatory parameters if (checkParameter(ICLoader.ICContainer, "ICContainer", true)) return; if (checkParameter(ICLoader.HostedCSS, "HostedCSS", false)) return; ICLoader.ICContainerDiv = document.getElementById(ICLoader.ICContainer); // Check the obligatory attributes if (ICLoader.ICContainerDiv.style.width == "") { alert('*** ENGINE ERROR ***\n\nMissing "style.width": "' + ICLoader.ICContainer + '"'); return; } if (ICLoader.ICContainerDiv.style.height == "") { alert('*** ENGINE ERROR ***\n\nMissing "style.height": "' + ICLoader.ICContainer + '"'); return; } // Hosted Instant Chat or not // iPod Touch, or any other iPod // iPhone // iPad // Palm Pre or Palm device with webOS // Android if (!(IsHostedInstance() || (!IsHostedInstance() && !AmIiPodTouch() && !AmIiPhone() && !AmIiPad() && !AmIPalmPre() && !AmIAndroid()))) { // Generate an empty viewport var meta = document.createElement("meta"); meta.name = "viewport"; meta.id = "viewport"; // Disallow zooming + set default viewstate (for iPhone + iPod Touch) meta.content = "width=334; height=434; user-scalable=0;"; // Set default container size (for iPhone + iPod Touch) ICLoader.ICContainerDiv.style.width = "334px"; ICLoader.ICContainerDiv.style.height = "434px"; // iPad if (AmIiPad()) { ICLoader.ICContainerDiv.style.width = "538px"; // 70% of 768 ICLoader.ICContainerDiv.style.height = "663px"; // (70% of 1024) - safari header height // Disallow zooming meta.content = "width=538; height=663; user-scalable=0;"; } // Palm Pre or Palm device with webOS if (AmIPalmPre()) { ICLoader.ICContainerDiv.style.width = "334px"; ICLoader.ICContainerDiv.style.height = "480px"; // Allow zooming meta.content = "width=334; height=480; user-scalable=yes;"; } // Android if (AmIAndroid()) { ICLoader.ICContainerDiv.style.width = "334px"; // Default ic size ICLoader.ICContainerDiv.style.height = "700px"; // Allow zooming meta.content = "width=334; height=700; user-scalable=yes;"; } // Apply viewstate document.getElementsByTagName("head").item(0).appendChild(meta); } if (ICLoader.PrivateCode != null) if (ICLoader.PrivateCode.length > 6) ICLoader.PrivateCode = ICLoader.PrivateCode.substring(0, 6); // Encode hasmark var encodedLocation = window.location + ""; encodedLocation = encodedLocation.replace("#", "-h-a-s-m1-a2-r5-k7-"); // Generate content var content = ""; // Start to communicate with Client Engine msp = setInterval(GetMessagesFromClientEngine, 1000); // Add content ICLoader.ICContainerDiv.innerHTML = content; ICLoader.ICMainFrame = document.getElementById("ic_mainframe"); } // Set the position of main div this.centralizeGUI = function() { if (ICLoader != null) { // Hosted Instant Chat or not // iPod Touch, or any other iPod // iPhone // iPad // Palm Pre or Palm device with webOS // Android if (IsHostedInstance() || (!IsHostedInstance() && !AmIiPodTouch() && !AmIiPhone() && !AmIiPad() && !AmIPalmPre() && !AmIAndroid())) { if (!document.body.offsetWidth || document.body.offsetWidth == 0) { if ((parseInt(window.innerWidth) + 20) > parseInt(getLiveProperty(ICLoader.ICContainerDiv, "width"))) ICLoader.ICMainFrame.style.width = parseInt(window.innerWidth) + 20 + "px"; } else { if ((parseInt(document.body.offsetWidth) + 20) > parseInt(getLiveProperty(ICLoader.ICContainerDiv, "width"))) { if (navigator.userAgent.indexOf("MSIE 8") != -1 || navigator.userAgent.indexOf("MSIE 9") != -1) ICLoader.ICMainFrame.style.width = parseInt(document.body.offsetWidth) + 16 + "px"; else ICLoader.ICMainFrame.style.width = parseInt(document.body.offsetWidth) + 20 + "px"; } } if (document.documentElement.clientHeight) { if (parseInt(document.documentElement.clientHeight) > parseInt(getLiveProperty(ICLoader.ICContainerDiv, "height"))) ICLoader.ICMainFrame.style.height = parseInt(document.documentElement.clientHeight) + "px"; } } } } // Check the obligatory parameters function checkParameter(obj, name, type) { var returnValue = false; if (obj == null || !obj) { alert('*** ENGINE ERROR ***\n\nMissing object parameter: "' + name + '"'); returnValue = true; } else if (type && !document.getElementById(obj)) { alert('*** ENGINE ERROR ***\n\nMissing HTML element: "' + obj + '"'); returnValue = true; } return returnValue; } // Return QueryString parameter function getParameter(name) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return results[1]; } // Get actual property of style attribute function getLiveProperty(oObject, sProperty) { // 0px is the default value var sPropertyValue = "0px"; if (oObject.currentStyle) sPropertyValue = oObject.currentStyle[sProperty]; else if(window.getComputedStyle) { var oStyle = window.getComputedStyle(oObject, null); if (oStyle != null) sPropertyValue = oStyle.getPropertyValue(sProperty); } // E.g.: the return value is auto, then returns 0px, only for IE sessions if ((parseInt(sPropertyValue) + "").indexOf("NaN") != -1) sPropertyValue = "0px"; return sPropertyValue; } // Communicate with Client Engine function GetMessagesFromClientEngine() { mspcounter += 1; var tmpstr = window.location + ""; if (tmpstr.indexOf("#") != -1) { clearInterval(msp); if (ICLoader.HostedErrorHandler != null) { if ((tmpstr.substring(tmpstr.indexOf("#") + 1).indexOf("-del") == -1) && (tmpstr.substring(tmpstr.indexOf("#") + 1).length != webSessionIdLength)) { ICLoader.HostedErrorHandler(tmpstr.substring(tmpstr.indexOf("#") + 1)); if (tmpstr.substring(tmpstr.indexOf("#") + 1).length != webSessionIdLength) window.location = tmpstr + "-del"; } } } if (mspcounter > 60) clearInterval(msp); } function encodeURIComponent2(inputstr) { var str = encodeURIComponent(inputstr); str = decodeText3(str, "%25", "%"); str = decodeText3(str, "'", '"'); return str; } // Remove bookmark function removeBookmark(url) { if (url.indexOf("#") != -1) return url.substring(0, url.indexOf("#")); else return url; } function decodeText3(text, first, second) { var stext = text; while (stext.indexOf(first) != -1) { stext = stext.replace(first, second); } return stext; } this.startBlinking = function(msgText) { if (windblinkingvar == null) windblinkingvar = setInterval(function() { document.title = ((document.title == msgText) ? windtitle : msgText); }, 300); } this.endBlinking = function() { if (windblinkingvar != null) { clearInterval(windblinkingvar); document.title = windtitle; windblinkingvar = null; } } this.setWindowTitle = function(docTitle) { document.title = docTitle; windtitle = docTitle; } // Hosted Instant Chat or not function IsHostedInstance() { // Under internal servers, e.g.: 3amlabs.net // Under Live servers, e.g.: LIVE, BETA, Enterprise, etc. if (IsUnderInternalServers(window.location + "") || IsUnderLiveServers(window.location + "")) // DEMO Instant Chat is a hosted instance under Rescue environment // Under Rescue Demo return IsUnderRescueDemo(window.location + ""); else return true; } // Under internal servers, e.g.: 3amlabs.net function IsUnderInternalServers(sUrl) { if (sUrl.toLowerCase().indexOf("3amlabs.net") != -1) return true; else return false; } // Under Live servers, e.g.: LIVE, BETA, Enterprise, etc. function IsUnderLiveServers(sUrl) { if (sUrl.toLowerCase().indexOf("logmeinrescue") != -1) return true; else return false; } // Under Rescue Demo function IsUnderRescueDemo(sUrl) { if ((sUrl.toLowerCase().indexOf("instantchat/demo/default.aspx") != -1) || (sUrl.toLowerCase().indexOf("instantchat/salesdemo/default.aspx") != -1) || (sUrl.toLowerCase().indexOf("chatnow/default.aspx") != -1)) return true; else return false; } // iPod Touch, or any other iPod function AmIiPodTouch() { // Get user agent string if (GetUserAgent().toLowerCase().indexOf("(ipod") != -1) return true; else return false; } // iPhone function AmIiPhone() { // Get user agent string if (GetUserAgent().toLowerCase().indexOf("(iphone") != -1) return true; else return false; } // iPad function AmIiPad() { // Get user agent string if (GetUserAgent().toLowerCase().indexOf("(ipad") != -1) return true; else return false; } // Android function AmIAndroid() { // Get user agent string if (GetUserAgent().toLowerCase().indexOf("android") != -1) return true; else return false; } // Palm Pre or Palm device with webOS function AmIPalmPre() { // Get user agent string if (GetUserAgent().toLowerCase().indexOf("webos") != -1 || GetUserAgent().toLowerCase().indexOf("hpwos") != -1) return true; else return false; } // Get user agent string function GetUserAgent() { if (navigator.userAgent) return navigator.userAgent; else return ""; } }