home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Delphi / nastroje / profil / Prodel_soubory / survey.js < prev    next >
Text File  |  2000-03-10  |  2KB  |  73 lines

  1.  
  2. //<!--
  3.  
  4.  
  5. var surveyLocation = "http://www.gamespot.com/research/zddownload/";
  6. var cookieName = "dl_study01";
  7. var sampleRate = .001;
  8. var expireDate = new Date(2000, 4, 8);
  9.  
  10.         var cookieValue = getCookie(cookieName);
  11.         if (cookieValue == null){
  12.  
  13.                 setCookie(cookieName, "Sampled", expireDate);
  14.  
  15.                 var sampled = getRandom();
  16.                 if(sampled < sampleRate) {
  17.                         if ((navigator.appName == "Microsoft Internet Explorer") &&
  18.                         (parseInt(navigator.appVersion) < 4)) {
  19.                                 window.location=(surveyLocation);
  20.                         }else{
  21.                         window.open(surveyLocation,'surveyWindow','scrollbars,resizable');
  22.                         }
  23.  
  24.                 }
  25. }
  26.  
  27.         function getRandom() {
  28.         var D = new Date();
  29.         this.seed = 2345678901 + (D.getSeconds() * 0xFFFFFF) + (D.getMinutes() * 0xFFFF);
  30.         this.A = 48271;
  31.         this.M = 2147483647;
  32.         this.Q = this.M / this.A;
  33.         this.R = this.M % this.A;
  34.         this.oneOverM = 1.0 / this.M;
  35.         var Hi = this.seed / this.Q;
  36.         var Lo = this.seed % this.Q;
  37.         var Test = this.A * Lo - this.R * Hi;
  38.         if(Test > 0)
  39.             this.seed = Test;
  40.         else
  41.             this.seed = Test + this.M;
  42.         return(this.oneOverM * this.seed);
  43. }
  44.  
  45.         function getCookie(Name) {
  46.                 var search = Name + "=";
  47.                 if (document.cookie.length > 0) { // if there are any cookies
  48.                         offset = document.cookie.indexOf(search);
  49.                         if (offset != -1) { // if cookie exists
  50.                                 offset += search.length ;
  51.                                 // set index of beginning of value
  52.                                 end = document.cookie.indexOf(";", offset);
  53.                                 // set index of end of cookie value
  54.                                 if (end == -1);
  55.                                         end = document.cookie.length;
  56.                         return unescape(document.cookie.substring(offset, end));
  57.       }
  58.    }
  59. }
  60.  
  61.         // Sets cookie values. Expiration date is optional
  62.  
  63.         function setCookie(name, value, expire) {
  64.                 document.cookie = name + "=" + escape(value)
  65.                 + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
  66. }
  67.  
  68.  
  69.  
  70. //-->
  71.  
  72.  
  73.