/* このファイルは（おそらく）メニューの（たぶん）ボップアップに使う（と思われる）JSです。2007.07.21 よこさん */


ns = (document.layers) ? true : false
ie = (document.all) ? true : false
moz = (document.getElementById && navigator.appName == "Netscape") ? true : false

// .... browser detection END

// START globals ....

//メニュー内のテキストの大きさとか色とか。
cssString = "<style type='text/css'>\n"
cssString += ".navTable{font-family:verdana,helvetica;color:#ffffff;font-size:11px;line-height:13px;}\n"
cssString += ".sub{font-family:verdana,helvetica;color:#ffffff;font-size:13px;"
if (ns) {cssString += "line-height:13px}"} else {cssString += "line-height:13px}"}
divString = ""
timer = null
menusPerp = new Array()
bomb = null
// Modify Height of the Dropdown

// メニューの縦幅 
// wを何に使ってるかはよくわからん
h = 21
w = 100
y = h + 110
heady = 100

// .... globals END

// START constructors ....

menu.prototype.list = list
menu.prototype.sublist = sublist

function menu(x,width,heading,alt,bgc,bgimg,button,override){
	i = menusPerp.length // how many dropdown menus we got?
	//document.write("<h1>"+menusPerp.length+"</h1>");
	menusPerp[i] = this // create the next one in the array
	this.h = 21 // height of the dropdown menu, must be indiviual item in list
	this.w = (width == null) ? w : width // width of the dropdown menu
	this.ow = (override) ? override : this.w // larger width of dropped menu
	this.x = (x == null) ? menusPerp[i - 1].x + menusPerp[i - 1].w - 1 : x // consider the menu before and create the x position on the page
	this.bgc = bgc
	this.bgimg = bgimg
	this.items = new Array() // set up array for the items on the menu (not the submenu)
	this.dropped = false
	this.id = "menu"+i
	this.heading = heading // image in top nav
	this.alt = alt
	this.y = 50 // y position of dropdown menu
	this.button = (!button) ? false : button
}
//menu1.list(value='Accessories','location (if the item on the main dropdown menu has a link)=#')
function list(value,location){
	i = this.items.length // see how many items we got
	this.items[i] = new item(value,location,this.id,i) // call the item function, pass the id of the menu and the length of it's current items
}

function sublist(value,location,ess){
	i = this.items.length - 1 // we get one off when we create the initial item list
	j = this.items[i].subitems.length 
	this.items[i].subitems[j] = new subitem(value,location,this.items[i].id,j)// this.items[1] is the specific item object in the array
	if (ess == "ess")this.items[i].subitems[j].ess = "ess" // not sure what this does yet
}

function item(value,location,id,index){
	this.id = id + "item" + index // menu1item0
	this.value = value
	this.location = location
	this.subitems = new Array() // sets up a possible array for a submenu
}


function subitem(value,location,id,index){
	this.id = id + "sub" + index // menu1item0sub0
	this.value = value
	this.location = location
}

// ....constructors END

// START build ....

