// JavaScript Document

/* Scrolling Back To Top */
function backToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backToTop()", 25);
  }
}

/* Slider */

/*		process:function(d){
			var cl,i; cl=array.length; i=0;
			for(i;i<cl;i++){
				var s,h,c,cd;
				s=array[i]; h=document.getElementById(s+'-sheader');
				c=s+'-scontent'; cd=document.getElementById(c); clearInterval(cd.timer);
				if(h==d&&cd.style.display=='none'){
					cd.style.display='block'; this.islide(c,1);
				}else if(cd.style.display=='block'){  this.islide(c,-1) }
			}
		},*/

var slider=function(){
	var array=[]; var speed=6; var timer=30;
	return{
		init:function(t,c){
			var s,ds,l,i,y;
			s=document.getElementById(t); ds=s.getElementsByTagName('div'); l=ds.length; i=y=0;
			for(i=0;i<l;i++){
				var d,did; d=ds[i]; did=d.id;
				if(did.indexOf("sheader")!=-1){
					y++; d.onclick=new Function("slider.process(this)");
				}else if(did.indexOf("scontent")!=-1){
					array.push(did.replace('-scontent','')); d.maxh=d.offsetHeight;
					if(c!=y){d.style.height='0px'; d.style.display='none'}
					else{ d.style.display='block' }
				} 
			}
		},
		process:function(d){
			var cl,i; cl=array.length; i=0;
			for(i;i<cl;i++){
				var s,h,c,cd;
				s=array[i]; h=document.getElementById(s+'-sheader');
				c=s+'-scontent'; cd=document.getElementById(c); clearInterval(cd.timer);
				if(h==d&&cd.style.display=='none'){
					cd.style.display='block'; this.islide(c,1); 
				} else if(h==d&&cd.style.display=='block'){
					this.islide(c,-1); 
				}else if(cd.style.display=='block'){ /* this.islide(c,-1) */}
			}
		},
		islide:function(i,d){var c,m; c=document.getElementById(i); m=c.maxh; c.direction=d; c.timer=setInterval("slider.slide('"+i +"')",timer)},
		slide:function(i){
			var c,m,h,dist; c=document.getElementById(i); m=c.maxh; h=c.offsetHeight;
			dist=(c.direction==1)?Math.round((m-h)/speed):Math.round(h/speed);
			if(dist<=1){dist=1}
			c.style.height=h+(dist*c.direction)+'px'; c.style.opacity=h/c.maxh; c.style.filter='alpha(opacity='+(h*100/c.maxh)+')';
			if(h<2&&c.direction!=1){
				c.style.display='none'; clearInterval(c.timer);
			}else if(h>(m-2)&&c.direction==1){clearInterval(c.timer)}
		}
};}();


/* 指定したIDの内容を書き換える */
function writeTypeMsg(DID,mes) {
	var _dom;
	_dom=(document.all?3:(document.getElementById?1:(document.layers?2:0)));
    if (_dom == 1) {
        var div = document.getElementById(DID);
        while(div.hasChildNodes()) div.removeChild(div.lastChild);
        var range=document.createRange();
        range.selectNodeContents(div);
        range.collapse(true);
        var cf=range.createContextualFragment(mes);
        div.appendChild(cf);
    }
    if (_dom == 2) {
        var div = document.layers[DID];
        div.document.open();
        div.document.write(mes);
        div.document.close();
    }
    if (_dom == 3) document.all(DID).innerHTML = mes;
}


/* BioGraphy - OnOff 切り替え */

