//#### BEGIN VARIOUS FUNCTIONS (USED ON MORE THEN 1 PLACE) ####//

  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 setCookie(name,value,path,expires){

    //cookie expiration options
    //   -1 = expire directly
    //    1 = after session
    //    0 = never expire (1 year duration)

    var cookie_date = new Date();
    var site_host = window.location.host;

    if(expires == -1){
      //##deletes cookie
      
      //date in past will delete cookie
      cookie_date.setTime(cookie_date.getTime() - 1);      
      document.cookie = name + "=;path=" + path + ";expires=" + cookie_date.toGMTString() + ";host=" + site_host;

    }else if(expires == 1){
      //##creates session cookie

      //will expire after session      
      document.cookie = name + "=" + value + ";path=" + path + ";expires=0" + "host=;" + site_host;

    }else if(expires == 0){
      //##creates domain/path cookie

      //will expire after 1 year
      cookie_date.setFullYear(cookie_date.getFullYear() + 1);
      document.cookie = name + "=" + value + ";path=" + path + ";expires=" + cookie_date.toGMTString() + "host=;" + site_host;
    }
  }

//#### END VARIOUS FUNCTIONS (USED ON MORE THEN 1 PLACE) ####//

//#### BEGIN FONT SIZE FUNCTIONS ####// 
  //function to change the appearance of the fontsize menu
function setFontsize(size){
  switch (size) {
    case 3: 
      $("body").removeClass("fontsize1").removeClass("fontsize2").addClass("fontsize3");
      $("#fontsize_normal").removeClass("selected");
      $("#fontsize_larger").removeClass("selected");
      $("#fontsize_extralarge").addClass("selected");
      break;
    case 2:
      $("body").removeClass("fontsize1").removeClass("fontsize3").addClass("fontsize2"); 
      $("#fontsize_normal").removeClass("selected");
      $("#fontsize_larger").addClass("selected");
      $("#fontsize_extralarge").removeClass("selected");
      break;
    default:  
      $("body").removeClass("fontsize2").removeClass("fontsize3").addClass("fontsize1");
      $("#fontsize_normal").addClass("selected");
      $("#fontsize_larger").removeClass("selected");
      $("#fontsize_extralarge").removeClass("selected");
      break;
  }
}

$(document).ready(function(){

  $("#menu_fontsize").each(
    function(){
      var labelText = "Seçiniz harf";
      var medium = "Normal ";
      var large = "Büyük";
      var extra = "Ekstra büyük";

      var oneYearFromNow = new Date();
      oneYearFromNow.setFullYear(oneYearFromNow.getFullYear() + 1);

      $(this).append($("<label title='" + labelText + "'>" + labelText + "</label>"));

      $(this).append($("<a id='fontsize_normal' href='#' title='" + medium + "'>A</a>").click(
        function(){
          setFontsize(1);
          setCookie("fontsize","fontsize1","/",0);
          return false;
        })
      );

      $(this).append($("<a id='fontsize_larger' href='#' title='" + large + "'>A</a>").click(
        function(){
          setFontsize(2);
          setCookie("fontsize","fontsize2","/",0);	
          return false;
        })
      );

      $(this).append($("<a id='fontsize_extralarge' href='#' title='" + extra + "'>A</a>").click(
        function(){
          setFontsize(3);
          setCookie("fontsize","fontsize3","/",0);
          return false;
        })
      );
    } 
  );     

  var fontsize = "fontsize1";

  if (readCookie("fontsize") != null) {
    fontsize = readCookie("fontsize");
  }

  switch (fontsize) {
    case "fontsize3":
      $("#fontsize_extralarge").addClass("selected");
      $("body").addClass("fontsize3").removeClass("fontsize1").removeClass("fontsize2");
      break; 
    case "fontsize2":
      $("#fontsize_larger").addClass("selected");
      $("body").addClass("fontsize2").removeClass("fontsize1").removeClass("fontsize3");
      break;
    default:
      $("#fontsize_normal").addClass("selected");
      $("body").addClass("fontsize1").removeClass("fontsize2").removeClass("fontsize3");
      break;
  }
});
//#### END FONT SIZE FUNCTIONS ####//

//#### BEGIN ADDING PRINT HYPERLINKS ####//
$(document).ready(function(){

  //adds print button to middle menu
  $("ul.showPrint li:first").before("<li><a href='javascript:print()' title='Çıkış' class='print'>Çıkış</a></li>");
    
  //add print buttons to forms when required
  $(".formblock").each(function(){ 
    
    var print_container = $("span.print",this).parent();
    $("span.print",this).remove();

    print_container.append("<a href='javascript:print()' title='Çıkış' class='print'>Çıkış</a>")
  });
});
//#### END ADDING PRINT HYPERLINKS ####//


