﻿// ********* embed swf ********* //
var vars = {};
var params = { scale:'noScale', 
               salign:'lt', 
               menu:'false', 
               allowfullscreen :'true', 
               wmode:'opaque',
               useExpressInstall:'true'
             };
var attributes = { id:'ContentsGallery', name:'ContentsGalleryName'};
swfobject.embedSWF("ContentsGalleryRoot.swf", "flashContent", "100%", "100%", "9.0.0", "js/expressInstall.swf", vars, params, attributes );

/**********************************************************************
*ウィンドウの幅、高さを取得する
*getViewAreaWidth/Height():ブラウザの表示領域の大きさを返す。
*getHorizontalScroll():水平のスクロールバーの位置を返す。
*getVerticalScroll():垂直のスクロールバーの位置を返す。
**********************************************************************/
var Geometry = {};
Geometry.getViewAreaWidth = function(){return document.body.clientWidth;};
Geometry.getViewAreaHeight = function(){return document.body.clientHeight;};

// ********* SwfResizer Object ********* //
var SwfResizer = {
	minW : 1024,
	minH : 768,
	fullscreen : 0,

	getElementById: function(idStr) {
		var elm = null;
		if (document.all && !document.getElementById) {
			elm = document.all[idStr];
		} else {
			elm = document.getElementById(idStr);
		}
		return elm;
	},
	// ********* window resize handler ********* //
	resizeHandler : function() {
		if (this.fullscreen) {
			this.fullArea();
		} else {
			this.freeUpMinArea();
		}
	},
	fullArea : function() {
		document.overflow = 'hidden';
		this.getElementById('flashContainer').style.width = Geometry.getViewAreaWidth();
		this.getElementById('flashContainer').style.height = Geometry.getViewAreaHeight();
	},
	freeUpMinArea : function() {
		// offset size
		var w = Geometry.getViewAreaWidth();
		var h = Geometry.getViewAreaHeight();
		// resize 'flashContainer'
		this.getElementById('flashContainer').style.width = (w > this.minW) ? w : this.minW;
		this.getElementById('flashContainer').style.height = (h > this.minH) ? h : this.minH;
	}
};

// ********* add event listener ********* //
var addEvent = (window.addEventListener) ? 
	(function(elm, type, event) {
		elm.addEventListener(type, event, false);
	}) : (window.attachEvent) ? 
	(function(elm, type, event) {
		elm.attachEvent('on' + type, event);
	}) : 
	(function(elm, type,  event) {
		elm['on' + type] = event;
	});
addEvent(window, 'load', function(){
	addEvent(window, 'resize', function(){SwfResizer.resizeHandler();});
});

// ********* Call FROM ActionScript ********* //
function resizeCalledFromAS(menuName) {
	if (menuName == 'Menu1' || menuName == 'Menu2'
	 || menuName == 'Menu3' || menuName == 'Menu4'
	 || menuName == 'Menu5') {
		SwfResizer.fullscreen = 1;
	} else {
		SwfResizer.fullscreen = 0;
	}
	SwfResizer.resizeHandler();
	return true;
}
