//サーチボックス
function Input(areaname,checkvalue,searchbox){
	if(document.forms[searchbox].elements[areaname].value == checkvalue){
		document.forms[searchbox].elements[areaname].value = "";
	}
}
function Output(areaname,checkvalue,searchbox){
	if(document.forms[searchbox].elements[areaname].value == ""){
		document.forms[searchbox].elements[areaname].value = checkvalue;
	}
}

/* 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         = 350;
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;
}

/*subメニューコマンド*/
var subcurrentLayer = null;//追加変数
var subcurrentLayerNum = 0;//追加変数
var subnoClose         = 0;//追加変数
var subcloseTimer      = null;//追加変数


function subopen(n) {
  var sm = document.getElementById("submenu"+n);
  var l  = document.getElementById("menu"+n);
  var mm = document.getElementById("mmenu"+n);
	
  if(l, sm) {
    subcancelclosetime();//追加
    l.style.visibility='visible';
    sm.style.visibility='visible';//追加
    if(currentLayer && (currentLayerNum != n))
      currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;
    subcurrentLayer = sm;//追加
 	}
    else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
 	}
}//subopen最終行

function subclosetime() {
  subcloseTimer = window.setTimeout(subclose, TimeOut);
}

function subcancelclosetime() {
  if(subcloseTimer) {
    window.clearTimeout(subcloseTimer);
    subcloseTimer = null;
  }
}

function subclose() {
  if(subcurrentLayer && subnoClose!=1)   {
    subcurrentLayer.style.visibility='hidden';
    subcurrentLayerNum = 0;
    subcurrentLayer = null;
    currentitem = null;
  } else {
    subnoClose = 0;
  }
  subcurrentLayer = null;
  currentitem = null;
}

document.onclick = mclose, subclose; //?

//フォント検出
/**
 * JavaScript code to detect available availability of a 
 * particular font in a browser using JavaScript and CSS. 
 * 
 * Author : Lalit Patel
 * Website: http://www.lalit.org/lab/jsoncookies
 * License: Creative Commons Attribution-ShareAlike 2.5
 *          http://creativecommons.org/licenses/by-sa/2.5/
 * Version: 0.1
 * Updated: Aug 11, 2007 10:09am
 * 
 */

/**
 * Actual function that does all the work. Returns an array with all the info.
 * My Assumption is that most of the browsers will have arial set as their default sans-serif font.
 */
var Detector = function(){
	var h = document.getElementsByTagName("body")[0];
	var d = document.createElement("div");
	var s = document.createElement("span");
	d.appendChild(s);
	d.style.fontFamily = "'ｍｓ ｐゴシック' ,sans-serif";		//font for the parent element DIV.
	s.style.fontFamily = "'ｍｓ ｐゴシック', sans-serif";		//arial font used as a comparator.
	s.style.fontSize   = "72px";			//we test using 72px font size, we may use any size. I guess larger the better.
	s.innerHTML        = "mmmmmmmmmml";		//we use m or w because these two characters take up the maximum width. And we use a L so that the same matching fonts can get separated
	h.appendChild(d);
	var defaultWidth   = s.offsetWidth;		//now we have the defaultWidth
	var defaultHeight  = s.offsetHeight;	//and the defaultHeight, we compare other fonts with these.
	h.removeChild(d);
	/* test
	 * params:
	 * font - name of the font you wish to detect
	 * return: 
	 * f[0] - Input font name.
	 * f[1] - Computed width.
	 * f[2] - Computed height.
	 * f[3] - Detected? (true/false).
	 */
	function test(font) {
		h.appendChild(d);
		var f = [];
		f[0] = s.style.fontFamily = font;	// Name of the font
		f[1] = s.offsetWidth;				// Width
		f[2] = s.offsetHeight;				// Height
		h.removeChild(d);
		font = font.toLowerCase();
		if (font == "arial" | font == "sans-serif") {
			f[3] = true;	// to set arial and sans-serif true
		} else {
			f[3] = (defaultWidth != f[1] || defaultHeight != f[2]);	// Detected?
		}
		return f;
	}
	this.test = test;
}

