$(function(){
	$.each(atObj, function(i, val) {
      if(val){
		$("#cat"+i).append("<span class=\"default_color\">("+val+")</span>");
	  }
    });
	$("#ures .bar_color, #txtlink .bar_color, #bannerlink .bar_color, .corner_job, .corner_resume").topCorner();
	$("#ures .bar_color, #txtlink .bar_color, #bannerlink .bar_color, .corner_job, .corner_resume").bottomCorner();
	//Employer
	$("#emp_form").submit(function(event){
		event.preventDefault();
		var ut = /[\W]/g;
		var ut3 = /\s/g;
		$("#emp_id").val($.trim($("#emp_id").val()));
		$("#emp_password").val($.trim($("#emp_password").val()));
		$("#emp_form").ajaxSubmit({
			beforeSubmit: function(){
				if(ut.test($("#emp_id").val()) || $("#emp_id").val().length<4 || $("#emp_id").val().length>50){
					$("#emp_su .login_msg").show().text("Username ไม่ถูกต้อง");
					return false;
				}else if(ut3.test($("#emp_password").val()) || $("#emp_password").val().length<4 || $("#emp_password").val().length>20){
					$("#emp_su .login_msg").show().text("Password ไม่ถูกต้อง");
					return false;
				}else{
					$("#emp_su .login_msg").hide();
					$("#emp_form").hide().after("<img src='/images/spin.gif' hspace='108' vspace='15' />");
					return true;
				}
			},
			success: function(msg){
				if(msg.substring(0, 2)=='OK'){
					window.location = '/company/index';
				}else{
					$("#emp_form").show();
					$("#emp_su .login_msg").show().text("Username หรือ Password ไม่ถูกต้อง");
					$("#emp_form ~ img").remove();
				}
			}
		 });
	});
	//Profile
	$("#profile_form").submit(function(event){
		event.preventDefault();
		var ut = /[\W]/g;
		var ut3 = /\s/g;
		$("#seeker_id").val($.trim($("#seeker_id").val()));
		$("#seeker_password").val($.trim($("#seeker_password").val()));
		$("#profile_form").ajaxSubmit({
			beforeSubmit: function(){
				if(ut.test($("#seeker_id").val()) || $("#seeker_id").val().length<4 || $("#seeker_id").val().length>50){
					$("#user_su .login_msg").show().text("Username ไม่ถูกต้อง");
					return false;
				}else if(ut3.test($("#seeker_password").val()) || $("#seeker_password").val().length<4 || $("#seeker_password").val().length>20){
					$("#user_su .login_msg").show().text("Password ไม่ถูกต้อง");
					return false;
				}else{
					$("#user_su .login_msg").hide();
					$("#profile_form").hide().after("<img src='/images/spin.gif' hspace='108' vspace='15' />");
					return true;
				}
			},
			success: function(msg){
				if(msg.substring(0, 2)=='OK'){
					window.location = '/profile/index';
				}else{
					$("#profile_form").show();
					$("#user_su .login_msg").show().text("Username หรือ Password ไม่ถูกต้อง");
					$("#profile_form ~ img").remove();
				}
			}
		 });
	});
	//
	$("#res_menu li").click(function(){
		$("#res_menu li").removeClass().addClass('bar_color').addClass('border_color').addClass('header_color');
		$("#cresume1, #cresume2").hide();
		if(this.id=='rsm1'){
			$("#rsm1").removeClass().addClass('selected').addClass('bg_color').addClass('border_color').addClass('link_style');
			$("#cresume1").show();
		}else{
			$("#rsm2").removeClass().addClass('selected').addClass('bg_color').addClass('border_color').addClass('link_style');
			$("#cresume2").show();
		}
	});
	//
	loadContent("/company/calm/page:1");
	$(".write_email").text("cs@jobbangkok.com");
	$("#ftp1").append('<iframe src="/truehits.php" width=1 height=1 frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>');	
});

