function setKeywords(w){
	if(!w){ return; }
	var words = w.split(',');
	var tmp = '<dl id="keywords"><dt>関連キーワード</dt><dd>';
	for( var i=0; i < words.length;i++){
		tmp += '<a href="http://wol.nikkeibp.co.jp/bns/bnsearch.jsp?BID=1290&amp;OFFSET=0&amp;SEARCH_TEXT=' + EscapeEUCJP(words[i]) + '">' + words[i] + '</a>';
		if(i != (words.length - 1) ){ tmp += ' , '; }
		
	}
	tmp += '</dd></dl>';
	document.getElementById('keywordsBox').innerHTML = tmp;
}

//add 2009/02/04 nnakazw@itpro
function getBody(iname){
 if(document.all){
  return(document.all(iname))
 } else if(document.getElementById){
  return(document.getElementById(iname))
 }
}

function callJSONP(Url, code){
 var c = (code) ? code : 'utf-8';
 var script = document.createElement('script');
 script.src = Url;
 script.charset = c;
 document.body.appendChild(script);
}

function addOnload2(){
 if (typeof(document.onload2) == 'undefined'){
  document.onload2 = {};
  document.onload2.add = function(f){
   if (document.onload2.load)
    return(f());
   if(typeof(document.onload2.funcs) == 'undefined' || document.onload2.funcs.length == 0){
    document.onload2.funcs = [f];
   }else{
    document.onload2.funcs.push(f);
   }
    if (document.onload2.running){
    return;
   }else{
    document.onload2.running = function(){
     document.onload2.load = true;
     while(document.onload2.funcs.length > 0){
      document.onload2.funcs[0]();
      document.onload2.funcs.shift();
     }
     document.onload2.running = null;
    }
   }
    //mac safari
   if(/WebKit/i.test(navigator.userAgent)){
    setInterval(function(){
     if (/loaded|complete/.test(document.readyState)) {
      document.onload2.running();
     }
    }, 10);
   //Firefox
   }else if (window.addEventListener){
    document.addEventListener("DOMContentLoaded", document.onload2.running, false);
   //MSIE
//   }else if(document.readyState && !!(window.attachEvent && !window.opera)){
//    document.write('<script defer src="javascript:void(0)" onreadystatechange="if (this.readyState == \'complete\')  document.onload2.running();"><\/script>');
   //その他
   }else{
    if (window.onload){
     if (window.attachEvent){
      window.attachEvent('onload', document.onload2.running);
     }else if (window.addEventListener){
      window.addEventListener('load', document.onload2.running, true);
     }else{
      window.onload = document.onload2.running;
     }
    }else{
     window.onload = document.onload2.running;
    }
   }
  }
 }
}
addOnload2();


function topics(){
 if (getBody('topics'))
  callJSONP('http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_topics_u8.js');
}
function ad_topics(d){
 if (d.length > 0 ){
 var html, i;
 html = '<h3>Topics</h3>';
 html += '<ul>';
 for (i = 0; i < d.length - 1; ++i) {
  html += '<li><a href="' + d[i].url + '" target="_blank">' + d[i].title + '</a></li>';
 }
 html += '</ul>';
 getBody('topics').innerHTML = html;
}}

function closeup(){
 if (getBody('closeup'))
  callJSONP('http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_closeup_u8.js');
}
function ad_closeup(d){
 if (d.length > 0 ){
 var html, i;
 html = '<h3>CloseUp</h3>';
 html += '<ul>';
 for (i = 0; i < d.length - 1; ++i) {
  html += '<li><a href="' + d[i].url + '" target="_blank">' + d[i].title + '</a></li>';
 }
 html += '</ul>';
 getBody('closeup').innerHTML = html;
}}


function sidePickup(){
 if (getBody('ad_sidePickup'))
  callJSONP('http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_sidepickup_u8.js');
}
function ad_sidepickup(d){
 if (d.length > 0 ){
 var html, i;
 html = '<div id="sidePickup">';
 html += '<h4>Pickup</h4>';
 html += '<ul>';
 for (i = 0; i < d.length - 1; ++i) {
  html += '<li><a href="' + d[i].url + '" target="_blank"><img src="' + d[i].image + '" width="70" height="70">' + d[i].title + '</a></li>';
 }
 html += '</ul>';
 html += '</div>';
 getBody('ad_sidePickup').innerHTML = html;
}}