function build(){
	for(i = 0; i < menusPerp.length;i++){ // go through all the main dropdown menus
		subcssString = ""
		subdivString = ""
		x = menusPerp[i].x // x position of the div layer
		wide = menusPerp[i].w // width of the div layer
		owide = menusPerp[i].ow // either equals w or an override value
		bgc = menusPerp[i].bgc
		bgimg = menusPerp[i].bgimg
		totalh = (menusPerp[i].h+1)*menusPerp[i].items.length // multiples by number of items to get total height of div layer
		id = menusPerp[i].id // I think this is one less than the variable assigned, ie menu0 (if) = menu1 (variable assigned)
		cssString+="#"+id+"{position:absolute;top:"+y+";left:"+x+";width:"+owide+";height:"+(totalh+1)+";clip:rect(0,"+owide+","+(totalh+1)+",0);background-image:url("+bgimg+");layer-background-image:url("+bgimg+");z-index:100;visibility:hidden;}\n" // add to already existing css, an id class for every dropdown
		divString+="<div id='"+id+"'>\n" // add to already existing divString, creating div for the dropdown menu
		for(j=0;j<menusPerp[i].items.length;j++){ // this goes through the items in the main dropdown menu
			subs=(menusPerp[i].items[j].subitems[0])?true:false // is there a submenu?
			idsub=menusPerp[i].items[j].id // id of the current item
			ysub=1+(j*(h+1)) // determines where to start each item, each item will have it's own span within div
			cssString+="#"+idsub+"{position:absolute;top:"+ysub+";left:1;width:"+(owide-2)+";height:"+h+";clip:rect(0,"+(owide-2)+","+h+",0);color:#ffffff;background-color:#"+bgc+";layer-background-color:#"+bgc+";font-family:verdana,helvetica,sans serif;font-size:10px;}\n" // add to already existing css, an idclass for every item in dropdown
			cssString+="#"+idsub+"c{position:absolute;top:"+ysub+";left:1;width:"+(owide-2)+";height:"+h+";clip:rect(0,"+(owide-2)+","+h+",0)}\n" // id class for item plus letter 'c'?
			divString+="<span id='"+idsub+"'><table border=0 cellpadding=0 cellspacing=0><tr><td class='navTable' width='4'"
			// below, creates two divs for each item, 1) is a table with the text and colors set, 2) is a blank image, that has the link and controls the hidding and rollover scripts
			if (ns) divString+=" style='background:#"+bgc+"'"
			divString+=">&nbsp;</td><td width="+(owide-20)+" height=21 class='navTable'"
			if (ns) divString+=" style='background:#"+bgc+"'"
			divString+=">"+menusPerp[i].items[j].value+"</td>"
			if (subs) divString+="<td width=8 class='navTable'"
			if (subs&&ns) divString+=" style='background:#"+bgc+"'"
			if (subs) divString+=">&gt;&gt;</td>"
			divString+="</tr></table></span>\n"
			divString+="<span id='"+idsub+"c'><a href='"+menusPerp[i].items[j].location+"' onmouseover='highlight(\""+idsub+"\");live("+i+");"
			if (subs) divString+="show("+i+","+j+",\""+idsub+"x\");' onmouseout='hide(\""+idsub+"x\");fade("+i+");"
			if (!subs) divString+="' onmouseout='fade("+i+");"
			divString+="dim(\""+idsub+"\",\""+bgc+"\")'><img border=0 src='../images/transparent.gif' width="+(owide-2)+" height="+h+"></a></span>\n"
			// the following creates the sub menu styles, two divs also, no table structure, no line-height set (just a note) in css
			if(subs){
			//Modify width of submenu
				w = 150
				wide = 120
				subcssString+="#"+idsub+"x{position:absolute;left:"+(x+owide-1)+";top:"+(heady+h+ysub+1)+";width:"+w+";height:"+(((h+1)*menusPerp[i].items[j].subitems.length)+1)+";clip:rect(0,"+w+","+(((h+1)*menusPerp[i].items[j].subitems.length)+1)+",0);background-image:url("+bgimg+");layer-background-image:url("+bgimg+");z-index:100;visibility:hidden}"
				subdivString+="<div id='"+idsub+"x'>\n"
				for(k=0;k<menusPerp[i].items[j].subitems.length;k++){
					idsubsub=menusPerp[i].items[j].subitems[k].id
					ysubsub=(j*(h+1))+(k*(h+2))
					suby=1+(k*(h+1))
					subBGC = bgc
					if(menusPerp[i].items[j].subitems[k].ess)subBGC = "AA221A" // if ess exists, change bg color, must be that red color
					if(j != 0 && k == 0) {
						subcssString+="#line"+idsubsub+"{position:absolute;left:1;top:0;width:"+(w-2)+";height:1;clip:rect(0,"+(w-2)+",1,0);background-color:#ffffff;layer-background-color:#ffffff;color:#ffffff;}\n"
						subcssString+="#line"+idsubsub+"c{position:absolute;left:1;top:0;width:"+(w-2)+";height:1;clip:rect(0,"+(w-2)+",1,0)}\n"
						subdivString+="<div id='line"+idsubsub+"'><img src=../images/l_pnav_white_sp02.gif width="+(w-2)+" height=1></div>\n"
						subdivString+="<div id='line"+idsubsub+"c'></div>"
					}
					subcssString+="#"+idsubsub+"{position:absolute;left:1;top:"+suby+";width:"+(w-2)+";height:"+h+";clip:rect(0,"+(w-2)+","+h+",0);background-color:#"+bgc+";layer-background-color:#"+bgc+";color:#ffffff;}\n"
					subcssString+="#"+idsubsub+"c{position:absolute;left:1;top:"+suby+";width:"+(w-2)+";height:"+h+";clip:rect(0,"+(w-2)+","+h+",0)}\n"
					subdivString+="<div id='"+idsubsub+"' class='sub'><table border=0 cellpadding=0 cellspacing=0><tr><td"
					if (ns) subdivString+=" style='background:#"+bgc+"'"
					subdivString+="><img src=../images/transparent.gif width='4' height='20'></td><td class='sub'"
					if (ns) subdivString+=" style='background:#"+bgc+"'"
					subdivString+=">"+menusPerp[i].items[j].subitems[k].value+"</td></tr></table></div>\n"
					subdivString+="<div id='"+idsubsub+"c'><a href='"+menusPerp[i].items[j].subitems[k].location+"' onmouseover='live("+i+");show("+i+","+j+",\""+idsub+"x\");highlight(\""+idsubsub+"\")' onmouseout='fade("+i+");hide(\""+idsub+"x\");dim(\""+idsubsub+"\",\""+subBGC+"\")'><img border=0 src='../images/transparent.gif' width="+(wide-2)+" height="+h+"></a></div>"
				}
				subdivString+="</div>\n"
			}
		}
		divString+="</div>\n"
		// add it all together
		cssString+=subcssString
		divString+=subdivString
		button="#"
		
	}
}

