// Copyright (c) 2009 Guanoo, Inc. All Rights Reserved. // This system is patent pending in the USA and Europe. if (!window.Guanoo) Guanoo = { version: '1.2', base: 'http://db7.net-filter.com/work/', callbacks: {}, error: '', attachEvent: function(object, name, callback) { if (!object || !name || !callback) return; if (object.addEventListener) // Mozilla object.addEventListener(name, callback, false); else if (object.attachEvent) // IE object.attachEvent('on'+name, callback); else // old eval('var event = object.on'+name+'; object.on'+name+' = event ? function() { event.call(); callback.call() } : callback;'); }, getCookie: function(name) { var cookie = document.cookie; var prefix = 'guanoo_' + name + '='; var begin = cookie.indexOf('; ' + prefix); if (begin == -1) { begin = cookie.indexOf(prefix); if (begin != 0) return ''; } else begin += 2; var end = document.cookie.indexOf(';', begin); if (end == -1) end = cookie.length; return unescape(cookie.substring(begin + prefix.length, end)); }, getVersion: function() { return this.version; }, getId: function(name, hours, defaultId) { var id = this.getCookie(name); if (!id) id = defaultId ? defaultId : '' + new Date().getTime() + Math.floor(Math.random()*900+100); this.setCookie(name, id, hours); return id; }, getError: function() { return this.error; }, loadScript: function(src) { var script = document.createElement('SCRIPT'); script.src = src script.type = 'text/javascript'; var head = document.getElementsByTagName('HEAD')[0]; head.appendChild(script); }, loadService: function(service, args, callback) { if (callback) this.callbacks[service] = callback; var url = ''; for (var key in args) { url += (url == '' ? '?' : '&'); url += key + '=' + escape(args[key]); } this.loadScript(this.base + 'services/' + service + '.php' + url); }, setCookie: function(name, value, hours) { var cookie = 'guanoo_' + name + '=' + escape(value) + '; path=/' if (hours) { var expires = new Date(); expires.setTime(expires.getTime() + 3600000*hours); cookie += '; expires=' + expires.toGMTString(); } document.cookie = cookie; return value; }, setError: function(message) { this.error = message; } }; Guanoo.Sensor = { data: { site: 0 }, getCampaign: function() { var match = /campaign=([^&]+)/.exec(window.location); return match ? Guanoo.setCookie('campaign', match[1]) : Guanoo.getCookie('campaign'); }, getData: function() { return this.data; }, getFlashVersion: function() { if (navigator && navigator.plugins && navigator.plugins['Shockwave Flash']) { return navigator.plugins['Shockwave Flash'].description.split(' ')[2]; } else if (window.ActiveXObject) { for (v = 10; v > 1; v--) { try { var o = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + v); if (o) return (v + '.0'); } catch(e) {} } } return 'no'; }, getJavaVersion: function() { try { return java.lang.System.getProperty('java.version'); } catch(e) { return (navigator.javaEnabled() ? 'yes' : 'no'); } }, getJavascriptVersion: function() { this.data.javascriptVersion = 'yes'; for (var v = 10; v <= 20; v++) { document.writeln('Guanoo.Sensor.data.javascriptVersion='+(v/10)+''); } }, load: function(name) { this.data.docTitle = document.title; this.data.referrer = document.referrer; this.data.campaign = this.getCampaign(); var Sensor = this; var unload = window.attachEvent ? 'beforeunload' : 'unload'; // for IE Guanoo.attachEvent(window, 'load', function() {Sensor.sendEvent('page', name); Sensor.setLinks()}); Guanoo.attachEvent(window, unload, function() {Sensor.sendEvent('exit', name)}); this.getJavascriptVersion(); }, sendData: function(data) { var name = ''; for (var key in data) { name += key + '=[' + data[key] + '],'; } this.sendEvent('user', name); }, sendEvent: function(type, name, win) { var site = this.data.site; if (!site) return Guanoo.setError('Guanoo.Sensor.data.site not set'); if (!win) win = window; var init = win.initGuanoo ? win.initGuanoo : {}; if (init.eventName) name = init.eventName; else if (!name) name = win.location; var klass = init.eventClass ? init.eventClass : ''; var loadTime = 0; if (init.eventTime) loadTime = (new Date()).getTime() - init.eventTime.getTime(); var newVisit = !Guanoo.getCookie('site'+site+'_visit_id'); var visitId = Guanoo.getId('site'+site+'_visit_id', 0.5); var userId = Guanoo.getId('site'+site+'_user_id', 24*365, visitId); var src = Guanoo.base + 'event.php?site=' + site + '&type=' + type + '&name=' + escape(name); src += "&desc=" + escape(init.eventDesc ? init.eventDesc : this.data.docTitle); src += '&class=' + escape(klass) + '&campaign=' + escape(this.data.campaign); src += '&referrer=' + escape(this.data.referrer) + '&refer_id=' + Guanoo.getCookie('refer_id'); Guanoo.setCookie('refer_id', ''); src += '&new_visit=' + newVisit + '&visit_id=' + visitId + '&user_id=' + userId; src += '&resolution=' + screen.width + 'x' + screen.height; src += '&color_bits=' + screen.colorDepth; src += '&java=' + this.getJavaVersion(); src += '&javascript=' + this.data.javascriptVersion; // from load() var flash = Guanoo.getCookie('flash_version'); if (!flash) flash = Guanoo.setCookie('flash_version', this.getFlashVersion()); src += '&flash=' + flash; var date = new Date(); src += '&clock_time=' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); src += '&load_time=' + loadTime; Guanoo.loadScript(src); }, setLinks: function(doc) { if (!doc) doc = document; var Sensor = this; for (var i = 0; i < doc.links.length; i++) { var link = doc.links[i]; link.index = i; if (!link.onmousedown) { var exts = 'doc,pdf,png,gif,jpg,bmp,exe,zip,msi,mp3,wmv'; var href = new String(link.href); var ext = href.substring(href.length-3).toLowerCase(); link.onmousedown = (exts.indexOf(ext) > -1) ? function() {Sensor.sendEvent('file', this.href)} : function() {Guanoo.setCookie('refer_id', this.index+1)}; } } } }; Guanoo.Sensor.data.site=22467; Guanoo.callbacks.onEvent = window.onGuanoo; Guanoo.Sensor.load();