//----------------------------------------------------------
// 機能：サニタイジング処理
// 引数：str サニタイジング対象文字列
//
//----------------------------------------------------------
function escapeHtml(str){
	if(typeof(this.divElement) == 'undefined') {
		this.divElement = document.createElement('div');
	}
	this.divElement.innerHTML = str;
	return this.divElement.innerHTML.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&");
}

//----------------------------------------------------------
// 機能：サイドバーのアクティブ化処理
// サイドバーを押下せずに詳細画面を表示するの場合等に、サイドバーをアクティブ化をします
// 引数：categoryList 表示対象のカテゴリIDリスト
//
//----------------------------------------------------------
function openSideBar(categoryList){

    for (var i = 0; i < categoryList.length; i++) {
       	switch(i) {
       		case 2:
       			if(document.getElementById("sideBar_id"+categoryList[2]) != null){
       				selectCategory3Item(document.getElementById("sideBar_id"+categoryList[2]));
       			}
       		    break;
       		case 1:
       			if(document.getElementById("sideBar_id"+categoryList[1]) != null){
       				selectCategory2Item(document.getElementById("sideBar_id"+categoryList[1]));
       			}
       		    break;
       		case 0:
       			if(document.getElementById("sideBar_id"+categoryList[0]) != null){
       				selectCategory1Item(document.getElementById("sideBar_id"+categoryList[0]));
       			}
       			break;
       		default:
       			break;
       	}
	}
}

//----------------------------------------------------------
//　機能：sideBar一階層目の選択
//　引数：in_Obj　選択オブジェクト
//
//----------------------------------------------------------
function selectCategory1Item(in_Obj) {
	// 選択されていた一階層目オブジェクトを非選択に設定
	if(typeof(this.gPreSelectedObj) != 'undefined') {

		this.gPreSelectedObj.parentNode.className = "normal";

	}
	// 選択されていた二階層目オブジェクトを非選択に設定
	if(typeof(this.gPreSelectRoot2Obj) != 'undefined') {

		this.gPreSelectRoot2Obj.parentNode.className = "normal";

	}
	// 選択されていた三階層目オブジェクトを非選択に設定
	if(typeof(this.gPreSelectRoot3Obj) != 'undefined') {

		this.gPreSelectRoot3Obj.parentNode.className = "normal";

	}

	// 選択されたオブジェクトを設定
	this.gPreSelectedObj = in_Obj;


	// 選択に設定
	in_Obj.parentNode.className= "active";

}

//----------------------------------------------------------
//　機能：sideBar二階層目の選択
//　引数：in_Obj　選択オブジェクト
//
//----------------------------------------------------------
function selectCategory2Item(in_Obj) {

	// 選択されていた二階層目オブジェクトを非選択に設定
	if(typeof(this.gPreSelectRoot2Obj) != 'undefined') {

		this.gPreSelectRoot2Obj.parentNode.className = "normal";

	}
	// 選択されていた三階層目オブジェクトを非選択に設定
	if(typeof(this.gPreSelectRoot3Obj) != 'undefined') {

		this.gPreSelectRoot3Obj.parentNode.className = "normal";

	}

	// 選択されたオブジェクトを設定
	this.gPreSelectRoot2Obj = in_Obj;


	// 選択に設定
	in_Obj.parentNode.className= "active";

}

//----------------------------------------------------------
//　機能：sideBar三階層目の選択
//　引数：in_Obj　選択オブジェクト
//
//----------------------------------------------------------
function selectCategory3Item(in_Obj) {

	// 選択されていた三階層目オブジェクトを非選択に設定
	if(typeof(this.gPreSelectRoot3Obj) != 'undefined') {

		this.gPreSelectRoot3Obj.parentNode.className = "normal";

	}

	// 選択されたオブジェクトを設定
	this.gPreSelectRoot3Obj = in_Obj;


	// 選択に設定
	in_Obj.parentNode.className= "active";

}