function writeCSS(){
	cssString+="</style>\n"
	document.open();
	document.write(cssString);
	document.close()
}

function writeHTML(){
	document.open();
	document.write(divString);
	document.close()
}

// .... build END
// only used of submenus
function show(i,j,id){
	// go through each of the items and see if they have a submenu
	for(p=0;p!=menusPerp[i].items.length;p++){
		if(menusPerp[i].items[p].subitems.length){
			str="menu"+i+"item"+p+"x" // recreate id (why not just grab the id passed in?
			// first hide all the submenus
			if(ie)document.all[str].style.visibility="hidden"
			if(ns)document[str].visibility="hide"
			if(moz)document.getElementById(str).style.visibility="hidden"
		}
	}
	// same as bomb, if timer has been set through the hide(), clear it
	if(timer)clearTimeout(timer)
	// depending on browser, show the submenu
	if(ie)document.all[id].style.visibility = 'visible'
	if(ns)document[id].visibility = "show"
	if(moz)document.getElementById(id).style.visibility = 'visible'
}
// passed the submenu id
function hide(ided){
	// after a short time, hide the submenu
	if(ie)timer=setTimeout('document.all.'+ided+'.style.visibility="hidden"',200)
	if(ns)timer=setTimeout('document.'+ided+'.visibility="hide"',200)
	if(moz)timer=setTimeout('document.getElementById("'+ided+'").style.visibility="hidden"',200)
}


function live(id){ // idea of top div
	// hide all the divs first
	for(p=0;p!=menusPerp.length;p++){
		str="menu"+p;
		if(ie)document.all[str].style.visibility="hidden"
		if(ns)document[str].visibility="hide"
		if(moz)document.getElementById(str).style.visibility="hidden"
	}
	// if the bomb was set with an OnMouseOut event with fade(), then clear it
	if (bomb) clearTimeout(bomb)
	// show the menu that has been rolled over
	if (ie){
		document.all["menu"+id].style.visibility = "visible";
		if (document.all.formLayer)document.all.formLayer.style.visibility = "hidden"
	}
	if (ns) document["menu"+id].visibility = "show";
	if (moz) document.getElementById("menu"+id).style.visibility = "visible";
}
function nnfixlive(){ // idea of top div
	// if the bomb was set with an OnMouseOut event with fade(), then clear it
	if (bomb) clearTimeout(bomb)
	// show the menu that has been rolled over
	if (ns) document["nnfix"].visibility = "show";
	if (ns) eval("document.nnfix").zIndex = 101;
}

