/*
#########################################################
#get Flash version method.
#show Flash Movie & image method.
#ex.JavaScript & VB Script.
#copyright: http://www.enneaplanet.com/
#editing: medal, Co,Ltd.
#########################################################
*/
// Judgment of version of a browser.
function versionCheck(){
	var is = new Is_env();
	var flag = (( is.OPERA && is.getBrowserVersion().substr(0,1)>= 6 ) ||
		( is.NN4X && is.getBrowserVersion().substr(0,3).toString()!='4.0' ) ||
		is.IE5X_UP || is.NN6X_UP || !is.IE45 ) ? true : false;

	return flag;
}

// Browsers other than WIN+MSIE are judged with JS.
function getJSFlashVersion() {
	var versionDelimiter = "r";

	for(var i=0; i<navigator.plugins.length; i++){
		var myPlugin = navigator.plugins[i];
		var myName = myPlugin.name;
		var myDesc = myPlugin.description;

		if(myName.indexOf("Shockwave")!=-1 && myName.indexOf("Flash")!=-1){
			var flashVersion = myDesc.substring(myDesc.indexOf("Flash")+6);
			var delimiterPos = flashVersion.indexOf(versionDelimiter);

			if(delimiterPos !=-1){
				var majarVersion = flashVersion.substring(0, delimiterPos);
				var minorVersion = parseInt(flashVersion.substring(delimiterPos+2));

				if(majarVersion<10) {
					minorVersion = "0"+minorVersion;
					return parseFloat(majarVersion + minorVersion);
				}else{
					return parseFloat(flashVersion);
				}
			}else{ //OS X Flash player 8 beta
				return parseFloat(flashVersion);
			}
		}
	}

	return Number(0);
}


// It judges with VBScript for WIN+MSIE.
function getVBFlashVersion(max) {
	var count_max = max; //Version examined first
	for( var i=count_max; i>0; i--){
		var flashVersion = getFlashControlVersion(i); //VBScript loading
		if(flashVersion !=0){
			var majarVersion = flashVersion >> 16;
			var minorVersion = flashVersion & 0x0000ffff;
			return parseFloat(majarVersion + '.' + minorVersion);
		}
	}

	return Number(0);
}


// Judgment of version of FLASH
function getFlashVersion() {
	var is = new Is_env();
	var max=6; //Version examined with VBScript first

	if(is.IE45) var flashVarsion = Number(0);
	else if(is.WIN && document.all && !is.OPERA) var flashVarsion = getVBFlashVersion(max);
	else var flashVarsion = getJSFlashVersion();

	//alert(flashVarsion);
	return flashVarsion;
}


/* 
#####################################################################################################################
# Plug-in of FlashPlayer is investigated, when there is nothing a problem, SWF is written out, 
# and a still picture is displayed at the time of NG.
# //new FlashDispatcher( requestVersion, swfFile, altImage, width, height,menuitem[true|false],bgcolor,
# windowmode[opaque|transparent], [JumpURL])
#####################################################################################################################
*/
function FlashDispatcher( requestVersion, swfFile, altImage, width, height, 
			menuitem, bgcolor, winmode, JumpURL, JumpTarget, pram, align, swfName, fullvalue ){
	this.requestVersion = requestVersion;
	this.swfFile  = swfFile;
	this.altImage = altImage;
	this.width    = width;
	this.height   = height;
	this.menuitem = menuitem;
	this.bgcolor  = bgcolor;
	this.wmode    = winmode;
	this.value    = pram;
	this.align    = align;
	this.name     = swfName;

	if(fullvalue == null || fullvalue == "undefined" || fullvalue == ""){
		this.fullscreen = false;
	}else{
		this.fullscreen = fullvalue;
	}

	if( JumpURL ){
		if( JumpTarget ){
			this.pageJump( JumpURL, JumpTarget );
		}else{
			this.pageJump( JumpURL, null );
		}
	}
}

