<!--
/* vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 filetype=javascript: */
/* SVN: $Id:$ */
var AdInformation = {"NE":[{"SpacePath_id":"219","prefix":"<div id=\"adsBlock\">","suffix":"<\/div>","pos":"NE","height":"250","width":"300","start":"1252940400","end":"1285858800","priority":"0","comment":"\u8239\u8d8a\u82f1\u4e00\u90ce \u4e0a\u539f\u7f8e\u512a\u306e\u30c6\u30ec\u30d3\uff23\uff2d\u3067<br>\r\n\u304a\u306a\u3058\u307f\u306e\u5f01\u8b77\u58eb\u6cd5\u4eba\uff29\uff34\uff2a\u6cd5\u5f8b\u4e8b\u52d9\u6240","url":"http:\/\/www.bengo4.com\/adv\/itj\/index.html","AdEntity_id":"21","extension":"gif","AdPosition_id":"15","AdSchedule_id":"28"}],"TXT":[{"SpacePath_id":"219","prefix":"<div class=\"prBlock\"><ul>","suffix":"<\/ul><\/div>","pos":"TXT","height":"0","width":"0","start":"1273849200","end":"1280761200","priority":"0","comment":"\u5404\u7a2e\u8abf\u67fb\u306a\u308938\u5e74\u306e\u4fe1\u983c\u300c\u63a2\u5075 \u76f8\u6ca2\u4eac\u5b50\u8abf\u67fb\u5ba4\u300d","url":"http:\/\/www.web-chosa.com\/behavior\/","AdEntity_id":"1923","extension":"","AdPosition_id":"14","AdSchedule_id":"2360"},{"SpacePath_id":"219","prefix":"<div class=\"prBlock\"><ul>","suffix":"<\/ul><\/div>","pos":"TXT","height":"0","width":"0","start":"1276095600","end":"1283266800","priority":"0","comment":"\u5a5a\u6d3b\u306e\u7b2c\u4e00\u6b69\u306f\u7406\u60f3\u306e\u7d50\u5a5a\u76f8\u624b\u50cf\u3092\u77e5\u308b\u4e8b\u304b\u3089\u30b9\u30bf\u30fc\u30c8\u21d2\u7d50\u5a5a\u76f8\u624b\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u7d39\u4ecb","url":"https:\/\/www.sunmarie.com\/q\/partner\/sunmarie\/post.html?AccessCode=1006150111301","AdEntity_id":"2232","extension":"","AdPosition_id":"14","AdSchedule_id":"2671"},{"SpacePath_id":"219","prefix":"<div class=\"prBlock\"><ul>","suffix":"<\/ul><\/div>","pos":"TXT","height":"0","width":"0","start":"1258297200","end":"1288537200","priority":"0","comment":"\u907a\u8a00\u66f8\u4f5c\u6210\u306e\u6c7a\u5b9a\u7248\uff01\u6cd5\u5f8b\u3092\u77e5\u3089\u306a\u3044\u4eba\u3067\u3082\u3088\u304f\u308f\u304b\u308b\uff01\u5b89\u5fc3\u30fb\u7d0d\u5f97\u306e\u4f5c\u6210\u30ec\u30b7\u30d4","url":"http:\/\/www.kajo.co.jp\/book\/40383000001.html","AdEntity_id":"575","extension":"","AdPosition_id":"14","AdSchedule_id":"820"}]};
var AdsRedirect = '/redirect/id/';
var AdsServer = 'http://ads.authense.co.jp';

// fake link
function FixFakeLink()
{
  this.href = this.ad.url;
}

function FakeLink()
{
  this.href = AdsServer + AdsRedirect + this.ad.AdSchedule_id;
  if (this.callback) {
    this.callback(this.ad.url);
  }
  this.onmouseout = FixFakeLink;
}

function SetFakeLink(ad, callback, id)
{
  var obj = document.getElementById('authense_ad_system_'+ id);
  obj.ad = ad;
  obj.callback = callback;
  obj.onclick = FakeLink;
}

/**
 * ad insert function.
 *
 * @param pos position name
 * @param callback callback function; you can call your own process
 * @param delim image ad delimter
 * @return void
 */
