
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
};
 
// Usage
$.preloadImages("image/topParts/top_photo00.jpg", "image/topParts/topPhoto02.jpg", "image/topParts/topPhoto03.jpg", "image/topParts/topPhoto04.jpg", "image/topParts/topPhoto05.jpg", "image/topParts/topPhoto06.jpg", "image/topParts/topPhoto07.jpg", "image/topParts/topPhoto08.jpg");

//メニュー部分

$(function(){
	$("img.imgMenu").mouseover(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1$2"));
	}).each(function(){
		$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))
	});
});



//トップページ　写真のコントロール

$(document).ready(function(){

	var pict = 1;
	pict = parseInt(pict);

	$("#read01").fadeIn();

	pict = pict + 1;
	saisei = setInterval(function(){
		$("#white").show();
		$("#photoBox").css("backgroundImage", "url('" + $("a.pict0" + pict).attr("href") + "')")
	
		$("div.readAll").fadeOut();
		$("#read0" + pict).fadeIn();
		
		$("#white").fadeOut(2500);
		
		if(pict == 8)pict = 1;
		else pict = pict + 1;
		
	}, 15000);

	$("#play").click(function(){
		$("#white").show();
			$("#photoBox").css("backgroundImage", "url('" + $("a.pict0" + pict).attr("href") + "')");
			$("#white").fadeOut();
			if(pict == 8)pict = 1;
			else pict = pict + 1;
			
		saisei = setInterval(function(){
			$("#white").show();
			$("#photoBox").css("backgroundImage", "url('" + $("a.pict0" + pict).attr("href") + "')");
			
			$("div.readAll").fadeOut();
			$("#read0" + pict).fadeIn();
			
			$("#white").fadeOut(2500);
		
			if(pict == 8)pict = 1;
			else pict = pict + 1;
		
		}, 15000);
		$(this).css("display","none");
		$("#stop").show();
	});
	
	$("#stop").click(function(){
			clearInterval(saisei);
			$(this).css("display","none");
			$("#play").show();
			pict = pict - 1;
	});
	
	$("#prev").click(function(){
		if( $("#stop").css("display") == "block" )
			clearInterval(saisei), pict = pict - 1;
			
			$("#stop").css("display","none");
			$("#play").show();

			if(pict == 1)pict = 8;
			else pict = pict - 1;
			
			$("#white").show();
			$("#photoBox").css("backgroundImage", "url('" + $("a.pict0" + pict).attr("href") + "')");
			$("#white").fadeOut();
			
			$("div.readAll").fadeOut();
			$("#read0" + pict).fadeIn();
			
	});

	$("#next").click(function(){
		if( $("#stop").css("display") == "block" )
			clearInterval(saisei), pict = pict - 1;
			$("#stop").css("display","none");
			$("#play").show();
			if(pict == 8)pict = 1;
			else pict = pict + 1;
			
			$("#white").show();
			$("#photoBox").css("backgroundImage", "url('" + $("a.pict0" + pict).attr("href") + "')");
			$("#white").fadeOut();
			
			$("div.readAll").fadeOut();
			$("#read0" + pict).fadeIn();
			
	});

	
	$("#photoControllerBox div a").click(function(){
		if( $("#stop").css("display") == "block" )
			clearInterval(saisei);
		$("#stop").css("display","none");
		$("#play").show();
		
		$("#white").show();
		$("#photoBox").css("backgroundImage", "url('" + $(this).attr("href") + "')");
		$("#white").fadeOut();
		
		var num = $(this).attr("class");
		num = num.charAt(5);
		num = parseInt(num);
		pict = num;
		
		$("div.readAll").fadeOut();
		$("#read0" + pict).fadeIn();
		
		return false;
		
	});	
	
	
});

$(document).ready(function(){

	$("#count").load("counter/hello.php #counter");

});

$(function(){
	$.ajax({
		url: 'js/tenki3.php',
		dataType: 'xml',
		success: function(data){
			$("item:eq(1)",data).each(function(){
				$("#tenki").append("<a href='"+$("link",this).text()+"'>"
				+$("title:eq(1)",this).text()+"</a><br />"
				+$("description",this).text()+"<br />");
				$("#tenkiIcon").append("<img src='"+$("url",this).text()+"'>");
			});
		}
	});
});
/*
$(document).ready(function(){

	$("#kousinBox").load("sitehistory.html #hisList" , function(){
		$("#kousinBox li:gt(3)").css("display", "none");
	});
	

});
*/
$(function(){
	$("td div.evDay").click(function(){
		$("#moyoosi div").remove();
		hiduke = $(this).attr("id");
		//$("#moyoosi").text(hiduke);
		$("#moyoosi").load("documents/event/event.html div.e" + hiduke);
	});
});

$(function(){
     $(".footerToTop a").click(function(){
     $('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
     return false;
     })
});
$(function(){
	$("#copyright").text((new Date().getFullYear()) + "　じねんびと");
});

