//=============================================================================
// Display Header
//=============================================================================
/*var displayHeader = function() {
	var header;
	
	header = "<h1><a href='index.html'><img src='/img/logo.png' alt='Web制作、ホームページ制作 Web Greed' width='150' height='60' border='0' /></a></h1>";
	header += "<p><a name='pagetop' id='pagetop'>Web制作をコンサルティングからデザイン、開発、保守まで、価値あるアーキテクチャをご提供。</a></p>";
	
	document.write(header);
}
*/



//=============================================================================
// Display Footer
//=============================================================================
var displayFooter = function() {
	var footer;
	
	footer = "<div class='pageTop'>";
	footer += "<p><a href='javascript:void(0);' onClick='movePageTop(); return false' title='このページの先頭へ'>▲ このページの先頭へ</a></p>";
	footer += "</div>";
	footer += "<hr />";
	
	footer += "<div id='footer'>";
	footer += "<div class='clearfix'>";
	footer += "<p><img src='/img/footer_logo.png' width='150' height='60' alt='Web制作、ホームページ制作 Web Greed' /></p>";
	
	footer += "<div class='box'>";
	footer += "<ul>";
	footer += "<li><a href='/sitemap.html' title='サイトマップ'>サイトマップ</a></li>";
	footer += "<li><a href='/tokutei.html' title='特定商取引法の表記'>特定商取引法の表記</a></li>";
	footer += "<li><a href='/privacy.html' title='個人情報の取り扱いについて'>個人情報の取扱いについて</a></li>";
	footer += "<li><a href='/link_web.html' title='相互リンク'>相互リンク</a></li>";
	footer += "</ul>";
	footer += "<br clear='all' />";
	footer += "<hr />";
	
	footer += "<address>Copyright &copy 2009 <a href='index.html' title='Web制作、ホームページ制作 Web Greed'>Web Greed</a> All Rights Reserved.</address>";
	footer += "</div>";
	footer += "</div>";
	footer += "</div>";
	
	document.write(footer);
}



//=============================================================================
// Display Right Banner Content
//=============================================================================
var displayImgLink = function() {
	var imglink;
	
	imglink = "<p><a href='/service_system.html#ec' title='トータルサービスでのECサイト構築'><img src='/img/banner/ec.gif' alt='トータルサービスでのECサイト構築' width='234' height='100' border='0' /></a></p>";
	imglink += "<p><a href='/service_system.html#cms' title='自社で簡単更新 CMS構築'><img src='/img/banner/cms.gif' alt='自社で簡単更新 CMS構築' width='234' height='100' border='0' /></a></p>";
	
	imglink += "<p><img src='/img/banner/tel.gif' width='234' height='60' alt='Web Greed 電話番号 03-5840-8815' /></p>";
	imglink += "<p><a href='/form/contact' title='お問合せ'><img src='/img/banner/mail.gif' alt='お問合せ' width='234' height='60' border='0' /></a></p>";

	document.write(imglink);
}



//=============================================================================
// Display Right Banner Content
//=============================================================================
var displayBanner= function() {
	var banner;
	
	banner = "<p><a href='http://www.topgate.co.jp' title='株式会社トップゲート' target='_blank'><img src='/img/banner/topgate.gif' width='234' height='60' border='0' alt='株式会社トップゲート' /></a></p>";
	banner += "<p><a href='http://www.team-6.jp' title='チームマイナス6%' target='_blank'><img src='/img/banner/banner_ondanka2.jpg' width='177' height='50' border='0' alt='チームマイナス6%' /></a></p>";
	banner += "<p><a href='http://www.nice-vec.jp/'><img src='http://image.nice-vec.jp/images/bunner/halfbun_04.gif' width='234' height-'60' alt='つながりを力に!起業支援ネットワーク NICe' border='0' /></a></p>";
	banner += "<p><a href='http://www.ishino-ya.com/' title='リサイクル' target='_blank'><img src='/img/banner/banner_ishino.jpg' width='170' height='60' border='0' alt='リサイクル' /></a></p>";
	banner += "<p class='last'><a href='http://www.core-spirit.com/' title='core siprit' target='_blank'><img src='/img/banner/banner_core.jpg' width='170' height='60' border='0' alt='core spirit' /></a></p>";

	document.write(banner);
}



