(function(){
	hirer = {
		box:null,
		boxcontent:null,
		options:{},
		report : function(options)
		{
			this.options = Object.extend({
				rid:null,
				name:null
			}, options || {});
			this.box = new Lightbox();
			this.box.start(450, 330, '简历虚假提交—中国工程监理人才网');
			this.boxcontent = $('boxcontent');
			this.boxcontent.insert({top:this.genReportForm(this.options.rid, this.options.name)});
			this.boxcontent.insert('<div id="notice" class="red">企业遇到到虚假信息可以在这里提交反馈回来给我们。</div>');
			var th = this;
			(function(){
				$('ok').observe('click', th.saveReport.bind(th));
			}).defer();
		},
		genReportForm:function(rid, name){
			var form = Builder.node('form', {id:'reportform', action:'/find_idl.php?action=saveReport', method:'post'},
			Builder.node('ul', {id:'report_ul'},[
			Builder.node('li', {className:'b'}, '举报对象：'),
			Builder.node('li', {}, Builder.node('input', {id:'biaoti', name:'biaoti', className:'txt', value:'简历编号：'+rid + ', ' + name})),
			Builder.node('li', {className:'b'}, '举报内容：'),
			Builder.node('li', {}, Builder.node('textarea', {id:'neirong', name:'neirong', className:'txt', style:'width:420px;height:130px;'})),
			Builder.node('li', {}, '请详细描叙简历不真实或有错误的地方!我们将会电话核实后发送结果至您的邮箱!')
			])
			);
			return form;
		},
		saveReport:function()
		{
			if($F('biaoti') == '' || $F('neirong') == ''){
				alert('标题或举报内容不能为空');
				return false;
			}
			var form = $('reportform');
			var th = this;
			form.request({
				parameters:{ajax:1, rid:this.options.rid},
				onComplete:function(transport){
					//Common.dump(transport.responseText);return;
					var arr = transport.responseText.evalJSON();
					$('pro-txt').remove();
					$('proccessing').remove();
					$('reportform').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(){
					form.disable();
					$('notice').remove();
					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);
				}
			});
		},
		invite:function(options)
		{
			this.options = Object.extend({
				rid:null,
				name:null
			}, options || {});
			this.box = new Lightbox();
			this.box.start(540, 430, '向“'+this.options.name+'”发送招聘意向');
			this.boxcontent = $('boxcontent');
			this.getPosition(1);
			var th = this;
			(function(){
				$('ok').observe('click', th.saveInvite.bind(th));
			}).defer();
		},
		getPosition : function(page)
		{
			var url = '/find_idl.php?action=getPosition', th = this;
			var page = page || 1;
			
			new Ajax.Request(url,{
				method:'get',
				parameters:{ajax:1, page:page},
				onSuccess:function(transport){
					$('loa-txt').remove();
					$('loading').remove();
					if($('list_position')) $('list_position').remove();
					th.box.update(transport.responseText, true);
				},
				onCreate:function(){
					th.boxcontent.insert(dynamic.options.loadingText);
					th.boxcontent.insert(dynamic.loadImg());
				},
				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);
				}
			});
		},
		saveInvite:function()
		{
			var pid = getRadio('pid', 'list_position');
			if(!pid){
				alert('请选择一个职位向 “'+this.options.name+' ”发送招聘意向');
				return false;
			}
			var url = '/find_idl.php?action=saveInvite';
			var th = this;
			new Ajax.Request(url, {
				method:'post',
				parameters:{ajax:1, rid:this.options.rid, pid:pid},
				onSuccess:function(transport){
					//Common.dump(transport.responseText);return;
					var arr = transport.responseText.evalJSON();
					$('pro-txt').remove();
					$('proccessing').remove();
					$('ok').remove();
					$('list_position').remove();
					th.boxcontent.style.height = '150px';
					if(arr.status == 1){
						th.box.update(dynamic.endNoticeMsg(null, '<p class="green" id="suc-txt" style="pading:3px;border:#698B22 solid 1px;">发送招聘意向成功 ，请等候“'+th.options.name+'”的回复</p>'), true);
					}else{
						th.box.update(dynamic.endNoticeMsg(dynamic.options.errorImg, dynamic.options.errorText), true);
					}
				},
				onCreate:function(){
					$('ok').disable();
					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);
				}
			});
		}
	};
})();
