
//選択項目
var selectId = 0;

//各項目名
var item = [ 'project', 'motion', 'print', 'web', 'logo', 'character', 'info' ];

var imgNum = [ 13, 9, 7, 3, 17, 6, 1 ];

//読み込み時
function onLoad( )
{
	arrange( ); 
	
	changePage( 0 );
}

//リサイズ時再配置
function arrange( ) 
{
	//ウィンドウ高さ
	var winH;
	
	//現在のウィンドウサイズ取得
	//opera
	if( window.opera ) 
	{
		winH = window.innerHeight;
	} 
	//ie4
	else if( document.all )
	{	
		winH = window.document.body.clientHeight;
	} 
	//n6-7, m1, s1
	else if( document.getElementById )
	{	
		winH = window.innerHeight;
	}

	//ヘッダーの高さ取得
	var mainTop = document.getElementById( "header" ).clientHeight;

	//ウィンドウサイズからヘッダーの高さをひいたものをメインの高さに設定
	document.getElementById( "main" ).style.height = ( winH - mainTop ) + "px";
}

//リンク
function changePage( id )
{
	//選択されていたボタン画像をOFF
	document.images[ item[ selectId ] + '_btn' ].src = "./img/" + item[ selectId ] + "_off.jpg";

	//選択されたボタン画像をON
	document.images[ item[ id ] + '_btn' ].src = "./img/" + item[ id ] + "_on.jpg";

	//前のページを隠す
	document.getElementById( item[ selectId ] ).style.display = "none";

	//現在のページを表示
	document.getElementById( item[ id ] ).style.display = "block";

	//選択ID変更
	selectId = id;
	
	//画像
	for( i = 0; i < imgNum[ id ]; i++ )
	{
		//選択されていたボタン画像をOFF
		document.images[ item[ id ] + ( i + 1 ) ].src = "./img/" + item[ id ] + ( i + 1 ) + ".jpg";
		
//		alert( item[ id ] + ( i + 1 ) );
	}
	
	//スクロール位置リセット
	document.getElementById( 'main' ).scrollTop = 0;
}

//画像差し替え
function changeImage( target, imgSrc )
{
	if( target != item[ selectId ] + '_btn' )
	{
		document.images[ target ].src = imgSrc;
	}
}

function mailto( )
{
	this.location.href = 'mailto:info@tgbdesign.com';
}

function link( url )
{
	this.location.href = url;
}

