﻿$(window).load(function() {
	$("div#intro").delay(800).fadeOut(500);
});



$(function(){
	$(window).hashchange( function(){

		var hash = location.hash;
		if(hash != "#HOME" && hash != ""){
			document.title = hash.replace( /^#/, '' ) + ' - グラフィカルノイズ';
		} else {
			document.title = 'グラフィカルノイズ';
		}

		$("body[id='state-home']").each( function(){ //from home

			if(hash == "#ABOUT"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-about" ).children("div#nav").css("backgroundPosition","0px -17px").nextAll("div#bgimage").fadeOut(100).prevAll("a#toplogo,div#lastnote").fadeOut(200);
				$(this).children("div#about,div#nav-bg").css("z-index","110").delay(600).fadeIn(300);
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}

			if(hash == "#PORTFOLIO"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-portfolio" ).children("div#nav").css("backgroundPosition","0px -17px").nextAll("div#bgimage").fadeOut(100).prevAll("a#toplogo,div#lastnote").fadeOut(200);
				$(this).children("div#portfolio,div#nav-bg").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}

			if(hash == "#WORKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-works" ).children("div#nav").css("backgroundPosition","0px -17px").nextAll("div#bgimage").fadeOut(100).prevAll("a#toplogo,div#lastnote").fadeOut(200);
				$(this).children("div#works,div#nav-bg").css("z-index","110").delay(600).fadeIn(300);
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}

			if(hash == "#LINKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-links" ).children("div#nav").css("backgroundPosition","0px -17px").nextAll("div#bgimage").fadeOut(100).prevAll("a#toplogo,div#lastnote").fadeOut(200);
				$(this).children("div#links,div#nav-bg").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}

		});


		$("body[id='state-about']").each( function(){ //from about
			if(hash == "#HOME" || hash == ""){
				$(this).animate({backgroundColor:"#0074df"}, 300).attr("id", "state-home" ).children("div#nav").css("backgroundPosition","0px 0px").prevAll("div#about,div#nav-bg").css("z-index","-10").fadeOut(100);
				$(this).children("a#toplogo,div#bgimage,div#lastnote").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}
			if(hash == "#PORTFOLIO"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-portfolio" ).children("div#about").css("z-index","-10").fadeOut(300);
				$(this).children("div#portfolio").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
			}
			if(hash == "#WORKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-works" ).children("div#about").css("z-index","-10").fadeOut(300);
				$(this).children("div#works").css("z-index","110").delay(600).fadeIn(300);
			}
			if(hash == "#LINKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-links" ).children("div#about").css("z-index","-10").fadeOut(300);
				$(this).children("div#links").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
			}
		});

		$("body[id='state-portfolio']").each( function(){ //from portfolio
			if(hash == "#HOME" || hash == ""){
				$(this).animate({backgroundColor:"#0074df"}, 300).attr("id", "state-home" ).children("div#nav").css("backgroundPosition","0px 0px").prevAll("div#portfolio,div#nav-bg").css("z-index","-10").fadeOut(100);
				$(this).children("a#toplogo,div#bgimage,div#lastnote").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}
			if(hash == "#ABOUT"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-about" ).children("div#portfolio").css("z-index","-10").fadeOut(300);
				$(this).children("div#about").css("z-index","110").delay(600).fadeIn(300);
			}
			if(hash == "#WORKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-works" ).children("div#portfolio").css("z-index","-10").fadeOut(300);
				$(this).children("div#works").css("z-index","110").delay(600).fadeIn(300);
			}
			if(hash == "#LINKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-links" ).children("div#portfolio").css("z-index","-10").fadeOut(300);
				$(this).children("div#links").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
			}
		});

		$("body[id='state-works']").each( function(){ //from works
			if(hash == "#HOME" || hash == ""){
				$(this).animate({backgroundColor:"#0074df"}, 300).attr("id", "state-home" ).children("div#nav").css("backgroundPosition","0px 0px").prevAll("div#works,div#nav-bg").css("z-index","-10").fadeOut(100);
				$(this).children("a#toplogo,div#bgimage,div#lastnote").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}
			if(hash == "#ABOUT"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-about" ).children("div#works").css("z-index","-10").fadeOut(300);
				$(this).children("div#about").css("z-index","110").delay(600).fadeIn(300);
			}
			if(hash == "#PORTFOLIO"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-portfolio" ).children("div#works").css("z-index","-10").fadeOut(300);
				$(this).children("div#portfolio").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
			}
			if(hash == "#LINKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-links" ).children("div#works").css("z-index","-10").fadeOut(300);
				$(this).children("div#links").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
			}
		});

		$("body[id='state-links']").each( function(){ //from links
			if(hash == "#HOME" || hash == ""){
				$(this).animate({backgroundColor:"#0074df"}, 300).attr("id", "state-home" ).children("div#nav").css("backgroundPosition","0px 0px").prevAll("div#links,div#nav-bg").css("z-index","-10").fadeOut(100);
				$(this).children("a#toplogo,div#bgimage,div#lastnote").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
				$(this).children("div#nav").children("a").css("display","none").delay(200).fadeOut(1, function(){
					$(this).css("display","block");
				});
			}
			if(hash == "#ABOUT"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-about" ).children("div#links").css("z-index","-10").fadeOut(300);
				$(this).children("div#about").css("z-index","110").delay(600).fadeIn(300);
			}
			if(hash == "#PORTFOLIO"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-portfolio" ).children("div#links").css("z-index","-10").fadeOut(300);
				$(this).children("div#portfolio").css("z-index","110").delay(600).fadeIn(300, function(){
					$(this).css('filter','');
				});
			}
			if(hash == "#WORKS"){
				$(this).animate({backgroundColor:"#f0f0f0"}, 300).attr("id", "state-works" ).children("div#links").css("z-index","-10").fadeOut(300);
				$(this).children("div#works").css("z-index","110").delay(600).fadeIn(300);
			}
		});

	});
	$(window).hashchange();
});