function changeModeBio(ID) {

	if (ID == 'ALL') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-all.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','block');
		SwitchMenuBio('LIVE','block');
		SwitchMenuBio('EVENT','block');
		SwitchMenuBio('TV','block');
		SwitchMenuBio('RADIO','block');
		SwitchMenuBio('DRAMA','block');
		SwitchMenuBio('MOVIE','block');
		SwitchMenuBio('CM','block');
		SwitchMenuBio('PHOTO','block');
		SwitchMenuBio('OTHER','block');
	}
	if (ID == 'RELEASE') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-release.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','block');
		SwitchMenuBio('LIVE','none');
		SwitchMenuBio('EVENT','none');
		SwitchMenuBio('TV','none');
		SwitchMenuBio('RADIO','none');
		SwitchMenuBio('DRAMA','none');
		SwitchMenuBio('MOVIE','none');
		SwitchMenuBio('CM','none');
		SwitchMenuBio('PHOTO','none');
		SwitchMenuBio('OTHER','none');
	}
	if (ID == 'LIVE/EVENT') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-live.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','none');
		SwitchMenuBio('LIVE','block');
		SwitchMenuBio('EVENT','block');
		SwitchMenuBio('TV','none');
		SwitchMenuBio('RADIO','none');
		SwitchMenuBio('DRAMA','none');
		SwitchMenuBio('MOVIE','none');
		SwitchMenuBio('CM','none');
		SwitchMenuBio('PHOTO','none');
		SwitchMenuBio('OTHER','none');
	}
	if (ID == 'TV/RADIO') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-tv.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','none');
		SwitchMenuBio('LIVE','none');
		SwitchMenuBio('EVENT','none');
		SwitchMenuBio('TV','block');
		SwitchMenuBio('RADIO','block');
		SwitchMenuBio('DRAMA','none');
		SwitchMenuBio('MOVIE','none');
		SwitchMenuBio('CM','none');
		SwitchMenuBio('PHOTO','none');
		SwitchMenuBio('OTHER','none');
	}
	if (ID == 'DRAMA/MOVIE') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-drama.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','none');
		SwitchMenuBio('LIVE','none');
		SwitchMenuBio('EVENT','none');
		SwitchMenuBio('TV','none');
		SwitchMenuBio('RADIO','none');
		SwitchMenuBio('DRAMA','block');
		SwitchMenuBio('MOVIE','block');
		SwitchMenuBio('CM','none');
		SwitchMenuBio('PHOTO','none');
		SwitchMenuBio('OTHER','none');
	}
	if (ID == 'CM') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-cm.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','none');
		SwitchMenuBio('LIVE','none');
		SwitchMenuBio('EVENT','none');
		SwitchMenuBio('TV','none');
		SwitchMenuBio('RADIO','none');
		SwitchMenuBio('DRAMA','none');
		SwitchMenuBio('MOVIE','none');
		SwitchMenuBio('CM','block');
		SwitchMenuBio('PHOTO','none');
		SwitchMenuBio('OTHER','none');
	}
	if (ID == 'PHOTO') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-photo.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','none');
		SwitchMenuBio('LIVE','none');
		SwitchMenuBio('EVENT','none');
		SwitchMenuBio('TV','none');
		SwitchMenuBio('RADIO','none');
		SwitchMenuBio('DRAMA','none');
		SwitchMenuBio('MOVIE','none');
		SwitchMenuBio('CM','none');
		SwitchMenuBio('PHOTO','block');
		SwitchMenuBio('OTHER','none');
	}
	if (ID == 'OTHER') {
		writeTypeMsg("BioGenreMenu",'<img src="/fukuyama/mashamaro-shuppan/images/bio/bio-main-menu-other.jpg" border="0" usemap="#Map2" />');
		SwitchMenuBio('RELEASE','none');
		SwitchMenuBio('LIVE','none');
		SwitchMenuBio('EVENT','none');
		SwitchMenuBio('TV','none');
		SwitchMenuBio('RADIO','none');
		SwitchMenuBio('DRAMA','none');
		SwitchMenuBio('MOVIE','none');
		SwitchMenuBio('CM','none');
		SwitchMenuBio('PHOTO','none');
		SwitchMenuBio('OTHER','block');
	}
}


function SwitchMenuBio(IdOrName,mode){
	if(!document.layers){
		/* IdOrNameの含んだALL配列取得 */
		var s,ds,l,i,y;
		s=document.getElementById('BioContent'); ds=s.getElementsByTagName('div'); l=ds.length; i=y=0;
		for(i=0;i<l;i++){
			var d,did; d=ds[i]; did=d.id;
			if(did.indexOf(IdOrName)!=-1){
				ImgId = IdOrName + "marker";
				d.style.display = mode;
			}
		}
		
	}
}

