﻿//ページトップ





var Mac = navigator.appVersion.indexOf('Mac',0) != -1;

var Win = navigator.appVersion.indexOf('Win',0) != -1;

var IE  = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;

var NN  = navigator.appName.indexOf("Netscape",0) != -1;

var Moz = navigator.userAgent.indexOf("Gecko") != -1;

var Vmajor = parseInt(navigator.appVersion); // ex. 3

var Vminor = parseFloat(navigator.appVersion); // ex. 3.01



var MacIE4 = ((Mac && navigator.appVersion.indexOf('MSIE 4.',0) != -1));

var MacIE3 = ((Mac && navigator.appVersion.indexOf('MSIE 3.',0) != -1));



function setObj(id) {

 if (document.all) {

  return document.all(id);

 } else if (document.getElementById) {

  return document.getElementById(id);

 } else if (document.layers) {

  return document.layers[id];

 }

 return false;

}



function getScrollLeft() { // 020225

 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {

  return document.body.scrollLeft;

 } else if (window.pageXOffset) {

  return window.pageXOffset;

 } else {

  return 0;

 }

}



function getScrollTop() { // 020225

 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {

  return document.body.scrollTop;

 } else if (window.pageYOffset) {

  return window.pageYOffset;

 } else {

  return 0;

 }

}



function getScrollWidth() { // 010317

 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {

  return document.body.scrollWidth;

 } else if (window.innerWidth) {

  return window.innerWidth;

 }

 return 0;

}



function getScrollHeight() { // 010317

 if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {

  return document.body.scrollHeight;

 } else if (window.innerHeight) {

  return window.innerHeight;

 }

 return 0;

}



// 



function setLayerPosX(elementname,_posX) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  obj.style.pixelLeft = _posX;

 } else if (document.getElementById && obj.style) {

  obj.style.left  = _posX + 'px';

 } else if (document.layers) {

  obj.left = _posX;

 }

}



function setLayerPosY(elementname,_posY) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  obj.style.pixelTop = _posY;

 } else if (document.getElementById && obj.style) {

  obj.style.top  = _posY + 'px';

 } else if (document.layers) {

  obj.top = _posY;

 }

}



function setLayerPosTo(elementname,_posX,_posY) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  obj.style.pixelLeft = _posX;

  obj.style.pixelTop  = _posY;

 } else if (document.getElementById && obj.style) {

  obj.style.left = _posX + 'px';

  obj.style.top  = _posY + 'px';

 } else if (document.layers) {

  obj.moveTo(_posX,_posY);

 }

}



function setLayerPosBy(elementname,_posX,_posY) { // 010317

 var obj = setObj(elementname);

 _posX = parseInt(_posX); _posY = parseInt(_posY);

 if (document.all && obj.style) {

  obj.style.pixelLeft = _posX + getDivPosX(elementname);

  obj.style.pixelTop  = _posY + getDivPosY(elementname);

 } else if (document.getElementById && obj.style) {

  obj.style.left = _posX + getDivPosX(elementname) + 'px';

  obj.style.top  = _posY + getDivPosY(elementname) + 'px';

 } else if (document.layers) {

  obj.moveTo(_posX,_posY);

 }

}



function getLayerPosX(elementname) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  return parseInt(obj.style.pixelLeft);

 } else if (document.getElementById && obj.style) {

  if (Moz) {

   style = getComputedStyle(obj,null);

   return parseInt(style.getPropertyValue('left'));

  }

  return parseInt(obj.style.left);

 } else if (document.layers) {

  return parseInt(obj.left);

 }

 return '';

}



function getLayerPosY(elementname) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  return parseInt(obj.style.pixelTop);

 } else if (document.getElementById && obj.style) {

  if (Moz) {

   style = getComputedStyle(obj,null);

   return parseInt(style.getPropertyValue('top'));

  }

  return parseInt(obj.style.top);

 } else if (document.layers) {

  return parseInt(obj.top);

 }

 return '';

}



function getLayerWidth(elementname) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  return obj.clientWidth;

 } else if (document.getElementById && obj.style) {

  if (Moz) {

   style=getComputedStyle(obj,null);

   return parseInt(style.getPropertyValue('width'));

  }

  return parseInt(obj.style.width);

 } else if (document.layers) {

  return obj.clip.width;

 }

 return '';

}



function getLayerHeight(elementname) { // 010317

 var obj = setObj(elementname);

 if (document.all && obj.style) {

  return obj.clientHeight;

 } else if (document.getElementById && obj.style) {

  if (Moz) {

   style=getComputedStyle(obj,null);

   return parseInt(style.getPropertyValue('height'));

  }

  return parseInt(obj.style.height);

 } else if (document.layers) {

  return obj.clip.height;

 }

 return '';

}



