            
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Konstantin Jagello | http://javascript-array.com/ */

var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

function mopen(n) {
  var l  = document.getElementById("menu"+n);
  var mm = document.getElementById("mmenu"+n);
	
  if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
      currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;			
  } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
 	}
}

function mclosetime() {
  closeTimer = window.setTimeout(mclose, TimeOut);
}

function mcancelclosetime() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
  }
}

function mclose() {
  if(currentLayer && noClose!=1)   {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
  } else {
    noClose = 0;
  }
  currentLayer = null;
  currentitem = null;
}

//document.onclick = mclose; 

          

/*
 * class=rolloverの要素の み対象
 * オーバー画像はファイル名に_onが付いてること
 * (いずれもpropsの値を外部から変更することで変更できる)
 */
var RollOver = Class.create();
RollOver.prototype = {
	initialize: function(option) {
		var props = {
			hclass : "rollover"
			,suffix : "_on"
		};

		if(option) for(var key in option) props[key] = option[key];
		
		$$('img.'+props.hclass,'input.'+props.hclass).each(
		function(el){
			var osrc = el.getAttribute('src');
			if (!osrc) return;
			
			var hsrc = osrc.replace(/(\.gif|\.jpg)/,props.suffix+'$1');
			(new Image()).src = hsrc; //キャッシュに読込む
			el.observe("mouseover",function(){
				el.setAttribute('src', hsrc);
			}).observe("mouseout",function(){
				el.setAttribute('src', osrc);
			});
		}
		);
	}
}//prototype
Event.observe(window,'load',function(){new RollOver();});


///////////////////////////////////////////////////////////////////////////////////////////
//swf書き出し

/* 通常 */
function swfLoad(movie,width,height)
{
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
	document.write(' ID=start width=' + width + ' height=' + height + '>\n');
	document.write(' <PARAM NAME=movie VALUE="' + movie + '"/>\n');
	document.write(' <PARAM NAME=quality VALUE=high/>\n');
	document.write(' <PARAM NAME=bgcolor VALUE=#000000/>\n');
	document.write(' <EMBED src="' + movie + '" quality=high bgcolor=#ffffff swLiveConnect=FALSE \n');
	document.write(' width="' + width + '" height="' + height + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">\n');
	document.write(' </EMBED>\n');
	document.write(' </OBJECT>\n');
}

/* 背景透過 */
function swfLoadAlpha(movie,width,height)
{
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
	document.write(' ID=start width=' + width + ' height=' + height + '>\n');
	document.write(' <PARAM NAME=movie VALUE="' + movie + '"/>\n');
	document.write(' <PARAM NAME=quality VALUE=high/>\n');
	document.write(' <param name="wmode" value="transparent">\n');
	document.write(' <EMBED src="' + movie + '" quality=high swLiveConnect=FALSE \n');
	document.write(' width="' + width + '" height="' + height + '" wmode="transparent" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">\n');
	document.write(' </EMBED>\n');
	document.write(' </OBJECT>\n');
}

///////////////////////////////////////////////////////////////////////////////////////////
//プルダウン選択

function changeURL(myURI){
 if(myURI !="default"){
  window.document.location.href=myURI;
 }
}

///////////////////////////////////////////////////////////////////////////////////////////
//  トップページゲーム紹介画像(pickup)とリンクの入れ替えfunction

function changeImage(gameName,gameLink,gameAlt) {
	document.pickup.src = "img/pickup_game_" + gameName + ".jpg";
	document.pickup.alt = gameAlt;
	var link = document.getElementById("pickuplink");
	link.href = gameLink;

}

///////////////////////////////////////////////////////////////////////////////////////////
//  ロールオーバースクリプト(ヘッダーメニュー用)

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////
//  お知らせ情報取得

function getInfo(id,lid,gid,cnt,top){

	var q_top = "";
 	if(arguments.length == 5){
		q_top = "&top=" + top;
	} 

	$(id).innerHTML = "<div style='width:100%; text-align:center;'><img src='/img/common/loading.gif'><br>loading...</div>";

	var a = new Ajax.Request(
		"/information/api/getinfo.php?lid=" + lid + "&gid=" + gid + "&cnt=" + cnt + "&tt=" + (new Date()).getTime() + q_top,
		//"/information/api/getinfo.php?lid=" + lid + "&gid=" + gid + "&cnt=" + cnt + "&tt=",
		{
			"method": "get",
			onComplete: function(request) {
				$(id).innerHTML = request.responseText;
			}
		}
	);
}

///////////////////////////////////////////////////////////////////////////////////////////
//  サイズ固定ウィンドウオープン

//▼サイズ自由指定
function openWin(myURL,Wid,Hei){
window.open(myURL, 'newWin', 'width='+ Wid+', height='+ Hei+',resizable=yes, scrollbars=yes');
}

//▼サイズ固定(mydata用)
function openWinMydata(myURL){
window.open(myURL, 'newWin', 'width=600, height=740, resizable=yes, scrollbars=yes');
}

function ToFavorite(toURL,toStr){
	//Internet Explorer
	if(navigator.userAgent.indexOf("MSIE") > -1){
		window.external.AddFavorite(toURL,toStr);
	}else{
	//Lunascape
	if(navigator.userAgent.indexOf("Lunascape") > -1){
		alert("[Ctrl]と[G}ボタンを同時に押してください。");
	}else{
	//Firefox
	if(navigator.userAgent.indexOf("Firefox") > -1){
		window.sidebar.addPanel(toStr,toURL,'');
	}else{
	//Opera
	if(navigator.userAgent.indexOf("Opera") > -1){
		window.open(toURL,'sidebar','title='+toStr);
	}else{
	//Chrome,Safari
	if(navigator.userAgent.indexOf("Chrome") > -1){
		alert("[Ctrl]と[D}ボタンを同時に押してください。");
	}else{
	//Chrome,Safari
	}}}}}}