/** End **/
function addAction(){
	$(".subpage a").click(function(event){
		event.preventDefault();
		loadContent($(this).attr("href"));
	});
}
function loadContent(arg){
	$.ajax({
	type: "GET",
	url: encodeURI(arg),
	data: "rand="+Math.random(),
	beforeSend: function(){ $("#hotcompany").empty().html("<img src='/images/spin.gif' class='hot_downloading' />"); },
	success: function(msg){ $("#hotcompany").html(msg); addAction(); }
	});
}
function getTypeTxt(){
	return ' <ul><li id="cat1" class="sep_type"><a href="/jobs/search/searchtype:1">บัญชี/การเงิน</a></li><li id="cat2" class="sep_type"><a href="/jobs/search/searchtype:2">ธุรการ/เลขานุการ</a></li><li id="cat3" class="sep_type"><a href="/jobs/search/searchtype:3">เกษตร/ปศุสัตว์/ประมง/เหมือง</a></li><li id="cat5" class="sep_type"><a href="/jobs/search/searchtype:5">พัฒนาธุรกิจ/ที่ปรึกษา/ISO</a></li><li id="cat6" class="sep_type"><a href="/jobs/search/searchtype:6">โยธา/สถาปัตย์/แต่งภายใน</a></li><li id="cat7" class="sep_type"><a href="/jobs/search/searchtype:7">บริการลูกค้า/ประชาสัมพันธ์</a></li><li id="cat8" class="sep_type"><a href="/jobs/search/searchtype:8">ส่งเอกสาร/ขับรถ/แม่บ้าน/รปภ</a></li><li id="cat9" class="sep_type"><a href="/jobs/search/searchtype:9">ช่าง/วิศวกร</a></li><li id="cat13" class="sep_type"><a href="/jobs/search/searchtype:13">นำเข้า/ส่งออก/Shipping</a></li><li id="cat14" class="sep_type"><a href="/jobs/search/searchtype:14">ธนาคาร/ประกันภัย/หุ้น</a></li><li id="cat10" class="sep_type"><a href="/jobs/search/searchtype:10">ศิลป์/กราฟฟิคดีไซน์/ออกแบบ</a></li><li id="cat11" class="sep_type"><a href="/jobs/search/searchtype:11">ท่องเที่ยว/โรงแรม/ไกด์/ล่าม</a></li><li id="cat12" class="sep_type"><a href="/jobs/search/searchtype:12">ทรัพยากรบุคคล</a></li><li id="cat15" class="sep_type"><a href="/jobs/search/searchtype:15">ไอที/คอมพิวเตอร์</a></li><li id="cat16" class="sep_type"><a href="/jobs/search/searchtype:16">กฎหมาย</a></li><li id="cat17" class="sep_type"><a href="/jobs/search/searchtype:17">ผลิต/ควบคุมคุณภาพ/โรงงาน</a></li><li id="cat18" class="sep_type"><a href="/jobs/search/searchtype:18">การตลาด</a></li><li id="cat19" class="sep_type"><a href="/jobs/search/searchtype:19">บันเทิง/สื่อ/โฆษณา</a></li><li id="cat20" class="sep_type"><a href="/jobs/search/searchtype:20">จัดซื้อ/คลังสินค้า/Logistics</a></li><li id="cat21" class="sep_type"><a href="/jobs/search/searchtype:21">วิทยาศาสตร/R&amp;D</a></li><li id="cat22" class="sep_type"><a href="/jobs/search/searchtype:22">การขาย</a></li><li id="cat23" class="sep_type"><a href="/jobs/search/searchtype:23">อาจารย์/ด้านวิชาการ</a></li><li id="cat24" class="sep_type"><a href="/jobs/search/searchtype:24">Part-time/นักศึกษาฝึกงาน</a></li><li id="cat26" class="sep_type"><a href="/jobs/search/searchtype:26">อาหาร-เครื่องดื่ม/กุ๊ก</a></li><li id="cat28" class="sep_type"><a href="/jobs/search/searchtype:28">ผู้บริหาร/ผู้จัดการ</a></li><li id="cat27" class="sep_type"><a href="/jobs/search/searchtype:27">เขียนแบบ/งาน Drawing</a></li><li id="cat25" class="sep_type"><a href="/jobs/search/searchtype:25">อื่นๆ</a></li></ul>';
}