//=============================================================================
//	Display Back to Page Top
//=============================================================================
var displayPageTop = function() {
	var pageTop;

	pageTop = "<p class='pageTop hidden'><a href='javascript:void(0);' onClick='movePageTop(); return false' title='このページの先頭へ'>▲ このページの先頭へ</a></p>";
	
	document.write(pageTop);
}





//=============================================================================
//	OS & Browser Check関数
//=============================================================================
function osCheck(obj) {
	var Agent = navigator.userAgent;
	
	if (Agent.indexOf("Safari") != -1) {
		document.write("<link rel=\"stylesheet\" href=\"css/safari.css\" type=\"text/css\" media=\"all\" />");
		return;
	}
	else if (Agent.indexOf("Opera") != -1) {
		document.write("<link rel=\"stylesheet\" href=\"css/opera.css\" type=\"text/css\" media=\"all\" />");
		return;
	}
	else if (Agent.indexOf("Firefox") != -1) {
		if (Agent.indexOf("Windows NT 5.1") != -1) {
			document.write("<link rel=\"stylesheet\" href=\"css/xp_ff.css\" type=\"text/css\" media=\"all\" />");
			return;
		}
		else if (Agent.indexOf("Windows NT 6.0") != -1) {
			document.write("<link rel=\"stylesheet\" href=\"css/vista_ff.css\" type=\"text/css\" media=\"all\" />");
			return;
		}
	}
	else if (Agent.indexOf("MSIE 7") != -1) {
		document.write("<link rel=\"stylesheet\" href=\"css/ie7.css\" type=\"text/css\" media=\"all\" />");
		return;
	}
	else if (Agent.indexOf("MSIE 6.0") != -1) {
		document.write("<link rel=\"stylesheet\" href=\"css/ie6.css\" type=\"text/css\" media=\"all\" />");
		return;
	}
}



