var yomotsuPutSWF = {	
	
	conf : [
			//e.g.
			//{targetId:"#div1",filePath:"swf/movie.swf",width:500,height:200,ver:7},
		  {targetId:"#visualImage", filePath:"index.swf", width:485, height:242, ver:7}
	],
		
	pluginVer : 0,// <= do not change this.
	
	hideFlashArea : function(){
		var i, selectorText="";
		
		for( i in yomotsuPutSWF.conf ){
			selectorText += yomotsuPutSWF.conf[i]["targetId"]+",";
		}
		
		document.writeln('<style type="text/css">'+selectorText.slice(0,-1)+'{visibility:hidden;}</style>');
		/*
		if( document.styleSheets.length == 0 ){
			document.getElementsByTagName("head")[0].appendChild(document.createElement("style"));
		}
		
		for( i in yomotsuPutSWF.conf ){
			if( document.styleSheets[0].insertRule ) //!IE
				document.styleSheets[0].insertRule( yomotsuPutSWF.conf[i]["targetId"] + "{visibility:hidden;}", document.styleSheets[0].cssRules.length );
			else if( document.styleSheets[0].addRule ) //for IE
				document.styleSheets[0].addRule( yomotsuPutSWF.conf[i]["targetId"], "{visibility:hidden;}" );
		}
		*/
	},
	
	getFlashVer : function(){
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : null;
		if (navigator.mimeTypes["application/x-shockwave-flash"]) {
			yomotsuPutSWF.pluginVer = parseInt(plugin.description.replace(/Shockwave\sFlash\s/,''));
		}
		// for IE
		else{
			document.writeln('\n<script type="text/vbscript">');
			document.writeln('on error resume next');
			document.writeln('Dim Flash');
			document.writeln('Flash=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash"))');
			document.writeln('yomotsuPutSWF.pluginVer=Left(Hex(Int(CreateObject("ShockwaveFlash.ShockwaveFlash").FlashVersion)),1)');
			document.writeln('</sc'+'ript>');
			yomotsuPutSWF.pluginVer = parseInt(yomotsuPutSWF.pluginVer.replace(/0000$/,''),16);
		}
	},
	
	replaceSWF : function (){
		var i, putArea, object, param;
		for(i in yomotsuPutSWF.conf){
			putArea = document.getElementById(yomotsuPutSWF.conf[i].targetId.slice(1));
			if((yomotsuPutSWF.pluginVer>=yomotsuPutSWF.conf[i].ver)&&putArea){
				//put swf
				putArea.innerHTML = ('<object data="'+yomotsuPutSWF.conf[i].filePath+'" type="application/x-shockwave-flash" width="'+yomotsuPutSWF.conf[i].width+'" height="'+yomotsuPutSWF.conf[i].height+'"><param name="movie" value="'+yomotsuPutSWF.conf[i].filePath+'" /><param name="wmode" value="transparent" /></object>');
				/*
				putArea.innerHTML = ('<object data="'+yomotsuPutSWF.conf[i][1]+'" type="application/x-shockwave-flash" width="'+yomotsuPutSWF.conf[i][3]+'" height="'+yomotsuPutSWF.conf[i][3]+'"><param name="movie" value="'+yomotsuPutSWF.conf[i][1]+'" /></object>');
				
				putArea.innerHTML = ('');
				
				object = document.createElement("object");
				object.setAttribute("data",yomotsuPutSWF.conf[i][1])
				object.setAttribute("type","application/x-shockwave-flash")
				object.setAttribute("width",yomotsuPutSWF.conf[i][2])
				object.setAttribute("height",yomotsuPutSWF.conf[i][3])
				putArea.appendChild(object);
				
				param = document.createElement("param");
				param.setAttribute("name","movie")
				param.setAttribute("value",yomotsuPutSWF.conf[i][1])
				object.appendChild(param);
				
				param = document.createElement("param");
				param.setAttribute("name","wmode")
				param.setAttribute("value","transparent")
				object.appendChild(param);
				*/
			}
		}
	},
	
	showFlashArea : function(){
		var i;
		for( i in yomotsuPutSWF.conf ){
			/*
			if( document.styleSheets[0].insertRule ) //!IE
			document.styleSheets[0].insertRule( yomotsuPutSWF.conf[i]["targetId"] + "{visibility:visible;}", document.styleSheets[0].cssRules.length );
			else if( document.styleSheets[0].addRule ) //for IE
			document.styleSheets[0].addRule( yomotsuPutSWF.conf[i]["targetId"], "{visibility:visible;}");
			*/
			document.getElementById(yomotsuPutSWF.conf[i]["targetId"].slice(1)).style.visibility = "visible";
		}
	},
	
	start : function(){
		this.hideFlashArea();
		this.getFlashVer();
		try {
			window.addEventListener('load', this.replaceSWF, false);
			window.addEventListener('load', this.showFlashArea, false);
		} catch (e) {		
			window.attachEvent('onload', this.showFlashArea);
			window.attachEvent('onload', this.replaceSWF);
		}
	}
}

yomotsuPutSWF.start();