

/* ------------------------------------
*
*Since: 2008-03-28
*Editor: BBmedia Inc. D_sasaki
*
-------------------------------------*/

jQuery(function($) {
				
	var illustObj = {
		ill_1: false,
		ill_2: false,
		ill_3: false
	}
	
	$('html,body').animate({scrollTop: 0}, 900)
	
	$('.mainNavi a').click(function() {
		var target = $(this).attr("href")
		var offset = $(target).offset()

		$('html,body').animate({scrollTop: offset.top}, 900);
	
		if(target == "#philosophy" && illustObj.ill_1 == false) {
			setTimeout(
				function(){
					$("#ill_1_01, #ill_1_02, #ill_1_03").fadeIn(2600)
				},1000)
			illustObj.ill_1 = true
		}
		
		if(target == "#origin" && illustObj.ill_2 == false) {
			setTimeout(
				function(){
					$("#ill_2_01, #ill_2_02").fadeIn(2600)
				},1000)
			illustObj.ill_2 = true
		}
		
		if(target == "#about" && illustObj.ill_3 == false) {
			setTimeout(
				function(){
					$("#ill_3_01, #ill_3_02").fadeIn(2600)
				},1000)
			illustObj.ill_3 = true
		}
		
		return false;
	}).focus(function(){this.blur();});

	var philosophy = {
		slide:function (position, node){
			var targetNode = node;
			$('div#moveBox')
			.animate({left:position}, 500)	
			
			$(node)
			.addClass("on")
			.parent()
			.parent()
			.find("a")
			.not($(targetNode))
			.removeClass("on")
		},
		position:1
	}	
	
	$('#number a').each(function(e){
		var pos = -e * 422
		$(this)	.click(function(){
			philosophy.slide(pos, this)
			//philosophy.position = e + 1
			return false
		})
	}).focus(function(){this.blur();});

	$('#back a').click(function(){
		var nowPos = $('#moveBox').css("left")
		var nowPosNumber = new Number(nowPos.split("p")[0])
		if(nowPosNumber%422) return false
		
		var nextPos = nowPosNumber + 422 + "px"
		var targetPos = -nowPosNumber/422
		//alert(posNumber)
		if(targetPos == 0) return false
		
		philosophy.slide(nextPos, "#num0" + targetPos + " a")
		return false
	}).focus(function(){this.blur();});
	
	$('#next a').click(function(){
		var nowPos = $('#moveBox').css("left")
		var nowPosNumber = new Number(nowPos.split("p")[0])
		if(nowPosNumber%422) return false
		
		var nextPos = nowPosNumber - 422 + "px"
		var targetPos = -nowPosNumber/422 + 2
		var maxPos = ($('#number a').length - 1) * -422
		//alert(posNumber)
		if(nowPosNumber == maxPos) return false
		
		philosophy.slide(nextPos, "#num0" + targetPos + " a")
		return false
	}).focus(function(){this.blur();});
	
});


function winOpen(targetURL) {
	var url = targetURL;
	var wn = 'sub';
	var ww = 720;
	var hh = 700;
	var tt = (screen.height-hh)/2;
	var ll = (screen.width-ww)/2;
	var fea = "top="+tt+",left="+ll+",width="+ww+",height="+hh+",scrollbars=1,resizable=1";
	var subwin = window.open(url,wn,fea);
	subwin.focus();
}