// Flash Write
function fwriteTop()
{
  var htm = ""
  var swf = "/fukuyama/mashamaro-shuppan/images/top/top20090113.swf";
  var width = "850";
  var height = "323";
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'"
  htm+="        width   = " + width
  htm+="        height  = " + height + " align='middle'>"
  htm+="<param  name    = movie value=" + swf + ">"
  htm+="<param  name    = quality value=high>"
  htm+="<embed  src     = " + swf + " "
  htm+="        quality = high  "
  htm+="        width   = "+ width
  htm+="        height  = " + height + " align='middle'"
  htm+="        type    = 'application/x-shockwave-flash' "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  htm+="</embed>"
  htm+="</object>"
  
  document.write(htm)
}

function fwriteBrosTop(param)
{
  var htm = ""
  var swf = "/fukuyama/mashamaro-shuppan/images/bros-top/bros20100222-b.swf" + param;
  var width = "850";
  var height = "323";
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'"
  htm+="        width   = " + width
  htm+="        height  = " + height + " align='middle'>"
  htm+="<param  name    = movie value=" + swf + param + ">"
  htm+="<param  name    = quality value=high>"
  htm+="<embed  src     = " + swf + " "
  htm+="        quality = high  "
  htm+="        width   = "+ width
  htm+="        height  = " + height + " align='middle'"
  htm+="        type    = 'application/x-shockwave-flash' "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  htm+="</embed>"
  htm+="</object>"
  
  document.write(htm)
}


function fwriteNews()
{
  var htm = ""
  var swf = "/fukuyama/mashamaro-shuppan/images/news/news-mainscreen20090702.swf";
  var swf = "/fukuyama/mashamaro-shuppan/images/top/top20091209.swf";
  var width = "850";
  var height = "323";
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'"
  htm+="        width   = " + width
  htm+="        height  = " + height + " align='middle'>"
  htm+="<param  name    = movie value=" + swf + ">"
  htm+="<param  name    = quality value=high>"
  htm+="<embed  src     = " + swf + " "
  htm+="        quality = high  "
  htm+="        width   = "+ width
  htm+="        height  = " + height + " align='middle'"
  htm+="        type    = 'application/x-shockwave-flash' "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  htm+="</embed>"
  htm+="</object>"
  
  document.write(htm)
}

function fwriteBio()
{
  var htm = ""
  var swf = "./bio.swf";
  var width = "850";
  var height = "323";
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'"
  htm+="        width   = " + width
  htm+="        height  = " + height + " align='middle'>"
  htm+="<param  name    = movie value=" + swf + ">"
  htm+="<param  name    = quality value=high>"
  htm+="<embed  src     = " + swf + " "
  htm+="        quality = high  "
  htm+="        width   = "+ width
  htm+="        height  = " + height + " align='middle'"
  htm+="        type    = 'application/x-shockwave-flash' "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  htm+="</embed>"
  htm+="</object>"
  
  document.write(htm)
}

function fwriteBrosFAQ()
{
  var htm = ""
  var swf = "/fukuyama/mashamaro-shuppan/images/faq/bros-faq.swf";
  var width = "850";
  var height = "323";
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'"
  htm+="        width   = " + width
  htm+="        height  = " + height + " align='middle'>"
  htm+="<param  name    = movie value=" + swf + ">"
  htm+="<param  name    = quality value=high>"
  htm+="<embed  src     = " + swf + " "
  htm+="        quality = high  "
  htm+="        width   = "+ width
  htm+="        height  = " + height + " align='middle'"
  htm+="        type    = 'application/x-shockwave-flash' "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  htm+="</embed>"
  htm+="</object>"
  
  document.write(htm)
}

function fwriteShuzaitecho(param)
{
  if (param == '?xf=') {
      param = '?xf=infoxml.php';
  }

  var htm = ""
  var swf = "/fukuyama/mashamaro-shuppan/images/techo/techo.swf" + param;
  var width = "850";
  var height = "323";

  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'"
  htm+="        width   = " + width
  htm+="        height  = " + height + " align='middle'>"
  htm+="<param  name    = movie value=" + swf + param + ">"
  htm+="<param  name    = quality value=high>"
  htm+="<embed  src     = " + swf + " "
  htm+="        quality = high  "
  htm+="        width   = "+ width
  htm+="        height  = " + height + " align='middle'"
  htm+="        type    = 'application/x-shockwave-flash' "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  htm+="</embed>"
  htm+="</object>"
  
  document.write(htm)
}