var myurl = location.href;
var ua = navigator.userAgent;
var path = "./";


function asdf(t) {
	if(t != undefined) alert(t);
	else alert("asdf");
}

if(tree == 0) {
	path = "./";
}else if(tree == 1) {
	path = "../";
}

//_________________________________________________________
//                                           ロールオーバー
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];}
}
//_____________________________________________________
//                                     画像のプリロード
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 setProductsTopList() {
	if(myurl.match("/products/")) {
		$("#topindex>li:odd").css({"margin-left":"48px"});
	}
}

/*
var time = 11;
function readyCountdown(u) {
	if(time <= 0) location.href=u;
	else time--;
	$("#readytime").html(time);
	setTimeout(function() { readyCountdown(u)} , 1000);
}
*/


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openMap() {
	MM_openBrWindow('map.html','map','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=600')
}


//                   スパメニュー

function writeSpaNavi() {
	var res = "";
	var btn_ary = new Array();
	for(var i=1;i<=8;i++) {
		btn_ary[i] = "_off";
	}
	
	if(myurl.match("concept.html")) btn_ary[1] = "_on";
	if(myurl.match("flow.html")) btn_ary[2] = "_on";
	if(myurl.match("body.html")) btn_ary[3] = "_on";
	if(myurl.match("skin.html")) btn_ary[4] = "_on";
	if(myurl.match("optional.html")) btn_ary[5] = "_on";
	if(myurl.match("info.html")) btn_ary[6] = "_on";
	if(myurl.match("contact.html")) btn_ary[7] = "_on";
	if(myurl.match("package.html")) btn_ary[8] = "_on";
	
	res += '<ul>';
		res += '<li id="spali0"><a href="./index.html"><img src="./images/btn0.gif" /></a></li>';
		res += '<li id="spali1"><a href="./concept.html" id="spa1"><img src="./images/btn1'+btn_ary[1]+'.gif" id="spabtn1" /></a></li>';
		res += '<li id="spali2"><a href="./flow.html" id="spa2"><img src="./images/btn2'+btn_ary[2]+'.gif" id="spabtn2" /></a></li>';
		res += '<li id="spali3"><a href="./body.html" id="spa3"><img src="./images/btn3'+btn_ary[3]+'.gif" id="spabtn3" /></a></li>';
		res += '<li id="spali4"><a href="./skin.html" id="spa4"><img src="./images/btn4'+btn_ary[4]+'.gif" id="spabtn4" /></a></li>';
		res += '<li id="spali5"><a href="./optional.html" id="spa5"><img src="./images/btn5'+btn_ary[5]+'.gif" id="spabtn5" /></a></li>';
		res += '<li id="spali8"><a href="./package.html" id="spa8"><img src="./images/btn8'+btn_ary[8]+'.gif" id="spabtn8" /></a></li>';
		res += '<li id="spali6"><a href="./info.html" id="spa6"><img src="./images/btn6'+btn_ary[6]+'.gif" id="spabtn6" /></a></li>';
		res += '<li id="spali7"><a href="./contact.html" id="spa7"><img src="./images/btn7'+btn_ary[7]+'.gif" id="spabtn7" /></a></li>';
	res += '</ul>';
	
	$("#spa_menu").html(res);
	
	$("#spa1").mouseover(function() { MM_swapImage("spabtn1", "", "./images/btn1_on.gif", 1); });
	$("#spa2").mouseover(function() { MM_swapImage("spabtn2", "", "./images/btn2_on.gif", 1); });
	$("#spa3").mouseover(function() { MM_swapImage("spabtn3", "", "./images/btn3_on.gif", 1); });
	$("#spa4").mouseover(function() { MM_swapImage("spabtn4", "", "./images/btn4_on.gif", 1); });
	$("#spa5").mouseover(function() { MM_swapImage("spabtn5", "", "./images/btn5_on.gif", 1); });
	$("#spa6").mouseover(function() { MM_swapImage("spabtn6", "", "./images/btn6_on.gif", 1); });
	$("#spa7").mouseover(function() { MM_swapImage("spabtn7", "", "./images/btn7_on.gif", 1); });
	$("#spa8").mouseover(function() { MM_swapImage("spabtn8", "", "./images/btn8_on.gif", 1); });
	$("#spa1").mouseout(function() { MM_swapImgRestore(); });
	$("#spa2").mouseout(function() { MM_swapImgRestore(); });
	$("#spa3").mouseout(function() { MM_swapImgRestore(); });
	$("#spa4").mouseout(function() { MM_swapImgRestore(); });
	$("#spa5").mouseout(function() { MM_swapImgRestore(); });
	$("#spa6").mouseout(function() { MM_swapImgRestore(); });
	$("#spa7").mouseout(function() { MM_swapImgRestore(); });
	$("#spa8").mouseout(function() { MM_swapImgRestore(); });
}



