// JavaScript Document
// JavaScript Document
var leftValue = 0;
var flg = +1;
var sWidth = GetWindowWidthHeight().width;
var value1 = -4063+sWidth;

document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAT-q7wojbRva1JiDYoduwLxRnMZxdcL3XVKXYfhb6ufcXS5nw0BQL8SRwEkHWRfuoJCUB-rjyBr-RaQ" type="text/javascript"></script>');

function GetWindowWidthHeight(){
	var myWidth = 0, myHeight = 0;
	if(typeof(window.innerWidth) == 'number'){
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return {'width' : myWidth, 'height' : myHeight};
}

window.onload = function(){
	var sHeight = GetWindowWidthHeight().height;
	var sWidth = GetWindowWidthHeight().width;

	document.getElementsByTagName('h1')[0].style.marginTop = (sHeight/2)-(sHeight/4)-60+'px';
	document.getElementById('map').style.width = sWidth+'px';
	document.getElementById('map').style.height = sHeight/2+'px';

	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		var center = new GLatLng(35.670671,139.659566);
		map.setCenter(center,16);
		var tilelayer = new GTileLayer(new GCopyrightCollection(),0,17);
		tilelayer.getTileUrl = function(tile,zoom){
			return "http://takanoriohira.com/image/white.gif";
		}
		tilelayer.getOpacity = function(){
			return 0.6;
		}
		map.addOverlay(new GTileLayerOverlay(tilelayer));
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
		var marker = new GMarker(center);
		map.addOverlay(marker);
		map.openInfoWindowHtml(center,'<div style="font-size:12px; color:#CCCCCC;">〒156-0041<br />東京都世田谷区大原2-17-15<br />新興スタービル3F<br /><br />大平貴臣建築設計事務所<br />TEL+FAX　0503105360</div>');
	}

	var defaultLeftValue = (sWidth-820);

	var profileboxWidth = 95;
	var worksboxWidth = 85;
	var compeboxWidth = 110;
	var publicationboxWidth = 160;
	var accessboxWidth = 90;
	var blogboxWidth = 70;
	var contactboxWidth = 90;
	var linksboxWidth = 80;
	var omsboxWidth = 50;
	document.getElementById('profilebox').style.left = defaultLeftValue+'px';
	
	var worksboxLeftValue = defaultLeftValue+profileboxWidth;
	document.getElementById('worksbox').style.left = worksboxLeftValue+'px';
	
	var compeboxLeftValue = worksboxLeftValue+worksboxWidth;
	document.getElementById('compebox').style.left = compeboxLeftValue+'px';
	
	var publicationboxLeftValue = compeboxLeftValue+compeboxWidth;
	document.getElementById('publicationbox').style.left = publicationboxLeftValue+'px';
	
	var accessboxLeftValue = publicationboxLeftValue+publicationboxWidth;
	document.getElementById('accessbox').style.left = accessboxLeftValue+'px';
	
	var blogboxLeftValue = accessboxLeftValue+accessboxWidth;
	document.getElementById('blogbox').style.left = blogboxLeftValue+'px';
	
	var contactboxLeftValue = blogboxLeftValue+blogboxWidth;
	document.getElementById('contactbox').style.left = contactboxLeftValue+'px';

	var linksboxLeftValue = contactboxLeftValue+contactboxWidth;
	document.getElementById('linksbox').style.left = linksboxLeftValue+'px';
	
	var omsboxLeftValue = sWidth-omsboxWidth;
	document.getElementById('omsbox').style.left = omsboxLeftValue+'px';
}
window.onresize = function(){
	var sHeight = GetWindowWidthHeight().height;
	var sWidth = GetWindowWidthHeight().width;
	document.getElementsByTagName('h1')[0].style.marginTop = (sHeight/2)-(sHeight/4)-60+'px';
	document.getElementById('map').style.width = sWidth+'px';
	document.getElementById('map').style.height = sHeight/2+'px';

	var defaultLeftValue = (sWidth-820);

	var profileboxWidth = 95;
	var worksboxWidth = 85;
	var compeboxWidth = 110;
	var publicationboxWidth = 160;
	var accessboxWidth = 90;
	var blogboxWidth = 70;
	var contactboxWidth = 90;
	var linksboxWidth = 80;
	var omsboxWidth = 50;

	document.getElementById('profilebox').style.left = defaultLeftValue+'px';
	
	var worksboxLeftValue = defaultLeftValue+profileboxWidth;
	document.getElementById('worksbox').style.left = worksboxLeftValue+'px';
	
	var compeboxLeftValue = worksboxLeftValue+worksboxWidth;
	document.getElementById('compebox').style.left = compeboxLeftValue+'px';
	
	var publicationboxLeftValue = compeboxLeftValue+compeboxWidth;
	document.getElementById('publicationbox').style.left = publicationboxLeftValue+'px';
	
	var accessboxLeftValue = publicationboxLeftValue+publicationboxWidth;
	document.getElementById('accessbox').style.left = accessboxLeftValue+'px';
	
	var blogboxLeftValue = accessboxLeftValue+accessboxWidth;
	document.getElementById('blogbox').style.left = blogboxLeftValue+'px';
	
	var contactboxLeftValue = blogboxLeftValue+blogboxWidth;
	document.getElementById('contactbox').style.left = contactboxLeftValue+'px';

	var linksboxLeftValue = contactboxLeftValue+contactboxWidth;
	document.getElementById('linksbox').style.left = linksboxLeftValue+'px';
	
	var omsboxLeftValue = sWidth-omsboxWidth;
	document.getElementById('omsbox').style.left = omsboxLeftValue+'px';
}

contentsArray = new Array("profile","works","compe","blog");

function openClose(id){
	if(document.getElementById(id).style.display == false || document.getElementById(id).style.display == 'none'){
		//var tdName = id+'Td';
		var sHeight = GetWindowWidthHeight().height;
		//document.getElementById(tdName).style.backgroundImage = 'url(http://takanoriohira.com/image/arrowunder.gif)';
		document.getElementById(id).style.display = 'block';
		document.getElementById(id).style.height = sHeight/2-sHeight/4-15+'px';
		for(i=0;i<5;i++){
			if(contentsArray[i] != id){
				if(document.getElementById(contentsArray[i]).style.display == 'block' || document.getElementById(id).style.display == false){
					//tdName = contentsArray[i]+'Td';
					//document.getElementById(tdName).style.backgroundImage = 'url(http://takanoriohira.com/image/arrowright.gif)';
					document.getElementById(contentsArray[i]).style.display = 'none';
				}
			}
		}
	}else{
		//var tdName = id+'Td';
		//document.getElementById(tdName).style.backgroundImage = 'url(http://takanoriohira.com/image/arrowright.gif)';
		document.getElementById(id).style.display = 'none';
	}
}