/*
 * mainmenu.js という名前だけどメニューに限らず共通で使用できる
 * スクリプトを収録
 */

var isIe = navigator.appName.charAt(0) == "M";
var isMz = !isIe && document.getElementById;

/* document.location.href で指定すると、baseタグの値が反映されないために
 * ここで設定する。
 */

var baseurl = "http://www.akl.co.jp/";

var productmenu;
var servicemenu;
var supportmenu;
var profilemenu;

var menubackground;
var menuforeground;
var menuborder = "#e0e0e0";
var menuhighlightfg = "#ffffff";
var menuhighlightbg = "#a0a0a0";
var menuhighlightbd = "#404040";

// CMenu for toppage menu
function _CTopMenu_showMenu(e)
{
  this.superShowMenu(e);
  if (isMz)
    this.currentMenuElem = e.target;
  else if (isIe)
    this.currentMenuElem = window.event.srcElement;
  this.currentMenuElem.style.borderColor = "#005070";
  this.currentMenuElem.style.backgroundColor = "#ccccff";
  this.currentMenuElem.style.borderWidth = "1px";
  this.currentMenuElem.style.borderStyle = "solid";
  this.currentMenuElem.style.padding = "4px";
}

function _CTopMenu_closeMenu()
{
  this.superCloseMenu();
  if (this.currentMenuElem != null)
  {
    this.currentMenuElem.style.backgroundColor = "transparent";
    this.currentMenuElem.style.borderWidth = "0px";
    this.currentMenuElem.style.padding = "5px";
    this.currentMenuElem = null;
  }
}

function CTopMenu(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 || 0;
  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;
}
CTopMenu.prototype = new CMenu();
CTopMenu.prototype.superShowMenu = CTopMenu.prototype.showMenu;
CTopMenu.prototype.superCloseMenu = CTopMenu.prototype.closeMenu;
CTopMenu.prototype.showMenu = _CTopMenu_showMenu;
CTopMenu.prototype.closeMenu = _CTopMenu_closeMenu;

function goHome()
{
  document.location.href = baseurl;
}

function onProduct(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "products/";
    break;
  case 1:
    document.location.href = baseurl + "products/processx/";
    break;
  case 2:
    document.location.href = baseurl + "products/caddie/";
    break;
  case 3:
    document.location.href = baseurl + "products/claims/";
    break;
  case 4:
    document.location.href = baseurl + "products/fsx/";
    break;
  case 5:
    document.location.href = baseurl + "products/processx/custom1/";
    break;
  case 6:
    document.location.href = baseurl + "products/flowdesigner/";
    break;
  }
}

function onService(idx)
{
  switch (idx)
  {
  case 0:
    document.location.href = baseurl + "solution/";
    break;
  case 1:
    document.location.href = baseurl + "solution/develop/";
    break;
  case 2:
    document.location.href = baseurl + "solution/simulation/";
    break;
  case 3:
    document.location.href = baseurl + "solution/consulting/";
    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/";
    break;
  case 1:
    document.location.href = baseurl + "support/faq/";
    break;
  case 2:
    document.location.href = baseurl + "support/dllist.php";
    break;
  case 3:
    document.location.href = baseurl + "support/inquire.php";
    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/";
    break;
  case 1:
    document.location.href = baseurl + "profile/profile.php";
    break;
  case 2:
    document.location.href = baseurl + "profile/aboutus.php";
    break;
  case 3:
    document.location.href = baseurl + "profile/careers/";
    break;
  case 4:
    document.location.href = baseurl + "profile/access.php";
    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 CTopMenu("productmenu",2,1);
	productmenu.addItem("Flow Designer", "onProduct(6)");
	productmenu.addItem("ProcessX", "onProduct(1)");
//	productmenu.addItem("新規顧客獲得支援版(ProcessX)", "onProduct(5)");
//	productmenu.addItem("CADdie算", "onProduct(2)");
//	productmenu.addItem("InfoClaims2004", "onProduct(3)");
//	productmenu.addItem("FSX", "onProduct(4)");
	productmenu.build();
	
	servicemenu = new CTopMenu("servicemenu", 2,1);
	servicemenu.addItem("ソフトウェア開発", "onService(1)");
	servicemenu.addItem("解析サービス", "onService(2)");
	servicemenu.addItem("コンサルティング", "onService(3)");
//	servicemenu.addItem("ネットワーク構築", "onService(4)");
	servicemenu.addItem("開発事例", "onService(5)");
	servicemenu.build();
	
	supportmenu = new CTopMenu("supportmenu", 2,1);
	supportmenu.addItem("FAQ", "onSupport(1)");
	supportmenu.addItem("ダウンロード", "onSupport(2)");
	supportmenu.addItem("インストールガイド", "onSupport(6)");
	supportmenu.addItem("お問い合わせ", "onSupport(3)");
	supportmenu.addItem("製品購入", "onSupport(4)");
	supportmenu.addItem("技術情報", "onSupport(5)");
	if (loggedin == true)
	{
	  supportmenu.addItem("ユーザーページ", "onSupport(10)");
	}
	supportmenu.build();
	
	profilemenu = new CTopMenu("profilemenu", 2,1);
	profilemenu.addItem("カンパニープロファイル", "onProfile(1)");
	profilemenu.addItem("アドバンスドナレッジ研究所について", "onProfile(2)");
	profilemenu.addItem("採用情報", "onProfile(3)");
//	profilemenu.addItem("所在地・マップ", "onProfile(4)");
	profilemenu.build();
}

function urlreplace(url)
{
  document.location.replace(baseurl+url);
}