//                         スクール　サイドナビ
function writeSchoolNavi() {
	res = '';
	res += '<div id="sch_menu">';
		res += '<h4><a href="./index.html"><img src="./images/logo.gif" /></h4>';
		res += '<p><img src="./images/logo_text.gif" /></p>';
		res += '<ul>';
			res += '<li id="sc_btn1li"><a href="./inst.html" id="sc_btn1id"><img src="./images/btn1.gif" alt="学校紹介" name="sc_btn1img" width="59" height="12" id="sc_btn1img" /></a></li>';
			res += '<li id="sc_btn2li"><a href="./corse.html" id="sc_btn2id"><img src="./images/btn2.gif" alt="コース体系・講座内容" name="sc_btn2img" width="139" height="12" id="sc_btn2img" /></a></li>';
			res += '<li id="sc_btn3li"><a href="instructor.html" id="sc_btn3id"><img src="./images/btn3.gif" alt="講師紹介" name="sc_btn3img" width="59" height="13" id="sc_btn3img" /></a></li>';
			res += '<li id="sc_btn4li"><a href="./entry.html" id="sc_btn4id"><img src="./images/btn4.gif" alt="お申し込み方法" name="sc_btn4img" width="99" height="13" id="sc_btn4img" /></a></li>';
			res += '<li id="sc_btn5li"><a href="./access.html" id="sc_btn5id"><img src="./images/btn5.gif" alt="アクセス" name="sc_btn5img" width="52" height="11" id="sc_btn5img" /></a></li> ';
		res += '</ul>';
	res += '</div>';
	res += '<div id="sch_banners">';
		res += '<a href="./index2.html"><img src="./images/banner_school.gif" alt="スクール体験会お申し込み受付中!" width="213" height="113" border="0" /></a>';
		res += '<a href="./corse_primary.html#c3"><img src="./images/banner_ifpa.gif" alt="IFPA" width="213" height="113" border="0" /></a>';
		res += '<img src="./images/banner_salon.gif" alt="" width="213" height="113" border="0" />';
		res += '<a href="#"><img src="./images/banner_tel.gif" alt="お電話でのお問い合わせ" width="213" height="88" border="0" /></a>';
		res += '<a href="./contact.html"><img src="./images/banner_contact.gif" alt="資料請求・お問い合わせ" width="213" height="53" border="0" /></a>';
		//res += '<div id="banner_fla"></div>';
		res += '<a href="http://therapynetcollege.com/ch/011.html" target="_blank"><img src="./images/banner_tncc.gif" alt="" border="0" /></a>';
		//res += '<a href="http://ameblo.jp/ifpajapan/" target="_blank"><img src="./images/banner_ifpa2.gif" alt="" width="200" height="48" border="0" /></a>';
	res += '</div>';
	
	$("#sch_secondary").html(res);
	setSwf("./swf/623-mbtn.swf", "mbtn", "8", "#ffffff", "banner_fla", "200", "100");
	
	if(myurl.match("inst.html")) { $("#sc_btn1li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"}) };
	$("#sc_btn1id").mouseover(function() { if(!myurl.match("inst.html")) $("#sc_btn1li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"})});
	$("#sc_btn1id").mouseout(function() { if(!myurl.match("inst.html")) $("#sc_btn1li").css({"background":"url(../school/images/btn_bg_off.gif) left top no-repeat"})});
	
	if(myurl.match("corse")) { $("#sc_btn2li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"}) };
	$("#sc_btn2id").mouseover(function() { if(!myurl.match("corse")) $("#sc_btn2li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"})});
	$("#sc_btn2id").mouseout(function() { if(!myurl.match("corse")) $("#sc_btn2li").css({"background":"url(../school/images/btn_bg_off.gif) left top no-repeat"})});
	
	if(myurl.match("instructor")) { $("#sc_btn3li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"}) };
	$("#sc_btn3id").mouseover(function() { if(!myurl.match("instructor")) $("#sc_btn3li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"})});
	$("#sc_btn3id").mouseout(function() { if(!myurl.match("instructor")) $("#sc_btn3li").css({"background":"url(../school/images/btn_bg_off.gif) left top no-repeat"})});
	
	if(myurl.match("entry")) { $("#sc_btn4li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"}) };
	$("#sc_btn4id").mouseover(function() { if(!myurl.match("entry")) $("#sc_btn4li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"})});
	$("#sc_btn4id").mouseout(function() { if(!myurl.match("entry")) $("#sc_btn4li").css({"background":"url(../school/images/btn_bg_off.gif) left top no-repeat"})});

	if(myurl.match("access")) { $("#sc_btn5li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"}) };
	$("#sc_btn5id").mouseover(function() { if(!myurl.match("access")) $("#sc_btn5li").css({"background":"url(../school/images/btn_bg_on.gif) left top no-repeat"})});
	$("#sc_btn5id").mouseout(function() { if(!myurl.match("access")) $("#sc_btn5li").css({"background":"url(../school/images/btn_bg_off.gif) left top no-repeat"})});
	
	setSchoolLink();
	
	if(myurl.match("corse_primary")) {
		$(".sch_primary_tests tr:even td").css({"background":"#e4e4e4"});
		$(".sch_primary_cost tr:even td").css({"background":"#e4e4e4"});
	}
}

