//box = ['event','kunren','info'];
	
	//検索init
	function searching() {
		setSearch();
	}
	
	//検索ボックス準備（js on）
	function setSearch(){
		$sform = $("#searchbox form");
		$sform
			.attr("target","_self")
			.attr("action",$sform.attr("title"));
		$("#serach_url",$sform).remove();
		$("#search_txt").click(function() {
			$(this).css("background","none");
		});
		$("#search_txt").blur(function() {
			if($(this).val()) {
				$(this).css("background","none");
			}else{
				$(this).css("background","url(../images/search_bg.gif) no-repeat 2px 2px");
			}
		});
		
	}

function gmenuSelected() {
	/*
	nowurl = location.pathname;//ファイル名を取得
	bugtxt = "/goodjob/";
	blng = bugtxt.length-1;
	url = nowurl.slice(blng);
	*/
	
	url = location.pathname;
	
	if(url=="/seeker_leave.php") {//お仕事を探す
		$("#g_menu #shitsugyo a").addClass("selected");
	}
	if(url=="/seeker_jobsearch.php") {//お仕事を探す
		$("#g_menu #work a").addClass("selected");
	}
	if(url=="/seeker_kunren.php") {//職業訓練を受けたい
		$("#g_menu #kunren a").addClass("selected");
	}
	if(url=="/seeker_faq.php") {//なんでもfaq
		$("#g_menu #faq a").addClass("selected");
	}
	if(url=="/seeker_event.php") {//イベント情報
		$("#g_menu #event a").addClass("selected");
	}
	if(url=="/seeker_eventlist.php") {//イベント情報一覧
		$("#g_menu #event a").addClass("selected");
	}
	if(url=="/seeker_event_detail.php") {//イベント情報詳細
		$("#g_menu #event a").addClass("selected");
	}
	if(url=="/seeker_blog.php") {//スタッフブログ
		$("#g_menu #staffblog a").addClass("selected");
	}
	if(url=="/seeker_aboutUs.php") {//スタッフ紹介
		$("#g_menu #staff a").addClass("selected");
	}
		
}

function scrolltop() {
	jQuery.easing.quart = function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t -1) + b;
	}
	$(function () {
		$('a[href=#header]').click(function() {
			$($.browser.opera ? document.compatMode == 'BackCompat' ? 'body' : 'html' :'html,body').animate({scrollTop:0 ,scrollLeft:0});
			//$('html,body').animate({ scrollTop: 0 }, 400, 'quart');
		});
	});
}


function setTopElement() {
	//alert(box);
	var nowCookie = $.cookie('TOPBOXS');
	if(nowCookie) {
		box=nowCookie.split(",");
	}else {
		box = ['event','kunren','info'];
	}
	var box2 = ['event','kunren','info'];
	var elementArr = [];
	//alert("box is "+box);
	
	//boxの中身が空だったら
	if(box=="") {
		box = box2;
		//alert("true");
	}else{
		//boxの中身がある
		//alert("1st false");
		
		//boxの内容がbox2と一緒なら
		if(box ==box2){
			return;
			//alert("both");
		}else {//boxの内容がbox2の内容と異なるなら
			//alert("2nd false");
			//alert(box);
			for(var i=0; i<3; i++) {
				//alert(box[i]);
				elementArr[i] = $("#"+(box[i]+"_box"));
				$("#"+(box[i]+"_box")).remove();
			}
			setElement();
		}
	}
	function setElement(){
		for(var i=0; i<3; i++) {
			//alert("setelement is "+elementArr[i]);
			$("#content").append(elementArr[i]);
		}
		$.cookie('TOPBOXS',box,{expires:7,path:'/'});
	}
}
 
