// ----------------------------------------------------------
//　機能：一覧画面のtopicPathの表示処理
// ID="topicPath"、"topCategoryName"、"secondCategoryName"、"thirdCategoryName"のinnerHTMLを作成します
// 引数：なし
//
// ----------------------------------------------------------
function displayTopicPath() {
	MovieDetailListBlogic.selectAllParent(this.categoryId,{
    		callback : showTopicPath,
     		errorHandler : decideErrorDisplay
    		});
}
function showTopicPath(categoryList) {

    var topCategoryName          = document.getElementById("topCategoryName");
    var secondCategoryName 	     = document.getElementById("secondCategoryName");
    var thirdCategoryName 		 = document.getElementById("thirdCategoryName");
    topCategoryName.innerHTML    = "";
    secondCategoryName.innerHTML = "";
    thirdCategoryName.innerHTML  = "";

    elementList = new Array();
    elementList.push(topCategoryName);
    elementList.push(secondCategoryName);
    elementList.push(thirdCategoryName);
    
    sideBarList = new Array();
    
    var displayContents = "<li><a href='#' onclick='changeTopPageDisplay()'>トップページ</a><span>&gt;</span></li>";
	if(categoryList != null){
		for (var i = 0; i < categoryList.length-1; i++) {
			var entity                                                = categoryList[i];
			elementList[i].innerHTML                                  = entity.categoryName14;
			elementList[i].attributes.getNamedItem("class").nodeValue = "active";
			sideBarList.push(entity.categoryId);
			displayContents                                          += "<li><a href='#' onclick='changeListDisplay("+entity.categoryId+")'>"+entity.categoryName+"</a><span>&gt;</span></li>";
		}
		var entity       = categoryList[categoryList.length-1];
		displayContents += "<li>"+entity.categoryName+"</li>";
		sideBarList.push(entity.categoryId);
		if(elementList[categoryList.length-1] != null){
			if(categoryList.length == 3){
				elementList[categoryList.length-1].innerHTML = entity.categoryName;
			}else{
				elementList[categoryList.length-1].innerHTML = entity.categoryName14;
			}
			elementList[categoryList.length-1].attributes.getNamedItem("class").nodeValue = "active";
		}
	}
    document.getElementById("topicPath").innerHTML = displayContents;
	// サイドバーのアクティブ化
	openSideBar(sideBarList);
}

//----------------------------------------------------------
// 機能：詳細画面表示時のtopicPathの追加表示処理
// ID="topicPath"、"topCategoryName"、"secondCategoryName"、"thirdCategoryName"のinnerHTMLを作成します
// 引数：なし
//
//----------------------------------------------------------
function displayTopicPathByContentsId() {
	MovieDetailBlogic.selectAllParentByContentsId(this.contentsId,{
		callback : showDetailTopicPath,
 		errorHandler : decideErrorDisplay
		});
}
function showDetailTopicPath(topicList) {
    var topCategoryName          = document.getElementById("topCategoryName");
    var secondCategoryName 	     = document.getElementById("secondCategoryName");
    var thirdCategoryName 		 = document.getElementById("thirdCategoryName");
    topCategoryName.innerHTML    = "";
    secondCategoryName.innerHTML = "";
    thirdCategoryName.innerHTML  = "";

    sideBarList = new Array();
    
    for (var i = 0; i < topicList.length; i++) {
    	switch(i) {
    		case 3:
    			thirdCategoryName.innerHTML                                   = topicList[2].categoryName;
    		    thirdCategoryName.attributes.getNamedItem("class").nodeValue  = "active";
    		    break;
    		case 2:
    			secondCategoryName.innerHTML                                  = topicList[1].categoryName14;
    		    secondCategoryName.attributes.getNamedItem("class").nodeValue = "active";
    		    break;
    		case 1:
    			topCategoryName.innerHTML                                     = topicList[0].categoryName14;
    		    topCategoryName.attributes.getNamedItem("class").nodeValue    = "active";
    			break;
    		default:
    			break;
    	}
    }
	
    var displayContents = "<li><a href='#' onclick='changeTopPageDisplay()'>トップページ</a><span>&gt;</span></li>";
	if(topicList != null){
		for (var i = 0; i < topicList.length-1; i++) {
			displayContents +="<li><a href='#' onclick='decideContentsList("+topicList[i].categoryId+")'>"+topicList[i].categoryName+"</a><span>&gt;</span></li>";
			sideBarList.push(topicList[i].categoryId);
		}
		displayContents += "<li>"+topicList[topicList.length-1].categoryName25+"</li>";
		// URLからコンテンツIdを指定された場合、カテゴリIDを持っていないので取得する
        if(window.parent.categoryId == 0){
        	window.parent.categoryId = topicList[0].categoryId;
        }
    	// サイドバーのアクティブ化
    	openSideBar(sideBarList);
	}
    document.getElementById("topicPath").innerHTML = displayContents;
    
    // 表示項目のラベル名設定・ソート・非表示処理
    displayCategoryDetailLabel(window.parent.categoryId);
}

//----------------------------------------------------------
// 機能：詳細画面表示時のtopicPathの追加表示処理
// ID="topicPath"、"topCategoryName"、"secondCategoryName"、"thirdCategoryName"のinnerHTMLを作成します
// 引数：なし
//
//----------------------------------------------------------
function displayPreviewTopicPath() {
	MovieDetailBlogic.selectAllParentByPreview(this.contentsId,{
		callback : showPreviewDetailTopicPath,
 		errorHandler : decideErrorDisplay
		});
}
function showPreviewDetailTopicPath(topicList) {
    var topCategoryName          = document.getElementById("topCategoryName");
    var secondCategoryName 	     = document.getElementById("secondCategoryName");
    var thirdCategoryName 		 = document.getElementById("thirdCategoryName");
    topCategoryName.innerHTML    = "";
    secondCategoryName.innerHTML = "";
    thirdCategoryName.innerHTML  = "";

    sideBarList = new Array();
    
    for (var i = 0; i < topicList.length; i++) {
    	switch(i) {
    		case 3:
    			thirdCategoryName.innerHTML                                   = topicList[2].categoryName;
    		    thirdCategoryName.attributes.getNamedItem("class").nodeValue  = "active";
    		    break;
    		case 2:
    			secondCategoryName.innerHTML                                  = topicList[1].categoryName14;
    		    secondCategoryName.attributes.getNamedItem("class").nodeValue = "active";
    		    break;
    		case 1:
    			topCategoryName.innerHTML                                     = topicList[0].categoryName14;
    		    topCategoryName.attributes.getNamedItem("class").nodeValue    = "active";
    			break;
    		default:
    			break;
    	}
    }
	
    // １件以上の場合（１件目は必ずコンテンツ情報）
    if(topicList.length >1){
        var displayContents = "<li><a href='#' onclick='changeTopPageDisplay()'>トップページ</a><span>&gt;</span></li>";
    
		for (var i = 0; i < topicList.length-1; i++) {
			displayContents +="<li><a href='#' onclick='decideContentsList("+topicList[i].categoryId+")'>"+topicList[i].categoryName+"</a><span>&gt;</span></li>";
			sideBarList.push(topicList[i].categoryId);
		}
		displayContents += "<li>"+topicList[topicList.length-1].categoryName25+"</li>";

		window.parent.categoryId = topicList[0].categoryId;
        
    	// サイドバーのアクティブ化
    	openSideBar(sideBarList);
    	document.getElementById("topicPath").innerHTML = displayContents;
    }
    
    // 表示項目のラベル名設定・ソート・非表示処理
    displayCategoryPreviewDetailLabel(window.parent.categoryId);
}

