
var _mode = true;
var _current = 'navihome';


$(function(){
	
	resizeWindow();
	$(window).resize(function(){
		resizeWindow();
	});
	
	$('#details div.detail').hide();
	
	$('#top_menu ul li a:not(#navihome,#navicontact)').click(function(){
		if(_current != $(this).attr('id')){
			var target = $(this).attr('href').split('?')[0];
			setDetail(target);
			_current = $(this).attr('id');
		}
		//return false;
	});
	$('#top_menu ul li a#navihome').click(function(){
		if(_current != 'navihome'){
			setTop();
			_current = 'navihome';
		}
		//return false;
	});

	$('#lng_select').hover(
function(){
		$('#lng_select').animate({
			'width': '146px'
	});
	},
function(){
		$('#lng_select').animate({
			'width': '25px'
	});
	}

);

	
});


function resizeWindow(){
	if(_mode){
		var	wh = document.documentElement.clientHeight || window.innerHeight || 0;
		var toppos = Math.floor(Math.max((wh/2-300),40));
	}
}

function setDetail(target){

	if(_mode){
		$('#declaration').animate({
			'top': '10px'
		},500);
		$('#philosophy').fadeOut();
		$('#declaration h3').fadeOut();
		$('#main').animate({
			'top': '170px'
			},500,'swing',function(){
				$('#details div.detail:not(target)').hide();
				$(target).fadeIn();

			}
		);
		$('#top_contents').fadeOut();
		_mode = false;
	}
	else {
		$('#details div.detail:not(target)').hide();
		$(target).fadeIn();
	}
}
function setTop(){

	$('#details div.detail').hide();
	var	wh = document.documentElement.clientHeight || window.innerHeight || 0;
	var toppos = Math.floor(Math.max((wh/2-300),40));
	$('#declaration').animate({
			'top': '100px'
	},500);
	$('#declaration h3').fadeIn();
	$('#philosophy').fadeIn();
	$('#main').animate({
			'top': '490px'
		},500,'swing',function(){
			$('#top_contents').fadeIn();
			_mode = true;

		}
	);
}