//#### BEGIN STICKY NOTE FUNCTIONS ####//

  function setStickynote(content_url){
    
    //get site language
    var site_lang = $("html").attr("lang");

    //sets a session cookie
    setCookie("stickynote_content",site_lang + "|" + escape(content_url),"/",1);

    return false;
  }

  $(document).ready(function(){

    //Some pages (e.g. the home page) should never show a sticky note. This can be set in the page metadata. 
    if (!$("body").hasClass("nonStick") && !($("#wizardlocation").length > 0)){      
      
      //get stickynote cookie
      var stickynote = readCookie('stickynote_content');

      if (stickynote && stickynote != ""){

        //get stickynote cookie value + language
        var stickynote_lang = stickynote.split("|")[0];
        var stickynote_content = unescape(stickynote.split("|")[1]);

        //get site language
        var site_lang = $("html").attr("lang");

        //delete the sticky note cookie when it was created in another language
        if(stickynote_lang != site_lang){

          //remove cookie
          setCookie("stickynote_content","","/",-1);

        }else{

          //load html from file into page
          $.get(stickynote_content ,{stickynote: true},     
            function(data) {
              var sticky = $("div#stickynote", data);
              $('a', sticky).each( function(){wireUpAnchorClick(this);});
              $(".close", sticky).click(function(){
                  setCookie("stickynote_content","","/",-1);
                  //remove div
                  $("#stickynote").remove();
                  return false;
              });
              
              //remove print button when page is loaded inIE
              ///if ($.browser.msie && parseFloat($.browser.version) < 7){
              if ($.browser.msie){
                
                $(".print", sticky).remove();

              }else{

                printpopup = null;

                $(".print", sticky).click(function(){
                  printpopup = window.open("", 'printpopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300,left = 690,top = 375');
                  var maincontent = "<h2>" + $(".titletop h2", sticky).eq(0).html() + "</h2>";
                  var lists = $("div.list",sticky).clone();
                  $("a[href]", lists).each(function(){
                    $("img", this).remove();
                    $(this).removeClass("external");
                    $(this).after($("<span>" + this.href + "</span>"));
                  }); 
                  lists.each(function(){
                    maincontent += "<div>" + this.innerHTML + "</div>";
                  });
                  var popupBoilerplate = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
                      popupBoilerplate += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"" + site_lang + "\" lang=\"" + site_lang + "\">\n";
                      popupBoilerplate += "<head>\n";
                      popupBoilerplate += "\t<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n";
                      popupBoilerplate += "\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\n";
                      popupBoilerplate += "\t<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n";
                      popupBoilerplate += "\t<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
                      popupBoilerplate += "\t<meta http-equiv=\"Expires\" content=\"0\" />\n";
                      popupBoilerplate += "\t<title>" + $(".titletop h2",sticky).text() + "</title>\n";
                      popupBoilerplate += "\t<link href=\"/int/tr/system/css/internet_regeling_print.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
                      popupBoilerplate += "\t<script type=\"text/javascript\" src=\"/int/tr/system/js/jquery.1.2.6.js\"></script>\n";
                      popupBoilerplate += "\t<script type=\"text/javascript\">\n";
                      popupBoilerplate += "\t\t$(function(){window.print();window.close();});\n";
                      popupBoilerplate += "\t</script>\n";
                      popupBoilerplate += "</head>\n";
                      popupBoilerplate += "<body class=\"stickynote_print\">\n";
                      popupBoilerplate += "<div id=\"maincontent\">" + maincontent + "</div>\n";
                      popupBoilerplate += "</body>\n";
                      popupBoilerplate += "</html>";
                  printpopup.document.write(popupBoilerplate);
                  
                  return false;
                });
              }

              $('#maincontent').prepend(sticky);
            }
          , "html");
        }
      }
    }
  });
//#### END STICKY NOTE FUNCTIONS ####//