function focus(){
 if (getBody('ad_sideInformation'))
  callJSONP('http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_focus_u8.js');
}
function ad_focus(d){
 if (d.length > 0 ){
 var html, i;
 html = '<div id="sideInformation">';
 html += '<h4>Information</h4>';
 html += '<ul>';
 for (i = 0; i < d.length - 1; ++i) {
  html += '<li><a href="' + d[i].url + '" target="_blank">' + d[i].title + '</a></li>';
 }
 html += '</ul>';
 html += '</div>';
 getBody('ad_sideInformation').innerHTML = html;
}}

var bottomwolSelectionUrls = [
 'http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_wolselection00_u8.js',
 'http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_wolselection01_u8.js',
 'http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_wolselection02_u8.js',
 'http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_wolselection03_u8.js',
 'http://bizad.nikkeibp.co.jp/NBP_AD/woman/ads/ad_wolselection04_u8.js',
];

var bottomwolSelectionNum = 0;
var bottomwolSelectionItems = {'count':0, 'items': []};

function bottomwolSelectionInit(){
 if (getBody('wolSelection'))
  callJSONP(bottomwolSelectionUrls[bottomwolSelectionNum] + '?' + (new Date()).getTime());
}
function ad_wolselection(d){
 d.item.pop();
 bottomwolSelectionItems.items[bottomwolSelectionNum++] = d; 
 bottomwolSelectionItems.count += d.item.length;
 if (bottomwolSelectionNum >= bottomwolSelectionUrls.length -1)
  mkBottomwolSelectionHtml();
 callJSONP(bottomwolSelectionUrls[bottomwolSelectionNum] + '?' + (new Date()).getTime());
}
function mkBottomwolSelectionHtml(){
 var i, j, html, genre, count, max;
 genre = ['What\'s New!', '美しく働く', '自分を磨く', 'キレイに健やかに', '豊かに暮らす'];
 html =  '<h3>WOL Selection</h3>';
 html +=  '<ul>';
 if (bottomwolSelectionItems.items[0].item.length > 0){
  html += '<li id="wolSelectWhatsNew"><h4>' + genre[0] + '</h4>';
  html +=  '<ul>';
  for(i=0; i<bottomwolSelectionItems.items[0].item.length; i++){
   html += '<li><a href="' + bottomwolSelectionItems.items[0].item[i].url + '" target="_blank">' + bottomwolSelectionItems.items[0].item[i].text + '</a></li>';
  }
  html += '</ul></li>';
 }
 //What's New分
  var count = 1;
 for(i=1; i<bottomwolSelectionItems.items.length; i++){
  if (bottomwolSelectionItems.items[i].item.length == 0) continue;
  if ( count == 1 ){
  html += '<li id="wolSelectUtukushiku">';
  }else if ( count == 2 ){
  html += '<li id="wolSelectMigaku">';
  }else if ( count == 3 ){
  html += '<li id="wolSelectKireini">';
  }else{
  html += '<li id="wolSelectYutakani">';
  }
  html += '<h4>' + genre[i] + '</h4>';
  html +=  '<ul>';
  for(j=0; j<bottomwolSelectionItems.items[i].item.length; j++){
   html += '<li><a href="' + bottomwolSelectionItems.items[i].item[j].url + '" target="_blank">' +  bottomwolSelectionItems.items[i].item[j].text + '</a></li>';
  }
  html += '</ul></li>';
  count++;
 }
 html += '</ul>';
 getBody('wolSelection').innerHTML = html;
}
function setIframeHeight(){
    var subContent = document.getElementById('subContent');
    var iframes = subContent.getElementsByTagName('iframe');
    iframes[0].setAttribute('height',2500);


    var iframes = document.getElementsByTagName('iframe');
    var count = 0;
    var loaded = false;
    for (var i = 0; i < iframes.length; i++) {
        iframes[i].onload = function () {
            count++;
            if (count >= iframes.length-1 && !loaded) {
                loaded = true;
                
            }
        };
    }

}


document.onload2.add(topics);
document.onload2.add(closeup);
document.onload2.add(bottomwolSelectionInit);
document.onload2.add(sidePickup);
document.onload2.add(focus);
document.onload2.add(setIframeHeight);