$(function(){
	$("div#sns > div.clearfix > a:eq(0)").hover( function(){$(this).parent("div.clearfix").next("div#popup").css("left","-27px").stop(true, true).fadeIn(400).children("div#circle").css("backgroundPosition","-417px 33px");},
	function(){$(this).parent("div.clearfix").next("div#popup").stop(true, true).fadeOut(300);});
});

$(function(){
	$("div#sns > div.clearfix > a:eq(1)").hover( function(){$(this).parent("div.clearfix").next("div#popup").css("left","-7px").stop(true, true).fadeIn(400).children("div#circle").css("backgroundPosition","-417px -184px");},
	function(){$(this).parent("div.clearfix").next("div#popup").stop(true, true).fadeOut(300);});
});

$(function(){
	$("div#sns > div.clearfix > a:eq(2)").hover( function(){$(this).parent("div.clearfix").next("div#popup").css("left","13px").stop(true, true).fadeIn(400).children("div#circle").css("backgroundPosition","-417px -141px");},
	function(){$(this).parent("div.clearfix").next("div#popup").stop(true, true).fadeOut(300);});
});


$(document).ready(function(){
	$("div.workslist span.coveroff").click(function(){
		$(this).css("backgroundPosition","-84px -70px").prev().css("backgroundPosition","-84px -82px").prev().fadeOut(700);
	});
});

$(document).ready(function(){
	$("div.workslist span.coveron").click(function(){
		$(this).next().css("backgroundPosition","-84px -82px").prev().css("backgroundPosition","-84px -70px").prev().fadeIn(700);
	});
});



var i;
var img = 4;
var imgs = new Array(img);

for(i = 0; i <= img; i++){
	imgs[i] = new Image();
}

imgs[0].src = "http://gnrsr.com/images/aboutbg.png";
imgs[3].src = "http://gnrsr.com/pic/little-library.jpg";

