// -----------------------------------------------------------------------------------
//		スムーズスクロール
// -----------------------------------------------------------------------------------

Event.observe(window, 'load', function() {

	if (!document.getElementsByTagName) { return false; }
	if (!document.getElementById) {	return false; }


	$$('a[href^=#]:not([href=#])').each(function(element) {

		var linkClass = element.readAttribute('class');

		if( ( linkClass == 'lightwindow') || ( linkClass == 'tabs' ) ) {
			return false;
		} else {
		    element.observe('click', function(event) {
		      new Effect.ScrollTo(this.hash.substr(1));
		      Event.stop(event);
		    }.bindAsEventListener(element))
		}

	})


})


// -----------------------------------------------------------------------------------
//		リンク設定
// -----------------------------------------------------------------------------------

Event.observe(window, 'load', function() {

	if (!document.getElementsByTagName) { return false; }
	if (!document.getElementById) {	return false; }


	// ポップアップ
	var links = document.getElementsByTagName('a');

	for (var i=0; i<links.length; i++) {

		// popUp 設定
		if (links[i].className == 'popUp') {
			links[i].onclick = links[i].onkeypress = function() {
				window.open(this.getAttribute('href'), '_blank');
				return false;
			}
		}

		// 仕事情報、企業情報 popUp 設定
		if (links[i].className == 'popUpDetail') {
			links[i].onclick = links[i].onkeypress = function() {
				window.open(this.getAttribute('href'),'','width=780,height=620,toolbar=yes,scrollbars=yes,resizable=yes,status=no,menubar=yes,location=no,directories=no');
				return false;
			}
		}

		// 検討中フォルダ bookmark 設定
		if (links[i].className == 'popUpBookmark') {
			links[i].onclick = links[i].onkeypress = function() {
				window.open(this.getAttribute('href'),'','width=400,height=300,toolbar=yes,scrollbars=yes,resizable=yes,status=no,menubar=no,location=no,directories=no');
				return false;
			}
		}

		// 閉じるボタン 設定
		if (links[i].className == 'closeButton') {
			links[i].onclick = links[i].onkeypress = function() {
				window.close();
				return false;
			}
		}

	}
})


// -----------------------------------------------------------------------------------
//		smallCategorySearchを非表示に（jsが無効時の対策）
// -----------------------------------------------------------------------------------

Event.observe(window, 'load', function() {

	if (!document.getElementsByTagName) { return false; }
	if (!document.getElementById) {	return false; }

	var smallCategorySearch = document.getElementById("smallCategorySearch");

	if ( document.getElementById("smallCategorySearch") ) {
		smallCategorySearch.style.display = "none";
		smallCategorySearch.style.position = "absolute";
	}

})


// -----------------------------------------------------------------------------------
//		かんたん検索エラー表示
// -----------------------------------------------------------------------------------

function checkEasySearchForm(){
	var errorMessage1 = "職種またはインターネットサービス分類を選択してください。";
	var errorMessage2 = "勤務地を指定する場合は、必ず職種も選択してください。";
	var jobCategory = document.getElementById("categorizedJobTypeId").value;
	var serviceCategory = document.getElementById("serviceCategoryId").value;
	var area = document.getElementById("areaId").value;

	if(jobCategory == 0 && serviceCategory == 0 && area == 0){
	document.getElementById("errorMessage").style.display = "block";
	document.getElementById("errorMessage").innerHTML = errorMessage1;
	return false;
	}else if(area > 0 && jobCategory == 0){
	document.getElementById("errorMessage").style.display = "block";
	document.getElementById("errorMessage").innerHTML = errorMessage2;
	return false;
	}
	return true;
}