

function getDir(){  // ディレクトリ階層の取得

  url = "ofhair.co.jp";  // トップフォルダ名
  path = location.pathname;
  ulen = url.length;
  unum = path.indexOf(url);

  if(unum < 0){  // WEB用
    path = path.substr(1);
    path = path.split("/");
    dnum = path.length - 1;

  }else{  // ディスクトップ用
    if(path.indexOf("\\") < 0){
      path = path.substr(unum + ulen + 1);
      path = path.split("/");
      dnum = path.length - 1;
    }else{
      path = path.substr(unum + ulen + 1);
      path = path.split("\\");
      dnum = path.length - 1;
    }
  }

  dir = "";
  for(i=0; i<dnum; i++){
    dir += "../";
  }
  return dir;

}


function CheckBrowser(){
  this.win=(navigator.userAgent.indexOf("Win") >= 0)?1:0;
  this.ver=navigator.appVersion;
  this.dom=document.getElementById?1:0; 
  this.ie5=(this.ver.indexOf("MSIE")>-1 && this.dom)?1:0; 
  this.ie4=(document.all && !this.dom)?1:0;
  this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
  return this;
}

function GetDivObject(obj,cont){
  cont=(!cont) ? '':'document.'+cont+'.';
  this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(cont+'document.'+obj):0;
  this.doc=bw.ns5?document:bw.dom?document.getElementById(obj).document:bw.ie4?document.all[obj].document:bw.ns4?eval(cont+'document.'+obj+'.document'):0;
  this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(cont+'document.'+obj):0;
  this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight;
  this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight;
  this.ChangeDiv = ChangeDiv;
  this.x;
  this.y; 
  this.obj = obj + "Object";
  eval(this.obj + "=this");
  return this;
}

function ChangeDiv(msg_){
  var msg=msg_;
  if(bw.ns4){
    this.el.document.open("text/html");
    this.el.document.write(msg);
    this.el.document.close();
  }else{
    this.el.innerHTML = msg;
  }
}

function changeImg(imgname,imgurl) {
  document.images[imgname].src = imgurl;
}

function overMouse(imgname,imgsrc){
  imgsrc = imgsrc.replace("-off","-on");
  changeImg(imgname,imgsrc);
}

function outMouse(imgname,imgsrc){
  imgsrc = imgsrc.replace("-on","-off");
  changeImg(imgname,imgsrc);
}

function wopenf(link, wnum, hnum){
    var NewWindow = window.open(link,"NewWin",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+wnum+',height='+hnum);
}

function wopen(link,wname,wnum,hnum){
    var NewWindow = window.open(link,wname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+wnum+',height='+hnum);
}

/****** open new window ******/
function openWindow(url,width,height,name){    // scrolls and resizable -- yes
  name = (!name) ? 'newWindow' : name;
  var WO = window.open( url, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height);
  WO.window.focus();
}

function openWindow_no(url,width,height,name){  // all options -- no
  name = (!name) ? 'newWindow' : name;
  var WO = window.open( url, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height);
  WO.window.focus();
}

function SetDefault(url){
  if(bw.ns4){
    window.open(url,'DenWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,location=no,resizable=no,width=465,height=455');
  }else if(bw.ns5){
    window.open(url,'DenWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,location=no,resizable=no,width=465,height=455');
  }else if(bw.win){
    window.open(url,'DenWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,location=no,resizable=no,width=465,height=455');
  }else {
    window.open(url,'DenWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,location=no,resizable=no,width=450,height=440');
  }
}




function jumpTop() {  // ページトップにスクロールさせる
  if(window.scrollTo){
    pgScroll(0,0,8);
  }else{
    location.hash = "top";
  }
}

var pgScrollTimer;
function pgScroll(toX,toY,speed,cuX,cuY) {
 if (pgScrollTimer) clearTimeout(pgScrollTimer);
 if (!toX || toX < 0) toX = 0;
 if (!toY || toY < 0) toY = 0;
 if (!cuX) cuX = 0 + getScrollLeft();
 if (!cuY) cuY = 0 + getScrollTop();
 if (!speed) speed = 6;

 cuX += (toX - getScrollLeft()) / speed; if (cuX < 0) cuX = 0;
 cuY += (toY - getScrollTop()) / speed;  if (cuY < 0) cuY = 0;
 var posX = Math.floor(cuX);
 var posY = Math.floor(cuY);
 window.scrollTo(posX, posY);

 if (posX != toX || posY != toY) {
  pgScrollTimer = setTimeout("pgScroll("+toX+","+toY+","+speed+","+cuX+","+cuY+")",20);
 }
}

function getScrollTop() {
 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {
  return document.body.scrollTop;
 } else if (window.pageYOffset) {
  return window.pageYOffset;
 } else {
  return 0;
 }
}

function getScrollLeft() {
 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {
  return document.body.scrollLeft;
 } else if (window.pageXOffset) {
  return window.pageXOffset;
 } else {
  return 0;
 }
}