///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// ドロップダウンメニュー表示スクリプト
//
// 2006/6/13 ベータ版作成
// 2006/6/16 Ver1.0作成
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

//ブラウザチェック
var ua = navigator.userAgent;
var isWinIE = ua.match(/MSIE/) && !ua.match(/Mac/i) && !ua.match(/Opera/i);
var isMacIE = ua.match(/MSIE/) && ua.match(/Mac/i) && !ua.match(/Opera/i);
var isNonIE = !ua.match(/MSIE/) && !ua.match(/Mac/i) && !ua.match(/Opera/i);
//NN6.xをチェック
var isNNver = '';
if(navigator.userAgent.indexOf("Netscape6") != -1){
	isNNver = true;
}
//IE7.xをチェック
var isIEver = '';
if(navigator.userAgent.indexOf("MSIE 7") != -1){
	isIEver = true;
}

//初期値
var TimerID, OpenMenu;
var DropDownShim = null;
var isOpen = false;

//ロールオーバー時にサブメニューを表示
function DropDown(target, mode, Height, Xposi) {
	isOpen = mode;
	var dl = document.getElementById(target);
	var img = dl.getElementsByTagName("img")[0];
	if(isWinIE && !isIEver){
		var ShimH = Height * 21;//IE5.x-6.x用
	}else{
		var ShimH = Height * 22;
	}
	if(mode==true) {
		if ( target == OpenMenu ) {
			clearTimeout(TimerID);
		} else {
			DropDownOff(OpenMenu);
		}
		dl.style.overflow='visible';
		//メニューの背後にIFRAMEを表示→SELECTと重なった時の対策。（IEのみ）
		if (isWinIE){
			if( !DropDownShim ) {
				DropDownShim = document.createElement('<iframe src="/dummy.html" scrolling="no" frameborder="0" id="DropDownShim"></iframe>');
				document.getElementById("menunavi").appendChild(DropDownShim);
			}
			DropDownShim.style.height    = ShimH + 'px';
			//DropDownShim.style.left    = dl.getBoundingClientRect().left-2 + 'px';
			DropDownShim.style.left      = Xposi + 'px';
			if(target == 'menu10'){DropDownShim.style.left = Xposi-84 + 'px';}
			if(ShimH > 0){//サブメニューがあればIFRAMEを表示
				DropDownShim.style.display   = "block";
			}
		}
	} else {
		TimerID = setTimeout("DropDownOff('"+target+"');", 10);
		OpenMenu = target;
	}
}
//サブメニューをOFFにする
function DropDownOff(target) {
	if( ! document.getElementById ) {
		return;
	}
	var dl = document.getElementById(target);
	if( !dl ) {
		return;
	}
	if (isWinIE){
		if(!isOpen){
		DropDownShim.style.display = "none";
		}
	}
	dl.style.overflow='hidden';
}

