﻿/*
	--------------------------------
	Created: 2008.03.20
	Last Modified: 2008.06.09
	--------------------------------
	- Table of Contents -

	スプラッシュ
	--------------------------------
*/



/* --------------------------------
	スプラッシュ
-------------------------------- */
/*
var splash = new Splash();
$_.addEvent(window, 'load', function() { splash.init('splash', 'transform'); }, false);
*/
function Splash() {
	// 初期化
	this.init = function(foreground, background) {
		// クエリに [ splash=1 ] が指定されている場合はクッキーの状態にかかわらずスプラッシュを表示
		if (!location.search.match('(^[?]|&)splash=1(&|$)') && $_.getCookie('play')) {
			document.getElementById(background).style.visibility = 'visible';
		} else {
			this.isIE5 = navigator.userAgent.match('MSIE 5');
			this.foreground = $_.element('div', { id: foreground });// 前景
			$_('#body').appendChild(this.foreground);
			this.background = $_('#' + background);// 背景
			this.size = this.getSize(this.background);
			this.foreground.style.height = this.size.height + 'px';
			var so = new SWFObject('default/flash/splash.swf', 'splash_swf', this.size.width, this.size.height, '9', '#FFFFFF');
			so.addParam('allowScriptAccess', 'always');
			so.addParam('allowFullScreen', 'false');
			so.addParam('wmode', 'transparent');
			so.addVariable('height', this.size.height);
			so.write(this.foreground.id);
			this.show();
		}
	}

	// スプラッシュを表示
	this.show = function() {
		if (this.isIE5) $_('#bigad').style.visibility = 'hidden';
		this.foreground.style.display = 'block';
		this.background.style.visibility = 'visible';
	}

	// スプラッシュを非表示
	this.hide = function() {
		$_.setCookie('play', 1, 1000 * 60 * 60 * 24 * 7, '/');
		if (this.isIE5) $_('#bigad').style.visibility = 'visible';
		this.foreground.style.display = 'none';
	}

	// サイズの取得
	this.getSize = function(elm, mode) {
		var w = elm.offsetWidth || elm.clientWidth || 0;
		var h = elm.offsetHeight || elm.clientHeight || 0;
		return (mode == 'w') ? w : (mode == 'h') ? h : { width: w, height: h }
	}
}







