/////// マウスオーバー //////

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/////// 別ウインドウオープン //////

function wopen(url)
{
    newwindow = window.open(url, "newwindow");
    newwindow.focus();
}


////// デジタルリユース専用ウインドウオープン //////

function dreuse_open(url)
{
    reusewindow =window.open(url,"dreuse","toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
    reusewindow.focus();
}


////// MDA用OS表記部専用ウインドウオープン //////

function WgaWinOpen()
{
    window.open("http://www.fmworld.net/ms/wga/index.html","wga","width=900,height=742,fullscreen=no,toolbar=yes,scrollbars=yes,location=yes,menubar=yes,status=yes,resizable=yes");
}

/////// フォトギャラリー用ウインドウオープン //////

function swopen(url,xlength,ylength,scbar,lbar,mbar,rhand,stbar,tbar,dbar)
{
    option = "width=" + xlength + ",height=" + ylength + ",scrollbars=" + scbar + ",location=" + lbar + ",menubar=" + mbar + ",resizable=" + rhand + ",status=" + stbar + ",toolbar=" + tbar + ",directories=" + dbar;
    newwin = window.open(url,"regulation",option);
    newwin.focus();
}

////// Flashの代替表示 //////

var MM_contentVersion = 8;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

	if ( plugin ) {
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		    for (var i = 0; i < words.length; ++i)
		    {
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i];
		    }
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
	   && (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<scr' + 'ipt language=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
		document.write('</scr' + 'ipt\> \n');
	}
function flashPlugin(swf,width,height,img) {
	if ( MM_FlashCanPlay ) {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write('        codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
		document.write('        width   ="' + width + '"');
		document.write('        height  ="' + height + '"');
		document.write('        class   ="vbottom">');
		document.write('<param  name    ="movie" value="' + swf + '" />');
		document.write('<param  name    ="quality" value="high" />');
		document.write('<param  name    ="wmode" value="opaque" />');
		document.write('<param  name    ="allowScriptAccess" value="sameDomain" />');
		document.write('<embed  src     ="' + swf + '"');
		document.write('        width   ="' + width + '"');
		document.write('        height  ="' + height + '"');
		document.write('        class   ="vbottom"');
		document.write('        quality ="high"');
		document.write('        wmode ="opaque"');
		document.write('        allowScriptAccess ="sameDomain"');
		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>');
		document.write('</object>');
	} else{
		document.write('<img    src     ="' + img + '"');
		document.write('        width   ="' + width + '"');
		document.write('        height  ="' + height + '"');
		document.write('        class   ="vbottom" />');
	}
}


////// ページ内スクロール //////

var eventTimer;
var restScroll=0;

function Scroll(base,move){

	var obj_base  = getElemPosition(base);

	var elem_move = document.getElementById(move);
	var obj_move  = getElemPosition(elem_move);

	restScroll = obj_move.y-obj_base.y;
	eventTimer = setInterval(setScrollPosition,10);
}

function setScrollPosition() {

	var moveValue=0;

	if(Math.abs(restScroll)>80){
		moveValue = (restScroll>0)?20:-20;
	}else{
		moveValue = Math.round(restScroll/4);
	}

	parent.scrollBy(0,moveValue);

	restScroll = (restScroll>0)?restScroll-moveValue:restScroll-moveValue;

	if(moveValue==0){
		clearInterval(eventTimer);
		restScroll=0;
	}
}

function getElemPosition(elem) {
	var obj = new Object();
	obj.x = elem.offsetLeft;
	obj.y = elem.offsetTop;

	while(elem.offsetParent) {
		elem = elem.offsetParent;
		obj.x += elem.offsetLeft;
		obj.y += elem.offsetTop;
	}
	return obj;
}

