///////////////////////////////////////////////////////////////////////////////////////////
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Konstantin Jagello | http://javascript-array.com/ */

var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

function mopen(n) {
  var l  = document.getElementById("menu"+n);
  var mm = document.getElementById("mmenu"+n);
	
  if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
      currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;			
  } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
 	}
}

function mclosetime() {
  closeTimer = window.setTimeout(mclose, TimeOut);
}

function mcancelclosetime() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
  }
}

function mclose() {
  if(currentLayer && noClose!=1)   {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
  } else {
    noClose = 0;
  }
  currentLayer = null;
  currentitem = null;
}

document.onclick = mclose; 


///////////////////////////////////////////////////////////////////////////////////////////
/* 表示位置固定
----------------------------------------------- */
window.onresize = function() { positioning(); }
window.onload = function() { positioning(); }

function positioning() {
	var nv = navigator.userAgent;
	var bt = document.getElementById("pageup");
	if (nv.match(new RegExp("MSIE 6", "i"))) { floatbt(); }
	else {
		bt.style.position = "fixed";
		bt.style.left = (document.body.offsetWidth / 2) + 460 + "px";
		bt.style.bottom = "110px";
	}
	try{ tabCheck(); }
	catch(e){}
}
function floatbt() {
	var bt = document.getElementById("pageup");
	bt.style.position = "absolute";
	bt.style.left = (document.body.offsetWidth / 2) + 460 + "px";
	bt.style.top = document.body.offsetHeight + document.body.scrollTop - 120 + "px";
	setTimeout("floatbt()", 10);
}


/* page up
----------------------------------------------- */
function pageup() {
	var mode = (document.compatMode && document.compatMode=="CSS1Compat");
	if (mode) { posi = document.documentElement.scrollHeight; }
	else { posi = document.body.scrollHeight; }
	moveObje(posi);
}
function moveObje(position) {
	move = position / 10;
	point = parseInt(position - move);
	scrollTo(0,point);
	if (point > 0) { setTimeout("moveObje(point)",1); }
}

