/*****************************************************************
/*
/* ガマニアを含めコピーサイト連携用
/*
/*****************************************************************/
var pathName;
var baseURL;
var isIndex;
var isGamania;

pathName = location.pathname.split("/");

if( pathName[1].match(/(gamania)|(biglobe)|(dion)|(nifty)|(ocn)|(so-net)/) ) {
	baseURL   = "/" + pathName[1];
	baseIndex = 2;
	IsGamania = true;
} else {
	baseURL   = ""
	baseIndex = 1;
	IsGamania = false;
}

isIndex = (pathName[baseIndex]=="index.aspx" || pathName[baseIndex]=="index_gamania.aspx" || pathName[baseIndex]=="");

function AlterLink(){
	var m;
	var path;

	for(i=0; i<document.links.length; i++){
		if( document.links[i].target=="alterlink" || document.links[i].target=="alterblank" ) {

			if( document.links[i].target=="alterblank" ) {
				document.links[i].target = "_blank";
			} else {
				document.links[i].target = "";
			}

			m = document.links[i].pathname.indexOf("?");

			if( m>0 ) {
				path = document.links[i].pathname.substring(0,m) + document.links[i].search;
			} else {
				path = document.links[i].pathname + document.links[i].search;
			}

			if( document.links[i].pathname[0]=="/" ) {
				document.links[i].href = baseURL + path;
			} else {
				document.links[i].href = baseURL + "/" + path;
			}
		}
	}
}

/*****************************************************************
/*
/* Flash表示の為のスクリプト
/* Quality, FlashVars, wModeには無ければデフォルト値を挿入
/*
/*****************************************************************/
function ShowFlash(Width, Height, Src, Quality, FlashVars, wMode) {

  var flashClassID = "D27CDB6E-AE6D-11cf-96B8-444553540000";
  var iePlugIn     = "//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
  var niePlugIn    = "//www.macromedia.com/go/getflashplayer";

	var now    = new Date();
	var year   = now.getFullYear();
	var month  = now.getMonth();
	var day    = now.getDay();
	var hour   = now.getHours();
	var min    = now.getMinutes();
	var sec    = now.getSeconds();
	var Target = Src;// + '?' + year + month + day + hour + day + min + sec;


	if( typeof(Quality) == "undefined" ) {
		Quality = "high";
	}

	if( typeof(FlashVars) == "undefined" ) {
		FlashVars = "";
	}

	if( typeof(wMode) == "undefined" ) {
		wMode = "opaque";
	}

	document.write(
			"<object classid='clsid:"+flashClassID+"' width='" + Width + "' height='" + Height + "' codebase='"+iePlugIn+"'>"
		+  "<param name='movie' value='" + Target + "'>"
		+  "<param name='quality' value='" + Quality + "'>"
		+  "<param name='menu' value='false'>"
		+  "<param name='wmode' value='" + wMode + "'>"
	);

	if( FlashVars != "" ) {
		document.write(
			"<param name='FlashVars' value='" + FlashVars + "'>"
		);
	}

	document.write(
		"<embed src='" + Target + "' quality='" + Height + "' width='" + Width + "' height='" + Height + "' menu='false' wmode='" + wMode + "' FlashVars='" + FlashVars + "' pluginspage='"+niePlugIn+"' type='application/x-shockwave-flash'></embed></object>"
	);

}


/*****************************************************************
/*
/* JavaScriptメニュー表示
/* 指定されたIDのBOXを表示したりしなかったり
/* 表示しない:hidden, none
/* 表示する:visible, block
/*
/*****************************************************************/
function ShowMenu(TagID, Visibility) {
  
  switch(Visibility) {

    case "block":
    case "none":
    case "inline":
    case "list-item":
    	document.getElementById(TagID).style.display = Visibility;
    	break;

    case "hidden":
    case "visible":
    default:
    	document.getElementById(TagID).style.visibility = Visibility;
    	break;
	}
	
}



/*****************************************************************
/*
/* 事前に用意された２つの画像
/* **_f1.*** と **_f2.*** をスワップ（入替）
/*
/* Stateの指定が無い場合はファイル名でStateを判断
/*
/*****************************************************************/
function SwapImg(TagID, State) {

  SwapImg = document.getElementById(TagID).src;

	if( typeof(State) == "undefined" ) {
    if(SwapImg.IndexOf("_f1.")>0) {
  		State = "normal";
    } else {
  		State = "over";
    }
	}

	if( State == "over" ) {
		document.getElementById(TagID).src = SwapImg.replace("_f1.", "_f2.");
	} else {
		document.getElementById(TagID).src = SwapImg.replace("_f2.", "_f1.");
	}

}

/*****************************************************************
/*
/* JavaScriptメニュー表示
/* 指定されたIDのBOXを表示したりしなかったり
/* 表示しない:hidden
/* 表示する:visible
/*
/*****************************************************************/
function NewBanner(RegDate, Term, Tag){

	if( typeof(Term) == "undefined" ) {
		Term = 2;
	}

	if( typeof(Tag) == "undefined" ) {
		Tag = "<img align='absmiddle' src='/images/new_icon.gif'>";
	}

	if( ((new Date()-new Date(RegDate)) / (24*60*60*1000)) <= Term) {
		document.write(Tag);
	}
}