function setLayerDisplay(elementname, _status) { // 020307

 var obj = setObj(elementname);

 if ((document.getElementById || document.all) && obj.style && _status != null) {

  obj.style.display = _status;

 }

}



function getLayerDisplay(elementname) { // 010520

 var obj = setObj(elementname);

 if ((document.getElementById || document.all) && obj.style) {

  return obj.style.display;

 }

}



function setLayerClip(elementname,clipTop,clipRight,clipBottom,clipLeft) {

 var obj = setObj(elementname);

 if ((document.getElementById || document.all) && obj.style) {

  obj.style.clip = 'rect(' + clipTop + 'px,' + clipRight + 'px,' + clipBottom + 'px,' + clipLeft + 'px)';

 } else if (document.layers) {

  obj.clip.top = clipTop;

  obj.clip.bottom = clipBottom;

  obj.clip.left = clipLeft;

  obj.clip.right = clipRight;

 }

}



function getLayerClip(elementname,_which) {

 var obj = setObj(elementname);

 if ((document.getElementById || document.all) && obj.style) {

  if (obj.style.clip == 'auto') return 'auto';

  var clipv = obj.style.clip.split('rect(')[1].split(')')[0].split(" ");

  if (_which == "top")    return parseInt(clipv[0]);

  if (_which == "right")  return parseInt(clipv[1]);

  if (_which == "bottom") return parseInt(clipv[2]);

  if (_which == "left")   return parseInt(clipv[3]);

 } else if (document.layers) {

  if (_which == "top")    return obj.clip.top;

  if (_which == "right")  return obj.clip.right;

  if (_which == "bottom") return obj.clip.bottom;

  if (_which == "left")   return obj.clip.left;

 }

}



function setLayerZIndex(elementname,_order) {

 var obj = setObj(elementname);

 if ((document.getElementById || document.all) && obj.style) {

  obj.style.zIndex = _order;

 } else if (document.layers) {

  obj.zIndex = _order;

 }

}



function getLayerZIndex(elementname) {

 var obj = setObj(elementname);

 if ((document.getElementById || document.all) && obj.style) {

  return obj.style.zIndex;

 } else if (document.layers) {

  return obj.zIndex;

 } 

}



function rewriteInnerHTML(elementname,_code) {

 var obj = setObj(elementname);

 if (document.all) {

  obj.innerHTML=_code;

 } else if (document.getElementById) {

  obj.innerHTML=_code;

 } else if (document.layers) {

  obj.document.open();

  obj.document.write(_code);

  obj.document.close();

 }

}



function setDisplay(target, str) {

 var obj = setObj(target);

 if ((document.getElementById || document.all) && obj.style) {

  if (str == null) str = ( obj.style.display == 'none' || obj.style.display == '') ? 1 : 0;

  obj.style.display = (str > 0) ? 'block' : 'none';

 }

}



var hexbox = new Array(16);

for (i = 0; i < 10; i++) hexbox[i] = i;

hexbox[10]="a"; hexbox[11]="b"; hexbox[12]="c";

hexbox[13]="d"; hexbox[14]="e"; hexbox[15]="f";



function toHex(_int) {

 if (i < 0) {

  return '00';

 } else if (_int > 255) {

  return 'ff';

 } else {

  return '' + hexbox[Math.floor(_int/16)] + hexbox[_int%16];

 }

}



function preloadImg(imgName) {

 if (document.images) (new Image()).src = imgName;

}



function preloadimgApp(imgArray) {

 for (i=0; i<imgArray.length; i++) {

  preloadImg(imgArray[i]);

 }

}



function swapImage(target,src) {

 if (document.images) document.images[target].src = src;

}



var pageScrollTimer;

function pageScroll(toX,toY,frms,cuX,cuY) { // 020314

 if (pageScrollTimer) clearTimeout(pageScrollTimer);

 if (!toX || toX < 0) toX = 0;

 if (!toY || toY < 0) toY = 0;

 if (!cuX) cuX = 0 + getScrollLeft();

 if (!cuY) cuY = 0 + getScrollTop();

 if (!frms) frms = 6;



 if (toY > cuY && toY > (getAnchorPosObj('end','enddiv').y) - getInnerSize().height) toY = (getAnchorPosObj('end','enddiv').y - getInnerSize().height) + 1;

 cuX += (toX - getScrollLeft()) / frms; if (cuX < 0) cuX = 0;

 cuY += (toY - getScrollTop()) / frms;  if (cuY < 0) cuY = 0;

 var posX = Math.floor(cuX);

 var posY = Math.floor(cuY);

 window.scrollTo(posX, posY);



 if (posX != toX || posY != toY) {

  pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+cuX+","+cuY+")",16);

 }

}



