//define attributes.
var SRC_URL 				= "http://www.ambition.ne.jp/matchbow/pc/parts/";
var SWF_FILE 				= "fool.swf";
var MATCHBOW_DIV_ID = "matchbow_bp_id";

var SWF_FILE_FLOAT 	= SRC_URL + "fool2.swf";
var BACKGROUND_IMG	= SRC_URL + "back.png";

var FLOAT_ID 				= "Floating";
var BACKGROUND_ID 	= "FloatingBg";
var SHOW_TICKER_FLG = 0;


/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/*
 * SWFObject end
 */


// MacIEチェックを行う
isMacIE = checkMacIE();

function ShowPage(sMode){
	var oLayer;
	var sId;
	var iLayerTop;
	var iLayerWidth;
	var iLayerHeight;


	// 非表示モードの場合
	if(sMode != 1) {
		
		location.reload();
		return;
		
		// オブジェクトIDを作成する
		sId = FLOAT_ID;
		oLayer = document.getElementById(sId);
		
		// オブジェクトを削除する
		oLayer.style.display='none';
		oLayer.innerHTML='';

		// オブジェクトIDを作成する
		sId = BACKGROUND_ID;
		oLayer = document.getElementById(sId);
		
		// オブジェクトを削除する
		oLayer.style.display='none';
		oLayer.innerHTML='';
		
		// フラグを更新する
		SHOW_TICKER_FLG = 0;
		
		// 自動調整をオフにする
		clearInterval(iIntervalId);
		clearInterval(iIntervalBgId);
		
		return;
	}
	
	
	// 現在表示されている場合
	if(SHOW_TICKER_FLG == 1){

		return;
		
	// 現在表示されていない場合
	} else {
		
		// 表示モードの場合
		if(sMode == 1){

			// 背景作成
			oLayer = document.createElement('DIV');
			oLayer.id = BACKGROUND_ID;

			oLayer.style.position = "absolute";
			oLayer.style.zIndex = 999;
			oLayer.style.display = "block";
			
			// レイヤーサイズ計算
			iLayerWidth = getWindowSize("width");
			iLayerHeight = getWindowSize("height");

			if(checkBrowserMode()){
				oLayer.style.width = iLayerWidth + "px";
				oLayer.style.height = iLayerHeight + "px";
				oLayer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + BACKGROUND_IMG  + ", sizingmethod=scale)";

			} else {
				oLayer.style.width = "100%";
				oLayer.style.height = "100%";
				oLayer.style.backgroundImage = "url('" + BACKGROUND_IMG + "')";
			}

			// フローティングレイヤーにスタイルを指定する
			oLayer.style.top = getScrollPos("top") + "px";
			oLayer.style.left = getScrollPos("left") + "px";

			// SWFタグを作成する
			var sHtml = "&nbsp;";
			
			// SWFを挿入する
			oLayer.innerHTML = sHtml;
			
			// オブジェクトを追加する
			document.getElementsByTagName('body')[0].appendChild(oLayer);

			iIntervalBgId = setInterval("setLayPos('" + BACKGROUND_ID + "')", 100);
			
			// Flash表示用レイヤー
			// オブジェクトを作成する
			oLayer = document.createElement('DIV');
			oLayer.id = FLOAT_ID;

			oLayer.style.position = "absolute";
			oLayer.style.zIndex = 1000;
			oLayer.style.display = "block";
			
			// フローティングレイヤーのサイズを算出する
			iLayerWidth = getWindowSize("width");
			iLayerHeight = getWindowSize("height");

			if(checkBrowserMode()){
				oLayer.style.width = iLayerWidth + "px";
				oLayer.style.height = iLayerHeight + "px";

			} else {
				oLayer.style.width = "100%";
				oLayer.style.height = "100%";
			}

			// フローティングレイヤーにスタイルを指定する
			oLayer.style.top = getScrollPos("top") + "px";
			oLayer.style.left = getScrollPos("left") + "px";

			//フラッシュのサイズ指定
			var fla_width  = 1024;
			var fla_height = 768;

			if(document.body.clientHeight < 768){
				fla_height = document.body.clientHeight;
				fla_width  = 1024 * (document.body.clientHeight/768)
			}

			// SWFタグを作成する
			var sHtml = "";
			sHtml += '<table style="background-color:transparent; border:none; padding:0; margin:0; text-align:center; vertical-align:middle"  border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">';
			sHtml += '<tr><td align="center" valign="middle" style="padding:0; margin:0; border:none; background-color:transparent; text-align:center; vertical-align:middle">';
			sHtml += '<object id="fool2" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fla_width +'" height="'+ fla_height +'" align="middle">';
			sHtml += '<param name="bgcolor" value="#FFFFFF" />';
			sHtml += '<param name="allowScriptAccess" value="always" />';
			sHtml += '<param name="movie" value="' + SWF_FILE_FLOAT + '" />';
			sHtml += '<param name="quality" value="high" />';
			sHtml += '<param name="wmode" value="transparent" />';
			sHtml += '<param name="salign" value="lt" />';
			sHtml += '<param name="SWLIVECONNECT" value="TRUE" />';
			sHtml += '<param name="FlashVars" value="dur=' + document.URL + '" />';			
			sHtml += '<embed bgcolor="#FFFFFF" SWLIVECONNECT="TRUE" salign="lt" align="middle" src="' + SWF_FILE_FLOAT + '" FlashVars="dur='+document.URL+'" quality="high" wmode="transparent" width="'+ fla_width +'" height="'+ fla_height +'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			sHtml += '</object>';
			sHtml += '</td></tr></table>';
			
			// SWFを挿入する
			oLayer.innerHTML = sHtml;
			
			// オブジェクトを追加する
			document.getElementsByTagName('body')[0].appendChild(oLayer);

			//レイヤー順序指定
			oLayer.style.zIndex = '1150000';
			
			iIntervalId = setInterval("setLayPos('" + FLOAT_ID + "')", 100);
			
			// フラグを変更する
			SHOW_TICKER_FLG = 1;
		}
	}
	
	// MacIEの場合
	if(isMacIE == 1){
		// 再レンダリングする
		window.scrollBy(0, 1);
	}
	
}

