/* lecStatisticsByNedstat.js
// Lectric Internetoplossingen
// 9292ov 
// A.E.Veltstra 2007, 2008
//
// Version 20080702T1016
//
// Remarks:
// This code has been adapted from nl.sitestat.com and www.nedstat.com, 
// in order to allow it being executed unobtrusively.
// It is added to the LecJS javascript object defined elsewhere.
//
// Usage:
// Add a script element to the page in which this script should run.
// Add it after the script element that loads the LecJS object.
// This is unobtrusive javascript, meaning Smartsite's header deference won't work.
//
*/


/*
// Ruud van Falier, 1 july 2008:
// Added global declaration for ns_pixelUrl
// This is required by sitestat.js!
*/
//aev20080702: declaring this only when LecJS is available should work too
//var ns_pixelUrl;


if(typeof(LecJS)!='undefined'){

 //required by nedstat. We don't like this as it clutters up the default memory space.
 if(typeof(ns_loadingtime1)=='undefined'){var ns_loadingtime1}
 if(typeof(ns_loadingtime2)=='undefined'){var ns_loadingtime2}
 //aev20080702: this declaration should work. 
 if(typeof(ns_pixelUrl)=='undefined'){var ns_pixelUrl}

 //aev20080702: ns_loadingtime only measured on home page.
 //ns_loadingtime1=(new Date()).getTime();
 
 LecJS.nedstat=({
  sitestat:function(ns_l){
   if(document && LecJS.doc){if(LecJS.doc.cE && LecJS.doc.aC){
    ns_l+="&ns__t="+(new Date()).getTime(); /* careful: ns__t is inside a string literal: not a real parameter */
    //rdf20080701: declaration is required to be global;
    //if(typeof(ns_pixelUrl)=='undefined'){
    // var ns_pixelUrl;
    //}
    ns_pixelUrl=ns_l;
    if(typeof(ns_0)=='undefined'){
     var ns_0;
    }
    if(document.referrer){
     ns_0=document.referrer;
    }
    if(ns_0){
      ns_0=((ns_0.lastIndexOf("/")==(ns_0.length-1))?ns_0.substring(ns_0.lastIndexOf("/"),0):ns_0);
      if(ns_0.length>0){
       ns_l+="&ns_referrer="+escape(ns_0);
      }
    } /* ns_0? */
    if(typeof(ns_1)=='undefined'){
     var ns_1;
    }
    ns_1=LecJS.doc.cE('img');
    if(ns_1){
     ns_1['src']=ns_l;
     ns_1['width']=1;
     ns_1['height']=1;
     ns_1['border']=0;
     ns_1['alt']='NedStat';
     ns_1['title']=ns_1['alt'];
     ns_1['className']='imgNedStat';
     LecJS.doc.aC(ns_1);
     //alert('Debug info: \nNedstat Pixel: \n'+ns_1['src']);
     return true;
    }
   }}
   return false;
  } /* LecJS.nedstat.sitestat() */,
  loadJS:function(){
   //aev20080702: ns_loadingtime only measured on home page.
   //ns_loadingtime2=(new Date()).getTime();
   if(document && LecJS){if(LecJS.doc){
    if(LecJS.doc.cE && LecJS.doc.aC && LecJS.doc.sA){
     var s=LecJS.doc.cE('script');
     if(s){
      LecJS.doc.sA(s,'type','text/javascript');
      /* hard uri required due to Smartsite's javascript parsing policy. */
      LecJS.doc.sA(s,'src','/scripts/sitestat.js');
      LecJS.doc.sA(s,'id','jsSitestat');
      LecJS.doc.aC(s);
      //alert('Debug info: \nNedstat Loadingtime End: \n'+ns_loadingtime1);
     } /* s? */
    }
   }} /* LecJS.doc? */
  } /* LecJS.nedstat.loadJS() */,
  initOVR:function(){
   if(document && LecJS.nedstat && LecJS.doc){
    if(document.title && LecJS.nedstat.sitestat && LecJS.doc.meta){
     var i,t;
     i=LecJS.doc.meta('pageid');
     t=document.title.replace(/ /g,'_').replace(/[^a-z,0-9,_,-]/gi,'').replace(/,/g,'');
     LecJS.nedstat.sitestat("http://nl.sitestat.com/ovr/9292nl/s?" + i + "." + t);
    } /* document.title && LecJS.nedstat.sitestat && LecJS.doc.meta ? */
   } /* document && LecJS.nedstat && LecJS.doc? */ 
   LecJS.nedstat.loadJS(); 
  } /* LecJS.nedstat.initOVR() */,
  initSTIR:function(){
   if(LecJS.nedstat){if(LecJS.nedstat.sitestat){
    var i,t;
    i=LecJS.doc.meta('pageid');
    t=document.title.replace(/ /g,'_').replace(/[^a-z,0-9,_,-]/gi,'').replace(/,/g,'');
    if(document.cookie.indexOf('ns_Cfilter')!=-1) {
        LecJS.nedstat.sitestat("http://nl.sitestat.com/adfactor/9292ov/s?" + i + "." + t);
    }
   }} /* LecJS.nedstat.sitestat  ? */
   LecJS.nedstat.loadJS(); 
  } /* LecJS.nedstat.initSTIR() */
 }) /* LecJS.nedstat() */
 if(LecJS.doc && LecJS.nedstat){
  if(LecJS.doc.addEvt && LecJS.nedstat.initOVR){
   LecJS.doc.addEvt(window,'load', LecJS.nedstat.initOVR);
  }
 }
} /* LecJS? */