function jumpToPageTop() { // 020301

// if (!MacIE3 && !MacIE4 && !NN && window.scrollTo || NN && (Vminor >= 4.75) && window.scrollTo) {

  pageScroll(0,0,5);

// } else {

//  location.hash = "top";

// }

}



function getInnerSize() {

 var obj = new Object();



 if (document.all || (document.getElementById && IE)) {

  obj.width = document.body.clientWidth;

  obj.height = document.body.clientHeight;

 } else if (document.layers || (document.getElementById && Moz)) {

  obj.width = window.innerWidth;

  obj.height = window.innerHeight;

 }



 return obj;

}



function getAnchorPosObj(elementname, elementid) {

 var obj = setObj(elementname);

 var objnew = new Object();

 var objtmp;



 if (document.getElementById && IE) {

  objtmp = obj;

  objnew.x = objtmp.offsetLeft;

  objnew.y = objtmp.offsetTop;

  while ((objtmp = objtmp.offsetParent) != null) {

   objnew.x += objtmp.offsetLeft;

   objnew.y += objtmp.offsetTop;

  }

 } else if (document.getElementById && Moz) {

//  objnew.x = document.getElementsByTagName("A").namedItem(elementname).offsetLeft;

//  objnew.y = document.getElementsByTagName("A").namedItem(elementname).offsetTop;

  objnew.x = document.getElementsByTagName("DIV").namedItem(elementid).offsetLeft;

  objnew.y = document.getElementsByTagName("DIV").namedItem(elementid).offsetTop;

 } else if (document.all) {

  objtmp = obj;

  objnew.x = objtmp.offsetLeft;

  objnew.y = objtmp.offsetTop;

  while ((objtmp = objtmp.offsetParent) != null) {

   objnew.x += objtmp.offsetLeft;

   objnew.y += objtmp.offsetTop;

  }

 } else if (document.layers) {

  objnew.x = document.anchors[elementname].x;

  objnew.y = document.anchors[elementname].y;

 } else {

  objnew.x = 0;

  objnew.y = 0;

 }

 return objnew;

}



function jumpToAnchor(elementname, elementid) {

 if (getAnchorPosObj(elementname, elementid).x != 0 || getAnchorPosObj(elementname, elementid).y != 0) {

  pageScroll(0,getAnchorPosObj(elementname, elementid).y,5);

 } else {

  location.hash = elementname;

 }

}



/* open window */



function openWindow(url,title,width,height,options) {

 var newWin;

 if (!!window && url) {

  if (!title) title = "_blank";

  if (!options) options = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,favorites=no";

//  if (!options) options = "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,favorites=yes";

  var whop = "width="+width+",height="+height+","+options;

  newWin = window.open(url,title,whop);

  newWin.focus();

  newWin.moveTo(0, 0)

 }

}



// セルをクリックしたときにセル内のアンカーをクリック

// onclick/onkeypress に指定

// ex) actItemClick(this);

function actItemClick(_target) {

 if (!document.styleSheets) return;

 if (window.event) {

//  if (event.srcElement.tagName == "TD") _target.children.tags("A")[0].click();

  if (event.srcElement.tagName == "TD") _target.children.tags("TABLE").item(0).getElementsByTagName("A")[0].click();

 } else {

  location.href = _target.getElementsByTagName("A")[0].href;

 }

}



// フォーカスしたときに色を変化/マウスカーソルを変化

// onmouseover/onfocus に指定

// ex) actItemFocus(this);

function actItemFocus(_target) {

 if (!document.styleSheets) return;

 var _bgColor = "#eeeeee";

 if (window.event) {

  if (!_target.contains(event.fromElement)) {

   _target.style.cursor = "hand";

   _target.style.backgroundColor = _bgColor;

  }

 } else {

  _target.style.cursor = "pointer";

  _target.style.backgroundColor = _bgColor;

 }

}



// フォーカスが離れたときに色を戻す/マウスカーソルを戻す

// onmouseout/onblur に指定

// ex) actItemBlur(this);

function actItemBlur(_target) {

 var _bgColor = "#f9f9f9";

 if (!document.styleSheets) return;

 if (window.event) {

  if (!_target.contains(event.toElement)) {

   _target.style.cursor = "default";

   _target.style.backgroundColor = _bgColor;

  }

 } else {

  _target.style.cursor = "default";

  _target.style.backgroundColor = _bgColor;

 }

}















// flash preitems





//ポップアップウインドウ

function openNewWindow(URLtoOpen, windowName, windowFeatures) { 

  newWindow=window.open(URLtoOpen, windowName, windowFeatures);

}









//fireworksシンプルロールオーバー



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_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_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];}

}

