/*
+-----------------------------------------------
+	Javascript for WeSpace Softs.
+	-----------------------------------------
+	Copyright (c) 2004 - 2009 wesofts.com
+	http://www.wesofts.com
+-----------------------------------------------
*/
var displaylang = {
	'apply_ur' : '您还没有选择求职简历',
	'apply_ss' : '恭喜您! 您的职位申请已经提交完成',
	'apply_confirm' : '您是否要提交职位申请',
	'apply_process' : '正在提交您的申请, 请稍候...',
	'faver_ss' : '加入收藏夹完成',
	'faver_confirm' : '您是否确定要将该职位加入到您的收藏夹',
	'faver_process' : '正在收藏, 请稍候...',
	'email_ss' : '职位推荐已经发送完成',
	'email_ue' : '您还没有填写收件人地址',
	'email_ie' : '收件人地址格式不正确, 请检查后再试',
	'email_confirm' : '您是否确定要发送职位推荐?',
	'email_process' : '正在推荐, 请稍候...',
	'us' : '您还没有填写安全码\n\n提示: \n1: 请将右边图片的字符填写到左边的文本框中.\n2: 点击图片, 替换安全码.',
	'is' : '您填写的安全码不正确或已过期\n\n点击图片, 替换安全码',
	'loading' : '正在加载, 请稍候...', 
	'display_plugins_people' : '人', 
	'display_plugins_peoples' : '多人'

};
function display_object(){
	this.ajaxid = 'display_ajaxwrap';
	this.ajaxoff = function(){if ($(this.ajaxid)){$(this.ajaxid).style.display = 'none';}};
	this.ajaxwidth = 578;
	/*
	+-------------------------------------------
	+ Change.Category.ID
	+-------------------------------------------
	*/
	this.setcate = function(id){
		var cateid = 'categoryextends';
		if ($(cateid)){
			$(cateid).style.display = id == -1 ? '' : 'none';
		}
	}
	/*
	+-------------------------------------------
	+ MulityJobList Switch
	+-------------------------------------------
	*/
	this.gotojob = function(id){
		var lists = '';
		var _wraper = 'gotojob_wraper';
		var _detail = 'gotojob_detail';
		if (isNaN(id) || id < 0 || id >= joblinks.length){ return false; }
		id = parseInt(id);
		for (var i = 0; i < joblinks.length; i++){
			var tmps = joblinks[i].split(',');
			if (i == id){
				lists += '<li class="t">'+tmps[1]+'</li>';
				if ($(_detail + tmps[0])){
					$(_detail + tmps[0]).style.display = '';
				}
				//FIXED: 20090901
				if ($('gotojob_detail_jobname')){
					$('gotojob_detail_jobname').innerHTML = tmps[1];
				}
				if ($('gotojob_detail_people') && typeof(tmps[2]) != 'undefined'){
					tmps[2] = parseInt(tmps[2]);
					$('gotojob_detail_people').innerHTML = tmps[2] > 0 ? (tmps[2] + ' ' + displaylang.display_plugins_people) : displaylang.display_plugins_peoples;
				}
				if ($('gotojob_detail_jobkinds') && typeof(tmps[3]) != 'undefined'){
					$('gotojob_detail_jobkinds').innerHTML = tmps[3];
				}
			} else {
				lists += '<li class="f"><a href="#" onclick="displayer.gotojob('+i+');return false">'+tmps[1]+'</a></li>';
				if ($(_detail + tmps[0])){
					$(_detail + tmps[0]).style.display = 'none';
				}
			}
		}
		if ($(_wraper)){
			$(_wraper).innerHTML = '<ol>' + lists + '</ol>';
		}
	};
	/*
	+-------------------------------------------
	+ Switch to Detail Description.
	+-------------------------------------------
	*/
	this.godetail = function(jobid,amount){
		for (var i = 1; i <= 2; i++){
			if (i == amount){
				$('display_jobsnavs_' + jobid + '_' + i).className = 't';
				$('display_jobswrap_' + jobid + '_' + i).style.display = '';
			} else {
				$('display_jobsnavs_' + jobid + '_' + i).className = 'f';
				$('display_jobswrap_' + jobid + '_' + i).style.display = 'none';
			}
		}
	};
	/*
	+-------------------------------------------
	+ ActionQuery
	+-------------------------------------------
	*/
	this.apply = function(url,results){
		var theform = document.wane_jobs_apply;
		if (results){ globals.masker(false,true);
			if (results == 'ss'){ alert(displaylang.apply_ss); this.ajaxoff(); return true;}
			var tmpmsg = '';
			var focuser = '';
			switch (results){
				case 'ur' : tmpmsg = displaylang.apply_ur; break;
				case 'us' : tmpmsg = displaylang.us; focuser = 'securiteid'; break;
				case 'is' : tmpmsg = displaylang.is; focuser = 'securiteid'; break;
			}
			if (tmpmsg != ''){ alert(tmpmsg); }
			if (focuser != ''){ eval('theform.'+focuser+'.focus()'); }
			if (theform.SubmitName.disabled){ theform.SubmitName.disabled = false; }
		} else {
			if (url){ globals.position(this.ajaxid,this.ajaxwidth);
				Ajax.xml(url,this.ajaxid);
			} else {
				if (theform.securiteid && theform.securiteid.value == ''){
					this.apply(false,'us');
					return false;
				}
				if (confirm(displaylang.apply_confirm)){
					theform.SubmitName.disabled = true;
					globals.masker(displaylang.apply_process);
				} else {
					return false;
				}
			}
		}
	};
	this.faver = function(url,results){
		var theform = document.wane_jobs_faver;
		if (results){globals.masker(false,true);
			if (results == 'ss'){ alert(displaylang.faver_ss); this.ajaxoff(); return true;}
			var tmpmsg = '';
			var focuser = '';
			switch (results){
				case 'us' : tmpmsg = displaylang.us; focuser = 'securiteid'; break; 
				case 'is' : tmpmsg = displaylang.is; focuser = 'securiteid'; break; 
			}
			if (tmpmsg != ''){ alert(tmpmsg); }
			if (focuser != ''){ eval('theform.'+focuser+'.focus()'); }
			if (theform.SubmitName.disabled){ theform.SubmitName.disabled = false; }
		} else {
			if (url){ globals.position(this.ajaxid,this.ajaxwidth);
				Ajax.xml(url,this.ajaxid);
			} else {
				if (theform.securiteid && theform.securiteid.value == ''){
					this.faver(false,'us');
					return false;
				}
				if (confirm(displaylang.faver_confirm)){
					theform.SubmitName.disabled = true;
					globals.masker(displaylang.faver_process);
				} else {
					return false;
				}
			}
		}
	};
	this.email = function(url,results){
		var theform = document.wane_jobs_email;
		if (results){globals.masker(false,true);
			if (results == 'ss'){ alert(displaylang.email_ss); this.ajaxoff(); return true;}
			var tmpmsg = '';
			var focuser = '';
			switch (results){
				case 'ue' : tmpmsg = displaylang.email_ue; focuser = 'recmail'; break; 
				case 'ie' : tmpmsg = displaylang.email_ie; focuser = 'recmail'; break; 
				case 'us' : tmpmsg = displaylang.us; focuser = 'securiteid'; break; 
				case 'is' : tmpmsg = displaylang.is; focuser = 'securiteid'; break; 
			}
			if (tmpmsg != ''){ alert(tmpmsg); }
			if (focuser != ''){ eval('theform.'+focuser+'.focus()'); }
			if (theform.SubmitName.disabled){ theform.SubmitName.disabled = false; }
		} else {
			if (url){ globals.position(this.ajaxid,this.ajaxwidth);
				Ajax.xml(url,this.ajaxid);
			} else {
				if (theform.recmail.value == ''){
					this.email(false,'ue');
					return false;
				}
				if (theform.securiteid && theform.securiteid.value == ''){
					this.email(false,'us');
					return false;
				}
				if (confirm(displaylang.email_confirm)){
					theform.subject.value = $('email_subject').innerHTML;
					theform.message.value = $('email_message').innerHTML;
					theform.SubmitName.disabled = true;
					globals.masker(displaylang.email_process);
				} else {
					return false;
				}
			}
		}
	};
}
var displayer = new display_object();