function setLayPos(sId){
	var oTarget = document.getElementById(sId);

	if(checkBrowserMode()){
		oTarget.style.width = getWindowSize("width") + "px";
		oTarget.style.height = getWindowSize("height") + "px";
	}
	
	oTarget.style.top = getScrollPos("top") + "px";
	oTarget.style.left = getScrollPos("left") + "px";
}

function getScrollPos(sMode){

	var iScrollPosition;

	if(sMode == "left"){
		if(self.pageXOffset){
			iScrollPosition = self.pageXOffset;
		// Explorer 6 Strict
		}else if(document.documentElement && document.documentElement.scrollLeft){
			iScrollPosition = document.documentElement.scrollLeft;
		// all other Explorers
		}else if(document.body){
			iScrollPosition = document.body.scrollLeft;
		}
	} else {

		if(self.pageYOffset){
			iScrollPosition = self.pageYOffset;
		// Explorer 6 Strict
		}else if(document.documentElement && document.documentElement.scrollTop){
			iScrollPosition = document.documentElement.scrollTop;
		// all other Explorers
		}else if(document.body){
			iScrollPosition = document.body.scrollTop;
		}
	}
	
	return iScrollPosition;
}

function getWindowSize(sMode){
	var iWindowWidth, iWindowHeight;
	
	// all except Explorer
	if(self.innerHeight){
		iWindowWidth = self.innerWidth;
		iWindowHeight = self.innerHeight;
	// Explorer 6 Strict Mode
	}else if(document.documentElement && document.documentElement.clientHeight){
		iWindowWidth = document.documentElement.clientWidth;
		iWindowHeight = document.documentElement.clientHeight;
	// other Explorers
	}else if(document.body){
		iWindowWidth = document.body.clientWidth;
		iWindowHeight = document.body.clientHeight;
	}
	
	if(sMode == "width"){
		return (iWindowWidth);
	} else {
		return (iWindowHeight);
	}
}
	

function checkMacIE(){
	var sOs = getOS();
	var sNavigator = getNavi();
	
	if((sOs == "MacOSX" || sOs == "MacOS") && sNavigator == "Explorer"){
		return true;
	} else {
		return false;
	}
}

function checkBrowserMode(){
	var sOs = getOS();
	var sBrowser = getNavi();

	if(sOs == "Windows" && sBrowser == "Explorer"){
		return true;
	}
	return false;
}


function getOS()
{
	var uAgent  = navigator.userAgent.toUpperCase();
	if (uAgent.indexOf("MAC OS X") >= 0) return "MacOSX";
	if (uAgent.indexOf("MAC") >= 0) return "MacOS";
	if (uAgent.indexOf("WIN") >= 0) return "Windows";
	if (uAgent.indexOf("X11") >= 0) return "UNIX";
	return "";
}

function getNavi(){
	if(navigator.IBM_HPR) return "HomepageReader";
	
	aName  = navigator.userAgent.toUpperCase();
	if (aName.indexOf("SAFARI") >= 0) return "Safari";
	if (aName.indexOf("CHIMERA") >= 0) return "Camino";
	if (aName.indexOf("OPERA") >= 0) return "Opera";
	
	aName = navigator.appName.toUpperCase();
	if (aName.indexOf("NETSCAPE") >= 0)  return "Netscape";
	if (aName.indexOf("MICROSOFT") >= 0) return "Explorer";
	return "";
}

document.write('<div id="div' + MATCHBOW_DIV_ID + '"></div>');
setTimeout( function() {
	var so = new SWFObject( SRC_URL + SWF_FILE + "?" + (new Date().getTime()), MATCHBOW_DIV_ID, "160", "250", "9", "#ffffff");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "always");
	so.addVariable("dur", document.URL);
	so.write( document.getElementById("div" + MATCHBOW_DIV_ID ) );
}, 1 );
