function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function newWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addData(val1, val2){
 val2.value = val1.value;
 return(true);
}


function addBookMarkTop(){
 try{
  window.external.AddFavorite(document.location.href, document.title);
 }catch(e){
  alert('お使いのブラウザでは未対応の機能です');
 }
}


function getopt(s, name){
 var i;
 if (s.indexOf('#') >= 0)
  s = s.substring(0, s.indexOf('#'));
 if (s = s.split('?')[1]){
  var opts = new Array();
  opts = s.split('&');
  for(i = 0; i < opts.length; i++){
   if (opts[i].substring(0, name.length).toLowerCase() == name.toLowerCase()){
    return(opts[i].substring(name.length + 1));
   }
  }
 }
 return('');
}
function url2path(url){
 if (url.substr(0,1) == '/') return(url);
 var p1 = url.indexOf('://');
 if (p1 < 0) return('');
 var p2 = url.substr(p1+3).indexOf('/');
 if (p2 < 0) return('');
 return(url.substr(p1+p2+3));
}
function entopt(s, name, value){
 var opt, i, flg, aname;
 flg = true;
 if (s.indexOf('#') >= 0){
  aname= s.substring(s.indexOf('#') + 1, s.length);
  s = s.substring(0, s.indexOf('#'));
 }else{
  aname = '';
 }
 if (opt = s.split('?')[1]){
  var opts = new Array();
  opts = opt.split('&');
  for(i = 0; i < opts.length; i++){
   if (opts[i].substring(0, name.length).toLowerCase() == name.toLowerCase()){
    opts[i] = name + '=' + value;
    flg = false;
    break;
   }
  }
  s = s.split('?')[0] + '?' + opts.join('&');
  if (flg){
   s = s + '&' + name + '=' + value;
  }
 }else{
  s = s + '?' + name + '=' + value;
 }
 if (aname == '')
  return(s);
 else
  return(s + '#' + aname);
}

function changeHref(){
 var opt, i, s, chtml, p;
 var objs = new Array();
 opt = getopt(document.location.href, 'ST');
 if (!opt){
  if(document.setFocus.elements[0]){
   opt = document.setFocus.elements[0].value;
  }
 }
 if (document.getElementById){
  chtml = document.getElementById('change_url');
  if (chtml != null){
   objs = chtml.getElementsByTagName('a');
   for(i=0; i<objs.length;i++){
    s = objs[i].attributes.getNamedItem('href').value;
    p = -1;
    if (s.toLowerCase().indexOf('http://itpro.nikkeibp.co.jp',0) >= 0){
     p = 27;
    }else if (s.toLowerCase().indexOf('https://itpro.nikkeibp.co.jp',0) >= 0){
     p = 28;
    }else if (s.toLowerCase().indexOf('http://192.168.47.57',0) >= 0){
     p = 20;
    }else if (s.toLowerCase().indexOf('http://pc.nikkeibp.co.jp',0) >= 0){
     p = 24;
    }else if (s.toLowerCase().indexOf('https://pc.nikkeibp.co.jp',0) >= 0){
     p = 25;
    }else if ((s.toLowerCase().indexOf('http://',0) < 0)&&(s.toLowerCase().indexOf('https://',0) < 0)&&(s.toLowerCase().indexOf('mailto:',0) < 0)&&(s.toLowerCase().indexOf('ftp://',0) < 0)){
     p = 0;
    }
    if (p >= 0){
     s = s.substr(p);
     if ((s.substr(0, 9) == '/article/') || (s.substr(0, 9) == '/members/') || (s.substr(0, 6) == '/free/') || (s.substr(0, 8) == '/prembk/')){
      if (getopt(s, 'ST') == ''){
       objs[i].attributes.getNamedItem('href').value = entopt(objs[i].attributes.getNamedItem('href').value, 'ST', opt);
      }
     }
    }
   }
  }
 }
}


