// Live Help Server Version: 1.1 Rev. 1 // TODO PETER - // VALIDAR que Google Maps este habilitado de lo contrario no imprimir el tracking // ADICIONAR EL URL DEL SERVIDOR DINAMICAMENTE var region = ''; var country = ''; var city = ''; var countrycode = ''; var latitude = ''; var longitude = ''; function initgeo(geoDict) { countrycode = geoDict['CountryCode']; country = geoDict['CountryName']; city = geoDict['City']; latitude = geoDict['Latitude']; longitude = geoDict['Longitude']; region = geoDict['RegionName']; } //--- BEGIN GEO LOCATION --- //document.writeln(''); //--- END GEO LOCATION --- // JavaScript Check Status Functions var topMargin = 10; var leftMargin = 10; var itopMargin = topMargin; var ileftMargin = leftMargin; var ns6 = (!document.all && document.getElementById); var ie4 = (document.all); var ns4 = (document.layers); var initiateOpen = 0; var initiateLoaded = 0; var infoOpen = 0; var infoImageLoaded = 0; var countTracker = 0; var timeElapsed; var timerTracker; var trackingInitalized = 0; var trackerLoaded = 0; var windowWidth = 470 var windowHeight = 369 var hAlign = ""; var vAlign = ""; var layerHeight = 238; var layerWidth = 377; var slideTime = 1200; var windowLeft = (screen.width - windowWidth) / 2; var windowTop = (screen.height - windowHeight) / 2; var size = 'height=' + windowHeight + ',width=' + windowWidth + ',top=' + windowTop + ',left=' + windowLeft; //Images trackerStatus = new Image; openingTrackerStatus = new Image; acceptTrackerStatus = new Image; declineTrackerStatus = new Image; var title = document.title; var referrer; //Script tracking and status indicator var _vlDomain = 0; var _vlLanguage = 'en'; var _vlService = 1; var _vlTracking = new Boolean(true); var _vlStatus_indicator = new Boolean(true); var _request_initiated = new Boolean(false); function none() { } function toggle(object) { if (document.getElementById) { if (document.getElementById(object).style.visibility == 'visible') document.getElementById(object).style.visibility = 'hidden'; else document.getElementById(object).style.visibility = 'visible'; } else if (document.layers && document.layers[object] != null) { if (document.layers[object].visibility == 'visible' || document.layers[object].visibility == 'show' ) document.layers[object].visibility = 'hidden'; else document.layers[object].visibility = 'visible'; } else if (document.all) { if (document.all[object].style.visibility == 'visible') document.all[object].style.visibility = 'hidden'; else document.all[object].style.visibility = 'visible'; } return false; } function statusClass (s_id, _vlDomain) { this.s_id = s_id; this.currentTime = currentTime; this.toggle = toggle; this.initiateFloatLayer = initiateFloatLayer; // this.floatRefresh = floatRefresh; this.resetTimer = resetTimer; this.floatObject = floatObject; // this.mainPositions = mainPositions; this.mainTrigger = mainTrigger; // this.floatStart = floatStart; this.animate = animate; this.resetLayerLocation = resetLayerLocation; this.stopLayer = stopLayer; this.acceptInitiateChat = acceptInitiateChat; this.declineInitiateChat = declineInitiateChat; this.onloadEvent = onloadEvent; this.checkInitiate = checkInitiate; this.openInfo = openInfo; this.infoImageLoad = infoImageLoad; this.displayInfo = displayInfo; this.closeInfo = closeInfo; this.cancelClosingInfo = cancelClosingInfo; this.openLiveHelp = openLiveHelp; this.onlineTracker = onlineTracker; var server = 'http://www.yongefloristtoronto.ca'; var request = ''; var domain = '.yongefloristtoronto.ca'; var timerClosingLiveHelpInfo; var timerLiveHelpInfo; var timerInitiateLayer; var idleTimeout = 90 * 60 * 1000; var timeStart = currentTime(); function currentTime() { var date = new Date(); return date.getTime(); } if (document.referrer.indexOf('') >= 0) { referrer = ''; } else { referrer = escape(document.referrer); } // JavaScript Initiate Chat Layer Functions function initiateFloatLayer() { var trkUrl = ""; //var openingTrackerStatus = new Image; var time = currentTime(); trkUrl = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=' + s_id + '&TIME=' + time + '&INITIATE=Opened'; openingTrackerStatus.src = trkUrl; if ( ie4 ) document.all['initiateChatResponse_' + s_id].location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Opened'; if ( ns4 ) eval("document.initiateChatResponse_" + s_id + ".location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Opened'"); if ( ns6 ) document.getElementById('initiateChatResponse_' + s_id).location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Opened'; floatRefresh(); } function get_vertical_scroll( ) { if( window.pageYOffset ) return window.pageYOffset; else if ( ( document.documentElement ) && ( document.documentElement.scrollTop ) ) return document.documentElement.scrollTop; else if ( ( document.body ) && ( document.body.scrollTop ) ) return document.body.scrollTop; else return 0; } window.floatRefresh = function() { var trkUrl = ""; window.clearTimeout(timerInitiateLayer); window.clearTimeout(timerTracker); if (countTracker == 10000) { var time = currentTime(); trkUrl = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time; trackerStatus.onload = resetTimer; trackerStatus.src = trkUrl; countTracker = 0; } else { countTracker = countTracker + 10; //timerInitiateLayer = window.setTimeout('mainPositions();floatRefresh();', 10); //timerInitiateLayer = window.setTimeout('floatRefresh();', 10); document.getElementById( 'floatLayer_1' ).style.top = ( get_vertical_scroll( ) + 10 ) + "px"; setTimeout( function(){ glue( document.getElementById( 'floatLayer_1' )); }, 10 ); } } function glue( object ) { object.style.top = ( get_vertical_scroll( ) + 10 ) + "px"; setTimeout( function(){ glue( object ); }, 1 ); } window.mainPositions=function() { if(_vlTracking == false){ return false; } /* if (ns4) { eval("this.currentY = document.floatLayer_" + s_id + ".top"); eval("this.currentX = document.floatLayer_" + s_id + ".left"); this.scrollTop = window.pageYOffset; this.scrollLeft = window.pageXOffset; mainTrigger(); } else if(ns6) { this.currentY = parseInt(document.getElementById('floatLayer_' + s_id).style.top); this.currentX = parseInt(document.getElementById('floatLayer_' + s_id).style.left); this.scrollTop = scrollY; this.scrollLeft = scrollX; mainTrigger(); } else if(ie4) { this.currentY = document.all['floatLayer_' + s_id].style.pixelTop; this.currentX = document.all['floatLayer_' + s_id].style.pixelLeft; this.scrollTop = document.body.scrollTop; this.scrollLeft = document.body.scrollLeft; mainTrigger(); } */ //glue( document.getElementById( 'floatLayer_1' ) ); } function resetTimer() { mainPositions(); floatRefresh(); } function floatObject() { if (ns4 || ns6) { findHeight = window.innerHeight; findWidth = window.innerWidth; } else if(ie4) { findHeight = document.body.clientHeight; findWidth = document.body.clientWidth; } } function mainTrigger() { var newTargetY = this.scrollTop + this.topMargin; if((this.scrollLeft + this.leftMargin) > 400) { var newTargetX = this.scrollLeft + this.leftMargin -300; }else { var newTargetX = this.scrollLeft + this.leftMargin; } if ( this.currentY != newTargetY || this.currentX != newTargetX) { if ( newTargetY != this.targetY || newTargetX != this.targetX ) { this.targetY = newTargetY; this.targetX = newTargetX; floatStart(); } animate(); } } function floatStart() { var now = new Date(); this.Y = this.targetY - this.currentY; this.X = this.targetX - this.currentX; this.C = Math.PI / ( 2 * this.slideTime ) this.D = now.getTime() if (Math.abs(this.Y) > this.findHeight) { this.E = this.Y > 0 ? this.targetY - this.findHeight : this.targetY + this.findHeight; this.Y = this.Y > 0 ? this.findHeight : -this.findHeight; } else { this.E = this.currentY; } if (Math.abs(this.X) > this.findWidth) { this.F = this.X > 0 ? this.targetX - this.findWidth : this.targetX + this.findWidth; this.X = this.X > 0 ? this.findWidth : -this.findWidth; } else { this.F = this.currentX; } } function animate() { var now = new Date() ; var newY = this.Y * Math.sin( this.C * ( now.getTime() - this.D ) ) + this.E; var newX = this.X * Math.sin( this.C * ( now.getTime() - this.D ) ) + this.F; newY = Math.round(newY); newX = Math.round(newX); if (( this.Y > 0 && newY > this.currentY ) || ( this.Y < 0 && newY < this.currentY )) { if ( ie4 ) { document.all['floatLayer_' + s_id].style.pixelTop = newY } else if ( ns4 ) { eval("document.floatLayer_" + s_id + ".top = newY"); } else if ( ns6 ) { document.getElementById('floatLayer_' + s_id).style.top = newY; } } if (( this.X > 0 && newX > this.currentX ) || ( this.X < 0 && newX < this.currentX )) { if ( ie4 ) { document.all['floatLayer_' + s_id].style.pixelLeft = newX; } else if ( ns4 ) { eval("document.floatLayer_" + s_id + ".left = newX"); } else if ( ns6 ) { document.getElementById('floatLayer_' + s_id).style.left = newX; } } } function resetLayerLocation() { var browserWidth = 0, browserHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { browserWidth = window.innerWidth; browserHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { browserWidth = document.documentElement.clientWidth; browserHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { browserWidth = document.body.clientWidth; browserHeight = document.body.clientHeight; } if ((ns4) || (ns6)) { if (hAlign == "left") { leftMargin = ileftMargin; } if (hAlign == "right") { leftMargin = window.innerWidth-ileftMargin-layerWidth-20; } if (hAlign == "center") { leftMargin = Math.round((window.innerWidth-20)/2)-Math.round(layerWidth/2); } if (vAlign == "top") { topMargin = itopMargin; } if (vAlign == "bottom") { topMargin = window.innerHeight-itopMargin-layerHeight; } if (vAlign == "center") { topMargin = Math.round((window.innerHeight-20)/2)-Math.round(layerHeight/2); } } if (ie4) { if (hAlign == "left") { leftMargin = ileftMargin; } if (hAlign == "right") { leftMargin = document.body.offsetWidth-ileftMargin-layerWidth-20; } if (hAlign == "center") { leftMargin = Math.round((document.body.offsetWidth-20)/2)-Math.round(layerWidth/2); } if (vAlign == "top") { topMargin = itopMargin; } if (vAlign == "bottom") { topMargin = browserHeight-itopMargin-layerHeight; } if (vAlign == "center") { topMargin = Math.round((browserHeight-20)/2)-Math.round(layerHeight/2); } } } function stopLayer() { window.clearTimeout(timerInitiateLayer); if ( ns4 ) { eval("document.floatLayer_" + s_id + ".top = '10'"); eval("document.floatLayer_" + s_id + ".left = '10'"); } else if ( ns6 ) { document.getElementById('floatLayer_' + s_id).style.top = "10"; document.getElementById('floatLayer_' + s_id).style.left = "10"; } else if ( ie4 ) { document.all['floatLayer_' + s_id].style.pixelTop = "10px"; document.all['floatLayer_' + s_id].style.pixelLeft = "10px"; } } function acceptInitiateChat() { var trkUrl = ""; //var acceptTrackerStatus = new Image; var time = currentTime(); trkUrl = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Accepted'; acceptTrackerStatus.src = trkUrl; if ( ie4 )document.all['initiateChatResponse_' + s_id].location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Accepted'; if ( ns4 )eval("document.initiateChatResponse_" + s_id + ".location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Accepted'"); if ( ns6 )document.getElementById('initiateChatResponse_' + s_id).location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Accepted'; if (initiateOpen == 1) { toggle('floatLayer_' + s_id); } initiateLoaded = 0; stopLayer(); onlineTracker(); } function declineInitiateChat() { var trkUrl = ""; //var declineTrackerStatus = new Image; var time = currentTime(); trkUrl = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Declined'; declineTrackerStatus.src = trkUrl; if ( ie4 )document.all['initiateChatResponse_' + s_id].location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Declined'; if ( ns4 )eval("document.initiateChatResponse_" + s_id + ".location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Declined'"); if ( ns6 )document.getElementById('initiateChatResponse_' + s_id).location = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=s_id&TIME=' + time + '&INITIATE=Declined'; if (initiateOpen == 1) { toggle('floatLayer_' + s_id); initiateOpen = 0; } initiateLoaded = 0; stopLayer(); onlineTracker(); } window.onload = onloadEvent; window.onresize = resetLayerLocation; function onloadEvent() { resetLayerLocation(); mainPositions(); } function checkInitiate() { // Check if site visitor has an Initiate Chat Request Pending for display... var imageWidth = this.width; var imageHeight = this.height; if ((imageWidth == 2 && imageHeight == 2 && initiateOpen == 0) || initiateLoaded == 1) { initiateFloatLayer(); toggle('floatLayer_' + s_id); initiateOpen = 1; } } function openInfo(statusImage, e) { return false; if(_vlTracking == false){ return false; } window.clearTimeout(timerLiveHelpInfo); cancelClosingInfo(); var iLayerX = document['LiveHelpInfoContent_' + s_id].width; var iLayerY = document['LiveHelpInfoContent_' + s_id].height; var iPosX = statusImage.offsetLeft; var iPosY = statusImage.offsetTop; var iWidth = statusImage.clientWidth; var iHeight = statusImage.clientHeight; if (!iWidth) { iWidth = statusImage.offsetWidth; } obj = statusImage.offsetParent; while(obj != null){ iPosX += obj.offsetLeft; iPosY += obj.offsetTop; obj = obj.offsetParent; } var iCurrentY; var iCurrentX; var iScrollTop; var iScrollLeft; var iFindHeight; var iFindWidth; if (ns4) { iScrollTop = window.pageYOffset; iScrollLeft = window.pageXOffset; } else if(ns6) { iScrollTop = scrollY; iScrollLeft = scrollX; } else if(ie4) { iScrollTop = document.body.scrollTop; iScrollLeft = document.body.scrollLeft; iFindHeight = document.body.clientHeight; iFindWidth = document.body.clientWidth; } if (ns4 || ns6) { iFindHeight = window.innerHeight; iFindWidth = window.innerWidth; } infoImage = new Image(); infoImage.onload = infoImageLoad; var iMarginHeight = iFindHeight - (iHeight + iPosY - iScrollTop); var iMarginWidth = iFindWidth - (iWidth + iPosX - iScrollLeft); if (iMarginHeight < iLayerY && iPosY > iLayerY) { if (ie4) { document.all['LiveHelpInfo_' + s_id].style.background = 'url(' + infoImage.src + ')'; } else if (ns4) { eval("document.LiveHelpInfo_" + s_id + ".background = 'url(' + infoImage.src + ')'"); } else if(ns6) { document.getElementById('LiveHelpInfo_' + s_id).style.background = 'url(' + infoImage.src + ')'; } iNewX = iPosX - 15; iNewY = iPosY + 20 - iLayerY - 20; } else { if (ie4) { document.all['LiveHelpInfo_' + s_id].style.background = 'url(' + infoImage.src + ')'; } else if (ns4) { eval("document.LiveHelpInfo_" + s_id + ".background = 'url(' + infoImage.src + ')'"); } else if(ns6) { document.getElementById('LiveHelpInfo_' + s_id).style.background = 'url(' + infoImage.src + ')'; } iNewX = iPosX + 15; iNewY = iPosY + 20 + statusImage.height - 20; } if (iMarginWidth < iLayerX && iPosX > iLayerX) { iNewX = iPosX - iLayerX + 175; } else if (iMarginWidth > iLayerX && iPosX < iLayerX) { iNewX = iPosX + 25; } if (ie4) { document.all['LiveHelpInfo_' + s_id].style.pixelTop = iNewY; document.all['LiveHelpInfo_' + s_id].style.pixelLeft = iNewX; } else if (ns4) { eval("document.LiveHelpInfo_" + s_id + ".top = iNewY"); eval("document.LiveHelpInfo_" + s_id + ".left = iNewX"); } else if(ns6) { document.getElementById('LiveHelpInfo_' + s_id).style.top = iNewY + "px"; document.getElementById('LiveHelpInfo_' + s_id).style.left = iNewX + "px"; } if (infoImageLoaded == 1) { displayInfo(); } } function infoImageLoad() { infoImageLoaded = 1; } //TODO - Improve the method for displayInfo and closeInfo because this method is not using s_id directly function displayInfo() { if (infoOpen == 0) { timerLiveHelpInfo = window.setTimeout("toggle('LiveHelpInfo_1'); infoOpen = 1;", 2000); } } function closeInfo() { return false; window.clearTimeout(timerLiveHelpInfo); if (infoOpen == 1) { timerClosingLiveHelpInfo = window.setTimeout("toggle('LiveHelpInfo_1'); infoOpen = 0;", 500); } } function cancelClosingInfo() { window.clearTimeout(timerClosingLiveHelpInfo); } function openLiveHelp() { switch(s_id) { case 1 : { var winLiveHelp = window.open('http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/index.php?' + 'DOMAINID=' + _vlDomain + '&URL=' + document.location + '&TITLE=' + title + '&SERVER=http://www.yongefloristtoronto.ca&COOKIE=.yongefloristtoronto.ca&LANGUAGE=' + _vlLanguage + '&CHARSET=', 'SUPPORTER' + s_id + '_0', size) break } case 4 : { var winLiveHelp = window.open('http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/webc_form.php?URL=' + document.location + '&TITLE=' + title + '&SERVER=http://www.yongefloristtoronto.ca&COOKIE=.yongefloristtoronto.ca&LANGUAGE=&CHARSET=', 'SUPPORTER' + s_id + '_0', size) break } } if (winLiveHelp) { winLiveHelp.opener = self; } } function onlineTracker() { var trkUrl = ""; var time = currentTime(); if ( ie4 ) { if (document.all['initiateChatResponse_' + s_id]) { trackerLoaded = 1; } } else if ( ns4 ) { if(eval("document.initiateChatResponse_" + s_id)) { trackerLoaded = 1; } } else if ( ns6 ) { if(document.getElementById('initiateChatResponse_' + s_id)) { trackerLoaded = 1; } } if (trackingInitalized == 0) { //-- Geo Location data trkUrl = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=' + s_id + '&TIME='+ time + '&WIDTH=' + screen.width + '&HEIGHT=' + screen.height + '&TITLE=' + title + '&URL=' + document.location + '&REFERRER=' + referrer + '&COOKIE=.yongefloristtoronto.ca&USERID=&services=' + '&LANGUAGE=' + _vlLanguage + '&DOMAINID=' + _vlDomain + '&SERVICE=' + _vlService + '®ion=' + region + '&country=' + country + '&city=' + city + '&countrycode=' + countrycode + '&latitude=' + latitude + '&longitude=' + longitude; trackerStatus.src = trkUrl; trackingInitalized = 1; } else { if (trackerLoaded == 1) { trkUrl = 'http://www.yongefloristtoronto.ca/administrator/components/com_activehelper_livehelp/server/import/tracker.php?status_id=' + s_id + '&TIME=' + time + '&USERID=&services='+ '&DOMAINID=' + _vlDomain + '&LANGUAGE=' + _vlLanguage + '&SERVICE=' + _vlService; trackerStatus.onload = checkInitiate; trackerStatus.src = trkUrl; } } // If the Site Visitor has been Idle for under the given idleTimeout then run the tracker timeElapsed = time - timeStart; if ((timeElapsed < idleTimeout) && (_vlTracking == true)) { window.clearTimeout(timerTracker); timerTracker = window.setTimeout('s' + s_id + '.onlineTracker();', 10000); } } onlineTracker(); } function startLivehelp() { // loadGeoLocation(); document.writeln(''); if(_vlTracking){ document.writeln(''); document.writeln('
