/** オンロード処理 */
window.onload = function(){

	// ロールオーバーの設定
	ROfunction();
		
	// イベント登録
	if($("TourokuNaviInputForm") != null){
		Event.observe($("TourokuNaviInputForm"), 'click', TourokuNaviInputForm);
	}
	if($("TourokuNaviKakunin") != null){
		Event.observe($("TourokuNaviKakunin"), 'click', TourokuNaviKakunin);
	}
	
	// Validate設定の追加
	//タイトル
	Validation.add('required-title', '', {
			minLength : 1,
			maxLength : 20
		}
	);
	//お名前
	Validation.add('required-name', '', {
			minLength : 1,
			maxLength : 10
		}
	);
	//撮影場所
	Validation.add('required-place', '', {
			minLength : 1,
			maxLength : 20
		}
	);
	
	// Validationを有効にする
	if ($("form2") != null) {
		valid = new Validation($("form2"), {
			useTitles: true
		});
	}
}

/** 「入力フォームへ戻る」ボタン押下 */
function TourokuNaviInputForm(){	TourokuNavi('0');}
/** 「確認画面に進む」ボタン押下 */
function TourokuNaviKakunin(){	TourokuNavi('1');}

/**
 * サブミットを実行
 * カテゴリIDを取得してイベント情報を更新する
 * 
 */
function TourokuNavi(actionId){
	
	var obj = $("form2");
	
	if (actionId != null && valid.validate()) {
		obj.actionId.value = actionId;
		obj.encoding = 'multipart/form-data';
		obj.method = 'post';
		obj.submit();
	}
	
}

/**
 * ロールオーバー画像の切り替え
 */
function ROfunction(){

	var imgNum = document.getElementsByTagName("img");
	var inputNum = document.getElementsByTagName("input");
	
	overNum = new Array;
	
	for (i = 0; i < imgNum.length; i++) {
		overNum[i] = imgNum[i];
	}
	
	for (i = 0; i < inputNum.length; i++) {
		overNum[i + imgNum.length] = inputNum[i];
	}
	
	for (i = 0; i < overNum.length; i++) {
		if (overNum[i].className.indexOf("Rover") != -1 && overNum[i].src.indexOf("_o.") == -1) {
			overNum[i].overimg = new Image();
			if (overNum[i].className.indexOf(":") != -1) {
				Replace = overNum[i].className.split(":");
				Replace = Replace[1].split(" ");
				overNum[i].overimg.src = Replace[0];
			}
			else {
				Replace = overNum[i].src.length;
				overNum[i].overimg.src = overNum[i].src.substring(0, Replace - 4) + "_o" + overNum[i].src.substring(Replace - 4, Replace);
			}
			overNum[i].setAttribute("out", overNum[i].src);
			overNum[i].onmouseover = new Function('this.src=this.overimg.src;');
			overNum[i].onmouseout = new Function('this.src=this.getAttribute("out");');
		}
	}
}

