/*
 * windowFade - jQuery Plugin
 *
 * Copyright (c) DESIGN inc. All Rights Reserved.
 * http://www.design-inc.jp/
 *
 */

(function($){
	$.fn.windowFade = function(options){
		
		var settings = $.extend({
		}, options);
		
	
		$('#fade').each(function(){
			$('a').not('a.home').click(function(){
				var url = $(this).attr('href');
				if( this.href.match(location.hostname) && $(this).attr("href").charAt(0) != "#" && !$(this).attr("rel") && !$(this).attr("target") ){
					var LinkURL = $(this).attr("href");
					$('#fade').fadeIn(1000,function(){
						location.href = LinkURL;
					});
				return false;
				}
			});
			$('a.home').click(function(){
				var url = $(this).attr('href');
				if( this.href.match(location.hostname) && $(this).attr("href").charAt(0) != "#" && !$(this).attr("rel") && !$(this).attr("target") ){
					var LinkURL = $(this).attr("href");
					$('#fade-home').fadeIn(1000,function(){
						location.href = LinkURL;
					});
				return false;
				}
			});
		});
		
		return this;
	};
})(jQuery);

jQuery(function(){
	
	//#homeでは#fadeは消して、#fade-homeをフェードイン
	$('head').append('<style type="text/css">#fade-home{display:block;height:' + $(window).height() + 'px}</style>');
	$('#home #fade').hide().height($('body').height());
	$('#home #fade-home').fadeOut(1000).height($('body').height());
	
	//#lowerでは#fade-homeは消して、#fadeをフェードイン
	$('head').append('<style type="text/css">#fade{display:block;height:' + $(window).height() + 'px}</style>');
	$('#lower #fade-home').hide().height($('body').height());
	$('#lower #fade').fadeOut(1000).height($('body').height());
	
});

jQuery(window).load(function(){
    $.fn.windowFade();
});

