﻿// ランダム広告
function randomAdv() {
  m = 0, x = 0, y = 0;
  ad  = new Array();
  adv = new Array();
  hit = new Array();

  // hitには相対確率を入れる
  // 完全にランダムにするなら全部"1"にする
  // advには、広告のタグを入れる。改行はしないようにする
  // 広告を増やしたりする場合は、"[ ]"の数字が0から順になるようにする
  hit[0] = 1; adv[0] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ez&f=ifr&f=ifr" width="468" height="60" scrolling="no" marginwidth="0" marginheight="0" border="0" frameborder="0" style="border:none;"></iframe>';
  hit[1] = 1; adv[1] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=gift_certificates&banner=1514BQNJ0C581N58B2G2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[2] = 1; adv[2] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=amazongeneral&banner=0Q3RBVMDR1E41NFSX9R2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[3] = 1; adv[3] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=amazongeneral&banner=0X4RKMHRJYTJDHDG93R2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[4] = 1; adv[4] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=amazongeneral&banner=1DMBQ816JJSP1D9P7802&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[5] = 1; adv[5] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=tvgame&banner=1ZJG8M52VC1E4W1Z2H82&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[6] = 1; adv[6] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=tvgame&banner=1GQNTSAWGV20R58NVFG2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[7] = 1; adv[7] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=tvgame&banner=035JM4D6S6J45298S1G2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[8] = 1; adv[8] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=tvgame&banner=0N0N3D8BNAEDNCS871G2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[9] = 1; adv[9] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=books&banner=1ZC1GD7NSXJBJKM0GRG2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[10] = 1; adv[10] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=gamebooks&banner=1H6W3504MXRM81S3JS82&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[11] = 1; adv[11] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=comicbooks&banner=0YTDAE6C5ZQR4240WR02&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[12] = 1; adv[12] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=computerinternetbooks&banner=0VS5BBRF0XHDCN8XYG82&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[13] = 1; adv[13] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=businessbooks&banner=035TYTE0XNHAT3X2Z0G2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[14] = 1; adv[14] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=literaturebooks&banner=1JACY8NV170X360PA102&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  hit[15] = 1; adv[15] = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=andornot-22&o=9&p=13&l=ur1&category=papaerbackbooks&banner=00A0B18XS8T2GBJP1402&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>';
  for(i=0; i<=hit.length - 1; i++) {
    m += hit[i];
  }
  n = Math.floor(Math.random() * m);
  n++;
  for(i=0; i<=hit.length - 1; i++) {
    x = y;
    y += hit[i];
    if(x<n && n<=y) ad = adv[i];
  }
  document.write(ad);
}
