Function.prototype.createDelegation = function (obj){var method = this;return function (){return method.apply(obj, []);}}
oggtracker = function (page){this.sid = getSession();this.prefix = (("https:" == document.location.protocol) ? "https://" : "http://");this.accountId = page.act;this.p=page.p;this.cid = page.cid;this.base = this.prefix+page.host+'/monitor/';this.baseChat=this.prefix+page.host+'/cp';this.location = document.location.toString();this.title = document.title;this.referrer = document.referrer;this.psi = 10;this.pfi = 10;this.pi = 10;this.img = null;this.pt = null;this.isp = false;this.lastPingTime = (new Date()).getTime();this.interval = this.psi;this.mra = 10;this.ra = 0;this.invitePopupVisible = false;this.chatWindow = null;this.ct = null;this.ci = 5;this.status = null;}
oggtracker.A = 10;oggtracker.O = 11;oggtracker.R = 12;oggtracker.I = 13;oggtracker.CD = 14;oggtracker.CA = 15;oggtracker.CH = 20;oggtracker.ID = 16;
oggtracker.prototype = {onOpenSuccess: function (){if (1 == this.img.width){this.startP();}},onOpenFailure: function (){},
onPS: function (){this.isp = false;this.lastPingTime = (new Date()).getTime();this.interval = this.psi;if (this.img != null){switch (this.img.width){case 1:this.ra = 0;this.status = oggtracker.A;break;case 2:this.stopP();this.status = oggtracker.R;break;case 3:this.ra++;if (this.ra >= this.mra){this.stopP();}else{this.interval = this.pfi;}this.status = oggtracker.O;break;case 4:this.sip(false);this.status = oggtracker.I;break;case 5:this.status = oggtracker.CD;this.hip();break;case 6:this.status = oggtracker.CA;this.hip();break;case 7:this.status = oggtracker.CH;break;case 8:this.status = oggtracker.ID;this.hip();break;}}},
opf: function (){this.isp = false;this.lastPingTime = (new Date()).getTime();this.interval = this.pfi;},
ping: function (){var diff = (new Date()).getTime() - this.lastPingTime;if (!this.isp && diff > this.interval * 1000){this.isp = true;var url = this.base + 'ping.jsp?';url += 'accountId=' + this.accountId;url += '&sid=' + this.sid;url += '&p='+this.p;url += '&location=' + encodeURIComponent(this.location);url += '&t=' + (new Date()).getTime();var obj = this;this.img = new Image();this.img.onload = function () {obj.onPS();};this.img.onerror = function () {obj.opf();};this.img.src = url;}},
init: function (){this.status = oggtracker.A;var url = this.base + 'startjs.jsp?';url += 'accountId=' + this.accountId;url += '&sid=' + this.sid;url += '&cid=' + this.cid;url += '&p='+this.p;url += '&location=' + encodeURIComponent(this.location);url += '&title=' + encodeURIComponent(this.title);url += '&t=' + (new Date()).getTime();url += '&referrer=' + encodeURIComponent(this.referrer);var obj = this;this.img = new Image();this.img.onload = function () {obj.onOpenSuccess();};this.img.onerror = function () {obj.onOpenFailure();};this.img.src = url;if (document.location.toString().indexOf('oggPrev=yes') != -1){this.sip(true);}},
startP: function (){if (null == this.pt){var obj = this;this.pt = setInterval( function () {obj.ping();}, this.pi * 1000);}},
stopP: function (){if (this.pt != null){clearInterval(this.pt);this.pt = null;}},
getInvitePopup: function (preview){var retval = document.getElementById('oggp');if (!doDelayed(page.pdelay)){return;}
var mtop=page.popup_margin_top;var mleft=page.popup_margin_left;if (!mtop) mtop="15%";if (!mleft) mleft="30%";
if (!retval){setLP();var popup='https://'+page.host+'/monitor/popup.jsp?act='+this.accountId+'&sid='+this.sid+'&cid='+this.cid+'&font='+page.font+'&fs='+page.fs+'&img='+page.img;
    popup += '&t=' + (new Date()).getTime();retval = document.createElement('div');
    retval.id = 'oggp';retval.style.position = 'fixed';retval.style.top = mtop;retval.style.left = mleft;retval.style.display = 'none';retval.style.zIndex = 10000;var top = document.createElement('div');top.style.position = 'relative';top.style.overflow = 'hidden';
    iframe = document.createElement('iframe');iframe.frameBorder=0;iframe.allowTransparency=true;iframe.width="405px";iframe.height="300px";iframe.id="oggiframe";iframe.src=popup;iframe.scrolling="no";top.id = 'oggpopup';retval.appendChild(iframe);
    document.body.appendChild(retval);
    /*@if (@_jscript_version < 5.7)retval.style.position = 'absolute';if (document.compatMode != 'BackCompat'){retval.style.setExpression('top', 'documentElement.scrollTop+documentElement.clientHeight/2');}
    @else @*/
    if ('BackCompat' == document.compatMode){retval.style.position = 'absolute';}
    /*@end@*/
}else if (preview){var popup='https://'+page.host+'/monitor/popup.jsp?sid='+this.sid+'&cid='+this.cid+'&font='+page.font+'&fs='+page.fs;popup += '&t=' + (new Date()).getTime();var popupval = document.getElementById('oggpopup');var popupMsg= '<iframe id="oggiframe" width="400px" height="300px"  src="'+popup+'" scrolling="no" frameborder="0" ALLOWTRANSPARENCY="true"></iframe>';popupval.innerHTML = popupMsg;
}return retval;},
sip: function (preview){ if (!this.invitePopupVisible){var popup = this.getInvitePopup(true);if (popup){if (typeof popup.style.opacity !== 'undefined'){var opacity = 0;popup.style.opacity = 0;popup.style.display = 'block';var iter = function (){if (opacity < 1){opacity = opacity + 0.1;opacity = opacity > 1 ? 1 : opacity;popup.style.opacity = opacity;setTimeout(iter, 40);}};iter();}else{popup.style.display = 'block';}}this.invitePopupVisible = true;}},
hip: function (){if (this.invitePopupVisible){var popup = this.getInvitePopup(false);if (popup && 'block' == popup.style.display){if (typeof popup.style.opacity !== 'undefined'){var opacity = 1;var iter = function (){if (opacity > 0){opacity = opacity - 0.2;opacity = opacity < 0 ? 0 : opacity;popup.style.opacity = opacity;setTimeout(iter, 40);}else{popup.style.display = 'none';}};iter();}else{popup.style.display = 'none';}}this.invitePopupVisible = false;}},
startCloseCheck: function (){if (!this.ct){this.ct = setInterval(this.onCloseCheck.createDelegation(this), this.ci * 1000);}},
stopCloseCheck: function (){if (this.ct){clearInterval(this.ct);this.ct = null;}},onCloseCheck: function (){var stop = true;if (oggtracker.CA == this.status && this.chatWindow && !this.chatWindow.closed){stop = false;}if (oggtracker.CA == this.status && this.chatWindow && this.chatWindow.closed){this.chatWindow = null;this.sendCIC();}if (stop){this.stopCloseCheck();}},
sendCI: function (){var url = this.base + 'cancel.jsp';url += '?accountId=' + this.accountId;url += '&sid=' + this.sid;url += '&location=' + encodeURIComponent(this.location);url += '&t=' + (new Date()).getTime();var img = new Image();img.src = url;},
sendCIC: function (){var url = this.base + 'cancel.jsp';url += '?accountId=' + this.accountId;url += '&sid=' + this.sid;url += '&close=yes';url += '&location=' + encodeURIComponent(this.location);url += '&t=' + (new Date()).getTime();var img = new Image();img.src = url;}}
function setSession(sid){document.cookie="sid="+sid;return sid;}function getSession(){var sess = readCookie("sid");if (sess == undefined || sess ==""){sess = setSession(gg());}return sess;}function gg(){return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);return v.toString(16);});};function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' '){c = c.substring(1,c.length);}if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}function doDelayed(delay){var dh = readCookie("__dh");if (status == oggtracker.I){return true;};if (delay == null || delay <= 0 || dh == null || dh == '' ){return true;}else{var now = new Date();var time=now.getTime();if ((time-dh) > (delay*3600*1000)){return true;}else{var d = (time-dh)/(1000);return false;}}};function setLP(){var now = new Date();var lv = new Date();var time = now.getTime();time += 3600 * 1000*24*365;now.setTime(time);document.cookie = '__dh=' + lv.getTime() +'; expires=' + now +'; path=/';}
var tracker = new oggtracker(page);tracker.init();