function setSchoolLink() {
	
	$("#sch_primary1id").mouseover(function() { MM_swapImage("sch_primary1img", "", "./images/corse_primary_btn1_on.gif", 1); });
	$("#sch_primary2id").mouseover(function() { MM_swapImage("sch_primary2img", "", "./images/corse_primary_btn2_on.gif", 1); });
	$("#sch_primary3id").mouseover(function() { MM_swapImage("sch_primary3img", "", "./images/corse_primary_btn3_on.gif", 1); });
	$("#sch_primary1id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_primary2id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_primary3id").mouseout(function() { MM_swapImgRestore(); });
	
	$("#sch_second1id").mouseover(function() { MM_swapImage("sch_second1img", "", "./images/corse_second_btn1_on.gif", 1); });
	$("#sch_second2id").mouseover(function() { MM_swapImage("sch_second2img", "", "./images/corse_second_btn2_on.gif", 1); });
	$("#sch_second3id").mouseover(function() { MM_swapImage("sch_second3img", "", "./images/corse_second_btn3_on.gif", 1); });
	$("#sch_second4id").mouseover(function() { MM_swapImage("sch_second4img", "", "./images/corse_second_btn4_on.gif", 1); });
	$("#sch_second5id").mouseover(function() { MM_swapImage("sch_second5img", "", "./images/corse_second_btn5_on.gif", 1); });
	$("#sch_second6id").mouseover(function() { MM_swapImage("sch_second6img", "", "./images/corse_second_btn6_on.gif", 1); });
	$("#sch_second7id").mouseover(function() { MM_swapImage("sch_second7img", "", "./images/corse_second_btn7_on.gif", 1); });
	$("#sch_second1id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_second2id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_second3id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_second4id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_second5id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_second6id").mouseout(function() { MM_swapImgRestore(); });
	$("#sch_second7id").mouseout(function() { MM_swapImgRestore(); });
	
}


//                     メニューの書き出し
function writeTemplate() {
	writeSubNavi();
	writefooter();
	if(tree != 0) {
		writeNavi();
		writeExNavi();
		
		setProductsTopList();
	}
	
	if(myurl.match("/spa/")) {
		writeSpaNavi();
	}
	if(myurl.match("/school/")) {
		writeSchoolNavi();
	}
}