function elementChange(element,values) {
	var s = element;
	var v = values;
	
	//alert(s+' '+v);
	//alert(box);
	for(var i=0; i<3; i++) {
		if(s ==box[i]) {
			if(i==0) {//一番上にある場合
				if(v == 'UP') {//上をおすと反応しない
					//alert('no');
					return;
				}
				if(v == 'DOWN') {//下を押す
					//alert('down');
					//配列の要素を入れ替え
					//フェードアウト
					$("#"+(box[0]+"_box")).fadeOut(200,
						function () {
							}
					);
					$("#"+(box[1]+"_box")).fadeOut(200,
						function () {
							topChange();
							}
					);
					function topChange() {
						var d = box.splice(0,2,box[1],box[0]);
						//alert(box);
						//実際の要素を配列の順番に移動
						var boxA = $("#"+(box[0]+"_box"));
						var boxB = $("#"+(box[1]+"_box"));
						boxA.after(boxB);
						//フェードイン
						$("#"+(box[0]+"_box")).fadeIn(200);
						$("#"+(box[1]+"_box")).fadeIn(200);
						$.cookie('TOPBOXS',box,{expires:7,path:'/'});
						//alert(box);

						return;
					}
				}
			}
			if(i==1) {
				if(v == 'DOWN') {//下を押す
					//alert('down');
					//配列の要素を入れ替え
					//フェードアウト
					$("#"+(box[1]+"_box")).fadeOut(200,
						function () {
							}
					);
					$("#"+(box[2]+"_box")).fadeOut(200,
						function () {
							middleDownChange();
							}
					);
					function middleDownChange() {
						var d = box.splice(1,2,box[2],box[1]);
						//alert(box);
						//実際の要素を配列の順番に移動
						var boxA = $("#"+(box[1]+"_box"));
						var boxB = $("#"+(box[2]+"_box"));
						boxA.after(boxB);
						//フェードイン
						$("#"+(box[1]+"_box")).fadeIn(200);
						$("#"+(box[2]+"_box")).fadeIn(200);
						$.cookie('TOPBOXS',box,{expires:7,path:'/'});
						//alert(box);

					}
					return;
				}
				if(v == 'UP') {//上を押す
					//alert('UP');
					//配列の要素を入れ替え
					//フェードアウト
					$("#"+(box[0]+"_box")).fadeOut(200,
						function () {
							}
					);
					$("#"+(box[1]+"_box")).fadeOut(200,
						function () {
							middleUpChange();
							}
					);
					function middleUpChange() {
						var d = box.splice(0,2,box[0],box[1]);
						//alert(box);
						//実際の要素を配列の順番に移動
						var boxA = $("#"+(box[1]+"_box"));
						var boxB = $("#"+(box[0]+"_box"));
						boxA.after(boxB);
						//フェードイン
						$("#"+(box[0]+"_box")).fadeIn(200);
						$("#"+(box[1]+"_box")).fadeIn(200);
						$.cookie('TOPBOXS',box,{expires:7,path:'/'});
						//alert(box);

					}
					return;
				}
			}
			if(i==2) {
				if(v == 'DOWN') {//下を押しても反応ない
					//alert('no');
					return;
				}
				if(v == 'UP') {//上を押す
					//alert('UP');
					//配列の要素を入れ替え
					//フェードアウト
					$("#"+(box[1]+"_box")).fadeOut(200,
						function () {
							}
					);
					$("#"+(box[2]+"_box")).fadeOut(200,
						function () {
							underChange();
							}
					);
					function underChange() {
						var d = box.splice(1,2,box[2],box[1]);
						//alert(box);
						//実際の要素を配列の順番に移動
						var boxA = $("#"+(box[1]+"_box"));
						var boxB = $("#"+(box[2]+"_box"));
						boxA.after(boxB);
						//フェードイン
						$("#"+(box[1]+"_box")).fadeIn(200);
						$("#"+(box[2]+"_box")).fadeIn(200);
						$.cookie('TOPBOXS',box,{expires:7,path:'/'});
						//alert(box);

					}
					return;
				}
			}
			return;
		}
		//alert(box[i]);
	}
}


//職業訓練一覧のアコーディオンメニュー
function acodion() {
	$("div#training_list div.t_details").hide();
	$("div#training_list div.training_box div.t_list").click(function() {
		var target = $("div#training_list div.training_box div.t_list").index(this);	
		$("div#training_list div.t_details").eq(target).slideToggle("fast");
		}).mouseover(function() {
			$(this).addClass("over");//マウスオーバー
		}).mouseout(function() {
			$(this).removeClass("over");//マウスアウト
		}).css("cursor","pointer");
};

//クッキーにどこにいるか（求職者=s or事業主=e）を設定する
function setCookie() {
	//alert("cookie s");
	$.cookie('MAINVISIBLE','s',{expires:7,path:'/'});
}

$(document).ready(function() {
	setCookie();
	setTopElement();
	searching();
});


