/*****************************************************************
/*
/* Flash表示の為のスクリプト
/* Quality, FlashVars, wModeには無ければデフォルト値を挿入
/*
/*****************************************************************/
function ShowFlash(Width, Height, Src, Quality, FlashVars, wMode, forceRefresh) {

	// 強制FLASH・リフレッシュフラグ
	var debugFlashReflesh = false;


	// Wmode="opaque" だと日本語が時々おかしくなります
/*
	//Flash8用
  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";
*/
	//Flash9用
  var flashClassID = "d27cdb6e-ae6d-11cf-96b8-444553540000";
  var iePlugIn     = "//fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0";
  var niePlugIn    = "//www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";

	if( debugFlashReflesh || typeof(forceRefresh) != "undefined" && (forceRefresh=="true" || forceRefresh==true)  ) {
		var now    = new Date();
		var year   = now.getFullYear();
		var month  = now.getMonth();
		var day    = now.getDay();
		var hour   = now.getHours();
		var min  = now.getMinutes();

		Src += '?' + year + month + day + hour + min%5;
	}

	if( typeof(Quality) == "undefined" || Quality == "" ) {
		Quality = "autohigh";
	}

	if( typeof(wMode) == "undefined" || wMode== "" ) {
		wMode = "";
	}

	if( typeof(FlashVars) == "undefined" ) {
		FlashVars = "";
	}


	var LastTag = "<object classid='clsid:"+flashClassID+"' width='" + Width + "' height='" + Height + "' codebase='"+iePlugIn+"'>"
								+ "<param name='movie' value='" + Src + "'>"
								+ "<param name='quality' value='" + Quality + "'>"
								+ "<param name='menu' value='false'>"
								+ "<param name='wmode' value='" + wMode + "'>"
								+ "<param name='FlashVars' value='" + FlashVars + "'>"
								+ "<embed src='" + Src + "' quality='" + Height + "' width='" + Width + "' height='" + Height + "' menu='false' wmode='" + wMode + "' FlashVars='" + FlashVars + "' pluginspage='"+niePlugIn+"' type='application/x-shockwave-flash'></embed>"
								+ "</object>";

	document.write( LastTag );
	
	//alert(LastTag);
}


/*****************************************************************
/*
/* 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 addSocialBookmark(SMB, Link, Title) {

	var title;
	var link;
	var open_url;

	// タイトルの指定が無ければ現在のHTMLのタイトルを使用
	if( Title != undefined || Title=="" )
	{
		title = encodeURIComponent(Title);
	}
	else
	{
		title = encodeURIComponent(document.title);
	}

	// リンクの指定が無ければ現在のホスト名を利用
	if( Link != undefined || Link=="" )
	{
		link = encodeURIComponent(Link);
	}
	else
	{
		link = encodeURIComponent("http://" + window.location.hostname + "/");
	}


	switch( SMB )
	{
		case "Yahoo":
			open_url = "http://bookmarks.yahoo.co.jp/bookmarklet/showpopup"
									+ "?t=" + title
									+ "&u=" + link
									+ "&opener=bm&ei=UTF-8";
			break;

		case "Google":
			open_url = "http://www.google.com/bookmarks/mark"
									+ "?op=edit"
									+ "&title=" + title
									+ "&bkmk=" + link;

			break;

		case "Hatena":
			open_url = "http://b.hatena.ne.jp/append"
									+ "?" + link;
			break;

		case "Nifty":
			open_url = "http://clip.nifty.com/create"
									+ "?title=" + title
									+ "&url=" + link;
			break;
							

		case "livedoor":
			open_url = "http://clip.livedoor.com/redirect"
									+ "?title=" + title
									+ "&link=" + link;
			break;
							

		case "delicious":
			open_url = "http://del.icio.us/post"
									+ "?title=" + title
									+ "&url=" + link;
			break;

		
		default:
			open_url = ""
			break;
	}

	window.open(open_url);
	//alert(open_url);
}


/*****************************************************************
/*
/* ブックマークの登録用
/*
/*****************************************************************/
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;
    }
		
		return false;
}


/*****************************************************************
/*
/* 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);
}


/*****************************************************************
/*
/* ブラウザ強制閉じスクリプト
/*
/*****************************************************************/

function WindowForceClose() {

	window.opener = window;
	window.open(location.href,'_self');
	window.close();

}


/*****************************************************************
/*
/* XHTMLの為のIframe動的呼び出し
/*
/*****************************************************************/

function ShowIframe(Width, Height, Src, ID, Text, Scrolling) {
	
	if( typeof(Width) == "undefined" || Width=="" ) {
		Width = "100%";
	}

	if( typeof(Height) == "undefined" || Height=="" ) {
		Height = "100%";
	}

	if( typeof(Text) == "undefined" || Text=="" ) {
		Text = "ここはインラインフレームです";
	}

	if( typeof(Scrolling) == "undefined" || Scrolling=="" ) {
		Scrolling = "no";
	}

	var tag = "<iframe id='" + ID +"' src='" + Src +"' frameborder='0' width='" + Width + "' height='" + Height +"' scrolling='" + Scrolling + "'>"
							+ Text
							+ "</iframe>";
	
	document.write(tag);

}



/*****************************************************************
/*
/* サイト内検索
/*
/*****************************************************************/

function FormGuide(obj, show, text)
{
	if( obj.value != " サイト内検索" && obj.value != "" )
	{
		return;
	}
	
	if( show )
	{
		obj.value = text;
	}
	else
	{
		obj.value = "";
	}
}


function FormGuideCkeck(id)
{
	var obj = document.getElementById(id);
	
	return( obj.value != " サイト内検索" && obj.value != "" );
}
