home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 August / Chip_2004-08_cd1.bin / program / delphi / adresy / dd_soubory / show_ads.js < prev    next >
Text File  |  2004-05-04  |  5KB  |  167 lines

  1. google_ad_url = '';
  2. google_random = (new Date()).getTime();
  3. google_org_error_handler = window.onerror;
  4.  
  5. function quoted(str) {
  6.   return (str != null) ? '"' + str + '"' : '""';
  7. }
  8.  
  9. function google_encodeURIComponent(str) {
  10.   if (typeof(encodeURIComponent) == 'function') {
  11.     return encodeURIComponent(str);
  12.   } else {
  13.     return escape(str);
  14.   }
  15. }
  16.  
  17. function google_write_tracker(tracker_event) {
  18.   var img_url = window.google_ad_url.replace(/pagead\/ads/, 'pagead/imp.gif');
  19.   var img_src = img_url + '&event=' + tracker_event;
  20.   var img_tag = '<i' + 'mg height="1" width="1" border="0" ' +
  21.                 'src=' + quoted(img_src) +
  22.                 ' />';
  23.   document.write(img_tag);
  24. }
  25.  
  26. function google_append_url(param, value) {
  27.   if (value) {
  28.     window.google_ad_url += '&' + param + '=' + value;
  29.   }
  30. }
  31.  
  32. function google_append_url_esc(param, value) {
  33.   if (value) {
  34.     google_append_url(param, google_encodeURIComponent(value));
  35.   }
  36. }
  37.  
  38. function google_append_color(param, value) {
  39.   if (value && typeof(value) == 'object') {
  40.     value = value[window.google_random % value.length];
  41.   }
  42.   google_append_url('color_' + param, value);
  43. }
  44.  
  45. function google_show_ad() {
  46.   var w = window;
  47.   w.onerror = w.google_org_error_handler;
  48.   w.google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?' +
  49.                     'client=ca-' + escape(w.google_ad_client.toLowerCase()) +
  50.                     '&random=' + w.google_random;
  51.  
  52.   google_append_url('hl', w.google_language);
  53.   google_append_url('gl', w.google_gl);
  54.   google_append_url_esc('hints', w.google_hints);
  55.   google_append_url('adsafe', w.google_safe);
  56.   google_append_url('oe', w.google_encoding);
  57.   google_append_url('lmt', w.google_last_modified_time);
  58.   google_append_url_esc('alternate_ad_url', w.google_alternate_ad_url);
  59.   google_append_url('alt_color', w.google_alternate_color);
  60.  
  61.   if (w.google_ad_format) {
  62.     google_append_url_esc('format', w.google_ad_format.toLowerCase());
  63.   }
  64.  
  65.   google_append_url('num_ads', w.google_max_num_ads);
  66.   google_append_url('output', w.google_ad_output);
  67.   google_append_url('adtest', w.google_adtest);
  68.   if (w.google_ad_channel) {
  69.     google_append_url_esc('channel', w.google_ad_channel.toLowerCase());
  70.   }
  71.   google_append_url_esc('url', w.google_page_url);
  72.   google_append_color('bg', w.google_color_bg);
  73.   google_append_color('text', w.google_color_text);
  74.   google_append_color('link', w.google_color_link);
  75.   google_append_color('url', w.google_color_url);
  76.   google_append_color('border', w.google_color_border);
  77.   google_append_url('kw_type', w.google_kw_type);
  78.   google_append_url_esc('kw', w.google_kw);
  79.   google_append_url_esc('contents', w.google_contents);
  80.   google_append_url('num_radlinks', w.google_num_radlinks);
  81.   google_append_url('max_radlink_len', w.google_max_radlink_len);
  82.   google_append_url('rl_filtering', w.google_rl_filtering);
  83.  
  84.   w.google_ad_url = w.google_ad_url.substring(0, 1000);
  85.   w.google_ad_url = w.google_ad_url.replace(/%\w?$/, '');
  86.  
  87.   if (google_ad_output == 'js' && w.google_ad_request_done) {
  88.     document.write('<scr' + 'ipt language="JavaScript1.1"' +
  89.                    ' src=' + quoted(google_ad_url) +
  90.                    '></scr' + 'ipt>');
  91.   } else if (google_ad_output == 'html') {
  92.     if (w.name == 'google_ads_frame') {
  93.       google_write_tracker('reboundredirect');
  94.     } else {
  95.       document.write('<ifr' + 'ame' +
  96.                      ' name="google_ads_frame"' +
  97.                      ' width=' + quoted(w.google_ad_width) +
  98.                      ' height=' + quoted(w.google_ad_height) +
  99.                      ' frameborder=' + quoted(w.google_ad_frameborder) +
  100.                      ' src=' + quoted(w.google_ad_url) +
  101.                      ' marginwidth="0"' +
  102.                      ' marginheight="0"' +
  103.                      ' vspace="0"' +
  104.                      ' hspace="0"' +
  105.                      ' allowtransparency="true"' +
  106.                      ' scrolling="no">');
  107.       google_write_tracker('noiframe');
  108.       document.write('</ifr' + 'ame>');
  109.     }
  110.   }
  111.  
  112.   w.google_ad_frameborder = null;
  113.   w.google_ad_format = null;
  114.   w.google_page_url = null;
  115.   w.google_language = null;
  116.   w.google_gl = null;
  117.   w.google_hints = null;
  118.   w.google_safe = null;
  119.   w.google_encoding = null;
  120.   w.google_ad_output = null;
  121.   w.google_max_num_ads = null;
  122.   w.google_ad_channel = null;
  123.   w.google_contents = null;
  124.   w.google_alternate_ad_url = null;
  125.   w.google_alternate_color = null;
  126.   w.google_color_bg = null;
  127.   w.google_color_text = null;
  128.   w.google_color_link = null;
  129.   w.google_color_url = null;
  130.   w.google_color_border = null;
  131.   w.google_adtest = null;
  132.   w.google_kw_type = null;
  133.   w.google_kw = null;
  134.   w.google_num_radlinks = null;
  135.   w.google_max_radlink_len = null;
  136.   w.google_rl_filtering = null;
  137. }
  138.  
  139. function google_error_handler(message, url, line) {
  140.   google_show_ad();
  141.   return true;
  142. }
  143.  
  144. window.onerror = google_error_handler;
  145.  
  146. if (window.google_ad_frameborder == null) {
  147.   google_ad_frameborder = 0;
  148. }
  149.  
  150. if (window.google_ad_output == null) {
  151.   google_ad_output = 'html';
  152. }
  153.  
  154. if (window.google_ad_format == null && window.google_ad_output == 'html') {
  155.   google_ad_format = google_ad_width + 'x' + google_ad_height;
  156. }
  157.  
  158. if (window.google_page_url == null) {
  159.   google_page_url = document.referrer;
  160.   if (window.top.location == document.location) {
  161.     google_page_url = document.location;
  162.     google_last_modified_time = Date.parse(document.lastModified) / 1000;
  163.   }
  164. }
  165. google_show_ad();
  166.  
  167.