var catlist = ["Home","和装","洋装","ヘア＆メイク","インテリア","その他"];
var urllist = ["index.htm","wasomenu.htm","yosomenu.htm","hairmenu.htm","interiormenu.htm","etcmenu.htm"];
var topiclist = ["春","ヘアスタイルプラス"];//,"あなたの顔でシミュレーション"];//,"スポーツ","Flash版","特定ユーザ"];
var topicurl = ["springmenu.htm","hairplusmenu.htm","face.htm","outdoormenu.htm","flashmenu.htm","usermenu.htm","test01.htm"];
var labellist = ["Home","和装","洋装","ヘア＆メイク","インテリア／エクステリア","その他"]; //for sidenavi
var idlist = ["Home","Waso","Yoso","Hair","Intext","Etc"]; //for sidenavi
var topicidlist = ["Spring","Hairplus"];//,"Face"];//,"Sports","Flash","User"]; //for sidenavi

var catmember = [ ["Home"],
["Waso","Kssweb","Kimono","Furihair","Furisode","Hakama","Yukata","Yukata2","Yukata03","Kssweb/Furi","Kssweb/Hou","Kssweb/Tome","Uchiwa","K753"],
["Yoso","Bridal","Fashion","ubiquitous","Apparel","Apparelhair","Uniform","Mizugi1","Mizugi2","Mizugi3","Socks","Shoes","Muffler","Scarf","mufflerhat","Mystylebd","Walking"],
["Hair","GlassHair","HairGlass","Hairkensaku","Katsura","Hairstyle","Makeup","Makeupsp","Lips","Nailart3","Nailart3/base1","Nailart3/french1","Nailart3/french2","Nailart3/french3","Nailart3/marble1","Nailart3/marble2","Nailart3/motif1","Nailart3/motif2","Nailart3/motif3","Nailart3/pattern1","Nailart3/pattern2"],
["Intext","Interior2","Interior","Kotatu","Kotatu2","Flower","Flowerrot","Beach","Flower/Flower1","Flower/Flower2","Flower/Flower3","Flower/Flower4","Asagao","Tapestry","Garden"],
["Etc","Lunch","Basket","Osechi","Furosiki","Cafe","Uchiwaonly","Petfashion","Dog","Dog2","Decoden"]
];

var topicmember = [
//["Katsura","Osechi","Kotatu"],
//["GlassHair","Makeup","Apparelhair","Furihair"],
[],
[],
["Soccer"],
//["Mizugi3","Yukata2","Kotatu2","Furosiki"],
[],
[]
]

var groupnames = ["Kssweb","Flower","Nailart3"];
var grouplabels = ["振袖・訪問着・留袖","フラワーアレンジメント","ネイルアート"];
var groupurls = ["index.htm","index.htm","index.htm"];

var mutuallist = new Array();
mutuallist[0]  = [
["Kssweb/Furi","振袖","furisode.htm"],
["Kssweb/Hou","訪問着","houmon.htm"],
["Kssweb/Tome","留袖","tomesode.htm"]
]
mutuallist[1]  = [
["Flower/Flower1","プチアレンジ","flower1.htm"],
["Flower/Flower2","ミニブーケ","flower2.htm"],
["Flower/Flower3","ブーケ","flower3.htm"],
["Flower/Flower4","ボックス","flower4.htm"]
]
mutuallist[2]  = [
["Mizugi1","水着","../Mizugi1/index.htm"],
["Mizugi2","水着(その2)","../Mizugi2/index.htm"],
["Mizugi3","水着(その3)","../Mizugi3/index.htm"]
]

mutuallist[3]  = [
["Yukata","浴衣","../Yukata/index.htm"],
["Yukata2","浴衣２","../Yukata2/index.htm"],
["Yukata03","浴衣でデート","../Yukata03/index.htm"]
]

mutuallist[4]  = [
["Lunch","ランチボックス","../Lunch/index.htm"],
["Basket","バスケットランチ","../Basket/index.htm"]
]

function getMyMutualIndex(name){
	count = mutuallist.length;
	for(i=0;i<count;i++){
             count2 = mutuallist[i].length; 
             for(j=0;j<count2;j++){
                     if(mutuallist[i][j][0] == name)
				return i;	
	     }
	}
        return -1;	
}

//alert(getMyMutualIndex("Kssweb/Hou"));

function memberOf(n,name){
	for(j=0;j<catmember[n].length;j++){
		if (name == catmember[n][j])
                        return true;
        }
        return false;
}

function isMenu(id){
	for(i=0;i<idlist.length;i++){
		if (id == idlist[i])
                        return true;
        }
	for(i=0;i<topicidlist.length;i++){
		if (id == topicidlist[i])
                        return true;
        }
        return false;
}

function isMainMenu(id){
	for(i=0;i<idlist.length;i++){
		if (id == idlist[i])
                        return true;
        }
        return false;
}

function getTopiclistIndex(name){
	for(i=0;i<topicidlist.length;i++){
		if (name == topicidlist[i])
                        return i;
        }
        return -1;
}

function memberindex(n,name){
        if(n<0) return -1;
	for(j=0;j<catmember[n].length;j++){
		if (name == catmember[n][j])
                        return j;
        }
        return -1;
}

function getNamefromUrl(url){
 var count = topiclist.length;
        index = -1;
        for(i=0;i<count;i++){
                url2 = topicurl[i]; 
                if(url == url2){
                     index = i;
                     break;
                }       
        }
        if (index >= 0)
                return topiclist[index];
        else 
                return "";
}

