﻿// JavaScript Document
function LoadBBS( travelID )
{
	var options = {};
	options.method = "get";
	options.asynchronous = false;
	options.parameters = "Travel=" + travelID;
	new Ajax.Updater("TravelBBS", "../../bbs/travelbbs.php", options);
}

function ImageWindow(code, w, h)
{
	winwidth = w + 20;
	winheight = h + 120;
	sw = screen.availWidth;
	sh = screen.availHeight;
	wl = (sw-winwidth)/2;
	wt = (sh-winheight)/2;
	win = window.open( "", code,"width=" + winwidth + ",height=" + winheight + ",toolbar=no,scrollbars=no,left=" + wl + ",top=" + wt);
}
function ShowEmojiDialog(mevent)
{
	if( document.all )
	{
		document.all("LayerE").style.visibility = "visible";
	}
	else
	{
		var el = document.getElementById('LayerE');
		el.style.visibility = "visible";
	}
}
function CloseEmojiDialog()
{
	if( document.all )
	{
		document.all("LayerE").style.visibility = "hidden";
	}
	else
	{
		var el = document.getElementById('LayerE');
		el.style.visibility = "hidden";
	}
}
function EnterEmoji(nRet)
{
	if(nRet >= 10 && nRet <= 99 )
	{
		document.newtopic.message.focus();
		if( document.selection )
		{
			var strMsg;
			var sel = document.selection.createRange();
			sel.text = "{{EM" + nRet + "}}";
		}
		else
		{
			var el=document.getElementById('message');
			var sPos = el.selectionStart;
			var ePos = el.selectionEnd;
			var str = el.value.substring(sPos, ePos);
			el.value = el.value.substring(0, sPos) + "{{EM" + nRet + "}}" + el.value.substr(ePos);
			el.setSelectionRange( sPos + 8, sPos + 8 );
		}
	}
	CloseEmojiDialog();
}
function ShowPreview(travelID)
{
	if( FormCheck() == false ) return false;

	document.newtopic.action = "../../bbs/bbspreview.php?Travel=" + travelID;
	document.newtopic.method = "post";
	document.newtopic.submit();
}
function FormCheck() {
	if (document.newtopic.name.value.length == 0)
	{
		alert('お名前を入力してください');
		return false;
	}
	if (document.newtopic.title.value.length == 0)
	{
		alert('タイトルを入力してください');
		return false;
	}
	if (document.newtopic.message.value.length == 0)
	{
		alert('メッセージを入力してください');
		return false;
	}
	return true;
}
function DeleteFile(strUploadfile, strUploadfileLarge)
{
	document.newtopic.action = "../../bbs/bbsdeletefile.php";
	document.newtopic.method = "post";
	document.newtopic.submit();
}

