// image preload
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}

// Usage
$.preloadImages("./img/header/nav-about_on.gif", "./img/header/nav-works_on.gif", "./img/header/nav-contact_on.gif", "./img/header/youtube_on.gif", "./img/header/myspace_on.gif");

// image change
$(function(){
	$("#nav-about").hover(
		function(){ $('#nav-about').attr({ src: "./img/header/nav-about_on.gif" }); },
		function(){ $('#nav-about').attr({ src: "./img/header/nav-about.gif" }); }
	);
	$("#nav-guide").hover(
		function(){ $('#nav-guide').attr({ src: "./img/header/nav-guide_on.gif" }); },
		function(){ $('#nav-guide').attr({ src: "./img/header/nav-guide.gif" }); }
	);
	$("#nav-works").hover(
		function(){ $('#nav-works').attr({ src: "./img/header/nav-works_on.gif" }); },
		function(){ $('#nav-works').attr({ src: "./img/header/nav-works.gif" }); }
	);
	$("#nav-contact").hover(
		function(){ $('#nav-contact').attr({ src: "./img/header/nav-contact_on.gif" }); },
		function(){ $('#nav-contact').attr({ src: "./img/header/nav-contact.gif" }); }
	);
	$("#youtube").hover(
		function(){ $('#youtube').attr({ src: "./img/header/youtube_on.gif" }); },
		function(){ $('#youtube').attr({ src: "./img/header/youtube.gif" }); }
	);
	$("#myspace").hover(
		function(){ $('#myspace').attr({ src: "./img/header/myspace_on.gif" }); },
		function(){ $('#myspace').attr({ src: "./img/header/myspace.gif" }); }
	);
});




/*------- 項目の開閉 -------*/
$('#hayashi > div').hide();
$('#bishop > div').hide();
$('#tsutsumi > div').hide();
hayashi_close = true;
bishop_close = true;
tsutsumi_close = true;

$('#web2010 > div').hide();
$('#web2009 > div').hide();
$('#web2008 > div').hide();
web2010_close = true;
web2009_close = true;
web2008_close = true;



$('#hayashi > h2').click(function () {
	targetOffset = $('#hayashi').offset().top;
	$('#hayashi > div').slideToggle('fast');
	if(hayashi_close == true){
		$('#hayashi > h2 > span').html('<img src="./img/article/works/close.gif" alt="close" />');
		$('html, body').animate({scrollTop: targetOffset}, 500);
		hayashi_close = false;
	}
	else {
		$('#hayashi > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
		hayashi_close = true;
	}
});

$('#bishop > h2').click(function () {
	targetOffset = $('#bishop').offset().top;
	$('#bishop > div').slideToggle('fast');
	if(bishop_close == true){
		$('#bishop > h2 > span').html('<img src="./img/article/works/close.gif" alt="close" />');
		$('html, body').animate({scrollTop: targetOffset}, 500);
		bishop_close = false;
	}
	else {
		$('#bishop > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
		bishop_close = true;
	}
});

$('#tsutsumi > h2').click(function () {
	targetOffset = $('#tsutsumi').offset().top;
	$('#tsutsumi > div').slideToggle('fast');
	if(tsutsumi_close == true){
		$('#tsutsumi > h2 > span').html('<img src="./img/article/works/close.gif" alt="close" />');
		$('html, body').animate({scrollTop: targetOffset}, 500);
		tsutsumi_close = false;
	}
	else {
		$('#tsutsumi > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
		tsutsumi_close = true;
	}
});

$('#web2010 > h2').click(function () {
	targetOffset = $('#web2010').offset().top;
	$('#web2010 > div').slideToggle('fast');
	if(web2010_close == true){
		$('#web2010 > h2 > span').html('<img src="./img/article/works/close.gif" alt="close" />');
		$('html, body').animate({scrollTop: targetOffset}, 500);
		web2010_close = false;
	}
	else {
		$('#web2010 > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
		web2010_close = true;
	}
});

$('#web2009 > h2').click(function () {
	targetOffset = $('#web2009').offset().top;
	$('#web2009 > div').slideToggle('fast');
	if(web2009_close == true){
		$('#web2009 > h2 > span').html('<img src="./img/article/works/close.gif" alt="close" />');
		$('html, body').animate({scrollTop: targetOffset}, 500);
		web2009_close = false;
	}
	else {
		$('#web2009 > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
		web2009_close = true;
	}
});

$('#web2008 > h2').click(function () {
	targetOffset = $('#web2008').offset().top;
	$('#web2008 > div').slideToggle('fast');
	if(web2008_close == true){
		$('#web2008 > h2 > span').html('<img src="./img/article/works/close.gif" alt="close" />');
		$('html, body').animate({scrollTop: targetOffset}, 500);
		web2008_close = false;
	}
	else {
		$('#web2008 > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
		web2008_close = true;
	}
});



/*------- 閉じるボタン -------*/
$('#hayashi > div > .close').click(function () {
	$('#hayashi > div').slideToggle('fast');
	$('#hayashi > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
	hayashi_close = true;
});

$('#bishop > div > .close').click(function () {
	$('#bishop > div').slideToggle('fast');
	$('#bishop > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
	bishop_close = true;
});

$('#tsutsumi > div > .close').click(function () {
	$('#tsutsumi > div').slideToggle('fast');
	$('#tsutsumi > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
	tsutsumi_close = true;
});

$('#web2010 > div > .close').click(function () {
	$('#web2010 > div').slideToggle('fast');
	$('#web2010 > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
	web2010_close = true;
});

$('#web2009 > div > .close').click(function () {
	$('#web2009 > div').slideToggle('fast');
	$('#web2009 > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
	web2009_close = true;
});

$('#web2008 > div > .close').click(function () {
	$('#web2008 > div').slideToggle('fast');
	$('#web2008 > h2 > span').html('<img src="./img/article/works/open.gif" alt="open" />');
	web2008_close = true;
});