function writeNavi() {
	var page;
	if(myurl.match("concept1.html")) page = 0;
	if(myurl.match("concept2.html")) page = 1;
	if(myurl.match("/products/")) page = 2;
	if(myurl.match("/spa/")) page = 3;
	if(myurl.match("/school/")) page = 4;
	
	setMenu("../swf/menu.swf", "menu", "7", "#ffffff", "navi", "900", "95", page);
	/*
	var res = "";
	var btn_ary = new Array();
	for(var i=1;i<=6;i++) {
		btn_ary[i] = "_off";
	}
	if(myurl.match("concept1.html")) btn_ary[1] = "_on";
	if(myurl.match("concept2.html")) btn_ary[2] = "_on";
	if(myurl.match("/products/")) btn_ary[3] = "_on";
	if(myurl.match("/spa/")) btn_ary[4] = "_on";
	if(myurl.match("/school/")) btn_ary[5] = "_on";
	
	res += '<h1><a href="../"><img src="../common/logo.gif" alt="Fragrant Earth" width="113" height="95" /></a></h1>';
	res += '<ul>';
		res += '<li><a href="../" id="nav1"><img src="'+path+'common/main_btn1_off.gif" width="93" height="95" id="navbtn1" /></a></li>';
		res += '<li><a href="../concept/concept1.html" id="nav2"><img src="'+path+'common/main_btn2'+btn_ary[1]+'.gif" width="127" height="95" id="navbtn2" /></a></li>';
		res += '<li><a href="../concept/concept2.html" id="nav3"><img src="'+path+'common/main_btn3'+btn_ary[2]+'.gif" width="128" height="95" id="navbtn3" /></a></li>';
		res += '<li><a href="../products/index.html" id="nav4"><img src="'+path+'common/main_btn4'+btn_ary[3]+'.gif" width="92" height="95" id="navbtn4" /></a></li>';
		res += '<li><a href="../spa/index.html" id="nav5"><img src="'+path+'common/main_btn5'+btn_ary[4]+'.gif" width="93" height="95" id="navbtn5" /></a></li>';
		res += '<li><a href="../school/index.html" target="_blank" id="nav6"><img src="'+path+'common/main_btn6'+btn_ary[5]+'.gif" width="94" height="95" id="navbtn6" /></a></li>';
	res += '</ul>';
	res += '<div class="clear">&nbsp;</div>';
	$("#navi").html(res);
	
	$("#nav1").mouseover(function() { MM_swapImage("navbtn1", "", path + "common/main_btn1_on.gif", 1); });
	$("#nav2").mouseover(function() { MM_swapImage("navbtn2", "", path + "common/main_btn2_on.gif", 2); });
	$("#nav3").mouseover(function() { MM_swapImage("navbtn3", "", path + "common/main_btn3_on.gif", 3); });
	$("#nav4").mouseover(function() { MM_swapImage("navbtn4", "", path + "common/main_btn4_on.gif", 4); });
	$("#nav5").mouseover(function() { MM_swapImage("navbtn5", "", path + "common/main_btn5_on.gif", 5); });
	$("#nav6").mouseover(function() { MM_swapImage("navbtn6", "", path + "common/main_btn6_on.gif", 6); });
	$("#nav1").mouseout(function() { MM_swapImgRestore(); });
	$("#nav2").mouseout(function() { MM_swapImgRestore(); });
	$("#nav3").mouseout(function() { MM_swapImgRestore(); });
	$("#nav4").mouseout(function() { MM_swapImgRestore(); });
	$("#nav5").mouseout(function() { MM_swapImgRestore(); });
	$("#nav6").mouseout(function() { MM_swapImgRestore(); });
	*/
}

//                     エクストラナビゲーション
function writeExNavi() {
	var res = "";
	res += '<ul>';
		res += '<li><a href="http://fragrantearth-online.jp/" id="ex1" target="_blank"><img src="'+path+'common/ex_btn1_off.gif" id="exbtn1" /></a></li>';
		res += '<li><a href="'+path+'shop/index.html" id="ex2"><img src="'+path+'common/ex_btn2_off.gif" id="exbtn2" /></a></li>';
		res += '<li><a href="'+path+'exchange/index.html" id="ex3"><img src="'+path+'common/ex_btn3_off.gif" id="exbtn3" /></a></li>';
	res += '</ul>';
	res += '<div class="clear">&nbsp;</div>';
	$("#ex").html(res);
	
	$("#ex1").mouseover(function() { MM_swapImage("exbtn1", "", path + "common/ex_btn1_on.gif", 1); });
	$("#ex2").mouseover(function() { MM_swapImage("exbtn2", "", path + "common/ex_btn2_on.gif", 1); });
	$("#ex3").mouseover(function() { MM_swapImage("exbtn3", "", path + "common/ex_btn3_on.gif", 1); });
	$("#ex1").mouseout(function() { MM_swapImgRestore(); });
	$("#ex2").mouseout(function() { MM_swapImgRestore(); });
	$("#ex3").mouseout(function() { MM_swapImgRestore(); });
}

