


/*! Copyright 2009 the Rubicon Project.  All Rights Reserved.  No permission is granted to use, copy or extend this code */






oz_partner = "rubicon";





if(typeof oz_page_profiled=="undefined"){oz_page_profiled=false;}if(typeof oz_subframes_allowed=="undefined"){oz_subframes_allowed=false;}if(typeof oz_source=="undefined"){oz_source=document;}var oz_scripts_loaded=new Object();function OthersOnlineSensor(){this.config={delayAfterLoad:2*1000,sensor_sample:100,pixel_sample:25,domain_specific_parsing:false,use_local_storage:false,host:"http://www.othersonline.com",statichost:"http://www.othersonline.com"};
this.default_context={oz_partner:"othersonline.com",oz_session_id:null,oz_partner_user_id:null,oz_partner_channel:null};this.context=null;this.page_parser=null;this.timeout=1500;this.init=function(A){try{if(A){this.context=this.mergeProperties(A,this.default_context);}else{this.context=this.default_context;
}if(this.context.oz_host){this.config.host=this.context.oz_host;}if(this.context.oz_statichost){this.config.statichost=this.context.oz_statichost;}if(this.context.oz_delay){this.config.delayAfterLoad=this.context.oz_delay;}if(this.config.use_local_storage&&!this.context.oz_partner_user_id&&(typeof swfobject=="object")){try{if(!document.getElementById("oo_storage")){var C=document.createElement("div");
C.setAttribute("id","oo_storage");C.setAttribute("name","oo_storage");document.body.appendChild(C);swfobject.embedSWF(this.config.statichost+"/flash/storage/storage.swf","oo_storage","1","1","8",null,{enablejs:"true",autostart:"true"},{allowScriptAccess:"always",swLiveConnect:"true"},{});}}catch(B){}}}catch(B){}};
this.scriptsLoaded=new Object();this.addScript=function(B,C){var A;if(oz_scripts_loaded[B]){return ;}oz_scripts_loaded[B]=true;A=document.createElement("script");if(C){A.setAttribute("id",C);}A.setAttribute("type","text/javascript");B=B.replace(/\s/g,"+");A.setAttribute("src",B);document.getElementsByTagName("head").item(0).appendChild(A);
};this.trim=function(A){return A.replace(/^\s+|\s+$/g,"");};this.start=function(){try{var A=this;if(window.attachEvent){window.attachEvent("onload",function(C){A.onPageLoad();});}else{window.addEventListener("load",function(C){A.onPageLoad();},false);}}catch(B){}};this.format_phrases=function(B){var E="";
var A;var D=40;for(var C=0;C<B.length&&C<D;C++){A=B[C];E+=A.word+":"+A.count;if(C<B.length){E+=",";}}return E;};this.mergeProperties=function(B,A){if(typeof (B)=="undefined"||!B){return A;}if(typeof (A)=="undefined"||!A){return new Object();}for(var C in A){if(typeof B[C]=="undefined"){B[C]=A[C];}}return B;
};this.cookiesEnabled=function(){try{var B=(navigator.cookieEnabled)?true:false;if(typeof navigator.cookieEnabled=="undefined"&&!B){document.cookie="testcookie";B=(document.cookie.indexOf("testcookie")!=-1)?true:false;}return(B);}catch(A){}};this.shouldSamplePage=function(){return(Math.floor(Math.random()*100)<this.config.sensor_sample);
};this.shouldPixelPage=function(){return(Math.floor(Math.random()*100)<this.config.pixel_sample);};this.getTopPhrases=function(){if(this.page_parser==null){return null;}return this.page_parser.getTopPhrasesFromDocument(this.oz_source);};this.getUserProfile=function(){if(this.page_parser==null){return null;
}return this.page_parser.getProfileFromDocument(this.oz_source);};this.getPartnerUserProfile=function(){return this.context.oz_profile;};this.getPixels=function(){return oz_sensor_pixels;};this.profileUserForPage=function(){if(oz_page_profiled){return ;}try{if(this.oz_source.location.protocol.indexOf("http:")<0){return ;
}if(typeof PageParser!="function"){if(this.config.domain_specific_parsing){this.addScript(this.config.statichost+"/partner/scripts/"+this.context.oz_partner+"/page_parser.js?d="+this.oz_source.location.host);}else{this.addScript(this.config.statichost+"/partner/scripts/"+this.context.oz_partner+"/page_parser.js");
}var L=this;setTimeout(function(){L.profileUserForPage();},500);return ;}if(this.page_parser==null){this.page_parser=new PageParser();this.page_parser.doc=this.oz_source;this.page_parser.init();}var N;if(this.shouldSamplePage()){oz_page_profiled=true;if(!this.context.oz_partner_user_id&&(typeof OOStorage=="function")){try{var H=new OOStorage();
H.init("oo_storage");this.context.oz_partner_user_id=H.get("anon_user.token");if(this.context.oz_partner_user_id=="null"){this.context.oz_partner_user_id=null;}if(!this.context.oz_partner_user_id){var I;I="";I+=new Date().getTime().toString(36).toUpperCase();I+="-";I+=Math.floor(Math.random()*4096*4096).toString(36).toUpperCase();
this.context.oz_partner_user_id=I;H.set("anon_user.token",this.context.oz_partner_user_id);}}catch(J){}}N=this.getTopPhrases();if(N){var B;B=this.config.host+"/oz/sensor";B+="?p="+this.context.oz_partner;if(this.context.oz_session_id){B+="&fps="+this.context.oz_session_id;}if(this.context.oz_partner_user_id){B+="&afu="+this.context.oz_partner_user_id;
}if(this.context.oz_partner_channel){B+="&pc="+this.context.oz_partner_channel;}if(this.cookiesEnabled()){B+="&cd=false";}if(N.duration){B+="&xt="+N.duration;}B+="&k="+this.format_phrases(N.summary).replace(/\s+/g,"+");try{var M;M=this.page_parser.selectSERPStats(window.location.href);if((M)&&(M.queryTerms)){B+="&q="+M.queryTerms+":"+M.adCount;
}else{M=this.page_parser.selectSERPStats(this.oz_source.referrer);if((M)&&(M.queryTerms)){B+="&q="+M.queryTerms+":1";}}}catch(J){}try{var K;if(this.oz_source.referrer){K=this.oz_source.referrer.split("/")[2];}if(K&&(K!=this.oz_source.location.host)){B+="&rd="+K;}}catch(J){}new Image().src=B;}}var E=this.getUserProfile();
if(E){var D=false;var B;B=this.config.host+"/oz/feeds/"+this.context.oz_partner+"/profile";B+="?p="+this.context.oz_partner;if(this.context.oz_session_id){B+="&fps="+this.context.oz_session_id;}if(this.context.oz_partner_user_id){B+="&afu="+this.context.oz_partner_user_id;}if(this.context.oz_partner_channel){B+="&pc="+this.context.oz_partner_channel;
}for(var A in E){if(!E.hasOwnProperty(A)){continue;}D=true;if(typeof A!="function"){B+="&"+A+"="+E[A];}}if(D){new Image().src=B;}}var E=this.getPartnerUserProfile();if(E){var D=false;var B;B=this.config.host+"/oz/feeds/"+this.context.oz_partner+"/profile";B+="?p="+this.context.oz_partner;B+="&oz_source=partner";
if(this.context.oz_session_id){B+="&fps="+this.context.oz_session_id;}if(this.context.oz_partner_user_id){B+="&afu="+this.context.oz_partner_user_id;}if(this.context.oz_partner_channel){B+="&pc="+this.context.oz_partner_channel;}for(var A in E){if(!E.hasOwnProperty(A)){continue;}D=true;if(typeof A!="function"){B+="&"+A+"="+E[A];
}}if(D){new Image().src=B;}}var F=this.getPixels();if(F){for(var G=0;G<F.length;G++){var C=F[G].uri;setTimeout(function(){new Image().src=C;},250);}}}catch(J){}};this.onPageLoad=function(){if(this.pageLoadHandled){return ;}this.pageLoadHandled=true;if((this.oz_source!=document)||oz_subframes_allowed||((top.frames.length==3)&&(parent==top))||(window==top)){if(this.config.use_local_storage&&(Math.floor(Math.random()*100)<0)){if(typeof OOStorage!="function"){this.addScript(this.config.statichost+"/flash/storage/flashStorage.js");
}}var A=this;setTimeout(function(){A.profileUserForPage();},this.config.delayAfterLoad);}try{if(window!=top){if(Math.floor(Math.random()*100)<1){var B;var C;B=this.config.host+"/empty.gif?p="+this.context.oz_partner+"&frames=nested";if(this.context.oz_partner_channel){B+="&pc="+this.context.oz_partner_channel;
}try{if(this.oz_source.referrer){C=this.oz_source.referrer.split("/")[2];}if(C&&(C!=this.oz_source.location.host)){B+="&rd="+C;}}catch(D){}new Image().src=B;}}}catch(D){}};}function oz_sensor(E){try{var D=new OthersOnlineSensor();var C=new Object();var G=["oz_partner","oz_session_id","oz_partner_user_id","oz_host","oz_statichost","oz_delay","oz_sensor_filter","oz_profile","oz_partner_channel"];
var A;if(oz_source){D.oz_source=oz_source;}for(var B=0;B<G.length;B++){A=G[B];if(window[A]){C[A]=window[A];}}D.init(C);oz_sensor_partner_hook(D);D.start();if(E||D.autorun){D.onPageLoad();}}catch(F){}}var oz_sensor_pixels=[];function oz_sensor_partner_hook(A){return A;}function oz_parseUri(E){var D=oz_parseUri.options;
var A=D.parser[D.strictMode?"strict":"loose"].exec(E);var C={};var B=14;while(B--){C[D.key[B]]=A[B]||"";}C[D.q.name]={};C[D.key[12]].replace(D.q.parser,function(G,F,H){if(F){C[D.q.name][F]=H;}});return C;}oz_parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
var scripts;var src;if(oz_source||oz_subframes_allowed||(window==top)){scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){src=scripts[i].getAttribute("src");if(src&&src.indexOf("alice.js")>=0){var uri=oz_parseUri(src);if(uri.queryKey.autorun){oz_sensor(true);}break;}}}


