var yomotsuPutSWF = {	
	
	conf : [
			//e.g.
			//{targetId:"#div1",filePath:"swf/movie.swf",width:500,height:200,ver:7},
		  {targetId:"#floorMap", filePath:"index.swf",    width:630, height:383 , ver:7}
			
	],
		
	hideFlashArea : function(){
		var i, selectorText="";
		for( i = 0; i < yomotsuPutSWF.conf.length; i++ ){
			selectorText += yomotsuPutSWF.conf[i]["targetId"]+",";
		}
		document.writeln('<style type="text/css">'+selectorText.slice(0,-1)+'{visibility:hidden;}</style>');
	},
	
	getFlashVer : function(){
		var flashVer = 0;
		if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) {
			flash = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
			if (flash) {
				flashVer = flash.description.match(/(\d+(\.\d+)*) +r(\d+)/);
				if (flashVer) {
					flashVer = flashVer[1] + "." + ((flashVer.length >= 4) ? flashVer[3] : 0);
				}
			}
		}
		else if (typeof(ActiveXObject) == "object" || typeof(ActiveXObject) == "function") {
			try{
				flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				if(flash){
					flashVer = flash.GetVariable("$version");
					flashVer = flashVer.match(/(\d+(\,\d+)+)/)[1].replace(/,/g, ".");
				}
			}catch(e){}
		}
		
		return parseInt(flashVer);
	},
	
	replaceSWF : function (){
		var i, putArea, object, param;
		for(i = 0; i < yomotsuPutSWF.conf.length; i++){
			putArea = document.getElementById(yomotsuPutSWF.conf[i].targetId.slice(1));
			if((yomotsuPutSWF.getFlashVer()>=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+'" /></object>');
			}
		}
	},
	
	showFlashArea : function(){
		var i;
		for(i = 0; i < yomotsuPutSWF.conf.length; i++ ){
			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();