// 画像変更

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];}
}


// スクロールのスクリプト

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)?40:-40;
	}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;
}


// ランダム表示

len = 7;
chip = Math.floor(len * Math.random());
banner = '';

switch(chip){
case 0:
	banner += '<a href="http://www.amazon.co.jp/gp/product/4893665057?ie=UTF8&tag=mayday-22&linkCode=as2&camp=247&creative=1211&creativeASIN=4893665057" target="_blank"><img src="./image/affiliate/afli_01.gif" alt="ザ ヴァンパイアハンター セガサターン マニュアル Ver.2" width="140" height="138" border="0" /></a><img src="http://www.assoc-amazon.jp/e/ir?t=mayday-22&l=as2&o=9&a=4893665057" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
	break;
case 1:
	banner += '<a href="http://www.amazon.co.jp/gp/product/489366493X?ie=UTF8&tag=mayday-22&linkCode=as2&camp=247&creative=1211&creativeASIN=489366493X" target="_blank"><img src="./image/affiliate/afli_02.gif" alt="ザ ヴァンパイアハンター セガサターン マニュアル Ver.1" width="140" height="138" border="0" /></a><img src="http://www.assoc-amazon.jp/e/ir?t=mayday-22&l=as2&o=9&a=489366493X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
	break;
case 2:
	banner += '<a href="http://www.bent.co.jp/main/works/ad01/conten_tx.htm" target="_blank"><img src="./image/affiliate/afli_03.gif" alt="ALL ABOUT ヴァンパイアハンター" width="140" height="138" border="0" /></a>';
	break;
case 3:
	banner += '<a href="http://www.amazon.co.jp/gp/product/B0007Z3OLA?ie=UTF8&tag=mayday-22&linkCode=as2&camp=247&creative=1211&creativeASIN=B0007Z3OLA" target="_blank"><img src="./image/affiliate/afli_04.gif" alt="ヴァンパイア ダークストーカーズコレクション" width="140" height="138" border="0" /></a><img src="http://www.assoc-amazon.jp/e/ir?t=mayday-22&l=as2&o=9&a=B0007Z3OLA" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
	break;
case 4:
	banner += '<a href="http://www.amazon.co.jp/gp/product/B000069TCG?ie=UTF8&tag=mayday-22&linkCode=as2&camp=247&creative=1211&creativeASIN=B000069TCG" target="_blank"><img src="./image/affiliate/afli_05.gif" alt="セガサターン版 ヴァンパイアハンター" width="140" height="138" border="0" /></a><img src="http://www.assoc-amazon.jp/e/ir?t=mayday-22&l=as2&o=9&a=B000069TCG" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
	break;
case 5:
	banner += '<a href="http://www.amazon.co.jp/gp/product/B000064QNO?ie=UTF8&tag=mayday-22&linkCode=as2&camp=247&creative=1211&creativeASIN=B000064QNO" target="_blank"><img src="./image/affiliate/afli_06.gif" alt="ヴァンパイアハンター サウンドトラックCD" width="140" height="138" border="0" /></a><img src="http://www.assoc-amazon.jp/e/ir?t=mayday-22&l=as2&o=9&a=B000064QNO" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
	break;
case 6:
	banner += '<a href="http://www.vampire-dcc.com/" target="_blank"><img src="./image/affiliate/afli_07.gif" alt="ダークストーカーズコンビネーションカップDVD" width="140" height="138" border="0" /></a>';
	break;
}


// ページ内遷移

function hideall(){
  document.getElementById('id_1').style.display = "none";
  document.getElementById('id_2').style.display = "none";
  document.getElementById('id_3').style.display = "none";
  document.getElementById('id_4').style.display = "none";
  document.getElementById('id_5').style.display = "none";
  document.getElementById('id_6').style.display = "none";
  document.getElementById('id_7').style.display = "none";
}

function show(id){
  hideall();
  if(document.getElementById){
    if(document.getElementById(id).style.display == "none")
      document.getElementById(id).style.display = "block";
    else
      document.getElementById(id).style.display = "none";
  }
}
