/*****************************************************************
/*
/* 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(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 ChangeBlock(id, dest) {

	if (typeof (dest) == "undefined" || dest == "") {
		dest = "Dest";
	}


	InputDiv = document.getElementById(id);
	PreviewDiv = document.getElementById(dest);
	PreviewDiv.innerHTML = InputDiv.innerHTML;
	
	return false;
}

/*****************************************************************
/*
/* DreamWaver のロールオーバー用スクリプト
/*
/*****************************************************************/
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_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_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];}
}



/*****************************************************************
/*
/* ログインフォーム用のフォーム内アナウンス
/*
/*****************************************************************/
function FormGuide(obj, show, type)
{
	if( show )
	{
		if( obj.value == "" )
		{
			if( type == "id" )
			{
				obj.className="login_form_text login_form_id";
			}
			else
			{
				obj.className="login_form_text login_form_password";
			}
		}
	}
	else
	{
	 obj.className = "login_form_text";
	}
}

/*****************************************************************
/*
/* Editer
/*
/*****************************************************************/
function EditerCommand(command, arg) {

	var support_element
		= document.getElementById("form_message_clientid");
	var element
		= document.getElementById(support_element.value);

	if (command != "emotion" && command != "quote") {
		EditerMakeTag(element, "[" + command + ":" + arg + "]", "[/" + command + ":" + arg + "]");
	}
	else {
		EditerMakeTag(element, "[" + command + ":" + arg + " /]", "");
	}

}

function EditerMakeTag(str, stag, etag) {
	var mode;
	if (window.opera) {
		mode = 4;
	}
	else if (navigator.appName == 'Microsoft Internet Explorer') {
		if (navigator.platform == 'MacPPC') {
			mode = 4;
		}
		else {
			mode = 2;
		}
	}
	else if (navigator.userAgent.indexOf('Safari') != -1) {
		mode = 4;
	}
	else if (navigator.appName == 'Netscape') {
		if (navigator.platform == 'MacPPC') {
			mode = 4;
		}
		else {
			mode = 1;
		}
	}
	else if (navigator.userAgent.indexOf('Firefox') != -1) {
		mode = 1;
	}
	else if (navigator.userAgent.indexOf('Netscape') != -1) {
		mode = 1;
	}
	else if (navigator.userAgent.indexOf('Gecko') != -1) {
		mode = 1;
	}
	else {
		mode = 4;
	}

	if (mode == 1 || mode == 4) {
		var bl1 = str.value.substring(0, str.selectionStart);
		var bl2 = str.value.substring(str.selectionStart, str.selectionEnd);
		var bl3 = str.value.substring(str.selectionEnd, str.value.length);
		str.value = bl1 + stag + bl2 + etag + bl3;
	}
	else if (mode == 2) {
		str.focus();
		var sel = document.selection.createRange();
		var rang = str.createTextRange();
		rang.moveToPoint(sel.offsetLeft, sel.offsetTop);
		rang.moveEnd("textedit");
		if (rang.text.replace(/\r/g, "").length != 0) {
			var las = (str.value.match(/(\r\n)*$/), RegExp.lastMatch.length);
			str.selectionStart = str.value.length - (rang.text.length + las);
			str.selectionEnd = str.selectionStart + sel.text.length;
			str.selectionStart2 = str.value.replace(/\r/g, "").length - (rang.text.replace(/\r/g, "").length + las / 2);
			var bl1 = str.value.substring(0, str.selectionStart);
			var bl2 = str.value.substring(str.selectionStart, str.selectionEnd);
			var bl3 = str.value.substring(str.selectionEnd, str.value.length);
			str.value = bl1 + stag + bl2 + etag + bl3;
			str.selectionEnd2 = (str.selectionStart2 + stag.length + bl2.length + etag.length) - str.value.replace(/\r/g, "").length;
			rang.moveStart("character", str.selectionStart2);
			rang.moveEnd("character", str.selectionEnd2);
		} else {
			rang.moveToPoint(sel.offsetLeft, sel.offsetTop);
			rang.text = stag + etag;
			rang.moveStart("character", -(stag.length + etag.length));
		}
		rang.select();
	}
	else if (mode == 3) {
		str.value = stag + str.value + etag;
	}
	else {
		str.value += stag + etag;
	}
	return;
}


/*****************************************************************
/*
/* サーバ時間
/*
/*****************************************************************/
var m_ShortMonth = new Array(13) ;
var m_FullMonth = new Array(13) ;

m_ShortMonth[0] = "";
m_ShortMonth[1] = "Jan";
m_ShortMonth[2] = "Feb";
m_ShortMonth[3] = "Mar";
m_ShortMonth[4] = "Apr";
m_ShortMonth[5] = "May";
m_ShortMonth[6] = "Jun";
m_ShortMonth[7] = "Jul";
m_ShortMonth[8] = "Aug";
m_ShortMonth[9] = "Sep";
m_ShortMonth[10] = "Oct";
m_ShortMonth[11] = "Nov";
m_ShortMonth[12] = "Dec";

m_FullMonth[0] = "";
m_FullMonth[1] = "January";
m_FullMonth[2] = "February";
m_FullMonth[3] = "March";
m_FullMonth[4] = "April";
m_FullMonth[5] = "May";
m_FullMonth[6] = "June";
m_FullMonth[7] = "July";
m_FullMonth[8] = "August";
m_FullMonth[9] = "September";
m_FullMonth[10] = "October";
m_FullMonth[11] = "November";
m_FullMonth[12] = "December";

var m_ServerTime_Diff;
var m_ServerModule_Time;

function Set_ServerModule_Time() {
	var server_time = new Date((new Date()).getTime() + m_ServerTime_Diff);
	
	var Y = server_time.getFullYear();
	var M = server_time.getMonth() + 1;
	var D = server_time.getDate();
	var H = server_time.getHours();
	var T = server_time.getMinutes();
	var W = server_time.getDay();
	

	var AP="";
	if( H<12 )
	{
		AP = "am";
	}
	else if( H==12 )
	{
		AP = "pm";
	}
	else
	{
		AP="pm";
		H -= 12;
	}
	
	var T2="";
	if( T<10 )
	{
		T2 = "0"+T;
	}
	else
	{
		T2=T;
	}

	m_ServerModule_Time.innerHTML = m_ShortMonth[M] + " " + D + ", " + Y + " " + H + ":" + T2 + " " + AP.toUpperCase();

	setTimeout("Set_ServerModule_Time();", 5000);
}