/*
 * headmenu.js - head menu for MI web page  
 */

var isIe = navigator.appName.charAt(0) == "M";
var isMz = !isIe && document.getElementById;


var baseurl = "http://www.mi-research.com/";

var productmenu;
var servicemenu;
var supportmenu;
var profilemenu;
var languagemenu;

var productmenuJ;
var servicemenuJ;
var supportmenuJ;
var profilemenuJ;

var menubackground;
var menuforeground;
var menuborder = "#e0e0e0";
var menuhighlightfg = "#ffffff";
var menuhighlightbg = "#a0a0a0";
var menuhighlightbd = "#404040";

// CMenu for head menu
function _CHeaderMenu_showMenu(e)
{
  this.superShowMenu(e);
  if (isMz)
    this.currentMenuElem = e.target;
  else if (isIe)
    this.currentMenuElem = window.event.srcElement;
  //this.currentMenuElem.style.borderColor = "#ff0000";
  this.currentMenuElem.style.borderColor = "#00d030";
}

function _CHeaderMenu_closeMenu()
{
  this.superCloseMenu();
  if (this.currentMenuElem != null)
  {
    //this.currentMenuElem.style.borderColor = "#005070";
	this.currentMenuElem.style.borderColor = "#009030";
    this.currentMenuElem = null;
  }
}

function CHeaderMenu(id, align, position, width, bgcolor, hlcolor, itembordercolor, itemborder, menubordercolor, menuborder)
{
        // variables
	this.instancename = id;
        this.id = id+"id";
        this.width = width || "150";
        this.align = align || "left";
        this.position = position || 0;
	this.currentMenuElem = null;
	this.captions = new Array();
	this.actions = new Array();

        this.bgcolor = bgcolor || _CMenu_bgcolor;
        this.hlcolor = hlcolor || _CMenu_hlcolor;
        this.itembordercolor = itembordercolor || _CMenu_itembordercolor;
        this.itemborder = itemborder || _CMenu_itemborder;
        this.menubordercolor = menubordercolor || _CMenu_menubordercolor;
        this.menuborder = menuborder || _CMenu_menuborder;
        this.hltxtcolor = _CMenu_hltxtcolor;
}

CHeaderMenu.prototype = new CMenu();
CHeaderMenu.prototype.superShowMenu = CHeaderMenu.prototype.showMenu;
CHeaderMenu.prototype.superCloseMenu = CHeaderMenu.prototype.closeMenu;
CHeaderMenu.prototype.showMenu = _CHeaderMenu_showMenu;
CHeaderMenu.prototype.closeMenu = _CHeaderMenu_closeMenu;

function goHome()
{
  document.location.href = baseurl;
}

function onProduct(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "products/productlist.html";
    break;
  case 1:
    document.location.href = baseurl + "products/FlowDesigner7.html";
    break;
  case 2:
  	document.location.href = baseurl + "products/FDInstruction.html";
    break;
  case 3:
  	document.location.href = baseurl + "products/FDApplications.html";
    break;
  case 4:
  	document.location.href = baseurl + "products/FDGallary.html";
    break;
  case 5:
  	document.location.href = baseurl + "products/FDSeminar.html";
    break;
  case 7:
  	document.location.href = baseurl + "products/FDConvert.html";
    break;
  case 8:
  	document.location.href = baseurl + "products/ssm";
    break;
  case 9:
  	document.location.href = baseurl + "products/Kantum.html";
    break;
  case 10:
  	document.location.href = baseurl + "products/APS.html";
    break;
  case 11:
    document.location.href = baseurl + "products/FreeTools.html";
    break;
  case 12:
    document.location.href = baseurl + "products/MCFAN.html";
    break;
  }
}

function onProductJ(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "products/productlist-j.html";
    break;
  case 1:
    document.location.href = baseurl + "products/FlowDesigner-j.html";
    break;
  case 2:
    document.location.href = baseurl + "products/fluores-j.html";
    break;
  case 3:
    document.location.href = baseurl + "products/MCFAN-j.html";
    break;
  }
}

function onService(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "services/analysis.html";
    break;
  case 1:
    document.location.href = baseurl + "services/analysis.html";
    break;
  case 2:
    document.location.href = baseurl + "services/consulting.html";
    break;
  case 3:
    document.location.href = baseurl + "services/SWdev.html";
    break;
//  case 4:
//    document.location.href = baseurl + "solution/network/";
//    break;
//  case 5:
//    document.location.href = baseurl + "solution/casestudy/";
//    break;
  }
}

