// JavaScript Document

/*

	fadeImageGallery JS
	inputAutoEdit JS
	minatoNow Include

*/
/*--------------------------------------------------------

	fadeImageGallery JS

---------------------------------------------------------*/
(function($) {
	$.fn.fadeImageGallery = function(options){
		var element = this;
		// Option
		var conf = $.extend({
			changeInterval:		4000,
			target:				"dl",
			textArea:			"dd",
			moveSize:			60,
			moveDefaultSize:	0,
			handler:			"span",
			handlerClass:		"open",
			handlermoveSize:	20
		}, options);

		// Load Setting
		$(element).each(function(){
			$(this).append("<" + conf.handler + "></" + conf.handler + ">")
		});

		$(conf.target + ":not(:first)",element).hide();

		// Hover Event
		$(element).hover(function(){
			clearInterval(fadeImageTimer);
		},function(){
			fadeImage();
		});

		// Click Event
		$(conf.handler,element).click(function(){
			if(!$(this).hasClass(conf.handlerClass)){
				$(conf.textArea,element).stop(true,true).animate({bottom:"-=" + conf.moveSize + "px"},"fast");
				$(this).stop(true,true).animate({bottom:"-=" + conf.handlermoveSize + "px"},"fast");
			}else{
				$(conf.textArea,element).stop(true,true).animate({bottom:"+=" + conf.moveSize + "px"},"fast", function() {
					$(conf.textArea,element).css({bottom: conf.moveDefaultSize});
				});
				$(this).stop(true,true).animate({bottom:"+=" + conf.handlermoveSize + "px"},100);
			}
			$(conf.handler,element).toggleClass(conf.handlerClass);
		});

		// Timer Event
		var fadeImage = function () {
			fadeImageTimer = setInterval(function(){
				$(conf.target + ":first-child",element).fadeOut("slow").next(conf.target).fadeIn().end().appendTo(element);
				$(conf.handler,element).appendTo(element);
			},conf.changeInterval);
		}
		fadeImage();
	return this;
	};
})(jQuery);

$(function(){
	$("#photoGallery").fadeImageGallery();
});

/*--------------------------------------------------------

	inputAutoEdit JS
	For common.js
	
---------------------------------------------------------*/
$(function(){
	$("#subMobile form").inputAutoEdit();
});

/*--------------------------------------------------------

	minatoNow Include
	
---------------------------------------------------------*/
$(function(){
	$("#minatoNow div").load("/common/include/minato_now.html dl",function(){
		$(this).hide().fadeIn();
	});	   
});
