(function(){
	jobseeker = {
		box:null,
		boxcontent:null,
		options:{},
		apply:function(options){
			this.options = options;
			this.options.pid = this.options.pid || getCheckbox('id[]', 'list_table');
			if(!this.options.pid){
				alert('请选择一个职位');
				return false;
			}
			this.box = new Lightbox();
			this.box.start(400, 210, '申请所选职位');
			this.boxcontent = $('boxcontent');
			if(this.options.login == 0){
				this.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, '<p class="error" id="err-txt">对不起，您还没有登陆系统！</p>'),true);
				this.box.update(this.nologin,true);
			}else if(this.options.login == 1){
				this.boxcontent.insert(dynamic.options.loadingText);
				this.boxcontent.insert(dynamic.loadImg());
				var url = '/find_etp.php?action=getResume', th = this;
				new Ajax.Request(url,{
					method:'get',
					parameters:{ajax:1},
					onSuccess:function(transport){
						$('loa-txt').remove();
						$('loading').remove();
						th.box.update(transport.responseText, true);
					},
					onException:function(){
						$('loa-txt').remove();
						$('loading').remove();
						th.boxcontent.insert(dynamic.endNoticeMsg(dynamic.options.errorImg, '<p class="error" id="err-txt">网络发生错误，请联系本站：0668-2299566</p>'), true);
					}
				});
				var th = this;
				(function(){
					$('ok').observe('click', th.saveApply.bind(th));
				}).defer();
			}else{
				return false;
			}
		},
		saveApply:function(){
			var id = getRadio('rid', 'resume_tb');
			if(!id){
				alert('请选择一份简历');
				return false;
			}
			var url = '/find_etp.php?action=saveApply', th = this;
			//alert(typeof(this.options.pid));
			var pid = this.options.pid;
			if(typeof(this.options.pid) == 'object'){
				pid = this.options.pid.join(',');
			}
			new Ajax.Request(url, {
				method:'post',
				parameters:{ajax:1, rid:id, pid:pid},
				onSuccess:function(transport){
					//Common.dump(transport.responseText);
					var arr = transport.responseText.evalJSON();
					$('pro-txt').remove();
					$('proccessing').remove();
					$('resume_tb').remove();
					$('ok').remove();
					if(arr.status == 1){
						th.box.update(dynamic.endNoticeMsg(null, '<p class="success" id="suc-txt">操作成功 ，请等候企业的回复</p>'), true);
					}else{
						th.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, dynamic.options.errorText), true);
					}
				},
				onCreate:function(){
					th.boxcontent.insert(dynamic.options.proccessingText);
					th.boxcontent.insert(dynamic.proImg());
				},
				onException:function(){
					$('pro-txt').remove();
					$('proccessing').remove();
					th.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, '<p class="error" id="err-txt">网络发生错误，请联系本站：0668-2299566</p>'), true);
				}
			});
		},
		favorite:function(options){
			//this.options = options;
			var pid = options.pid || getCheckbox('id[]', 'list_table');
			if(!pid){
				alert('请选择一个职位');
				return false;
			}
			if(typeof(pid) == 'object'){
				pid = pid.join(',');
			}
			this.box = new Lightbox();
			this.box.start(400, 210, '收藏所选职位');
			this.boxcontent = $('boxcontent');
			$('ok').remove();
			if(options.login == 0){
				this.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, '<p class="error" id="err-txt">对不起，您还没有登陆系统！</p>'),true);
				this.box.update(this.nologin,true);
			}else if(options.login == 1){
				var url = '/find_etp.php?action=saveFavorite', th = this;
				new Ajax.Request(url,{
					method:'post',
					parameters:{ajax:1, pid:pid},
					onSuccess:function(transport){
						var arr = transport.responseText.evalJSON();
						$('pro-txt').remove();
						$('proccessing').remove();
						if(arr.status == 1){
							th.box.update(dynamic.endNoticeMsg(null, '<p class="success" id="suc-txt">操作成功，这些职位已在你收藏夹中，请对这些收藏的职位进一步了解。</p>'), true);
						}else{
							th.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, dynamic.options.errorText), true);
						}
					},
					onCreate:function(){
						th.boxcontent.insert(dynamic.options.proccessingText);
						th.boxcontent.insert(dynamic.proImg());
					},
					onException:function(){
						$('pro-txt').remove();
						$('proccessing').remove();
						th.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, '<p class="error" id="err-txt">网络发生错误，请联系本站：0668-2299566</p>'), true);
					}
				});
			}else{
				return false;
			}

		},
		nologin: '<table id="nologin" style="margin:10px;border-bottom:#ccc solid 1px;width:360px">\
			<tr><td>\
			<input type="button" class="rbutton" onclick="window.location.href=\'/login.php\';"\
			 value="马上去登陆" /><br><div style="margin-top:15px;">已注册未会员，请登录！</div>\
			 </td><td valign="top">\
			<input type="button" class="rbutton" onclick="window.location.href=\'/register.php?role=1\';"\
			 value="注册帐号" /><br><div style="margin-top:15px;">尚未注册成为会员，请先注册</div>\
			</td></tr>\
		</table>'
	};
})();