//                     サブナビゲーション
function writeSubNavi() {
	var res = "";
	res += '<ul id="spmenu">';
		res += '<li><a href="'+path+'shop/index.html" id="sp2"><img src="'+path+'common/sp_btn2_off.gif" id="spbtn2" /></a></li><!--';
		res += '--><li><a href="'+path+'exchange/index.html" id="sp3"><img src="'+path+'common/sp_btn3_off.gif" id="spbtn3" /></a></li>';
	res += '</ul>';
	res += '<ul id="banner">';
		res += '<li><a href="http://www.fragrantearth-online.jp/" target="_blank" id="bnr3"><img src="'+path+'common/banner_shop.gif" id="bnrbtn3" /></a></li><!--';
		res += '--><li><a href="http://www.aromatherapeutics.jp/" target="_blank" id="bnr1"><img src="'+path+'common/banner_at.gif" id="bnrbtn1" /></a></li><!--';
		res += '--><li><a href="http://osciem.jp/" target="_blank" id="bnr2"><img src="'+path+'common/banner_oc.gif" id="bnrbtn2" /></a></li>';
	res += '</ul>';
	res += '<div class="clear">&nbsp;</div>';
	
	$("#subnavi").html(res);
	
	//$("#sp1").mouseover(function() { MM_swapImage("spbtn1", "", path + "common/sp_btn1_on.gif", 1); });
	//$("#sp2").mouseover(function() { MM_swapImage("spbtn2", "", path + "common/sp_btn2_on.gif", 1); });
	//$("#sp3").mouseover(function() { MM_swapImage("spbtn3", "", path + "common/sp_btn3_on.gif", 1); });
	//$("#sp1").mouseout(function() { MM_swapImgRestore(); });
	//$("#sp2").mouseout(function() { MM_swapImgRestore(); });
	//$("#sp3").mouseout(function() { MM_swapImgRestore(); });
}

//                    フッタナビゲーション
function writefooter() {
	var res = "";
	res += '<ul>';
		res += '<li><a href="'+path+'data/company.html" id="foot1"><img src="'+path+'common/foot_btn1_off.gif" id="footbtn1" /></a></li><!--';
		res += '--><li><a href="'+path+'data/rule.html" id="foot2"><img src="'+path+'common/foot_btn2_off.gif" id="footbtn2" /></a></li><!--';
		res += '--><li><a href="'+path+'data/privacy.html" id="foot3"><img src="'+path+'common/foot_btn3_off.gif" id="footbtn3" /></a></li><!--';
		res += '--><li><a href="'+path+'data/contact.html" id="foot4"><img src="'+path+'common/foot_btn4_off.gif" id="footbtn4" /></a></li><!--';
		res += '--><li><a href="http://www.fragrantearth.com/" id="foot5" target="_blank"><img src="'+path+'common/foot_btn5_off.gif" id="footbtn5" /></a></li>';
	res += '</ul>';
	$("#footer").html(res);
	
	$("#foot1").mouseover(function() { MM_swapImage("footbtn1", "", path + "common/foot_btn1_on.gif", 1); });
	$("#foot2").mouseover(function() { MM_swapImage("footbtn2", "", path + "common/foot_btn2_on.gif", 1); });
	$("#foot3").mouseover(function() { MM_swapImage("footbtn3", "", path + "common/foot_btn3_on.gif", 1); });
	$("#foot4").mouseover(function() { MM_swapImage("footbtn4", "", path + "common/foot_btn4_on.gif", 1); });
	$("#foot5").mouseover(function() { MM_swapImage("footbtn5", "", path + "common/foot_btn5_on.gif", 1); });
	$("#foot1").mouseout(function() { MM_swapImgRestore(); });
	$("#foot2").mouseout(function() { MM_swapImgRestore(); });
	$("#foot3").mouseout(function() { MM_swapImgRestore(); });
	$("#foot4").mouseout(function() { MM_swapImgRestore(); });
	$("#foot5").mouseout(function() { MM_swapImgRestore(); });
}
	
