﻿// pre load.
jQuery.preloadImages = function() {
	for( var i = 0; i < arguments.length; i++)	{ jQuery("<img>").attr("src", arguments[i]); }
};
$.preloadImages( "img/all_navi01_on.gif", "img/all_navi02_on.gif", "img/all_navi03_on.gif", "img/all_navi04_on.gif", "img/all_navi05_on.gif", "img/all_navi06_on.gif");
$.preloadImages( "img/side_bnr01_on.gif", "img/side_navi01_on.gif", "img/side_navi02_cr.gif", "img/side_navi03_on.gif");

// shadowbox.
Shadowbox.init({ language: "jp", players: ["img"] });


// loaded.
$(document).ready(function(){
	
	// scroll setting.
	$(function(){
		$("a[href^='#']").click(function() {
			var href = this.hash;
			var $target = $(href == '#_top' ? 'body' : href);
	
			if($target.size()) {
				$.scrollTo( $target, 300, { easing: 'swing'});
			}
			return false;
		});
	});
	
	
	// loading footer setting.
	var level = ( $("#foot").html() )? $("#foot").html() : 0 ;
	var position = "";
	
	$("foot").html("")
	
	for( var i = 0; i < Number(level); i++){
		position = position + "../";
	}
	
	
	// loading footer.html
	$("#foot").load( position + "footer.html #foot > div", function(){
		
		// default position.
		$("#foot").css( "height", "55px");
		$("#foot").addClass( "close" );
		
		// image path setting.
		$("#foot img").each(function(){
			var src = $(this).attr("src");
			$(this).attr( "src", position + src );
		});
		
		// link path setting.
		$("#foot a").each(function(){
			// remove blank link.
			if( $(this).attr("target") != "_blank"){
				var href = $(this).attr("href");
				$(this).attr( "href", position + href );
			}
		});
		
		// click actions.
		$("#openlink").click(function(){
			//alert("open");
			
			//alert($("#foot").attr("class"));
			
			if( $("#foot").attr("class") == "close" ){
				
				$("#foot").animate({
					height: "295px"
				}, 300);
				
				$("#foot").removeClass();
				$("#foot").addClass( "open" );
			
			}
			else{
				
				$("#foot").animate({
					height: "55px"
				}, 300);
				
				$("#foot").removeClass();
				$("#foot").addClass( "close" );
			}
			
			return false;
		});
		$("#closelink").click(function(){
			//alert("close");
			
			$("#foot").animate({
				height: "55px"
			}, 300);
			
			$("#foot").removeClass();
			$("#foot").addClass( "close" );
			
			return false;
		});
	});
	
	
	// #index rollover.
	$("#index > dl > dd").each( function(){
		if( !$(this).attr("class") ){
			var href = $(this).children("a").attr("href");
			var add = href.substring( 3, href.length );
			add = ( add < 10 )? "0" + add : add ;
			$(this).children("a").prepend("<img src='" + position + "img/c04_no" + add + ".gif' alt='" + add + "' class='swap' />");
		}
	});
	
	$("#index > dl > dd > a").hover( function(){
		if( !$(this).parent().attr("class") ){
			var num = $(this).children("img:eq(0)").attr("alt");
			$(this).children("img:eq(0)").attr("src", position + "img/c04_no" + num + "_on.gif");
		}
	},
	function(){
		if( !$(this).parent().attr("class") ){
			var num = $(this).children("img:eq(0)").attr("alt");
			$(this).children("img:eq(0)").attr("src", position + "img/c04_no" + num + ".gif");
		}
	});
	
	
	
});