function onServiceJ(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "services/analysis-j.html";
    break;
  case 1:
    document.location.href = baseurl + "services/analysis-j.html";
    break;
  case 2:
    document.location.href = baseurl + "services/consulting-j.html";
    break;
  case 3:
    document.location.href = baseurl + "services/SWdev-j.html";
    break;
//  case 4:
//    document.location.href = baseurl + "solution/network/";
//    break;
//  case 5:
//    document.location.href = baseurl + "solution/casestudy/";
//    break;
  }
}

function onSupport(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "support/contact.html";
    break;
  case 1:
    document.location.href = baseurl + "support/contact.html";
    break;
  case 2:
    //document.location.href = baseurl + "FDusers/users.html";
    document.location.href = "http://en.akl.co.jp/userarea";
    break;
//  case 3:
//    document.location.href = baseurl + "phpBB3";
//    break;
//  case 4:
//    document.location.href = baseurl + "support/purchase/";
//    break;
//  case 5:
//    document.location.href = baseurl + "support/techinfo/";
//    break;
//  case 6:
//    document.location.href = baseurl + "support/install/";
//    break;
//  case 10:
//    document.location.href = baseurl + "userarea/top.php";
  }
}

function onSupportJ(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "support/contact-j.html";
    break;
  case 1:
    document.location.href = baseurl + "support/contact-j.html";
    break;
  case 2:
    //document.location.href = baseurl + "FDusers/users.html";
    document.location.href = "http://en.akl.co.jp/userarea";
    break;
//  case 3:
//    document.location.href = baseurl + "phpBB3";
//    break;
//  case 4:
//    document.location.href = baseurl + "support/purchase/";
//    break;
//  case 5:
//    document.location.href = baseurl + "support/techinfo/";
//    break;
//  case 6:
//    document.location.href = baseurl + "support/install/";
//    break;
//  case 10:
//    document.location.href = baseurl + "userarea/top.php";
  }
}

function goDownload()
{
  document.location.href = baseurl + "support/dllist.php";
}

function goPurchase()
{
  document.location.href = baseurl + "support/purchase/";
}

function onProfile(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "profile/profile.html";
    break;
  case 1:
    document.location.href = baseurl + "profile/aboutmi.html";
    break;
  case 2:
    document.location.href = baseurl + "profile/MImap.html";
    break;
   case 3:
    document.location.href = baseurl + "profile/MIpeople.html";
    break;
  }
}

function onProfileJ(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "profile/profile-j.html";
    break;
  case 1:
    document.location.href = baseurl + "profile/aboutmi-j.html";
    break;
  case 2:
    document.location.href = baseurl + "profile/MImap-j.html";
    break;
   case 3:
    document.location.href = baseurl + "profile/MIpeople-j.html";
    break;
  }
}

function onLanguage(idx)
{
  switch(idx)
  {
  default:
    document.location.href = baseurl + "index-e.html";
    break;
  case 2:
  	document.location.href = baseurl + "index-j.html";
  	break;
  }
} 
  

function highlightmenu(yes)
{
  var elem = window.event.srcElement;
  if (yes == true)
  {
    menuforeground = elem.style.color;
    menubackground = elem.style.backgroundColor;
    menuborder = elem.style.borderColor;
    elem.style.color= menuhighlightfg;
    elem.style.backgroundColor = menuhighlightbg;
    elem.style.borderColor = menuhighlightbd;
  }
  else
  {
    elem.style.color = menuforeground;
    elem.style.backgroundColor = menubackground;
    elem.style.borderColor = menuborder;
  }
}