//=============================================================================
//	Move to Page Top Function
//=============================================================================
var movePageTop = function() {
	var agent = navigator.appName;
	var posY = document.getElementById("pagetop").offsetTop;
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;
	
	//Select Browser
	if(agent = "Microsoft Internet Explorer") {
		posY+=50;
	}
	
	if (document.documentElement) {
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	if (document.body) {
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	
	if(y <= posY) {
		window.scrollTo(Math.floor(x / 2 * 1.6), Math.floor(y / 2 * 1.6));
	}
	else {
		window.scrollTo(x, posY);
	}

	if (x > 0 || y > 0) {
		window.setTimeout("movePageTop()", 25);
	}
}



//=============================================================================
//	Google Map API
//	2008/11/18
//=============================================================================
function load() {
	if (GBrowserIsCompatible()) {
		// 最初に関数を定義します
		function TextualZoomControl() {}
		
		// GControl を "subclass" にするには、prototype オブジェクトを
		// GControl オブジェクトのインスタンスに設定します
		TextualZoomControl.prototype = new GControl();
		
		// 各ボタンに対して1つの DIV を作成し、
		// コントロール要素として返されるコンテナ DIV に格納します。そのコントロールを
		// マップコンテナに追加し、マップクラスの要素を返して
		// 適切な位置を指定します。
		TextualZoomControl.prototype.initialize = function(map) {
			var container = document.createElement("div");
			var zoomInDiv = document.createElement("div");
			this.setButtonStyle_(zoomInDiv);
			container.appendChild(zoomInDiv);
			zoomInDiv.appendChild(document.createTextNode("拡小"));
			GEvent.addDomListener(zoomInDiv, "click", function() { map.zoomIn(); });
			
			var zoomOutDiv = document.createElement("div");
			this.setButtonStyle_(zoomOutDiv);
			container.appendChild(zoomOutDiv);
			zoomOutDiv.appendChild(document.createTextNode("拡大"));
			GEvent.addDomListener(zoomOutDiv, "click", function() { map.zoomOut(); });
			
			map.getContainer().appendChild(container);
			return container;
		}
		
		// デフォルトでは、このコントロールが地図の左上から
		// 7ピクセル離れた位置に表示されます。
		TextualZoomControl.prototype.getDefaultPosition = function() {
			return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
		}
		
		// 指定されたボタン要素に対して適切な CSS を設定します。
		TextualZoomControl.prototype.setButtonStyle_ = function(button) {
			button.style.textDecoration = "underline";
			button.style.color = "#0000cc";
			button.style.backgroundColor = "white";
			button.style.font = "small Osaka";
			button.style.border = "1px solid black";
			button.style.padding = "2px";
			button.style.marginBottom = "3px";
			button.style.textAlign = "center";
			button.style.width = "6em";
			button.style.cursor = "pointer";
		}
		
		// アイコン生成　
		var icon = new GIcon();
		icon.image = '/img/marker.png';
		icon.iconSize = new GSize(120,72); // 画像の大きさ
		icon.shadow = '/img/marker_shadow.png';
		icon.shadowSize = new GSize(120,72); // 影画像の大きさ
		icon.iconAnchor = new GPoint(10,60); // 画像の「基準点」
		icon.infoWindowAnchor = new GPoint(20,5); // 情報ウィンドウの基準点
		
		// マーカー生成
		var lng = 35.70771;
		var lat = 139.764405;
		var marker = new GMarker(new GPoint(lat, lng), icon);
		
		// Set the center of the map
		//map.setCenter(marker, 15);
		
		// マップ生成
		var map = new GMap(document.getElementById("map"));
		map.centerAndZoom(new GPoint(lat, lng), 0);
		map.addControl(new GSmallMapControl());
		
		// Add a marker to the map
		map.addOverlay(marker);
	}
}



//=============================================================================
//	Get and Set Footer Height Function
//	Takahashi Toshiya
//	2009/2/16
//=============================================================================
function setFooterHeight() {
	var agent = navigator.appName;
	var h = document.getElementById('footer');
	var browserHeight; //Current Browser Height
	var pos = getPosition('footer'); //Actual Position of Content
	var temp_height;
	
	//Select Browser
	switch (agent) {
	case "Microsoft Internet Explorer":
		browserHeight = document.documentElement.clientHeight;
		break;
	default:
		browserHeight = window.innerHeight;
		break;
	}

	temp_height = browserHeight - pos;

	if(temp_height < 200) {
		h.style.height = "200px";
	}
	else {
		h.style.height = temp_height + "px";
	}
}



//=============================================================================
//	Get Position Function
//	Takahashi Toshiya
//	2009/1/13
//=============================================================================
var getPosition = function(obj) {
	var pos = document.getElementById(obj);

	return pos.offsetTop;
}



//=============================================================================
//	Switch Button Function
//	Takahashi Toshiya
//	2009/1/13
//=============================================================================
var switchBtn = function(page, status) {
	if(page == "index" || page == "sitemap" || page == "privacy" || page == "tokutei" || page == "qr" || page == "link") {
		return;
	}

	var globalMenu = document.getElementById(page);
	
	globalMenu.firstChild.style.backgroundImage = "url('/img/menu/" + page + "_on.gif')";
}


//=============================================================================
//	Set Event Handler
//=============================================================================
function addEvent(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false); // Firefox等
	}
	catch(e){
		elm.attachEvent("on"+listener,fn); // IE用
	}
}

function currentPage() {
	var page = location.href;
	var temp = page.lastIndexOf("/");
	
	temp = page.substring(temp);
	temp = temp.split("/");
	
	temp = temp[1].split(".");
	temp = temp[0];

	temp = temp.split("_");
	page = temp[0];
//alert(page);
	switchBtn(page);
}

// Get Current Page Name
addEvent(window,"load",currentPage);
// Get and Set Footer Height
addEvent(window,"load",setFooterHeight);

// Get and Set Footer Height
//addEvent(window,"load",load);
// Get and Set Footer Height
//addEvent(window,"unload",GUnload);


onresize = function() {
	setFooterHeight();
};