//A page is changed when the jump place is specified.
FlashDispatcher.prototype.pageJump = function( JumpURL, JumpTarget ){
	var targetBrowser = versionCheck();
	var flashVersion  = getFlashVersion();

	if(flashVersion != 0){
		if( !targetBrowser || (flashVersion < this.requestVersion)){
			//the case where the window name is not specified -- or -- Case where it is _self
			//It's page changed.
			if(JumpTarget == null || JumpTarget == "_self" || JumpTarget == ""){
				//location.replace( JumpURL );
				top.location.href=JumpURL;
			}else{
				//A new page is displayed when the window name is specified.
				//openWin( JumpURL, JumpTarget, true, 'width=800,height=600', 0, 0);
				focusWin( JumpURL, JumpTarget, "WH", null, null, true );
			}
		}
	}else{
		alert("You are using an old version of Adobe Flash Player. Please install the newest version.");
	}
}


FlashDispatcher.prototype.writealerts = function( pram, path ){
	if(pram == '_root'){
document.write( '<div id="alertMsg" class="m1em">\n' );
document.write( '<h2>You are using an old version of Adobe Flash Player. Please install the newest version.</h2>\n');
document.write( '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="'+ path +'images/get_shock_player.gif" border="0" width="88" height="31" alt="get Flash player" title="get Flash player" class="mt6 mb6" /></a><br />\n');
document.write( '<p>This website uses');
document.write( '<a href="http://www.adobe.com/jp/products/studio/" target="_blank" class="white">Adobe<sup>&reg;</sup> Flash<sup>TM</sup></a></p>\n');
document.write( '<p>You will not be able to view this site because you are using an old version of Adobe Flash Player, or you do not have it installed.</p>\n');
document.write( '<p>Pleas download and install the newest version by clicking the banner above. The process will not take long.</p>\n');
document.write( '<hr class="mt6 mb6" />\n' );
document.write( '<p>Adobe<sup>&reg;</sup> and Flash<sup>TM</sup> are registered trademarks of Adobe Systems Incorporated.</p>\n' );
document.write( '</div>' );
	}
}


//A still picture is written out when a browser and plug-in is below the demand here.
//* A still picture will be displayed if true is passed to thisPageVisited.
//(It uses by cookie after the second time to display a still picture)
FlashDispatcher.prototype.writeContents = function( thisPageVisited, path ){
	var targetBrowser = versionCheck();
	var flashVersion  = getFlashVersion();

	document.open("text/html");

	if( targetBrowser ){
		if(( flashVersion < this.requestVersion ) || thisPageVisited ){
			this.writealerts( '_root', path );
		}else{
//flash write
document.write( '<object classid ="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write( 'codebase  ="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
document.write( 'id        ="'+ this.name +'" ');
document.write( 'width     ="'+ this.width +'" ');
document.write( 'height    ="'+ this.height +'" ');
document.write( 'align     ="'+ this.align +'"');
document.write( '>\n');
document.write( '<param name="movie" value="'+ this.swfFile +'" />\n');
document.write( '<param name="quality" value="high" />\n' );
document.write( '<param name="scale" value="showall" />\n');
document.write( '<param name="menu" value="'+ this.menuitem +'" />\n');
document.write( '<param name="bgcolor" value="'+ this.bgcolor +'" />\n');
document.write( '<param name="allowFullScreen" value="'+ this.fullscreen +'" />\n');
document.write( '<param name="wmode" value="'+ this.wmode +'" />\n');
document.write( '<param name="flashvars" value="pram='+ this.value +'" />\n');
document.write( '<embed src ="'+ this.swfFile +'" ');
document.write( 'quality="high" ');
document.write( 'scale     ="showall" ');
document.write( 'name      ="'+ this.name +'" ');
document.write( 'menu      ="'+ this.menuitem +'" ');
document.write( 'bgcolor   ="'+ this.bgcolor +'" ');
document.write( 'width     ="'+ this.width + '" ');
document.write( 'height    ="'+ this.height + '" ');
document.write( 'allowFullScreen="'+ this.fullscreen +'" ');
document.write( 'wmode     ="'+ this.wmode +'" ');
document.write( 'align     ="'+ this.align +'" ');
document.write( 'flashvars ="pram='+ this.value +'" ');
document.write( 'type      ="application/x-shockwave-flash" ');
document.write( 'pluginspage ="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
document.write( '</embed></object>');
		}
	}

	document.close();
}