//メニューのリンク先・表示画像・サブメニューのリスト
//サブメニューは随時追加削除可能。
var menu = {

	'menu1':{
	'link':'/index.html',
	'src':'/image/common/menu_home.gif',
	'alt':'Home',
	'id':'mn1',
	'width':49,
	'targetWin':'_top',
	'sub':'' //サブメニューがない場合はこのように記述
	},
	'menu2':{
	'link':'/ap/store/index.html',
	'src':'/image/common/menu_sp.gif',
	'alt':'店舗情報',
	'id':'mn2',
	'width':62,
	'targetWin':'_top',
	'sub':[
		{'txt':'都道府県別店舗一覧','link':'/ap/store/all.html'},
		{'txt':'催し物のご案内','link':'/ap/store/event/index.html'}
		]
	},
	'menu3':{
	'link':'/pickup/index.html',
	'src':'/image/common/menu_pk.gif',
	'alt':'おすすめ情報',
	'id':'mn3',
	'width':86,
	'targetWin':'_top',
	'sub':[
		{'txt':'おすすめフロア','link':'/pickup/index.html'},
//		{'txt':'ファッションのフロアの新商品','link':'/newitem/fashion.html'},
		{'txt':'暮らしのフロアの新商品','link':'/newitem/life.html'},
		{'txt':'食品のフロアの新商品','link':'/newitem/food.html'}//,
		]
	},
	'menu4':{
	'link':'/fashion/index.html',
	'src':'/image/common/menu_fs.gif',
	'alt':'ファッション',
	'id':'mn4',
	'width':78,
	'targetWin':'_top',
	'sub':[
		{'txt':'シーズン商品','link':'/fashion/season/index.html'},
		{'txt':'オリジナルブランド','link':'/fashion/brand/index.html'},
		{'txt':'エコリボン','link':'/fashion/eco/index.html'},
		{'txt':'年間商品','link':'/fashion/annual/index.html'},
		{'txt':'オーダー商品','link':'/fashion/order/index.html'}//,
//		{'txt':'キャンペーン情報','link':'/fashion/campaign/index.html'},
//		{'txt':'レディスウェア','link':'/fashion/ladies/index.html'},
//		{'txt':'メンズウェア','link':'/fashion/mens/index.html'},
//		{'txt':'ベビー&キッズウェア','link':'/fashion/baby_kids/index.html'},
//		{'txt':'バレンタインデー','link':'/fashion/valentine/index.html'},
//		{'txt':'靴','link':'/fashion/shoes/index.html'},
//		{'txt':'バッグ・アクセサリー','link':'/fashion/acc/index.html'},
//		{'txt':'トラベル','link':'/fashion/travel/index.html'},
//		{'txt':'ゆかた','link':'/fashion/yukata/index.html'},
//		{'txt':'レイングッズ','link':'/fashion/raingoods/index.html'},
//		{'txt':'福袋','link':'/fashion/season/fukubukuro/index.html'}
		]
	},
	'menu5':{
	'link':'/life/index.html',
	'src':'/image/common/menu_lf.gif',
	'alt':'暮らし',
	'id':'mn5',
	'width':48,
	'targetWin':'_top',
	'sub':[
//		{'txt':'シーズン商品','link':'/life/season/index.html'},
		{'txt':'セブン＆アイ限定商品','link':'/life/sioriginal/index.html'},
		{'txt':'イトーヨーカドー限定商品','link':'/life/iyoriginal/index.html'},
//		{'txt':'オーダー商品','link':'/life/order/index.html'},
//		{'txt':'家電','link':'/life/electronics/index.html'},
//		{'txt':'インテリア','link':'/life/interior/index.html'},
//		{'txt':'玩具','link':'/life/toy/index.html'},
//		{'txt':'介護用品','link':'/life/care/index.html'},
		{'txt':'家庭用品','link':'/life/household/index.html'},
//		{'txt':'コスメ','link':'/life/cosme/index.html'},
//		{'txt':'防災用品','link':'/life/disaster/index.html'},
		{'txt':'寝具','link':'/life/bedding/index.html'},
		{'txt':'ペット用品','link':'/life/pet/index.html'},
		{'txt':'売り場のご案内','link':'/life/floorinfo/index.html'},
		{'txt':'キャンペーン情報','link':'/life/campaign/index.html'}
		]
	},
	'menu6':{
	'link':'/food/index.html',
	'src':'/image/common/menu_fd.gif',
	'alt':'食品',
	'id':'mn6',
	'width':39,
	'targetWin':'_top',
	'sub':[
		{'txt':'セブン＆アイ限定商品','link':'/food/sioriginal/index.html'},
		{'txt':'イトーヨーカドー限定商品','link':'/food/iyoriginal/index.html'},
		{'txt':'年間商品','link':'/food/annual/index.html'},
		{'txt':'シーズン商品','link':'/food/season/index.html'},
//		{'txt':'お酒','link':'/food/alcohol/index.html'},
		{'txt':'売り場のご案内','link':'/food/floorinfo/index.html'},
		{'txt':'商品のご案内','link':'/food/iteminfo/index.html'},
//		{'txt':'キャンペーン情報','link':'/food/campaign/index.html'},
//		{'txt':'売出し情報','link':'/food/sales/index.html'},
		{'txt':'Weekly レシピ','link':'/ap/food/recipe/'}
		]
	},
	'menu7':{
	'link':'/support/index.html',
	'src':'/image/common/menu_sv.gif',
	'alt':'お客様へのサービス',
	'id':'mn7',
	'width':119,
	'targetWin':'_top',
	'sub':[
		{'txt':'お買い物サポート','link':'/support/shopping.html'},
		{'txt':'お母さんを応援します','link':'/support/mama.html'},
		{'txt':'エコロジー','link':'/support/ecology.html'},
		{'txt':'バリアフリー','link':'/support/bfree.html'},
		{'txt':'施設のご紹介','link':'/support/institution.html'},
		{'txt':'お得なサービス','link':'/support/service.html'},
		{'txt':'くらしのマメ知識 ','link':'/support/useful/index.html'}
		]
	},
	'menu8':{
	'link':'http://www.itoyokado.jp',
	'src':'/image/common/menu_net.gif',
	'alt':'ネットショッピング',
	'id':'mn8',
	'width':112,
	'targetWin':'_blank',
	'sub':''
	},
	'menu9':{
	'link':'/company/news/index.html',
	'src':'/image/common/menu_news.gif',
	'alt':'ニュースリリース',
	'id':'mn9',
	'width':96,
	'targetWin':'_top',
	'sub':[
		{'txt':'最新のリリース','link':'/company/news/new/index.html'},
		{'txt':'開店のお知らせ','link':'/company/news/open/index.html'},
		{'txt':'人事異動のお知らせ','link':'/company/news/psnl/index.html'},
		{'txt':'イベント・その他のお知らせ','link':'/company/news/spcl/index.html'}
		]
	},
	'menu10':{
	'link':'/company/profile/index.html',
	'src':'/image/common/menu_co.gif',
	'alt':'会社情報',
	'id':'mn10',
	'width':64,
	'targetWin':'_top',
	'sub':[
		{'txt':'ごあいさつ','link':'/company/profile/president/index.html'},
		{'txt':'会社概要','link':'/company/profile/summary/index.html'},
		{'txt':'採用情報','link':'/company/job/index.html'},
		{'txt':'社会的責任CSR','link':'/company/profile/csr/activity.html'},
		{'txt':'お取引先募集','link':'/company/mij/index.html'},
		{'txt':'セブン＆アイHLDGS.のご紹介','link':'http://www.7andi.com/'}
		]
	} //最後の閉じ}には,をつけないこと
}

