Event.observe(window, 'load', setEvent, false);

function setEvent(){
	
var bodyID = document.getElementsByTagName("body")[0].id;

	if (bodyID == "indivisual") {
		contentsForm();
		menuForm();
	}
if (bodyID == "commentPost") {
		commentError();
		menuForm();
	}else
	{
		menuForm();
	}
}

//contents部分のフォーム設定
function contentsForm() {
//各フォーム部品のIDを登録
var nameForm = $('name');
var addressForm = $('address');
var urlForm = $('url');
var commentAreaForm = $('commentArea');

	//comment name
	nameForm.onfocus = function () {
		Element.removeClassName(nameForm, "name");
		Element.addClassName(nameForm, "nameFocus");
	}
	nameForm.onblur = function () {
		Element.removeClassName(nameForm, "nameFocus");
		Element.addClassName(nameForm, "name");
	if (Field.getValue(nameForm) != '') {
		Element.removeClassName(nameForm, "name");
		Element.addClassName(nameForm, "nameFocus");
		}
	}

	//comment address
	addressForm.onfocus = function () {
		Element.removeClassName(addressForm, "address");
		Element.addClassName(addressForm, "addressFocus");
	}
	addressForm.onblur = function () {
		Element.removeClassName(addressForm, "addressFocus");
		Element.addClassName(addressForm, "address");
	if (Field.getValue(addressForm) != '') {
		Element.removeClassName(addressForm, "address");
		Element.addClassName(addressForm, "addressFocus");
		}
	}

	//comment url
	urlForm.onfocus = function () {
		Element.removeClassName(urlForm, "url");
		Element.addClassName(urlForm, "urlFocus");
	}
	urlForm.onblur = function () {
		Element.removeClassName(urlForm, "urlFocus");
		Element.addClassName(urlForm, "url");
	if (Field.getValue(urlForm) != '') {
		Element.removeClassName(urlForm, "url");
		Element.addClassName(urlForm, "urlFocus");
	}
	}

	//comment commentArea
	commentAreaForm.onfocus = function () {
			Element.removeClassName(commentAreaForm, "commentArea");
			Element.addClassName(commentAreaForm, "commentAreaFocus");
		if (Field.getValue(commentAreaForm) == 'コメントして下さい') {
			Field.clear(commentAreaForm);
		}
	}
	commentAreaForm.onblur = function () {
		if (Field.getValue(commentAreaForm) == '') {
			commentAreaForm.value = commentAreaForm.defaultValue;
			Element.removeClassName(commentAreaForm, "commentAreaFocus");
			Element.addClassName(commentAreaForm, "commentArea");
		}
		if (Field.getValue(commentAreaForm) != '') {
			Element.removeClassName(commentAreaForm, "commentArea");
			Element.addClassName(commentAreaForm, "commentAreaFocus");
		}
		if (Field.getValue(commentAreaForm) == 'コメントして下さい') {
			Element.removeClassName(commentAreaForm, "commentAreaFocus");
			Element.addClassName(commentAreaForm, "commentArea");
		}
	}
}


//menu部分のフォーム設定
function menuForm(){
//各フォーム部品のIDを登録
var searchBoxForm = $('searchArea');

//search
searchBoxForm.onfocus = function () {
if (searchBoxForm.value == 'サイト内検索') {
searchBoxForm.value = '';
}
}
searchBoxForm.onblur = function () {
if (searchBoxForm.value == '') {
searchBoxForm.value = 'サイト内検索';
}
}
}


function commentError() {
var backLink = $('backToPost');
backLink.href = 'javascript:void(0)';
Event.observe(backLink, 'click', pageBack, false);
}

function pageBack() {
	history.back(); return false;
}