function adInsert(pos, callback, delim)
{
  // body
  var ad = eval("AdInformation."+ pos);

  if (!ad) {
    return;
  }

  document.write(ad[0].prefix);
  //--------------------------------------
  //
  // Image Advertisement
  //
  //--------------------------------------
  if (ad[0].height >0 && ad[0].width>0) {
    for (var i=0; i<ad.length; i++) {
      //--------------------------------------
      //
      // FLASH Advertisement
      //
      //--------------------------------------
      if (ad[i].extension == 'swf' || ad[i].extension == 'swc') {
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ ad[i].width +'" height="'+ ad[i].height +'">');
        document.write('<param name="movie" value="/admedia/'+ ad[i].SpacePath_id +'/'+ ad[i].AdPosition_id +'/'+ ad[i].AdEntity_id +'/'+ ad[i].AdSchedule_id +'.'+ ad[i].extension +'" />');
        document.write('<param name="FlashVars" value="clickTAG='+ AdsServer + AdsRedirect + ad[i].AdSchedule_id +'" />');
        document.write('<!--[if !IE]>-->');
        document.write('<object type="application/x-shockwave-flash" data="/admedia/'+ ad[i].SpacePath_id +'/'+ ad[i].AdPosition_id +'/'+ ad[i].AdEntity_id +'/'+ ad[i].AdSchedule_id +'.'+ ad[i].extension +'" width="'+ ad[i].width +'" height="'+ ad[i].height +'">');
        document.write('<!--<![endif]-->');
        document.write('<param name="FlashVars" value="clickTAG='+ AdsServer + AdsRedirect + ad[i].AdSchedule_id +'" />');
        document.write('<!--[if !IE]>-->');
        document.write('</object>');
        document.write('<!--<![endif]-->');
        document.write('</object>');
      //--------------------------------------
      //
      // Advertisement with Title 
      //
      //--------------------------------------
      } else if (ad[0].pos == 'TAD') {
        document.write('<div class="ad-item">');

        // image
        document.write('<a class="ad-thumb" id="authense_ad_system_'+ ad[i].AdSchedule_id +'_image" href="'+ ad[i].url + '" target="_blank">');
        document.write('<img border="0" height="'+ ad[i].height +'" width="'+ ad[i].width +'" src="/admedia/'+ ad[i].SpacePath_id +'/'+ ad[i].AdPosition_id +'/'+ ad[i].AdEntity_id +'/'+ ad[i].AdSchedule_id +'.'+ ad[i].extension +'">');
        document.write('</a>');
        SetFakeLink(ad[i], callback, ad[i].AdSchedule_id +'_image');

        // title
        title = ad[i].comment.split('\r\n');
        if (title[0] != '') {
          document.write('<a class="ad-title" id="authense_ad_system_'+ ad[i].AdSchedule_id +'_title" href="'+ ad[i].url + '" target="_blank">');
          document.write(title[0]);
          document.write('</a>');
          SetFakeLink(ad[i], callback, ad[i].AdSchedule_id +'_title');
        }
        
        // body
        body = ad[i].comment.split('\r\n');
        if (body[1] != '') {
          document.write('<a class="ad-note" id="authense_ad_system_'+ ad[i].AdSchedule_id +'_body" href="'+ ad[i].url + '" target="_blank">');
          document.write(body[1]);
          document.write('</a>');
          SetFakeLink(ad[i], callback, ad[i].AdSchedule_id +'_body');
        }

        document.write('</div>');
      //--------------------------------------
      //
      // Advertisement
      //
      //--------------------------------------
      } else {
        if (ad[i].url) {
          // if fake link causes trouble, use bellow code. it's simple.
          //document.write('<a id="authense_ad_system_'+ ad[i].AdSchedule_id +'" href="'+ AdsServer + AdsRedirect + ad[i].AdSchedule_id + '" target="_blank">');
          document.write('<a id="authense_ad_system_'+ ad[i].AdSchedule_id +'" href="'+ ad[i].url + '" target="_blank">');
        }

        document.write('<img border="0" height="'+ ad[i].height +'" width="'+ ad[i].width +'" src="/admedia/'+ ad[i].SpacePath_id +'/'+ ad[i].AdPosition_id +'/'+ ad[i].AdEntity_id +'/'+ ad[i].AdSchedule_id +'.'+ ad[i].extension +'">');
        if (ad[i].comment) {
          document.write('<br>');
          document.write(ad[i].comment);
        }

        if (ad[i].url) {
          document.write('</a>');
          SetFakeLink(ad[i], callback, ad[i].AdSchedule_id);
        }
      }
      if (delim) document.write(delim);
    }
  } else {
    //--------------------------------------
    //
    // TEXT Advertisement
    //
    //--------------------------------------
    for (var i=0; i<ad.length; i++) {
      document.write('<li>');

      if (ad[i].url) {
        // if fake link causes trouble, use bellow code. it's simple.
        //document.write('<a id=":uthense_ad_system_'+ ad[i].AdSchedule_id +'" href="'+ AdsServer + AdsRedirect + ad[i].AdSchedule_id + '" target="_blank">');
        document.write('<a id="authense_ad_system_'+ ad[i].AdSchedule_id +'" href="'+ ad[i].url + '" target="_blank">');
      }

      document.write(ad[i].comment);

      if (ad[i].url) {
        document.write('</a>');
        SetFakeLink(ad[i], callback, ad[i].AdSchedule_id);
      }
      document.write('</li>');
    }
  }
  document.write(ad[0].suffix);
}
-->
