shot4u_ad_url = '';
shot4u_date = new Date();
shot4u_random = shot4u_date.getTime();
shot4u_org_error_handler = window.onerror;

function quoted(str) {
  return (str != null) ? '"' + str + '"' : '""';
}

function shot4u_encodeURIComponent(str) {
  if (typeof(encodeURIComponent) == 'function') {
    return encodeURIComponent(str);
  } else {
    return escape(str);
  }
}

function shot4u_write_tracker(tracker_event) {
  var img_url = window.shot4u_ad_url.replace(/pagead\/ads/, 'pagead/imp.gif');
  var img_src = img_url + '&event=' + tracker_event;
  var img_tag = '<i' + 'mg height="1" width="1" border="0" ' +
                'src=' + quoted(img_src) +
                ' />';
  document.write(img_tag);
}

function shot4u_append_url(param, value) {
  if (value) {
    window.shot4u_ad_url += '&' + param + '=' + value;
  }
}

function shot4u_append_url_esc(param, value) {
  if (value) {
    shot4u_append_url(param, shot4u_encodeURIComponent(value));
  }
}

function shot4u_append_color(param, value) {
  if (value && typeof(value) == 'object') {
    value = value[window.shot4u_random % value.length];
  }
  shot4u_append_url('color_' + param, value);
}

function shot4u_get_user_data() {
  var javaEnabled = navigator.javaEnabled();
  var tz = -shot4u_date.getTimezoneOffset();

  if (window.screen) {
    shot4u_append_url("u_h", window.screen.height);
    shot4u_append_url("u_w", window.screen.width);
    shot4u_append_url("u_ah", window.screen.availHeight);
    shot4u_append_url("u_aw", window.screen.availWidth);
    shot4u_append_url("u_cd", window.screen.colorDepth);
  }

  shot4u_append_url("u_tz", tz);
  shot4u_append_url("u_his", history.length);
  shot4u_append_url("u_java", javaEnabled);

  if (navigator.plugins) {
    shot4u_append_url("u_nplug", navigator.plugins.length);
  }
  if (navigator.mimeTypes) {
    shot4u_append_url("u_nmime", navigator.mimeTypes.length);
  }
}