/*****************************************************************
/*
/* ポップアップ表示用
/*
/*****************************************************************/
function popup(path, name, width, height, position, scrollbars, resizable) {

	if( typeof(position) == "undefined" ) {
		position = "center";
	}

	if( typeof(scrollbars) == "undefined" ) {
		scrollbars = "no";
	}

	if( typeof(resizable) == "undefined" ) {
		resizable = "yes";
	}

	if(position == "center") {
		lf= (window.screen.availWidth - width) / 2;
		tp = (window.screen.availHeight - height) / 2;
	} else if(position == "right") {
		lf = window.screen.availWidth - width - 10;
		tp= 0;
	} else {
		lf= 0;
		tp = 0;
	}

	window.open("/popup.html?src="+path, name, "top="+tp+",left="+lf+",width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scrollbars+",status=no,toolbar=no,directories=no,menubar=no");
}


// 過去の互換性維持
function popup2(path, name, width, height, position) {
	popup(path, name, width, height, position, "no", "no");
}

function popupAny(path, name, width, height, position, scrollbars, resizable) {

	if( typeof(position) == "undefined" ) {
		position = "center";
	}

	if( typeof(scrollbars) == "undefined" ) {
		scrollbars = "yes";
	}

	if( typeof(resizable) == "undefined" ) {
		resizable = "yes";
	}


	if(position == "center") {
		lf= (window.screen.availWidth - width) / 2;
		tp = (window.screen.availHeight - height) / 2;
	} else if(position == "right") {
		lf = window.screen.availWidth - width - 10;
		tp= 0;
	} else {
		lf= 0;
		tp = 0;
	}

	window.open(path, name, "top="+tp+",left="+lf+",width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scrollbars+",status=no,toolbar=no,directories=no,menubar=no");
}

// 過去の互換性維持
// リサイズ抜き
function popupAny2(path, name, width, height, position) {
 popupAny(path, name, width, height, position, "yes", "no")
}

// 過去の互換性維持
// リサイズ・スクロールバー抜き
function popupAny3(path, name, width, height, position) {
 popupAny(path, name, width, height, position, "no", "no")
}


/*****************************************************************
/*
/* ブックマークの登録用
/*
/*****************************************************************/
function addBookmark(URL, Title) {
	try {
		window.external.AddFavorite(URL, Title);
	} catch(e) {
		alert("このリンクはIE(Internet Exploler)専用です");
	}
}

/*****************************************************************
/*
/* 動きのあるTOPに戻る用
/*
/*****************************************************************/
var ReturnSpeed = 1;
// スクロールスピードを設定します。
// 値が大きくなればなるほど速くなります。

function ScrollTop() {

    // ページ最上部からの距離をピクセル単位でyに代入します。
    if(navigator.appName == "Microsoft Internet Explorer" && document.compatMode == "CSS1Compat"){
      var y = document.body.parentNode.scrollTop;
    }else{
      var y = document.body.scrollTop;
    }
	

    // ReturnSpeedの値が50未満且つyが0でない場合、以下の処理を行います。
    // ・yが2以上であるなら、y*1.2を四捨五入してyに代入。
    // 　以下ならば1を代入。つまりイージングの設定。
    // 　ReturnSpeedに1を加算し、ページをスクロール。
    // 　if文が真である間これを繰り返します。
    // ページ最上部までのスクロールが完了したら変数ReturnSpeedに1を代入しリセット。
    if(ReturnSpeed < 50 && y) {
      y = (y > 2) ? Math.ceil(y*.2) : 1;
      ReturnSpeed++;
      scrollBy(0,-y);
      setTimeout("ScrollTop()",10);
    }else{
      scrollTo(0,0);
      ReturnSpeed = 1;
    }
}
/*****************************************************************
/*
/* QuickTime表示の為のスクリプト
/* 
/*
/*****************************************************************/

function ShowQuickTime(Width, Height, Src, Control) {
	
	var CLASSID = "02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
	var iePlugIn     = "//www.apple.com/qtactivex/qtplugin.cab";
	var niePlugIn    = "//www.apple.com/quicktime/download/";
	
	if( typeof(Control) == "undefined" || Control=="" ) {
		Control = "true";
	}
	
	var LastTag = "<object classid='clsid:"+CLASSID+"' width='" + Width + "' height='" + Height + "' codebase='"+iePlugIn+"'>"
								 + "<param name='SRC' value='" + Src + "'>"
								 + "<PARAM name='AUTOPLAY' VALUE='true'>"
								 + "<PARAM name='TARGET' VALUE='QUICKTIMEPLAYER'>"
								 + "<PARAM name='SCALE' VALUE='TOFIT'>"
								 + "<PARAM name='HREF' VALUE='"+Src+"'>"
								 + "<PARAM name='CONTROLLER' VALUE='" + Control + "'>"
							   + "<embed src='" + Src + "' width='" + Width + "' height='" + Height + "' AUTOPLAY='true' SCALE='TOFIT' TARGET='QUICKTIMEPLAYER' CONTROLLER='"+Control+"' pluginspage='"+niePlugIn+"' href='"+Src+"'></embed>"
							   + "</object>";

	//alert(LastTag);

	document.write(LastTag);
}
