//----------------------------------------------------------------------------------------------------
//
//ImageScience::MediaContents::VERSION_2008.2.15
//
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
//FLASHファイルの配置
//----------------------------------------------------------------------------------------------------

/////////////////////
function embedFlash(theURL, theX, theY, theVirsion, theBGColor) {
	kazu=document.URL.indexOf("?");
	if(kazu>0){
	theURL=theURL+document.URL.substr(kazu,999);
	}
	if(theBGColor){
		toObject=' value="'+theBGColor+'"';
		toEmbed=' bgcolor="'+theBGColor+'"';
	}else{
		toObject="";
		toEmbed="";
	}
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+theVirsion+'" width="'+theX+'" height="'+theY+'" id="mainMovie" align="middle"><param name="allowFullScreen" value="true" /><param name="wmode" value="opaque" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+theURL+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor"'+toObject+' /><embed wmode="opaque" id="mainMovie" src="'+theURL+'" loop="false" menu="false" quality="high" width="'+theX+'" height="'+theY+'" name="mainMovie" allowFullScreen=true" align="middle" allowScriptAccess="sameDomain"'+toEmbed+' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
	if(location.href.indexOf("http://")>-1 || location.href.indexOf("https://")>-1){
	macmousewheel = new SWFMacMouseWheel(document.mainMovie);
	}else{
	//alert("localMode");
	}
	
	
}

//----------------------------------------------------------------------------------------------------
//FLASHプラグインチェック用
//----------------------------------------------------------------------------------------------------
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
function JSGetSwfVer(i) {
	if (navigator.plugins != null && navigator.plugins.length>0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash"+swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if (descArray[3] != "") {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			versionRevision = tempArrayMinor[1]>0 ? tempArrayMinor[1] : 0;
			flashVer = versionMajor+"."+versionMinor+"."+versionRevision;
		} else {
			flashVer = -1;
		}
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) {
		flashVer = 4;
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) {
		flashVer = 3;
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) {
		flashVer = 2;
	} else {
		flashVer = -1;
	}
	return flashVer;
}

//----------------------------------------------------------------------------------------------------
//FLASHプラグインチェック
//----------------------------------------------------------------------------------------------------
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
	reqVer = parseFloat(reqMajorVer+"."+reqRevision);	
	for (i=25; i>0; i--) {
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);
		}
		if (versionStr == -1) {
			return false;
		} else if (versionStr != 0) {
			if (isIE && isWin && !isOpera) {
				tempArray = versionStr.split(" ");
				tempString = tempArray[1];
				versionArray = tempString.split(",");
			} else {
				versionArray = versionStr.split(".");
			}
			versionMajor = versionArray[0];
			versionMinor = versionArray[1];
			versionRevision = versionArray[2];
			versionString = versionMajor+"."+versionRevision;
			// 7.0r24 == 7.24
			versionNum = parseFloat(versionString);
			// 
			if ((versionMajor>reqMajorVer) && (versionNum>=reqVer)) {
				return true;
			} else {
				return ((versionNum>=reqVer && versionMinor>=reqMinorVer) ? true : false);
			}
		}
	}
	return (reqVer ? false : 0.0);
}
//----------------------------------------------------------------------------------------------------
//表示非表示を切り替える
//----------------------------------------------------------------------------------------------------
function visibleChanger(ID1,ID2){
	$(ID1).style.display ="block";
	
	 $(ID2).style.display ="none";

}

//----------------------------------------------------------------------------------------------------
//フルスクリーンの場合、一定のサイズ以下でスクロールバーを出す
//----------------------------------------------------------------------------------------------------
function winMin(ataiX, ataiY) {
		if (document.all) {
			// for Internet Explorer
			winWidth = document.body.clientWidth;
			winHeight = document.body.clientHeight;
			if (winWidth<=ataiX) {
				objWidth = ataiX+15;
			} else {
				objWidth = "100%";
			}
			if ((winHeight<=ataiY)) {
				objHeight = ataiY+15;
			} else {
				objHeight = "100%";
			}
			if (document.mainMovie[0] && document.mainMovie[1]) {
				//for win
				document.mainMovie[0].width = objWidth;
				document.mainMovie[0].height = objHeight;
				document.mainMovie[1].width = objWidth;
				document.mainMovie[1].height = objHeight;
			} else {
				//for mac
				document.mainMovie.width = objWidth;
				document.mainMovie.height = objHeight;
			}
		} else {
			//
			if (window.innerWidth<=ataiX+15) {
				objWidth = ataiX+15;
			} else {
				objWidth = "100%";
			}
			if ((window.innerHeight<=ataiY+15)) {
				objHeight = ataiY+15;
			} else {
				objHeight = innerHeight;
			}
			if (navigator.userAgent.indexOf("Firefox", 0)>0) {
				document.mainMovie.width = objWidth;
				document.mainMovie.height = objHeight-10;
			} else {
				document.mainMovie.width = objWidth;
				document.mainMovie.height = objHeight;
			}
	}
}

//----------------------------------------------------------------------------------------------------
//マックでマウスホイールスクロール（リモートでのみ作動）
//----------------------------------------------------------------------------------------------------

function SWFMacMouseWheel(swfObject){
	this.so = swfObject;
	var isMac = navigator.appVersion.toLowerCase().indexOf( "mac" ) != -1;
	if( isMac ) this.init();
}

SWFMacMouseWheel.prototype = {
	
	init: function()
	{
		
		
		SWFMacMouseWheel.instance = this;
		if (window.addEventListener)
		{
	        window.addEventListener('DOMMouseScroll', SWFMacMouseWheel.instance.wheel, false);
		}
		window.onmousewheel = document.onmousewheel = SWFMacMouseWheel.instance.wheel;
	},
	
	handle: function( delta )
	{
		document[ this.so.getAttribute('id') ].externalMouseEvent( delta );
	},

	wheel: function(event){
		
        var delta = 0;
        if (event.wheelDelta) { /* IE/Opera. */
			delta = event.wheelDelta/120;
			if (window.opera) delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
            delta = -event.detail/3;
        }
        if( /AppleWebKit/.test(navigator.userAgent) ) {
        	delta /= 3;	
        }

        if (delta)
               SWFMacMouseWheel.instance.handle(delta);

        if (event.preventDefault) event.preventDefault();
		event.returnValue = false;
		
	}
};