//#### BEGIN SEARCHFORM FUNCTIONS ####//
$(document).ready(function(){   
  var sDefaultText = "1 ya da 2 kelime kullanınız"; 
  var sErrorText = "2 den fazla harf kullanmalısınız!"; 
    
  //add events to form in subcontent area
  $(".questionform").each(function(){   
    prepareSearchForm("questionform");
  });
    
  //add events to form in maincontent area
  $(".mainsearchform").each(function(){
    prepareSearchForm("mainsearchform");
  });
    
  //function to prepare a form, attach events
  function prepareSearchForm(theForm){          
      
    //add default text to field
    setDefaultText(theForm);
      
    //attach onfocus event to input field
    $("#" + theForm + "_q").bind("focus",function(){        
      clearField(theForm);
      updateOtherForm(theForm);
    });

     //attach onblur event to input field
    $("#" + theForm + "_q").bind("blur",function(){        
      setDefaultText(theForm);
      updateOtherForm(theForm);
    });

    //attach preSubmit function to form
    $("#" + theForm).bind("submit",function(){        
      return checkSearchQuery(theForm);
    });
  }
    
  //function to clear the query field
  function clearField(theForm){
    var searchQuery = $("#" + theForm + "_q").attr("value");
      
    //only creal the field when it still contains the default text
    if(searchQuery == sDefaultText){       
      $("#" + theForm + "_q").attr("value","");
    }
  }
    
  //function to set the default value in the query field
  function setDefaultText(theForm){     
    //insert the default text to the field when its value is empty
    if($("#" + theForm + "_q").attr("value") == ""){
      $("#" + theForm + "_q").attr("value",sDefaultText);
    }
  }
    
  //function to validate search query before submit
  function checkSearchQuery(theForm){
    var searchQuery = $("#" + theForm + "_q").attr("value");
    if(searchQuery == sDefaultText){
      //field has its default value; display error text and don't submit the form
      $("#" + theForm + "_error").text(sErrorText);
      return false;
    }else if(searchQuery.length < 3){
      //field value is to short for the search; display error text and dont't submit the form
      $("#" + theForm + "_error").text(sErrorText);
      return false;
    }else{
      //field value is ok for search; submit form
      return true;
    }
  }

  function updateOtherForm(currentForm){
    var currectValue = $("#" + currentForm + "_q").attr("value");;
    switch(currentForm){
      case "questionform":
        var otherForm = "mainsearchform";
        break;
      case "mainsearchform":
        var otherForm = "questionform";
        break;
    }
    $("#" + otherForm + "_q").attr("value",currectValue);
  }
});
//#### END SEARCHFORM FUNCTIONS ####//



//#### BEGIN KINDERNAMEN FUNCTIONS ####//

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var kindernaamPopupStatus = 0;
//loading popup
function loadKindernaamPopup(thelink){  
  centerKindernaamPopup();
  var Href = thelink.href;  
  //get into the into the popup
  $("#kindernaam_popup").each(function(){
    //load html from file into page
    $(".content", this).load(Href + " #maincontent div",{},function(responseText, status, response){
      //we only want to manipulate parts of the popup here
      $("#kindernaam_popup").each(function(){         
        //move text of the inserted H2 (of the page) into the H2 of the popup
        $("h2:eq(0)",this).text($("h2:eq(1)",this).text());         
        //remove any inserted H2's from the content
        $("h2:gt(0)",this).remove();
        $(".content",this).each(function(){
          //remove subnavigation from the content
          $("div:gt(0)",this).remove();
        });
        //remove home hyperlink from the content
        $("div.hideline", this).remove(); 
      });
    });
  });
  //loads popup only if it is disabled
  if(kindernaamPopupStatus==0){    
    //for IE6, hide select boxes (cause the will appear over the popup(background))
    $("select").css({
      "visibility": "hidden"
    });
    $("#kindernaam_popup_background").css({
      "opacity": "0.2"
    });
    $("#kindernaam_popup_background").fadeIn("slow");
    $("#kindernaam_popup").fadeIn("slow");
    kindernaamPopupStatus = 1;
  }		
}

//disabling popup with jQuery magic!
function disableKindernaamPopup(){

  //disables popup only if it is enabled
  if(kindernaamPopupStatus==1){
    $("#kindernaam_popup_background").fadeOut("slow");
    $("#kindernaam_popup").fadeOut("slow");
      kindernaamPopupStatus = 0;
  }

  //for IE6, hide select boxes (cause the will appear over the popup(background))
  $("select").css({
    "visibility": "visible"
  });
}

//get Y position of an object
function findYpos(obj){
  var curtop = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curtop += obj.offsetTop
      obj = obj.offsetParent;
      }
  }else if (obj.y){
    curtop += obj.y;
  }
  return curtop;
}

