/**
 *	@ Script : init.js
 *	@ WebSite : Tankumakitamise
 *
 *	@ Author: Kosuke Nakatani
 *	@ Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
 *	
*/

$(function() {
	/* Slideshow */
	function slideshow() {
		_this = '#gallery img';
			var _current = 0,
			_time = 2000,
			_delay = 4000,
			_total = $(_this).size() - 1;
	
		function loop() {
			getCurrent();
			$(_this).eq(_current).delay(_delay).fadeIn(_time, function() {
				$(_this).eq(_current - 1).css('display','none');
				loop();
			});
		}
		function getCurrent() {
			if (_current >= _total) _current = -1;
			_current++;
			$(_this).eq(_current - 1).css('z-index','0');
			$(_this).eq(_current).css('z-index','10');
		}
	
		$(_this).css("display", "none");
		$(_this).eq(_current).css("display", "block");
		$(_this).eq(_current).delay(_delay).fadeIn(_time, loop);
	}
	slideshow();
	
	/* WindowsSize // Scroll Monitoring */
	function overfloMonitor() {
		var _height = Math.floor($('#footer').position().top) + 50;
		if (document.documentElement.clientHeight > _height) {
			$('html,body').css('overflow-y','hidden');
		} else {
			$('html,body').css('overflow-y','auto');			
		}
	}
	$(window).bind('resize', function() {
		var _timer = null;
		if (_timer) clearTimeout(_timer);
		_timer = setTimeout(overfloMonitor, 10);
	});
	overfloMonitor();
	
	/* Callback Flash */
	var flashvars = {};
	var params = {
		menu: "false",
		wmode: "transparent"
	};
	var attributes = {};
	swfobject.embedSWF("/swf/main.swf", "flashContents", "700", "900", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
});