function mm(nowpage){
	//初期値
	var o='';
	var nowPosi='0px'; //ロールアウト時の初期値
	var dfPosi =''; //デフォルトでハイライトされるメニューのposition設定
	var nowPage = nowpage; //デフォルトでハイライトされるメニューのID
	var bgDrop = '0';//サブメニュー段数の初期値
	var Xposi = 27;//メニューの初期位置

	o+='<img src="/image/common/menu_spcr.gif" width="27" style="position:absolute;top:0px;left:0px;">';
	for(i in menu){

		bgDrop = menu[i].sub.length;//サブメニュー段数を取得

		//選択されたメニューをデフォルトでハイライトさせる設定
		if(i == nowPage){nowPosi = "-24px";dfPosi="background-position:0px -24px"}else{nowPosi = "0px";dfPosi="";}

		//MacIEまたはNN6.xの場合は、サブメニューを出さない
		if(isMacIE){
			o+='<a href="'+menu[i].link+'" id="'+i+'" target="'+menu[i].targetWin+'" style="left:'+Xposi+';background-image:url('+menu[i].src+');'+dfPosi+';width:'+menu[i].width+'px;float:left;"><img src="/image/common/spacer.gif" alt="'+menu[i].alt+'" height="23" border="0" id="'+menu[i].id+'" name="'+menu[i].id+'");")"></a>';
		}
		if(isNNver){
			o+='<dl id="'+i+'" style="left:'+Xposi+'px;background-image:url('+menu[i].src+');'+dfPosi+';width:'+menu[i].width+'px;" >';
			//メニューボタン用透明GIFを出力
			o+='<dt><a href="'+menu[i].link+'" id="'+menu[i].id+'" target="'+menu[i].targetWin+'"><img src="/image/common/spacer.gif" alt="'+menu[i].alt+'" width="'+menu[i].width+'" border="0"></a></dt>';
			o+='</dl>';
		}
		//IE以外のブラウザでは、ロールオーバーのスクリプトを埋め込まない
		if(isNonIE){
			o+='<dl id="'+i+'" onMouseOver="DropDown(\''+i+'\',true,'+bgDrop+','+Xposi+');" onMouseOut="DropDown(\''+i+'\',false,'+bgDrop+','+Xposi+');" style="left:'+Xposi+'px;background-image:url('+menu[i].src+');'+dfPosi+';width:'+menu[i].width+'px;" >';
			//メニューボタン用透明GIFを出力
			o+='<dt><a href="'+menu[i].link+'" id="'+menu[i].id+'" target="'+menu[i].targetWin+'"><img src="/image/common/spacer.gif" alt="'+menu[i].alt+'" width="'+menu[i].width+'" border="0"></a></dt>';
			//サブメニューを出力
			for(j=0; j<menu[i].sub.length; j++) {
				o+='<dd><a href="'+menu[i].sub[j].link+'">'+menu[i].sub[j].txt+'</a></dd>';
			}
			o+='</dl>';
		}
		else{
		//WinIEの場合
			o+='<dl id="'+i+'" onMouseOver="DropDown(\''+i+'\',true,'+bgDrop+','+Xposi+');BgPosi(\''+i+'\',\'-24px\')" onMouseOut="DropDown(\''+i+'\',false,'+bgDrop+','+Xposi+');BgPosi(\''+i+'\',\''+nowPosi+'\')" style="left:'+Xposi+'px;background-image:url('+menu[i].src+');background-position:0px '+nowPosi+';width:'+menu[i].width+'px;" >';
			//メニューボタン用透明GIFを出力
			o+='<dt><a href="'+menu[i].link+'" id="'+menu[i].id+'" target="'+menu[i].targetWin+'"><img src="/image/common/spacer.gif" alt="'+menu[i].alt+'" width="'+menu[i].width+'" border="0"></a></dt>';
			//サブメニューを出力
			for(j=0; j<menu[i].sub.length; j++) {
				o+='<dd><a href="'+menu[i].sub[j].link+'">'+menu[i].sub[j].txt+'</a></dd>';
			}
			o+='</dl>';
		}

		Xposi = Xposi + menu[i].width;//メニューの表示位置を算出

	}
	//alert(o);

	document.getElementById('menunavi').innerHTML=o;
}

//IEでは:hoverによるロールオーバーに不具合があったので、scriptで背景のpositionを操作する
function BgPosi(ID,Point){
	document.getElementById(ID).style.backgroundPositionY = Point;
}