//centering popup
function centerKindernaamPopup(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var contentHeight = findYpos(document.getElementById("canvas_footer")) + document.getElementById("canvas_footer").offsetHeight;
  var scrollTop = document.documentElement.scrollTop;
  var popupHeight = $("#kindernaam_popup").height();
  var popupWidth = $("#kindernaam_popup").width();

  //centering
  $("#kindernaam_popup").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2 + scrollTop,
    "left": windowWidth/2-popupWidth/2
  });

  //only need force for IE6
  $("#kindernaam_popup_background").css({
    "height": contentHeight
  });   
}

$(document).ready(function(){

  //HIDE THE SUBMIT BUTTON, WE DONT"T NEED IT WHILE JAVASCRIPT IS ENABLED
  //we only want to manipulate parts of the form here
  $(".kindernamen_formblock").each(function(){
    $(".button", this).css({
     "visibility": "hidden"
    });
  });

  //INSERT DIVS NEEDED FOR THE POPUP, IF WE DETECT A KINDERNAMEN LIST WITHIN THE PAGE
  $("div.kindernamen").each(function(){
    $("body").append("<div id='kindernaam_popup'><a class='close'>Sluiten</a><h2></h2><div class='content'></div></div><div id='kindernaam_popup_background'></div>");

    //Click the x event!
    $(".kindernamen").find("a").click(function(){

      /* kindernamen popup breaks in Safari, so we do not offer it in that browser for now */
      if (!$.browser.safari){
        loadKindernaamPopup(this);
        return false;
      }
    });
          
    //CLOSING POPUP
    //Click the x event!
    $("#kindernaam_popup").find(".close").click(function(){
      disableKindernaamPopup();
    });

    //Click out event!
    $("#kindernaam_popup_background").click(function(){
      disableKindernaamPopup();
    });

    //Press Escape event!
    $(document).keypress(function(e){
      if(e.keyCode==27 && kindernaamPopupStatus==1){
        disableKindernaamPopup();
      }
    });
  });
});
//#### END KINDERNAMEN FUNCTIONS ####//


//#### BEGIN "VESTIGINGEN KAART" FUNCTIONS ####//

$(document).ready(function(){
  // find the vestigingen map
  $(".vestigingenkaart").each(function(){
    // add mouseover event to each hyperlink
    $("a",this).bind("mouseover",function(){
      var showArea = $(this).attr("class").split(' ').slice(0,1);
      hoverArea(showArea);
    }); 
      
    //add mouseout event to hyperlink
    $("a",this).bind("mouseout",function(){    
      hoverArea();
    }); 
  });
    
  //highlight area
  function hoverArea(showArea){
    // find the vestigingen kaart
    $(".vestigingenkaart").each(function(){
      // for each image
      $("img",this).filter(".area").each(function(){
        //when the area belongs to the hyperlink      
        if($(this).hasClass(showArea)){
          $(this).css({"display": ""});
        }else{
          $(this).css({"display": "none"});
        }
      });      
    });
  }
});
//#### END "VESTIGINGEN KAART" FUNCTIONS ####/


//#### BEGIN "VESTIGINGENKAART MET ADRESSEN" FUNCTIONS ####//

$(document).ready(function(){
  
  // find all the lists that have a moreorless div
  $("div.vestigingenkaart_met_adressen").each(function(){

    var container  = $(this);

    // The first child of testimonial teaser DIV is a script element containing the data object as JSON
    var data = eval("(" + container.children()[0].innerHTML + ")");    
    
    // add area images to DOM
    for(i in data){

      if(data[i].mapImgSrc != ""){
        
         $("div.vestigingenkaart_met_adressen .nederland").after("<img src=\"" + data[i].mapImgSrc + "\" alt=\"" + data[i].mapImgAlt + "\" class=\"" + data[i].vestigingID + " area hide\" />");
      }
    }

    // add mouseover event to each hyperlink
    $("a",this).bind("mouseover",function(){
      var showArea = $(this).attr("class").split(' ').slice(0,1);
      hoverArea(showArea);
    })
      
    // add mouseout event to each hyperlink
    $("a",this).bind("mouseout",function(){    
      hoverArea();
    }); 
      
    //highlight area
    function hoverArea(showArea){

      // find the vestigingen map
      $("div.vestigingenkaart_met_adressen .kaart").each(function(){
        // for each image
        $("img.area",this).each(function(){
          //when the area belongs to the hyperlink      
          if($(this).hasClass(showArea)){
            $(this).removeClass("hide");
          }else{
            $(this).addClass("hide");
          }
        });    
      });

      //put selected class on related hyperlinks to show highlight color       
      $("div.vestigingenkaart_met_adressen a").each(function(){
        //when the area belongs to the hyperlink      
        if($(this).hasClass(showArea)){
          $(this).addClass("selected");
        }else{
          $(this).removeClass("selected");
        }
      }); 
    }
  });
});

