﻿//On load page, init the timer which check if the there are anchor changes each 300 ms
$().ready(function(){
	setInterval("checkAnchor()", 300);
	
});
var currentAnchor = null;
//Function which chek if there are anchor changes, if there are, sends the ajax petition
function checkAnchor(){
	//Check if it has changes
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		//if there is not anchor, the loads the default section
		if(!currentAnchor)
			query = "section=home";
		else
		{
			//Creates the  string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2
			var splits = currentAnchor.substring(1).split('&');
			//Get the section
			var section = splits[0];
			delete splits[0];
			//Create the params string
			var params = splits.join('&');
			var query = "section=" + section + params;
		}
		
		//Send the petition　クリック＆読み込みしたときの処理
		// home以外のとき
		if(query!="section=home"){
		
		$("#concept").slideUp("slow");
		$("#concept span").delay(500).fadeOut(500);
		$('#copyright').fadeOut("slow");
		}else
		{// homeのとき
		
		$("#concept").slideDown("slow");
		$("#concept span").delay(500).fadeIn(1000);
		$('#copyright').fadeIn("slow");		
		}
		$("#content").fadeOut("slow");
		$.get("callbacks.php",query, function(data){
			$("#content").hide();
			$("#content").html(data);
			$("#content").fadeIn("slow");
			
			// ---------------------------------------
			// serviceの処理 を追加（※表示させてからでないと有効にならない為ここに記述）
			// ---------------------------------------
			/*
			$('.detail_inner').hide();
			$(function(){
				$('#photolibrary dl dt a').click(function(){
				$('#photolibrary .detail_inner').slideToggle("slow");
				})
			});
			$(function(){
				$('#ad dl dt a').click(function(){
				$('#ad .detail_inner').slideToggle('slow');
				})
			});
			*/
			
		});
	}
}



// ---------------------------------------
// loading effects - 読み込み時の処理
// ---------------------------------------
$(function () {        
	$('#logoarea ul li').shuffle();
	$('#logoarea ul li').hide();
	$('#logoarea ul li').each(function (i) {
		$(this).delay(i * 150).fadeIn(1500);
		$(this).find('img').delay(i * 150).animate({height:"150px"}, 1500);
		});
	});

$(function () {
	$('#concept span').hide().delay(2500);
	$('#concept span').fadeIn("slow");
	});

$(function () {
	$('#menu li').hide().delay(3000);
	$('#menu li').each(function (i) {
		$(this).delay(i * 200).fadeIn(1000);
		});
	});

$(function () {
	$('#copyright').hide().delay(4000);
	$('#copyright').fadeIn("slow");
	});

$(function () {
	$('h1').hide().delay(2000);
	$('h1').fadeIn("slow");
	});