function getTopicIndex(name){
    var count = topicmember.length;
	for(i=0;i<count;i++){
                countj = topicmember[i].length; 
		for(j=0;j<countj;j++){
                      if (name == topicmember[i][j])
                               return i;
                }
        }
        return -1;
}

function getGroupIndex(name){
        gcount = groupnames.length;
        pos = name.indexOf("/");
        if(pos > 0){
	     owner = name.substring(0,pos);
             for (i=0;i<gcount;i++){
		if(owner == groupnames[i])
                        return i;
             }
        }
        return -1;
}

var menuflag = isMenu(_title);

var referrer = document.referrer;

ref = referrer.substring(referrer.lastIndexOf("/") + 1,referrer.length);

//var topicname = getNamefromUrl(ref);
var topicname = "";
if(! isMainMenu(_title)){topicname = getNamefromUrl(ref);}



text = "";
text = text + '<div id="toppane">';
text = text + '<div id="logo"><img src="http://210.249.70.213/Simlet/logo/logo.exe?cls=Simlet&ref=' + referrer + '"></div>';
text = text + '<div id="navi">';
text = text + '<table class="navi" id="navi01"><tr>';
document.write(text);

var curindex = -1;
var count = catlist.length;
//alert(count);
for(i=0;i<count;i++){
	var name = catlist[i];
	url = urllist[i];
	text = ""; 	
        if (memberOf(i,_title)){
            if(topicname){
		text = text + '<td class="link" id="curcategory">';
		text = text + '<a class ="link" href="../' + url + '">';
                text = text + name;
		text = text + '</a>';
		text = text + '</td>';
	    }
            else{	
		text = text + '<td class="link" id="curcategory">';
                text = text + name;
		text = text + '</td>';
                curindex = i;
	    } 
	}
        else{
		text = text + '<td class="link">';
                if(menuflag)
		    text = text + '<a class ="link" href="' + url + '">';
                else
		    text = text + '<a class ="link" href="../' + url + '">';
                text = text + name;
		text = text + '</a>';
		text = text + '</td>';
        }
        if (i < count-1) text = text + '<td class="separater">|</td>';
        document.write(text);
}

text = "";
text = text + '</tr></table></div>';
document.write(text);

name = topicname;
if(!name){
     index = getTopicIndex(_title);	
     if (index >0){
	name = topiclist[index];
        ref = topicurl[index];
     }
}

if (!name){
        name = catlist[curindex];
        ref = urllist[curindex];
}

if(menuflag && _title == "Home"){}
else{ 
var homename = catlist[0];
var homeurl = urllist[0];
text = "";
text = text + '<div id="navilevel">';
text = text + '<table id="navilevel"><tr>';
text = text + '<td class="level">';
if(menuflag) text = text + '<a class ="link" href="' + homeurl + '">' + homename + '</a>';
else text = text + '<a class ="link" href="' + '../' + homeurl + '">' + homename + '</a>';
text = text + '</td><td class="arrow">&gt;</td><td class="level">';

if(getTopiclistIndex(_title) >= 0){}
else{
    if(memberindex(curindex,_title) != 0){
	text = text + '<a href="' + '../' + ref + '">' + name + '</a>';
	text = text + '</td><td class="arrow">&gt;</td><td class="level">';
    }
}
gindex = getGroupIndex(_title);
if (gindex >=0){
	gurl = groupurls[gindex];
	gname = grouplabels[gindex];
	text = text + '<a href="' + gurl + '">' + gname + '</a>';
	text = text + '</td><td class="arrow">&gt;</td><td class="level">';
}
text = text + document.title;
text = text + '</td><tr></table></div>';
document.write(text);
document.write('</div>');
}

if(_myface){
text = '<table id="functionmenu">';
text = text + '<tr><td class="separater">|</td>';
text = text + '<td class="link" id="yourface"><a href="#" onclick="setYourFace();return false;">あなたの顔</a></td>';
text = text + '<td class="separater">|</td></tr>';
text = text + '</table>';
document.write(text);
};
	
var myindex = getMyMutualIndex(_title);
if(myindex >=0){
    text = "";
    text = text + '<div class="subnavi" id="subnavi">';
    text = text + '<table class="navi" id="subnavi01">';
    text = text + '<tr><td class="separater">|</td>';
    document.write(text);
    count = mutuallist[myindex].length;
    for(i=0;i<count;i++){
        if(mutuallist[myindex][i][0] == _title) continue;
        label = mutuallist[myindex][i][1];
        url =  mutuallist[myindex][i][2];
        text = "";        
	text = text + '<td class="sublink">';
	text = text + '<a class ="link" href="' + url + '">' + label + '</a>'; 
	text = text + '</td><td class="separater">|</td>';
    	document.write(text);
    }
    text = '</tr></table></div>';
    document.write(text);
}

/*
//document.write('<div id="add"></div>');  
var html = '<div id="add" style="position:absolute">';

html += '<script type="text/javascript">';
html += 'google_ad_client = "pub-9172631009443312";';
html += 'google_ad_width = 120;';
html += 'google_ad_height = 600;';
html += 'google_ad_format = "120x600_as";';
html += 'google_ad_type = "text_image";';
html += 'google_ad_channel ="";';
html += 'google_color_border = "FFFFFF";';
html += 'google_color_bg = "FFFFFF";';
html += 'google_color_link = "0000FF";';
html += 'google_color_text = "000000";';
html += 'google_color_url = "008000";';
html += '</script>';
html += '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

//html += "OK"; 
html += '</div>';

document.write(html);
*/
