﻿function header(whatever) {

	var head = document.getElementsByTagName('head')[0];

	var test = document.createElement('link');
		test.rel = "stylesheet";
		test.type = "text/css";
		test.media = "screen";
		test.href = "/common_shift/css/heightFix.css";
		head.appendChild(test);

	// 10.11.22 added to spread actual header
	var file = "";
	var path = document.URL;
	var deleteBodyIdentifier = false;
	var isRoot = false;
	var isSecondLevelExist = true;
	var pathSplit = path.split('/');
	var pathLength = pathSplit.length;
	if ( pathSplit[4] == '' || pathSplit[4] == 'index.html' ) {
		isSecondLevelExist = false;
	}
	if ( pathLength < 5 && isSecondLevelExist ) {
		isRoot = true;
	}

	if ( path.indexOf('help_rss.html') != -1 || path.indexOf('/sitemap/') != -1 || path.indexOf('/about/') != -1 || path.indexOf('/kinyu/') != -1 || path.indexOf('/kojinjoho') != -1 || path.indexOf('/socialmedia_policy') != -1  ) {
		file = "home/header00.html";

	//HOME
	} else if ( isRoot ) {
		file = "home/header01.html";

	//個人のお客様へ
	} else if ( path.indexOf('/personal/') != -1 ) {
		file = "individual/header01.html";
	} else 	if ( path.indexOf('/sumai-top/') != -1 ) {
		file = "individual/header02.html";
	} else 	if ( path.indexOf('/senior-top/') != -1 ) {
		file = "individual/header07.html";
	} else 	if ( path.indexOf('/resort-top/') != -1 ) {
		file = "individual/header03.html";
	} else 	if ( path.indexOf('/shopping-top/') != -1 ) {
		file = "individual/header04.html";
	} else 	if ( path.indexOf('/assetmanagement/') != -1 && path.indexOf('/structure/') == -1 ) {
		file = "individual/header05.html";
	} else 	if ( path.indexOf('/service-top/') != -1 ) {
		file = "individual/header06.html";

	//法人のお客様へ
	} else 	if ( path.indexOf('/business/') != -1 ) {
		file = "business/header01.html";
	} else 	if ( path.indexOf('/bldg/') != -1 ) {
		file = "business/header02.html";
	} else 	if ( path.indexOf('/commercial-top/') != -1 ) {
		file = "business/header03.html";
	} else 	if ( path.indexOf('/complex/') != -1 ) {
		file = "business/header04.html";
	} else 	if ( path.indexOf('/effective/') != -1 ) {
		file = "business/header05.html";

	//東急不動産について
	} else 	if ( path.indexOf('/corporate/') != -1 ) {
		file = "about/header01.html";
	} else 	if ( path.indexOf('/project/') != -1 ) {
		file = "about/header02.html";
	} else 	if ( path.indexOf('/company/') != -1 ) {
		file = "about/header03.html";
	} else 	if ( path.indexOf('/enterprise/') != -1 ) {
		file = "about/header04.html";
	} else 	if ( path.indexOf('/ir/') != -1 || path.indexOf('/stockholder/') != -1 ) {
		file = "about/header05.html";
	} else 	if ( path.indexOf('/csr/') != -1 ) {
		file = "about/header06.html";
	} else 	if ( path.indexOf('/saiyou/') != -1 ) {
		file = "about/header07.html";
	} else 	if ( path.indexOf('/topics/') != -1 || path.indexOf('/news/') != -1 ) {
		file = "about/header08.html";
	}

	var url = "/common_shift/include/header/" + file;


	var naviXML;
	var naviAjax = new Ajax.Request(
		url,
		{
			method: 'get',
			onComplete: gmenuInit
		}
	);
	function gmenuInit(httpObj) {


		// 10.11.14 added to read external fils for pages to shift


		var head = document.getElementsByTagName('head')[0];

		var e = document.createElement('link');
			e.rel = "stylesheet";
			e.type = "text/css";
			e.media = "screen";
			e.href = "/common_shift/css/common.css";
			head.appendChild(e);

		var p = document.createElement('link');
			p.rel = "stylesheet";
			p.type = "text/css";
			p.media = "print";
			p.href = "/common_shift/css/print.css";
			head.appendChild(p);

		var library = document.createElement('script');
			library.type = "text/javascript";
			library.laguage = "JavaScript";
			library.charset = "utf-8";
			library.defer = "defer";
			library.src = "/common_shift/js/library.js";
			head.appendChild(library);

		if ( navigator.userAgent.indexOf('MSIE 6') != -1 ) {

			var fix = document.createElement('link');
				fix.rel = "stylesheet";
				fix.type = "text/css";
				fix.href = "/common_shift/css/iepngfix.css";
				head.appendChild(fix);

			var library = document.createElement('script');
				library.type = "text/javascript";
				library.laguage = "JavaScript";
				library.charset = "utf-8";
				library.defer = "defer";
				library.src = "/common_shift/js/library.js";
				head.appendChild(library);
		}


		$('headerContainer').innerHTML = get_response_text(httpObj);
	}
}
function footer(whatever) {

	// 10.11.22 added to spread actual footer
	var file = "";
	var path = document.URL;
	var isRoot = false;
	var isSecondLevelExist = true;
	var pathSplit = path.split('/');
	var pathLength = pathSplit.length;
	if ( pathSplit[4] == '' || pathSplit[4] == 'index.html' ) {
		isSecondLevelExist = false;
	}
	if ( pathLength < 5 && isSecondLevelExist ) {
		file = "/common_shift/include/footer/footer_home.html"
	} else if ( path.indexOf('/ir/') != -1 || path.indexOf('/stockholder/') != -1 ) {
		file = "/common_shift/include/footer/footer_ir.html"
	} else {
		file = "/common_shift/include/footer/footer_general.html"
	}
	var url = file;

	var naviXML;
	var naviAjax = new Ajax.Request(
		url,
		{
			method: 'get',
			onComplete: showFooter
		}
	);
	function showFooter(httpObj) {
		$('footerContainer').innerHTML = get_response_text(httpObj);
	}
}

function get_response_text ( req ) {
	var text = req.responseText;
	if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
		var esc = escape( text );
		if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
			text = decodeURIComponent( esc );
		}
	}
	return text;
}

