if ( typeof(Wikinvest) == 'undefined' ) { Wikinvest = {}; } Wikinvest._partner = ''; Wikinvest._embeddedWikichartAdId = 'tdameritrade'; if (typeof(Wikinvest) == 'undefined') { Wikinvest = {}; } if (typeof(Wikinvest.NetworkMetrics) == 'undefined') { Wikinvest.NetworkMetrics = {}; } Wikinvest.NetworkMetrics.CookieManager = function() { this._testKey = "Wikinvest_TestKey"; this._cookiePath = "/"; }; Wikinvest.NetworkMetrics.CookieManager.prototype._testKey; Wikinvest.NetworkMetrics.CookieManager.prototype._cookiePath; /** this helper function will try to get id from the cookies. the logic is as follows: * * if (id exist) * return the id * else * if(setCookie && canSetCookie) * generate a new id * set it in the cookie. * else * return empty string * * @parameter: * setCookie true/false parameter that tells this function if it should * generate a new id to persist in the cookie or not. * key the specific key to get the id in the cookie * expire the time (in days) for the id to expire (0 = for this session only) */ Wikinvest.NetworkMetrics.CookieManager.prototype._getOrSetIdFromCookie = function(setCookie, key, expire, path) { if (key.length > 0) { var originalId = this._getCookie(key); if (originalId.length == 0) { // id does not exist, generate one and store in the cookie if (setCookie && this._canSetCookie()) { var newId = this._getUniqueId32(); this._setCookie(key, newId, expire, path); } // return either hte set cookie or an empty string if value cannot be set. return this._getCookie(key); } else { // found the id in cookie, return it. return originalId; } } // if it gets here, that means an invalid key has been passed in return ""; }; Wikinvest.NetworkMetrics.CookieManager.prototype._getUniqueId32 = function() { return (this._random4digits() + this._random4digits() + this._random4digits() + this._random4digits() + this._random4digits() + this._random4digits() + this._random4digits() + this._random4digits()); }; Wikinvest.NetworkMetrics.CookieManager.prototype._random4digits = function() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); }; Wikinvest.NetworkMetrics.CookieManager.prototype._canSetCookie = function() { var daysToExpire = 1; var randomValueBefore = this._getUniqueId32(); this._setCookie(this._testKey, randomValueBefore, daysToExpire, this._cookiePath); var randomValueAfter = this._getCookie(this._testKey); return (randomValueBefore == randomValueAfter); }; /** this method turns all cookie values into an array of name/value pairs such that * (id = array[0], value = array[1]). * then it tries to find the value for the given key, and returns the value, or empty * string if not found. * @parameter: * pKey the id for the cookie value we want to retrieve. */ Wikinvest.NetworkMetrics.CookieManager.prototype._getCookie = function(pKey) { var allCookies = document.cookie.split( ';' ); var thisCookie = ''; var cookieName = ''; var cookieValue = ''; for (i = 0; i < allCookies.length; i++) { thisCookie = allCookies[i].split('='); // trim left/right whitespace around the cookieName cookieName = thisCookie[0].replace(/^\s+|\s+$/g, ''); if (cookieName == pKey) { // found cookie, see if a value exists if (thisCookie.length > 1) { cookieValue = unescape(thisCookie[1].replace(/^\s+|\s+$/g, '')); return cookieValue; } } } return ""; }; /** this method sets the key-value pair in the cookie. this function will also check if * expirationDays = 0. if so, we will not set expiration at all (which defaults to * expire in the current web session. */ Wikinvest.NetworkMetrics.CookieManager.prototype._setCookie = function(pKey, pValue, pExpirationDays, pPath) { var cookieString = pKey + "=" + pValue; if (pExpirationDays > 0) { var expire = new Date(); expire.setDate(expire.getDate() + pExpirationDays); cookieString = cookieString + ";expires=" + expire.toGMTString(); } cookieString = cookieString + ";path=" + pPath; // this code will actually append the line to the end of the cookie since the only way to delete // a cookie is to set expiration_date <= current_date. document.cookie = cookieString; }; if ( typeof( Wikinvest ) == 'undefined' ) { Wikinvest = {}; } if ( typeof( Wikinvest.NetworkMetrics ) == 'undefined' ) { Wikinvest.NetworkMetrics = {}; } Wikinvest.NetworkMetrics.Tracker = function() { this._uniqueUserKey = "Wikinvest_UniqueUserKey"; this._sessionKey = "Wikinvest_SessionKey"; this._cookiePath = "/"; this._url = "http://metrics.wikinvest.com/wikinvest/metrics/api.php?"; this._urlDelimiter = "&"; this._quantcastUrl = "http://edge.quantserve.com/quant.js"; }; Wikinvest.NetworkMetrics.Tracker.prototype._uniqueUserKey; Wikinvest.NetworkMetrics.Tracker.prototype._sessionKey; Wikinvest.NetworkMetrics.Tracker.prototype._cookiePath; Wikinvest.NetworkMetrics.Tracker.prototype._url; Wikinvest.NetworkMetrics.Tracker.prototype._urlDelimiter; /** This function sends an end time visit signal to server for a given user. * * params: * trackingType this will match a #define action and dictates what server API to call * embedType the type of the embed content that we are tracking here */ Wikinvest.NetworkMetrics.Tracker.prototype._endTime = function(trackingType, embedType) { var actionType = this._getAction(trackingType); var type = this._getEmbedType(embedType); var setCookie = false; // do not need to set cookie at this time var userId = this._getUserId(setCookie); var sessionId = this._getSessionId(setCookie); if ( (actionType.length > 0) && (type.length > 0) && (userId.length > 0) && (sessionId.length > 0) ) { var url = this._url + actionType + this._urlDelimiter; url = url + type + this._urlDelimiter; url = url + userId + this._urlDelimiter; url = url + sessionId; this._makeUrlCall(url); } }; /** This function tracks an user view for a given type. * * params: * trackingType this will match a #define action and dictates what server API to call * embedType the type of the embed content that we are tracking here * currentPage url of the current page * referralPage referral url of the current page */ Wikinvest.NetworkMetrics.Tracker.prototype._trackPageView = function(trackingType, embedType, currentPage, referralPage) { var actionType = this._getAction(trackingType); var type = this._getEmbedType(embedType); var setCookie = true; // start of the page, need to set cookie if not exist var userId = this._getUserId(setCookie); var sessionId = this._getSessionId(setCookie); var pageUrl = this._getUrl("url=", currentPage); var referralUrl = this._getUrl("referral=", referralPage); if ( (actionType.length > 0) && (type.length > 0) && (userId.length > 0) && (sessionId.length > 0) && (pageUrl.length > 0) ) { var url = this._url + actionType + this._urlDelimiter; url = url + type + this._urlDelimiter; url = url + userId + this._urlDelimiter; url = url + sessionId + this._urlDelimiter; url = url + pageUrl + this._urlDelimiter; url = url + referralUrl; this._makeUrlCall(url); } }; /** This function does tracking for Quantcast */ Wikinvest.NetworkMetrics.Tracker.prototype._trackQuantcast = function(quantcastOptions) { //set quantcast account info window._qoptions = quantcastOptions; this._makeUrlCall(this._quantcastUrl); }; Wikinvest.NetworkMetrics.Tracker.prototype._getAction = function(trackingType) { if (trackingType == null) { return ""; } var actionString = "action="; switch(trackingType) { case 1: //this is a url action actionString = actionString + "view"; break; case 2: //this is a end time action actionString = actionString + "end"; break; default: actionString = ""; break; } return actionString; }; Wikinvest.NetworkMetrics.Tracker.prototype._getUrl = function(key, value) { if ( (value == null) || (value.length == 0) || (key == null) || (key.length == 0) ) { return ""; } var urlString = key + escape(value); return urlString; }; Wikinvest.NetworkMetrics.Tracker.prototype._getEmbedType = function(embedType) { if (embedType == null) { return ""; } var embedTypeString = "type="; switch(embedType) { case 1: // blogger network embedTypeString = embedTypeString + "blogger"; break; case 2: // embed charts embedTypeString = embedTypeString + "chart"; break; case 3: embedTypeString = embedTypeString + "datachart"; break; default: embedTypeString = ""; break; } return embedTypeString; }; Wikinvest.NetworkMetrics.Tracker.prototype._getUserId = function (setCookie) { var userIdString = "user="; var expire = 365; var cookieManager = new Wikinvest.NetworkMetrics.CookieManager(); var userId = cookieManager._getOrSetIdFromCookie(setCookie, this._uniqueUserKey, expire, this._cookiePath); userIdString = userIdString + userId; return userIdString; }; Wikinvest.NetworkMetrics.Tracker.prototype._getSessionId = function (setCookie) { var sessionIdString = "session="; var expire = 0; // session id only last for current session, so setting expiration to 0 var cookieManager = new Wikinvest.NetworkMetrics.CookieManager(); var sessionId = cookieManager._getOrSetIdFromCookie(setCookie, this._sessionKey, expire, this._cookiePath); sessionIdString = sessionIdString + sessionId; return sessionIdString; }; Wikinvest.NetworkMetrics.Tracker.prototype._makeUrlCall = function(url) { if ( (url != null) && (url.length > 0) ) { var script = document.createElement('script'); script.src = url; var addScript = function() { document.getElementsByTagName('head')[0].appendChild(script); }; setTimeout( addScript, 1 ); } }; (function() { if ((typeof(Wikinvest) == 'undefined') || (typeof(Wikinvest.NetworkMetrics) == 'undefined')) { // this js should not execute if the above namespaces do not exist //alert("cannot find necessary namespace for charts, exiting script"); return; // prevent the rest of the js files from executing } if ( (typeof(Wikinvest.Chart) == 'undefined') ) { Wikinvest.Chart = {}; } if ( (typeof(Wikinvest.Chart.ChartTracker) == 'undefined') ) { Wikinvest.Chart.ChartTracker = {}; } Wikinvest.Chart.ChartTracker.trackChartView = function(chartId) { if ( (chartId != null) && (chartId.length > 0) ) { var wikinvestChartViewTracker = new Wikinvest.NetworkMetrics.Tracker(); var metricAction = 1; // tracking a view var embedType = 2; // this is embedded charts var referral = ""; // none by default var label = "Charts"; if( typeof(Wikinvest._partner) != 'undefined' && Wikinvest._partner.length > 0 ) { // If a partner is set, then append it to Quantcast label and // set referral for internal tracking label += "." + Wikinvest._partner; referral = Wikinvest._partner; } wikinvestChartViewTracker._trackPageView(metricAction, embedType, chartId, referral); wikinvestChartViewTracker._trackQuantcast( {qacct:"p-d5SpXgbOajA6k", labels:label} ); } // this method will be called by flex, which will return null if method is not found // or if method does not have a return value. We are going to return default true // so that flex can tell if this method exists or not return true; }; })(); //Charts disables loading of the Wire on Blogger, //so we'll load Wire here if it is installed if(typeof(Wikinvest) == 'undefined') { Wikinvest = {}; } if(typeof(Wikinvest.Hacks) == 'undefined') { //On-DOM-Ready cross-browser implementation Wikinvest.Hacks = { //IEContentLoaded from http://javascript.nwbox.com/IEContentLoaded/ //IE-specific implementation for DOM ready IEContentLoaded : function (w, fn) { var d = w.document, done = false, // only fire once init = function () { if (!done) { done = true; fn(); } }; // polling for no errors (function () { try { // throws errors until after ondocumentready d.documentElement.doScroll('left'); } catch (e) { setTimeout(arguments.callee, 50); return; } // no errors, fire init(); })(); // trying to always fire before onload d.onreadystatechange = function() { if (d.readyState == 'complete') { d.onreadystatechange = null; init(); } }; }, OnDOMReady : function(fn) { var wrapperFunction = function() { //Ensure only one call is done if (arguments.callee.done){ return; } arguments.callee.done = true; fn(); }; if (document.addEventListener) { //For FF,Opera,Safari,Chrome,NS document.addEventListener("DOMContentLoaded", fn, null); } else if (typeof document.fileSize != 'undefined') { //for IE Wikinvest.Hacks.IEContentLoaded(window,fn); } else { //fallback to window.onload var currentOnload = window.onload; window.onload = function() { if(currentOnload) { currentOnload(); } fn(); }; } } }; var nvHackRuns = 0; (function() { nvHackRuns++; //in case head hasnt finished loading if(document.body === null && nvHackRuns < 20) { setTimeout(arguments.callee, 200); return; } ////Check if we are on blogger by looking at meta-generator var metaTags = document.getElementsByTagName("meta"); for(var i=0;i= 2) { WikinvestWire_UserName=matches[1]; var scr = document.createElement("script"); scr.type="text/javascript"; scr.src="http://plugins.wikinvest.com/plugin/javascript/relatedContent/blogger.php"; document.getElementsByTagName("head")[0].appendChild(scr); break; } } } } }); break; } } })(); } /* SWFObject v2.1 Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis This software is released under the MIT License nvchange - put swfobject into the Wikinvest namespace. Everything after the Wikinvest.Swfobject= is original code */ if (typeof(Wikinvest) == 'undefined') Wikinvest = {}; if (typeof(Wikinvest.Swfobject) == 'undefined') Wikinvest.Swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("