// JavaScript Document
	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	Update log:
	Version 1.1 	December, 1st 2005: Critical update for the new Firefox 1.5 browser
	Version 1.2: 	December, 21th 2005 : Mouseover effect when mouse moves outside of a submenu items text
	
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
		
	var dhtmlgoodies_menuObj;	
	var currentZIndex = 1000;
	var liIndex = 0;
	var visibleMenus = new Array();
	var activeMenuItem = false;
	var timeBeforeAutoHide = 1200;
	var dhtmlgoodies_menu_arrow = 'images/arrow.gif';
	
	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
	var navigatorVersion = navigator.appVersion.replace(/.*?MSIE ([0-9]\.[0-9]).*/g,'$1')/1;
	var menuBlockArray = new Array();
	var menuParentOffsetLeft = false;	
	
	function getTopPos(inputObj)
	{
		
	  var returnValue = inputObj.offsetTop;
	  if(inputObj.tagName=='LI' && inputObj.parentNode.className=='menuBlock1'){
	  	var aTag = inputObj.getElementsByTagName('A')[0];
	  	if(aTag)returnValue += aTag.parentNode.offsetHeight;

	  }	  
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;

	  return returnValue;
	}
	
	function getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
	
function subMenuMouseOverFunc( pobj, name)
{
    var sm = document.getElementById( name);
    if( sm){
      sm.style.visibility="visible";
      sm.style.display="block";
      sm.style.left=getLeftPos( pobj)+'px';
      sm.style.top=getTopPos( pobj)+3*pobj.offsetHeight/4+'px';
    }
}
function subMenuMouseOutFunc( pobj, name)
{
    var sm = document.getElementById( name);
    if( sm){
      sm.style.visibility="hidden";
      sm.style.display="none";
    }
}
function topMenuMouseOverFunc( obj)
{
    if( obj){
      obj.className="sub_menu_currentDepth2hover";
    }
}
function topMenuMouseOutFunc( obj)
{
    if( obj){
      obj.className="sub_menu_currentDepth2";
    }
}
	
///	window.onload = initDhtmlGoodiesMenu;
	
// クライアントのブラウザのタイプを検出
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// Flash Player プラグインのバージョン情報を検出するには、JavaScript ヘルパーが必要です
function JSGetSwfVer(i){
	// プラグイン配列内の Flash プラグインについて NS/Opera バージョンが 3 以上かどうかを確認します
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 は Flash 4 をサポートしています
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 は Flash 3 をサポートしています
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// それ以前のバージョンの WebTV は Flash 2 をサポートしています
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// 他のすべての状況では検出できません
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// パラメータを指定せずに呼び出した場合、この関数は浮動小数値を返します。
// これは、Flash Player のバージョンまたは 0.0 になります。
// 例 : Flash Player 7r14 の場合は 7.14 を返します
// reqMajorVer を指定して呼び出した場合、reqMinorVer、reqRevision は、それ以上のバージョンが使用可能なときには true を返します
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// 最新のバージョンを見つけるまで、バージョンを遡ってループします	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// メジャーバージョンは要求されたメジャーバージョン以上であり、かつマイナーバージョンは要求されたマイナーバージョン以上の場合
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}
// Plus-EPI
 /********************************
 
 
  ********************************/
function loadDataFile( div_id_name, load_file_name)
{
	new Ajax.Request(load_file_name, { method: 'get',
		onComplete: function(httpObj) {
			$(div_id_name).innerHTML = httpObj.responseText;
		}
	});
}
function loadDataFileEx( div_id_name, load_file_name, callBackFunc)
{
	new Ajax.Request(load_file_name, { method: 'get',
		onComplete: function(httpObj) {
			$(div_id_name).innerHTML = httpObj.responseText;
			if(callBackFunc != null) callBackFunc();
		}
	});
}
function loadDataFileByPost(  div_id_name, load_file_name, form_name)
{
	new Ajax.Request(load_file_name, 
					 { 
					 	method: 'post',
						asynchronous : true,
						postBody : Form.serialize(form_name),
						onComplete: function(httpObj) {
							$(div_id_name).innerHTML = httpObj.responseText;
						},
						onFailure : function(httpObj) {
							$(div_id_name).innerHTML = "ファイルの取得に失敗しました";
						}
					}
	);
}
 
 
function loadJSONFile( completeFunction, load_file_name)
{
	new Ajax.Request(load_file_name, { method: 'get',
		onComplete: function(httpObj) {
			var items = eval(   httpObj.responseText   );
				completeFunction( items);
		}
	});
}
/*
   post_url: POST URL
   hashParams: postデータをハッシュオブジェクトで渡す 
   			ex. $H( {name:'Hamada Takao', years: year.toString()});
   completeFunction: POST処理が成功し、データ受信完了後に呼び出される処理関数名。
   onFailreFunction: POST処理が失敗した際に呼び出される。

*/
function loadJSONByPost( post_url, hashParams, completeFunction,  onFailureFunction)
{
	var parameter = hashParams.toQueryString();
	new Ajax.Request(post_url, 
					 { 
					 	method: 'post',
						asynchronous : true,
						postBody : parameter,
						onComplete: function(httpObj) {
							var items = eval(   httpObj.responseText   );
							completeFunction( items);
						},
						onFailure :onFailureFunction
					}
	);
}

function JumpTo(url) {
    document.location = url;
}