//#### END "VESTIGINGENKAART MET ADRESSEN" FUNCTIONS ####//


//#### BEGIN ADDING ONCLICK EVENTS FOR EXTERNAL LINKS ####/
$(document).ready(function(){
  $('a').each( function(){wireUpAnchorClick(this);});
});

var getNewWindowName = function(){
  var count = 0;
  var f = function(){
    return "windowName" + count++;
  }
  return f;
}();

function wireUpAnchorClick(domAnchor){
  var anchor = $(domAnchor);
  var isExternal = (anchor.attr("rel") && anchor.attr("rel") == "external");
  var winopt = "";
  if (anchor.hasClass("popup")) {
    winopt = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=830,height=500";
  }

  if (anchor.hasClass("sitestatcomplink") || anchor.hasClass("sitestatform") || anchor.hasClass("nieuwsoverzicht")) {
    var json = domAnchor.getElementsByTagName("script")[0].innerHTML;    
    var dataIsland = eval("(" + json  + ")");
    var sitestatType = "";

    if (dataIsland.hasOwnProperty("type")) {sitestatType=dataIsland.type;}

    anchor.click(function(){return ns_onclick(domAnchor, anchor.attr('href'), dataIsland.sitestatid, sitestatType, dataIsland.taal, dataIsland.subsite,winopt); 
                                      window.open(anchor.attr('href'), getNewWindowName() , winopt); return false; 
                                    });
  }                                

  if ((anchor.hasClass("sitestat") && isExternal) || anchor.hasClass("sitestatpdf") ) {

    var json = domAnchor.getElementsByTagName("script")[0].innerHTML;    
    var dataIsland = eval("(" + json  + ")");
    var sitestatType = "";

    if (dataIsland.hasOwnProperty("type")) {sitestatType=dataIsland.type;}

    anchor.click(function(){
                                      domAnchor.target = getNewWindowName();
                                      return ns_onclick(domAnchor, anchor.attr('href'), dataIsland.sitestatid, sitestatType, dataIsland.taal, dataIsland.subsite, winopt); 
                                    });

  } else { if (anchor.hasClass("download") || isExternal || winopt.length > 0) { anchor.click( function(){ window.open(anchor.attr('href'), getNewWindowName() , winopt); return false; } ); } }

  if (anchor.hasClass("sitestatdigid")) {
    var json = domAnchor.getElementsByTagName("script")[0].innerHTML;    
    var dataIsland = eval("(" + json  + ")");
    var sitestatType = "";
    winopt = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=830,height=500";

    if (dataIsland.hasOwnProperty("type")) {sitestatType=dataIsland.type;}

    anchor.click(function(){
                                      domAnchor.target = getNewWindowName();
                                      return ns_onclick(domAnchor, anchor.attr('href'), dataIsland.sitestatid, sitestatType, dataIsland.taal, dataIsland.subsite, winopt); 
                                    });
  }
  
}

//#### END ADDING ONCLICK EVENTS FOR EXTERNAL LINKS ####/
//#### NEDSTAT code ####/
// This is the original nedstat click tracking code. We've kept this, 
// even though we know, for example, that the target processing is 
// useless in our situation. 
function ns_onclick (a, url, name, type, svbtaal, svbsubsite, winopt){
  var ns_l="http://nl.sitestat.com/svb/svb/s?";
  ns_l+=name;
  ns_l+='&ns_type='+type+'&svb_taal='+svbtaal+'&svb_subsite='+svbsubsite+'&ns_action=view'+'&ns_url='+url;
  ns_l+='&ns__t='+(new Date()).getTime();
  if(!url)url=a.href;
  var ns_0=document.referrer;
  if(ns_0.lastIndexOf('/')==ns_0.length-1)
    ns_0=ns_0.substring(ns_0.lastIndexOf('/'),0);
  if (ns_0.length>0)ns_l+='&amp;ns_referrer='+escape(ns_0);
  winopt=winopt||"";
  var target=(a&&a.target&&a.target!="")?(a.target.substring(0,1)=="_")?a.target.substring(1):a.target:"self";
  var ns_i=new Image();
  if(target&&url){
    if(window[target]){
      window.ns_softclick_timer=function(target,url){
         return function(){
                ns_i.onload=ns_i.onerror=function(){return;};
                window[((window[target])?target:"self")].location.href=url;
                }
      }(target,url);
      window.setTimeout('ns_softclick_timer()',5000);
      ns_i.onload=ns_i.onerror=window.ns_softclick_timer;
    }else{
      window.open(url,target,winopt);
    }
  }
  ns_i.src=ns_l;
  return false;
} 