function setupMenu(loggedin)
{
	productmenu = new CHeaderMenu("productmenu",2,0);
	productmenu.addItem("FlowDesigner7 - CFD tool", "onProduct(1)");
	productmenu.addItem("- FD7 Instruction", "onProduct(2)");
	productmenu.addItem("- FD7 Gallery", "onProduct(3)");
	productmenu.addItem("- FD7 Animation", "onProduct(4)");
	productmenu.addItem("- FD7 Consultation", "onProduct(5)");
	productmenu.addItem("- Unit conversion for FD", "onProduct(7)");
	productmenu.addItem("- FAQ for FD (registration required)", "onProduct(8)");
	productmenu.addItem("Optical measurement tools", "onProduct(9)");
	productmenu.addItem("Humidity control products", "onProduct(10)");
	productmenu.addItem("Free Tools", "onProduct(11)");
	productmenu.addItem("MC FAN - Blood flow visualizer", "onProduct(12)");
	productmenu.build();
	
	servicemenu = new CHeaderMenu("servicemenu", 2,0);
	servicemenu.addItem("Analysis Service", "onService(1)");
	servicemenu.addItem("Consulting", "onService(2)");
	servicemenu.addItem("Software Development", "onService(3)");
	servicemenu.build();
		
	supportmenu = new CHeaderMenu("supportmenu", 2,0);
//	supportmenu.addItem("Download", "onSupport(3)");
//	supportmenu.addItem("Install Guide", "onSupport(6)");
	supportmenu.addItem("Contact", "onSupport(1)");
	supportmenu.addItem("FD Users only", "onSupport(2)");
//	supportmenu.addItem("FD User Forum", "onSupport(3)");
//	supportmenu.addItem("Technical Info", "onSupport(5)");

	if (loggedin == true)
	{
	  supportmenu.addItem("User Page", "onSupport(10)");
	}
	supportmenu.build();
		
	profilemenu = new CHeaderMenu("profilemenu", 2,0);
	profilemenu.addItem("About MI Research, Inc.", "onProfile(1)");
//	profilemenu.addItem("Corporate Profile", "onProfile(3)");
//	profilemenu.addItem("é¬¯E®ãƒ»E«ç¹ï½»ãƒ»E°é««E´èŽ¨å¤²E½E½ãƒ»E¦éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E½éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E¡é¬¯E¯ãƒ»E¨ç¹ï½»ãƒ»E¾é«¯å…·E½E¹éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E½ç¹ï½»ãƒ»E½éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E¨é¬¯E®ãƒ»E«ç¹ï½»ãƒ»E²éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E°é¬©å¹¢E½E¢éš´è¶£E½E¢ç¹ï½»ãƒ»E½ç¹ï½»ãƒ»E»é©›ï½¢è­Žï½¢ãƒ»E½ãƒ»E»éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E°é©›ï½¢è­Žï½¢ãƒ»E½ãƒ»E»éƒ¢æ™¢E½E»ç¹ï½»ãƒ»E±", "onProfile(3)");
	profilemenu.addItem("Map", "onProfile(2)");
	profilemenu.addItem("MI People", "onProfile(3)");
	profilemenu.build();

	languagemenu = new CHeaderMenu("languagemenu",2,0);
	languagemenu.addItem("English","onLanguage(1)");
	languagemenu.addItem("Japanese","onLanguage(2)");
	languagemenu.build();
}

function setupMenuJ(loggedin)
{
	productmenuJ = new CHeaderMenu("productmenuJ",2,0);
	productmenuJ.addItem("ƒtƒ[ƒfƒUƒCƒi[", "onProductJ(1)");
	productmenuJ.addItem("MC FAN", "onProductJ(2)");
	productmenuJ.build();

	servicemenuJ = new CHeaderMenu("servicemenuJ", 2,0);
	servicemenuJ.addItem("‰ðÍƒT[ƒrƒX", "onServiceJ(1)");
	servicemenuJ.addItem("ƒRƒ“ƒTƒ‹ƒeƒBƒ“ƒO", "onServiceJ(2)");
	servicemenuJ.addItem("ƒ\ƒtƒgŠJ”­", "onServiceJ(3)");
	servicemenuJ.build();
		
	supportmenuJ = new CHeaderMenu("supportmenuJ", 2,0);
	supportmenuJ.addItem("ƒRƒ“ƒ^ƒNƒg", "onSupportJ(1)");
	supportmenuJ.addItem("FDƒ†[ƒU[ê—p", "onSupportJ(2)");

	if (loggedin == true)
	{
	  supportmenuJ.addItem("ƒ†[ƒU[ƒy[ƒW", "onSupportJ(10)");
	}
	supportmenuJ.build();
		
	profilemenuJ = new CHeaderMenu("profilemenuJ", 2,0);
	profilemenuJ.addItem("MIƒŠƒT[ƒ`‚É‚Â‚¢‚Ä", "onProfileJ(1)");
	profilemenuJ.addItem("’n}", "onProfileJ(2)");
	profilemenuJ.addItem("MI‚ÌƒXƒ^ƒbƒt", "onProfileJ(3)");
	profilemenuJ.build();
		
	languagemenu = new CHeaderMenu("languagemenu",2,0);
	languagemenu.addItem("English","onLanguage(1)");
	languagemenu.addItem("“ú–{Œê","onLanguage(2)");
	languagemenu.build();
}

function urlreplace(url)
{
  document.location.replace(baseurl+url);
}