/*
	*/

function oz_sensor_partner_hook(sensor)
{
	try
	{
		// get server-based configuration
		try
		{
			var cfg = null;
			if (typeof oz_sensor_config != "undefined" && (oz_sensor_config != null))
			{
				cfg = oz_sensor_config.sensor;
			}
	
			if (cfg != null && cfg.sampling)
				sensor.config.sensor_sample = cfg.sampling;
			
			// determine sampling based on domain list
			if (sensor.context.oz_sensor_filter == "domain")
			{
				sensor.config.domain_specific_parsing = true;
				sensor.config.sensor_sample = 0;
				if (cfg != null)
				{
					sensor.config.sensor_sample = cfg.domain_filter.sampling;
					if (cfg.domain_filter.domains[sensor.oz_source.location.host] != null)
					{
						sensor.config.sensor_sample = cfg.domain_filter.domains[sensor.oz_source.location.host].sampling;
						if (cfg.domain_filter.domains[sensor.oz_source.location.host].ajax_pageviews)
						{
							// hack to support ajax based pageviews
							sensor.context.autorun=true;
	
							// hook the profiling method
							sensor.old_profileUserForPage = sensor.profileUserForPage;
							sensor.profileUserForPage = function()
							{
								this.old_profileUserForPage();
								// hack to allow multiple sensor hits for lifetime of an ajax page
								oz_page_profiled = false;
							}
						}
					}
				}
			}
		}
		catch(e)
		{
			
		}
		
		// get server-based configuration
		try
		{
			var cfg = null;
			if (typeof oz_sensor_config != "undefined" && (oz_sensor_config != null))
			{
				cfg = oz_sensor_config.pixel;
			}
	
			if (cfg != null && cfg.sampling)
				sensor.config.pixel_sample = cfg.sampling;
			
			// determine sampling based on domain list
			if (sensor.context.oz_sensor_filter == "domain")
			{
				sensor.config.pixel_sample = 0;
				if (cfg != null)
				{
					sensor.config.pixel_sample = cfg.domain_filter.sampling;
					if (cfg.domain_filter.domains[sensor.oz_source.location.host] != null)
					{
						sensor.config.pixel_sample = cfg.domain_filter.domains[sensor.oz_source.location.host].sampling;
					}
				}
			}
		}
		catch(e)
		{
			
		}
		
		// update service URLs
		sensor.config.host = "http://tap.rubiconproject.com";
		sensor.config.statichost = "http://tap-cdn.rubiconproject.com";

		
		// hook the sensor object with new pixel drop methods
		sensor.getPixels = function ()
		{
			// do pixels 50% of the time
			var sampling=50;
			sampling = this.config.pixel_sample;

			if (Math.floor(Math.random()*100) < sampling)
			{
				var url;
				url = sensor.config.host + "/partner/agent/rubicon/channels.js?cb=oz_onPixelsLoaded";
				if (sensor.context.oz_partner_channel)
					url += "&pc="+sensor.context.oz_partner_channel;
				
				// fetch the pixel data after 1s
				var self=this;
				setTimeout(function() {	 self.addScript(url);	},1000);
			}
			return null;
		}
		sensor.onPixelsLoaded = function(pixels)
		{
			for (var i=0; i < pixels.tagcloud.length; i++)
			{
				var uri = pixels.tagcloud[i].token;
				if (uri && (uri.indexOf("http:") == 0))
					new Image().src = uri;
			}
			for (var i=0; i < pixels.pixels.length; i++)
			{
				var uri = pixels.pixels[i].url;
				if (uri && (uri.indexOf("http:") == 0))
					new Image().src = uri; 
			}
		}
		window.oz_onPixelsLoaded = function(pixels){sensor.onPixelsLoaded(pixels)};
		
		// Gather the sub-channel (oz_partner_channel)
		// rubicon_zone = "http://optimized-by.rubiconproject.com/a/2697/2718/8352" + "." + "js";
		// rubicon_zone = "http://optimized-by.rubiconproject.com/a/6291/9346/15214-9" + "." + "js";
		if (typeof rubicon_zone != "undefined" && (rubicon_zone != null))
		{
			var segments = rubicon_zone.split("/");
			if (segments.length > 6)
			{
				var account_id = segments[4];
				var site_id = segments[5];
				var zone_id = segments[6];
		
				sensor.context.oz_partner_channel = account_id+"/"+site_id;
			}
		}
	}
	catch(e)
	{
		// alert(e.message);
	}
	
}

/*
*/

oz_sensor_config = {"sensor":{"sampling":100,"domain_filter":{"sampling":0,"domains":{"localhost":{"sampling":100},"webmaila.netzero.com":{"sampling":100},"webmaila.netzero.net":{"sampling":100},"latimes.com":{"sampling":10},"baltimoresun.com":{"sampling":10}}}},"pixel":{"sampling":25,"domain_filter":{"sampling":1,"domains":{}}}}


oz_sensor();