// This is also nedstat code, called from the page. 
function sitestat(ns_l){// FromUrl v1.5 Copyright (c) 2001-2007 Nedstat B.V. All rights reserved.
var ns_type='' // leave empty for normal/ppc measurement, fill in for clickin, clickout or pdf
var r='' // yes=only parse url when there is a real document.referrer,
// no=only parse url when there is no real document.referrer, empty=always parse url
var t='?' // tag in url where parameters follow; default '?' could be replaced by "#"
var p=new Array();var w='';var l='';var d=document;var n=navigator;var ns_0=''
;if(top!=self){if('\u0041'=='A'){var u=n.userAgent;if(u.indexOf('Safari')==-1)
{var b=u.indexOf('Opera');if(b==-1||(u.charAt(b+6)+0)>5){b=u.indexOf('Mozilla'
);var xb=b!=-1?u.charAt(b+8)>4:1;if(u.indexOf('compatible')!=-1||xb){var c=
'try{ns_0=top.document.referrer}catch(e){}';eval(c);c=
'try{l=top.document.location.href}catch(e){}';eval(c);}}}}}else{ns_0=
d.referrer;l=d.location.href;}if(ns_0.lastIndexOf('/')==ns_0.length-1){ns_0=
ns_0.substring(ns_0.lastIndexOf('/'),0);}var f=ns_l.indexOf('?');if(f!=-1){
var q=ns_l.substring(f+1);ns_l=ns_l.substring(0,f);if(q){var m=q.indexOf('&');
w=q.substring(0,m==-1?q.length:m);if(w.indexOf('=')!=-1){w='';}if(w){q=
q.substring(m==-1?q.length:m+1);q+=(q?'&':'')+'ns_name='+w;}if(ns_0.length>0){
q+=(q?'&':'')+'ns_referrer='+escape(ns_0);}var s=0;var e=0;while(q.length){e=
q.indexOf('&');if(e==-1){e=q.length;}var o=q.substring(s,e);if(o.substring(0,4
)=='amp;'){o=o.substring(4);}if(o)p[p.length]=o;q=q.substring(e+1);}}}var a=
l.indexOf(t);a=a==-1?0:l.substring(a+1);var j;if(r=='yes')j=ns_0.length;else
if(r=='no')j=!ns_0.length;else if(r=='')j=1;if(a&&j){while(a.length){var e=
a.indexOf('&');if(e==-1){e=a.length;}var k=a.substring(0,a.substring(0,e)
.indexOf('='));var v=a.substring(a.substring(0,e).indexOf('=')+1,e);if(
k.substring(0,4)=='amp;'){k=k.substring(4);}while(v.substring(0,1)=='='){v=
v.substring(1);}if(k=='ns_name'){w=v;}else if(k=='ns_or'){var g='ns_referrer='
;for(var z=0;z<p.length;z++){if(p[z].substring(0,g.length)==g){p[z]=
'ns_referrer='+v;}}}else{if(k.substring(0,3)=='ns_'&&v&&k){var h=0;for(var x=0
;x<p.length;x++){if(p[x].substring(0,p[x].indexOf('='))==k){p[x]=k+"="+v;h=1}}
if(!h){p[p.length]=k+"="+v;}}}a=a.substring(e+1);}}if(!w){return;}var s='';
var y='';for(var i=0;i<p.length;i++)if(p[i].substring(0,8)!='ns_name='){if(p[i
].substring(0,12)!='ns_referrer='){s+='&'+p[i];}else{y='&'+p[i];}}s+=ns_type?
'&ns_type='+ns_type+'&ns_action=view':'';ns_pixelUrl=ns_l+'?'+w+"&ns__t="+(
new Date()).getTime();ns_l=ns_pixelUrl+s+y;if(d.images){ns_1=new Image();
ns_1.src=ns_l;}else{d.write('<img src='+ns_l+' width="1" height="1">');}}
//#### END NEDSTAT code ####/