function shot4u_show_ad() {
  var w = window;
  w.onerror = w.shot4u_org_error_handler;

  if (w.shot4u_num_ad_slots) {
    w.shot4u_num_ad_slots = w.shot4u_num_ad_slots + 1;
  } else {
    w.shot4u_num_ad_slots = 1;
  }

  if (w.shot4u_num_slots_to_rotate) {
    w.shot4u_prev_ad_formats = null;
    if (w.shot4u_num_slot_to_show == null) {
      w.shot4u_num_slot_to_show = w.shot4u_random % w.shot4u_num_slots_to_rotate
                                  + 1;
    }
    if (w.shot4u_num_slot_to_show != w.shot4u_num_ad_slots) {
      return;
    }
  } else if (w.shot4u_num_ad_slots > 3 && w.shot4u_ad_region == null) {
    return;
  }

  w.shot4u_ad_url = 'http://www.shot4u.com/tools/a/show_ads.asp?';
  w.shot4u_ad_client = w.shot4u_ad_client.toLowerCase();
  /*if (w.shot4u_ad_client.substring(0,3) != 'ca-') {
     w.shot4u_ad_client = 'ca-' + w.shot4u_ad_client;
  }*/
  w.shot4u_ad_url += 'client=' + escape(w.shot4u_ad_client) +
                     '&dt=' + w.shot4u_date.getTime();

  shot4u_append_url('hl', w.shot4u_language);
  if (w.shot4u_country) {
    shot4u_append_url('gl', w.shot4u_country);
  } else {
    shot4u_append_url('gl', w.shot4u_gl);
  }
  shot4u_append_url('gr', w.shot4u_region);
  shot4u_append_url_esc('gcs', w.shot4u_city);
  shot4u_append_url_esc('hints', w.shot4u_hints);
  shot4u_append_url('adsafe', w.shot4u_safe);
  shot4u_append_url('oe', w.shot4u_encoding);
  shot4u_append_url('lmt', w.shot4u_last_modified_time);
  shot4u_append_url_esc('alternate_ad_url', w.shot4u_alternate_ad_url);
  shot4u_append_url('alt_color', w.shot4u_alternate_color);
  shot4u_append_url("skip", w.shot4u_skip);

  if (w.shot4u_prev_ad_formats) {
    shot4u_append_url_esc('prev_fmts', w.shot4u_prev_ad_formats.toLowerCase());
  }

  if (w.shot4u_ad_format) {
    shot4u_append_url_esc('format', w.shot4u_ad_format.toLowerCase());
    if (w.shot4u_prev_ad_formats) {
      w.shot4u_prev_ad_formats = w.shot4u_prev_ad_formats + ',' + w.shot4u_ad_format;
    } else {
      w.shot4u_prev_ad_formats = w.shot4u_ad_format;
    }
  }

  shot4u_append_url('num_ads', w.shot4u_max_num_ads);
  shot4u_append_url('output', w.shot4u_ad_output);
  shot4u_append_url('adtest', w.shot4u_adtest);
  if (w.shot4u_ad_channel) {
    shot4u_append_url_esc('channel', w.shot4u_ad_channel.toLowerCase());
  }
  shot4u_append_url_esc('url', w.shot4u_page_url);
  shot4u_append_url('ad_type',w.shot4u_ad_type);
  shot4u_append_url('font_face',w.shot4u_font_face);
  shot4u_append_url('font_size',w.shot4u_font_size);
  shot4u_append_color('bg', w.shot4u_color_bg);
  shot4u_append_color('text', w.shot4u_color_text);
  shot4u_append_color('link', w.shot4u_color_link);
  shot4u_append_color('url', w.shot4u_color_url);
  shot4u_append_color('border', w.shot4u_color_border);
  shot4u_append_color('line', w.shot4u_color_line);
  shot4u_append_url('kw_type', w.shot4u_kw_type);
  shot4u_append_url_esc('kw', w.shot4u_kw);
  shot4u_append_url_esc('contents', w.shot4u_contents);
  shot4u_append_url('num_radlinks', w.shot4u_num_radlinks);
  shot4u_append_url('max_radlink_len', w.shot4u_max_radlink_len);
  shot4u_append_url('rl_filtering', w.shot4u_rl_filtering);
  shot4u_append_url('rl_mode', w.shot4u_rl_mode);
  shot4u_append_url('rt', w.shot4u_rt);
  shot4u_append_url('image_size', w.shot4u_image_size);
  shot4u_append_url('region', w.shot4u_ad_region);
  shot4u_append_url('feedback_link', w.shot4u_feedback);
  shot4u_append_url_esc('ref', w.shot4u_referrer_url);
  shot4u_append_url_esc('loc', w.shot4u_page_location);
  shot4u_get_user_data();

  w.shot4u_ad_url = w.shot4u_ad_url.substring(0, 1000);
  w.shot4u_ad_url = w.shot4u_ad_url.replace(/%\w?$/, '');

  if (shot4u_ad_output == 'js' && w.shot4u_ad_request_done) {
    document.write('<scr' + 'ipt language="JavaScript1.1"' +
                   ' src=' + quoted(shot4u_ad_url) +
                   '></scr' + 'ipt>');
  } else if (shot4u_ad_output == 'html') {
    if (w.name == 'shot4u_ads_frame') {
      shot4u_write_tracker('reboundredirect');
    } else {
      document.write('<ifr' + 'ame' +
                     ' name="shot4u_ads_frame"' +
                     ' width=' + quoted(w.shot4u_ad_width) +
                     ' height=' + quoted(w.shot4u_ad_height) +
                     ' frameborder=' + quoted(w.shot4u_ad_frameborder) +
                     ' src=' + quoted(w.shot4u_ad_url) +
                     ' marginwidth="0"' +
                     ' marginheight="0"' +
                     ' vspace="0"' +
                     ' hspace="0"' +
                     ' allowtransparency="true"' +
                     ' scrolling="no">');
      shot4u_write_tracker('noiframe');
      document.write('</ifr' + 'ame>');
    }
  }

  w.shot4u_ad_frameborder = null;
  w.shot4u_ad_format = null;
  w.shot4u_page_url = null;
  w.shot4u_language = null;
  w.shot4u_gl = null;
  w.shot4u_country = null;
  w.shot4u_region = null;
  w.shot4u_city = null;
  w.shot4u_hints = null;
  w.shot4u_safe = null;
  w.shot4u_encoding = null;
  w.shot4u_ad_output = null;
  w.shot4u_max_num_ads = null;
  w.shot4u_ad_channel = null;
  w.shot4u_contents = null;
  w.shot4u_alternate_ad_url = null;
  w.shot4u_alternate_color = null;
  w.shot4u_color_bg = null;
  w.shot4u_color_text = null;
  w.shot4u_color_link = null;
  w.shot4u_color_url = null;
  w.shot4u_color_border = null;
  w.shot4u_color_line = null;
  w.shot4u_adtest = null;
  w.shot4u_kw_type = null;
  w.shot4u_kw = null;
  w.shot4u_num_radlinks = null;
  w.shot4u_max_radlink_len = null;
  w.shot4u_rl_filtering = null;
  w.shot4u_rl_mode = null;
  w.shot4u_rt = null;
  w.shot4u_ad_type = null;
  w.shot4u_image_size = null;
  w.shot4u_feedback = null;
  w.shot4u_skip = null;
  w.shot4u_page_location = null;
  w.shot4u_referrer_url = null;
  w.shot4u_ad_region = null;
}

function shot4u_error_handler(message, url, line) {
  shot4u_show_ad();
  return true;
}

window.onerror = shot4u_error_handler;

if (window.shot4u_ad_frameborder == null) {
  shot4u_ad_frameborder = 0;
}

if (window.shot4u_ad_output == null) {
  shot4u_ad_output = 'html';
}

if (window.shot4u_ad_format == null && window.shot4u_ad_output == 'html') {
  shot4u_ad_format = shot4u_ad_width + 'x' + shot4u_ad_height;
}

if (window.shot4u_page_url == null) {
  shot4u_page_url = document.referrer;
  if (window.top.location == document.location) {
    shot4u_page_url = document.location;
    shot4u_last_modified_time = Date.parse(document.lastModified) / 1000;
    shot4u_referrer_url = document.referrer;
  }
} else {
  shot4u_page_location = document.referrer;
  if (window.top.location == document.location) {
    shot4u_page_location = document.location;
  }
}

shot4u_show_ad();


