/*
 * display loading animation, and load external html, and adjust heights.
 */
$( function(){
	initialize();
	process();
});

/* loading image. */
function initialize(){
    $("#menu"    ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );

	$("#xbox360" ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );
    $("#link"    ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );

	$("#notice"  ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );
    $("#notice0" ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );
    $("#footer"  ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );
}
/* loading process. */
function process(){
    $("#menu"    ).load( "ajax/menu.html", null, callbackfunction );
    
    $("#xbox360" ).load( "ajax/xbox360.html", null, callbackfunction );
    $("#link"    ).load( "ajax/link.html", null, callbackfunction );

	$("#notice"  ).load( "ajax/notice.html", null, callbackfunction );
    $("#notice0" ).load( "ajax/notice0.html", null, callbackfunction );

	$("#footer"  ).load( "ajax/footer.html", null, callbackfunction );
}
/* call back function for jQuery.load. */
function callbackfunction( text, status ){
	if( status == "success" ){

		/* .body配下のdivで最大の高さにmain/left/rightの高さを揃える. */
		var maxh = 0;
    	$('.body div').each( function(){
			var h = this.offsetHeight;
			if( h > maxh ){ maxh = h; }
		});
		
		$( '.main' ).css('height', maxh + 'px');
		$( '.left' ).css('height', maxh + 'px');
		$( '.right' ).css('height', maxh + 'px');
	}
}
/** reserved **/
/*
    $("#twitter" ).html( '<p class="center"><img src="./gif/ajax-loader.gif"></p>' );
    $("#twitter" ).load( "ajax/twitter.html", null, callbackfunction );
*/