/*-----------------------------------------------------------------------
 * ヘッダ、フッタ判定・生成
 *
 * DEPENDENCIES
 *  - co-brand.js
 *  - b-glonavi.js
 *
 * @version $Revision$
 *-----------------------------------------------------------------------
 */

var selectDisplayModeCalled = false;//window.onloadへの二重登録防止
var Nullnavi = {
	head : function(mode){},
	foot : function(mode){}
}

//グロナビ、co-brandの選択
//<body>タグ内で呼び出す必要がある
function selectDisplayMode(){
	if(typeof(CoBrand) != 'undefined' && CoBrand){
		if(selectDisplayModeCalled) return CoBrand;
		selectDisplayModeCalled = true;

		//エラー時にスタイルを戻すメソッドを追加登録
		var funcOriginal = window.onload;
		window.onload = function(){
			if(funcOriginal){
				funcOriginal();
			}
			CoBrand.undoStyleHandler();
		};
		return CoBrand;

	}
	if(typeof(Glonavi) && Glonavi){
		return Glonavi;
	}
	return Nullnavi;
}

//Header、Footerでtry～catchしているのはCPパラメータが不正な際に
//通常表示に戻すため

//ヘッダー生成部
var Header = {
	output : function(mode){
		try{
			selectDisplayMode().head(mode);
		}catch(e){
			if(typeof(Glonavi) != 'undefined' && Glonavi) Glonavi.head(mode);
		}
	}
}

//フッター生成部
var Footer = {
	output : function(mode){
		try{
			selectDisplayMode().foot(mode);
		}catch(e){
			if(typeof(Glonavi) != 'undefined' && Glonavi) Glonavi.foot(mode);
		}
	}
}