function popupImage(image, caption, winx, winy){
 if (escape){
  var dir = location.href;
  dir = dir.substr(0, dir.lastIndexOf('/')) + '/';
  w = window.open('/js/2006/popup.shtml?i='+escape(dir + image)+'&c='+escape(caption),'n','width=' + winx + ',height=' + winy + ',scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
  if(navigator.appVersion.charAt(0)>=3){w.focus()};
  return(false);
 }else{
  return(true);
 }
}

function popupComment(url, winx, winy){
 w = window.open(url,'c','width=' + winx + ',height=' + winy + ',scrollbars=yes,resizable=yes');
 if(navigator.appVersion.charAt(0)>=3){w.focus()};
 return(false);
}

function isFuture(pubdate){
 var d = new Date();
 today = new Date((d.getYear() > 1900 ? d.getYear() : d.getYear() + 1900) , d.getMonth(), d.getDate());
 tgday = new Date(pubdate.substr(0,4), pubdate.substr(5,2)-1, pubdate.substr(8,2));
 return(tgday > today);
}

function putTOC(toctitle, tocurl, tocdate, template){
 var title, prev, linkfrom, linkto;
 linkfrom = linkto = '';
 if (!tocdate){
  title = toctitle;
  prev = '(近日公開予定)';
 }else if (isFuture(tocdate) || !tocurl){
  title = toctitle;
  prev = '(' + tocdate + '公開予定)';
 }else{
  linkfrom = '<a href="' + tocurl + '">';
  linkto = '</a>';
  title = linkfrom + toctitle + linkto;
  prev = '';
 }
 return(template.replace(/%TITLE%/g, title).replace(/%PREV%/g, prev).replace(/%LINKFROM%/g, linkfrom).replace(/%LINKTO%/g, linkto));
}

function getBody(iname){
 if(document.all){
  return(document.all(iname))
 } else if(document.getElementById){
  return(document.getElementById(iname))
 }
}

function popupSSwin(url, w, h, t){
 var w = window.open(url + '&title=' + encodeURI(t),'tt','width=' + w + ',height=' + h + ',scrollbars=yes,resizable=yes');
 return(true);
}

var ranking_tId, ranking_wCount, ranking_filter;
ranking_filter = '';
function ranking_wait(){
 var wchar = new Array('／', '─', '＼', '│');
 ranking_wCount++;
 if (ranking_wCount >= wchar.length) ranking_wCount = 0;
 getBody('ranking_table').innerHTML = 'データをダウンロードしています。<br>しばらくお待ち下さい' + wchar[ranking_wCount];
}

function ranking_get(v){
 var Url;
 Url = 'http://itpro.nikkeibp.co.jp/js/2007/ranking/ranking_rt_' + v + '.js';
 ranking_wCount = 0;
 ranking_tId = setInterval(ranking_wait,100);
 var script = document.createElement('script');
 script.src = Url;
 script.charset = "euc-jp";
 document.body.appendChild(script);
}

function ranking_filtering(d){
 var tmp, res, i, j, p, hash, ccates, atypes;
 tmp = ranking_filter.split(/&/);
 hash = new Array();
 for(var i=0; i<tmp.length; i++){
  p = tmp[i].indexOf('=');
  if (p >= 0){
   hash[tmp[i].substr(0, p)] = tmp[i].substr(p+1);
  }
 }
 if (hash['ccate']){
  ccates = hash['ccate'].split(',');
  tmp = new Array();
  for(i=0; i<d.ranking.length; i++){
   for(j=0; j<ccates.length; j++){
    if (ccates[j] == d.ranking[i].ccate){
     tmp.push(d.ranking[i]);
    }
   }
  }
 }else{
  tmp = d.ranking;
 }
 if (hash['atype']){
  atypes = hash['atype'].split(',');
  res = new Array();
  for(i=0; i<tmp.length; i++){
   for(j=0; j<atypes.length; j++){
    if (atypes[j] == tmp[i].atype){
     res.push(tmp[i]);
    }
   }
  }
 }else{
  res = tmp;
  atypes = new Array();
 }
 return(res);
}