function nnfixfade(){
if (ns) eval("document.nnfix").zIndex = 1;
if(ns)document["nnfix"].visibility="hide";
}

// called for the main dropdown menus
function fade(id){
//	bomb = id;
	// make the main dropdowns hidden after a short about of time
	if(ie){
		bomb=setTimeout('document.all.menu'+id+'.style.visibility="hidden"',500)
		formsey = setTimeout('formHandle()',1000)
	}
	if(ns)bomb=setTimeout('document.menu'+id+'.visibility="hide"',500)
	if(moz)bomb=setTimeout('document.getElementById("menu'+id+'").style.visibility="hidden"',500)
}

function formHandle(){
		count = 0
		for (i = 0; i < menusPerp.length; i++){
			id = menusPerp[i].id
			if (document.all[id].style.visibility == "hidden") count ++
		}
		if (count == menusPerp.length && document.all.formLayer)document.all.formLayer.style.visibility = "visible"
}

//only in ie, allows you to change the backgroundcolor
function highlight(id){
	if(ie)document.all[id].style.backgroundColor = "#9D9C9C"
}

// only in ie, called from onmouseout, changes the background color
function dim(id,bgc){
	if(ie)document.all[id].style.backgroundColor = bgc
}

// MENU OBJECT CALLS
//Modify position of the RollOver Images


// メニューのインスタンス貼ってると思う。
// 一番後ろの引数は、メニューの横幅
// 一番前の引数は、メニューのx座標

menu1=new menu(275,null,"../images/nav_compnay_on.gif ","company","7777ee","../images/tab_line.gif",false,170)
menu2=new menu(150,null,"../images/nav_service_on.gif ","servicies","7777ee","../images/tab_line.gif",false,220)
menu3=new menu(20,null,"../images/nav_prd_on.gif ","products","7777ee","../images/tab_line.gif",false,300)//



//メニューで表示されるテキストとURLはこちら。
//Menu 1 company
							menu1.list('経営理念','vision.php')
							menu1.list('会社概要','history.php')
							menu1.list('経営チーム','message.php')
							menu1.list('個人情報保護方針','privacypolicy.php')
							menu1.list('アクセスマップ','contact.php')
							
//Menu 2 servicies
						menu2.list('E-ラーニングコンテンツ開発','contentdevelopment.php')
						menu2.list('システム開発','system.php')
						menu2.list('教育関連事業','educationrelated.php')
						menu2.list('オフショア開発','online_mitumori_s.php')
						
							

//Menu 3 products
						menu3.list('E-ラーニング管理 Eduwell LMS','LMSIntro.php')
						menu3.list('学習評価管理 Eduwell AMS','AMSIntro.php')
						menu3.list('卸商社向け小売店支援システム Shopwell','ShopwellIntro.php')
						menu3.list('DNNサイト構築','dnnIntro.php')
						menu3.list('オンライン学校 Eduwell School','elearningcontent.php')
						menu3.list('医事管理システム(i−HOSPITAL) ','IhospitalIntro.php')

// create the divString and cssString
build()
// open a document and write the stylesheet
writeCSS()
// open a document and write the divs

if (document.images){
	company = new Image(148,15); company.src="../images/nav_company_off.gif";
	company_roll = new Image(148,15); company_roll.src="../images/nav_company_on.gif";

	servicies = new Image(148,15); servicies.src="../images/nav_service_off.gif";
	servicies_roll = new Image(148,15); servicies_roll.src="../images/nav_service_on.gif";

	products = new Image(148,15); products.src="../images/nav_prd_off.gif";
	products_roll = new Image(148,15); products_roll.src="../images/nav_prd_on.gif";

}

function SimpleRollOn(imageid, imagename){
	if (document.layers) {
	document.images[imageid].src = eval(imagename+".src");
	}
	else if (document.all) {
	document.images[imageid].src = eval(imagename+".src");
	}
}

function SimpleRollOff(imageid, imagename){
	if (document.layers) {
	document.images[imageid].src = eval(imagename+".src");
	}
	else if (document.all) {
	document.images[imageid].src = eval(imagename+".src");
	}

}

writeHTML()

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_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_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];}
}
