//----------------------------------------------------------
// 機能：画面表示処理の決定処理
// 引数：contentsId コンテンツID
//
//----------------------------------------------------------
function decideTopDisplay(id,previewTopixId,previewContentsId) {
	// 初期化
	this.categoryId = 0;
	this.pageNumber = 0;
	this.pagerFlag  = true;
	
	if(id != null){
		// 詳細画面表示
		this.contentsId = id;
		displayTopicPathByContentsId();
		onDetail();
	}else if(previewContentsId != null){
		// プレビュー詳細画面表示
		this.contentsId = previewContentsId;
		displayPreviewTopicPath();
		onDetail();
	}else{
		// TOPページ表示
		this.topixId = previewTopixId;
		changeTopPageDisplay();
	}
}
//----------------------------------------------------------
// 機能：TOPページ表示処理を呼び出します
// 引数：なし
//
//----------------------------------------------------------
function changeTopPageDisplay() {	
	var elem = document.getElementById("listTop");
	if(elem.className == "active"){
		return;
	}
	// TOPページボタンのactive化処理
	selectCategory1Item(document.getElementById("listTopLink"));
	displayNewContentsList();
	displayLiveBroadcast();
	displayTopixList();
	displayFlash();
	onTopPage();
}
//----------------------------------------------------------
// 機能：ぺージャー処理なしの、コンテンツ一覧表示処理を呼び出します
// 引数：categoryId カテゴリID
//
//----------------------------------------------------------
function changeAllListDisplay(categoryId) {
	if(checkIsNotActive(categoryId)){
		this.categoryId = categoryId;
		this.pageNumber = 1;
		this.pagerFlag  = false;
		displayAllContentsList();
		displayTopicPath();
		onContentsList();
	}
}
//----------------------------------------------------------
// 機能：カテゴリIDを指定後の、コンテンツ一覧表示処理を呼び出します
// 引数：categoryId カテゴリID
//
//----------------------------------------------------------
function changeListDisplay(categoryId) {
	if(checkIsNotActive(categoryId)){
		this.categoryId = categoryId;
		this.pageNumber = 1;
		this.pagerFlag  = true;
		displayContentsFooter(categoryId,1);
		displayContentsList(categoryId,1);
		displayTopicPath();
		onContentsList();
	}
}
//----------------------------------------------------------
// 機能：コンテンツIDを引数にし、詳細画面表示処理を呼び出します
// 引数：categoryId カテゴリID
// 引数：contentsId コンテンツID
// 引数：page       ページ
//
//----------------------------------------------------------
function changeDetailDisplay(categoryId,contentsId,page) {
	this.categoryId = categoryId;
	this.contentsId = contentsId;
	this.pageNumber = page;
	displayTopicPathByContentsId();
	onDetail();
}
//----------------------------------------------------------
// 機能：ライブIDを引数にし、ライブ画面表示処理を呼び出します
// 引数：categoryId カテゴリID
// 引数：liveId     ライブID
// 引数：page       ページ
//
//----------------------------------------------------------
function changeLiveDetailDisplay(liveId,page) {
	this.pageNumber = page;
	getCategoryListByLiveId(liveId);
	displayLiveDetail(liveId);
	onLive();
}
//----------------------------------------------------------
// 機能：コンテンツ一覧表示方法を決定します
// 引数：categoryId カテゴリID
//
//----------------------------------------------------------
function decideContentsList(categoryId) {
	this.categoryId = categoryId;
	MovieDetailListBlogic.isLastCategory(categoryId,{
		callback : decideListDisplay,
 		errorHandler : serverError
		});
}
function decideListDisplay(flag) {
	if(flag){
		changeAllListDisplay(window.parent.categoryId);
	}else{
		changeListDisplay(window.parent.categoryId);
	}
}
//----------------------------------------------------------
// 機能：ぺージ指定でのコンテンツ一覧表示処理を呼び出します
// 引数：なし
//
//----------------------------------------------------------
function designatePageListDisplay() {
	this.pagerFlag  = true;
	displayContentsFooter(this.categoryId,this.pageNumber);
	displayContentsList(this.categoryId,this.pageNumber);
	displayTopicPath();
	onContentsList();
}
//----------------------------------------------------------
// 機能：遷移先エラー画面の決定処理
// 引数：errMessage エラーメッセージ
//
//----------------------------------------------------------
function decideErrorDisplay(errMessage){
	if("notFoundError" == errMessage){
		notFoundError();
	}else{
		serverError();
	}
}
//----------------------------------------------------------
// 機能：サーバエラー画面への遷移処理
// 引数：なし
//
//----------------------------------------------------------
function serverError(){
	location.href="./serverError.do";
}
//----------------------------------------------------------
// 機能：NotFoundエラー画面への遷移処理
// 引数：なし
//
//----------------------------------------------------------
function notFoundError(){
	location.href="./notFoundError.do";
}
//----------------------------------------------------------
//機能：TOPページ画面への遷移処理
//引数：なし
//
//----------------------------------------------------------
function topPage(){
	location.href="./topPage.do";
}
//----------------------------------------------------------
// 機能：TOP項目の表示処理
// 引数：なし
//
//----------------------------------------------------------
function onTopPage() {
	offContentsList();
	offDetail();
	document.getElementById("mainContents" ).attributes.getNamedItem("class").nodeValue = "topPage";
	document.getElementById("picUpMovie"   ).attributes.getNamedItem("class").nodeValue = "normal";
	document.getElementById("newContents"  ).attributes.getNamedItem("class").nodeValue = "normal";
}
//----------------------------------------------------------
// 機能：コンテンツ一覧項目の表示処理
// 引数：なし
//
//----------------------------------------------------------
function onContentsList() {
	offTopPage();
	offDetail();
	document.getElementById("mainContents"	).attributes.getNamedItem("class").nodeValue = "contentsList";
	document.getElementById("topicPath"		).attributes.getNamedItem("class").nodeValue = "clearfix";
	document.getElementById("listArea"		).attributes.getNamedItem("class").nodeValue = "normal";
  	document.getElementById("contentsFooter").attributes.getNamedItem("class").nodeValue = "normal";
}
//----------------------------------------------------------
// 機能：詳細項目の表示処理
// 引数：なし
//
//----------------------------------------------------------
function onDetail() {
	offTopPage();
	offContentsList();
	document.getElementById("mainContents"	).attributes.getNamedItem("class").nodeValue = "contentsList";
	document.getElementById("previewArea"   ).attributes.getNamedItem("class").nodeValue = "normal";
	document.getElementById("topicPath"		).attributes.getNamedItem("class").nodeValue = "clearfix";
	document.getElementById("contentsFooter").attributes.getNamedItem("class").nodeValue = "normal";
}
//----------------------------------------------------------
// 機能：ライブ項目の表示処理
// 引数：なし
//
//----------------------------------------------------------
function onLive() {
	offTopPage();
	offContentsList();
	offDetail();
	document.getElementById("mainContents"	).attributes.getNamedItem("class").nodeValue = "contentsList";
	document.getElementById("listArea"      ).attributes.getNamedItem("class").nodeValue = "normal";
	document.getElementById("contentsFooter").attributes.getNamedItem("class").nodeValue = "normal";
}
//----------------------------------------------------------
// 機能：TOP項目の非表示処理
// 引数：なし
//
//----------------------------------------------------------
function offTopPage() {
	document.getElementById("picUpMovie"    ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("newContents"   ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("liveBroadcast" ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("topics"        ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("picUpflashArea").innerHTML                                  = "";
}
//----------------------------------------------------------
// 機能：コンテンツ一覧項目の非表示処理
// 引数：なし
//
//----------------------------------------------------------
function offContentsList() {
	document.getElementById("topCategoryName"   ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("secondCategoryName").attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("thirdCategoryName"	).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("topicPath"         ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("listArea"          ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("contentsFooter"    ).attributes.getNamedItem("class").nodeValue = "none";
	
	document.getElementById("listArea"          ).innerHTML = "";
	document.getElementById("topCategoryName"   ).innerHTML = "";
	document.getElementById("secondCategoryName").innerHTML = "";
	document.getElementById("thirdCategoryName"	).innerHTML = "";
}
//----------------------------------------------------------
// 機能：詳細項目の非表示処理
// 引数：なし
//
//----------------------------------------------------------
function offDetail() {
	document.getElementById("previewArea"       ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("topCategoryName"   ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("secondCategoryName").attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("thirdCategoryName"	).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("topicPath"         ).attributes.getNamedItem("class").nodeValue = "none";
	document.getElementById("contentsFooter"    ).attributes.getNamedItem("class").nodeValue = "none";
	
	document.getElementById("movieArea"         ).innerHTML = "";
	document.getElementById("topCategoryName"   ).innerHTML = "";
	document.getElementById("secondCategoryName").innerHTML = "";
	document.getElementById("thirdCategoryName"	).innerHTML = "";
	document.getElementById("contentsFooter"    ).innerHTML = "";
}
//-----------------------------------------------------------
// 機能:クリックしたカテゴリが未選択かどうか判定
// 引数:クリックしたカテゴリID
// 戻り値：未選択ならtrue,選択済みならさらにその下位カテゴリが未選択ならfalse,選択済みならtrue
//      画面右部がリスト表示になっていない場合はtrueを返す
//-----------------------------------------------------------
function checkIsNotActive(categoryId){
	var listArea = document.getElementById("listArea");
	if(listArea.className == "none"){
		return true;
	}
	
	var elem = document.getElementById("sideBar_id" + categoryId);
	var parent = elem.parentNode;
	if(parent.className == "active"){
		var lis = parent.childNodes;
		for(i=0; i<lis.length; i++){
			if(lis[i].tagName == "UL"){
				var uls = lis[i].childNodes;
				for(j=0; j<uls.length; j++){
					if(uls[j].className == "active"){
						return true;
					}
				}
			}
		}
		return false;
	} else {
		return true;
	}
}

