/*
+-----------------------------------------------
+	WeSpace Base Javascript
+-----------------------------------------------
*/
var displayer = Display = {
	Lang : {
		people : '', 
		peoples : '多',
		apply : {
			uj : '您还没有选择要应聘的职位', 
			ur : '您还没有选择求职简历',
			ca : '确定要申请选定职位吗?', 
			ss : '您选中的职位已经申请完成',
			dialog : '申请职位'
		}, 
		faver : {
			ut : '您还没有填写新类别名称', 
			ss : '您选定的职位已经加入到您的收藏夹中',
			cf : '确定要收藏吗?',
			dialog : '收藏职位'
		},
		email : {
			un : '请填写收件人', 
			ue : '请填写收邮箱', 
			ie : '邮箱格式错误', 
			ss : '邮件已发到到 {email} 中',
			cs : '确定发送吗?', 
			dialog : '推荐给我的朋友'
		}
	},
	apply : function(url, results){
		if (url){
			WSBase.Ajax.xml(url.replace(/&amp;/ig, '&'), 'dialog', this.Lang.apply.dialog);
		} else {
			var theform = document.wane_display_jobs_apply, tmpmsg = prompter = ''; if (results){ WSBase._plugins.masker(true); WSBase._plugins.loader(true);
				switch (results){
					case 'uj' : tmpmsg = this.Lang.apply.uj; prompter = 'jobsapply_jobs'; break;
					case 'ur' : tmpmsg = this.Lang.apply.ur; prompter = 'jobsapply_resume'; break;
					case 'ss' : WSBase._displayer.closer(); tmpmsg = this.Lang.apply.ss; break;
				} WSBase._func.alerter(tmpmsg); WSBase._func.focuser(theform, false, prompter, tmpmsg);
			} else {
				if (WSBase._func.checks(theform) == ''){
					this.apply(false, 'uj');
					return false;
				} if (theform.cnresume.value == 0 && theform.enresume.value == 0){
					this.apply(false, 'ur');
					return false;
				} if (confirm(this.Lang.apply.ca)){
					WSBase._plugins.masker(); WSBase._plugins.loader();					
				} else {
					return false;
				}
			}
		}
	},
	faver : function(url, results){
		if (url){
			WSBase.Ajax.xml(url.replace(/&amp;/ig, '&'), 'dialog', this.Lang.faver.dialog);
		} else {
			var theform = document.wane_display_jobs_faver, tmpmsg = focuser = ''; if (results){ WSBase._plugins.masker(true); WSBase._plugins.loader(true);
				switch (results){
					case 'ut' : tmpmsg = this.Lang.faver.ut; focuser = 'foldername'; break;
					case 'ss' : WSBase._displayer.closer(); tmpmsg = this.Lang.faver.ss; break;
				} WSBase._func.alerter(tmpmsg); if (focuser != ''){
					WSBase._func.focuser(theform, focuser, focuser, tmpmsg);
				}
			} else {
				if (theform.folderid.value == -1 && theform.foldername.value == ''){
					this.faver(false, 'ut');
					return false;
				} WSBase._displayer.prompter(false, false, true); if (confirm(this.Lang.faver.cf)){ WSBase._plugins.masker(); WSBase._plugins.loader();
					theform.submit();
				} else {
					return false;
				}
			}
		}
	},
	email : function(url, results){
		if (url){
			WSBase.Ajax.xml(url.replace(/&amp;/ig, '&'), 'dialog', this.Lang.email.dialog);
		} else {
			var theform = document.wane_display_jobs_email, msg = field = ''; if (results){ WSBase._plugins.masker(true); WSBase._plugins.loader(true);
				switch (results){
					case 'un' : msg = this.Lang.email.un; field = 'recname'; break;
					case 'ue' : msg = this.Lang.email.ue; field = 'recmail'; break;
					case 'ie' : msg = this.Lang.email.ie; field = 'recmail'; break;
					case 'ss' : WSBase._displayer.closer(); msg = this.Lang.email.ss.replace(/\{email\}/ig, theform.recmail.value); break;
				} WSBase._func.error(theform, field, msg);
			} else {
				if (theform.recname.value == ''){
					this.email(false, 'un');
					return false;
				} if (theform.recmail.value == ''){
					this.email(false, 'ue');
					return false;
				} if (confirm(this.Lang.email.cs)){ WSBase._plugins.masker(); WSBase._plugins.loader();
					var os = WSBase._func.is_object('email_subject'), om = WSBase._func.is_object('email_message'); if (os && theform.subject){
						theform.subject.value = os.innerHTML;
					} if (om && theform.message){
						theform.message.value = om.innerHTML;
					} theform.submit();
				} else {
					return false;
				}
			}
		}
	},

	gotojob : function(id){
		var obj = WSBase._func.is_object('gotojob_wraper'), ij = 'gotojob_detail_jobname', ip = 'gotojob_detail_people', ik = 'gotojob_detail_jobkinds', jd = 'gotojob_detail';
		var lists = '', sid = !isNaN(id) && id > 0 && id < joblinks.length ? parseInt(id) : 0; for (var i = 0; i < joblinks.length; i++){
			var tmps = joblinks[i].split(','); if (tmps.length >= 4){
				var od = WSBase._func.is_object(jd + tmps[0]); if (od){
					if (i == sid){ od.style.display = 'block';
						var oj = WSBase._func.is_object(ij), op = WSBase._func.is_object(ip), ok = WSBase._func.is_object(ik); if (oj && op && ok){
							oj.innerHTML = tmps[1];
							op.innerHTML = !isNaN(tmps[2]) && tmps[2] > 0 ? parseInt(tmps[2]) + this.Lang.people : this.Lang.peoples;
							ok.innerHTML = tmps[3];
						} lists += '<li class="t"><a>'+tmps[1]+'</a></li>';
					} else { od.style.display = 'none';
						lists += '<li class="f"><a href="#" onclick="displayer.gotojob(' + i + ');return false">'+tmps[1]+'</a></li>';
					}
				}
			}
		} if (obj){
			obj.innerHTML = lists;
		}
	},
	godetail : function(jobid, handle){
		for (var i = 1; i <= 3; i++){
			var ot = WSBase._func.is_object('display_jobsnavs_' + jobid + '_' + i), ow = WSBase._func.is_object('display_jobswrap_' + jobid + '_' + i); if (ot && ow){
				if (i == handle){
					ot.className = 't';
					ow.style.display = 'block';
				} else {
					ot.className = 'f';
					ow.style.display = 'none';
				}
			}
		}
	}, 
	moder : function(isList){
		var cookname = 'listastable', cookhours = 365 * 24; if (isList){
			WSBase._func.cookier(cookname, 1, cookhours);
		} else {
			WSBase._func.cookier(cookname, 0, cookhours);
		} WSBase._func.director();
	},
	collapsed : function(id){
		var obj = WSBase._func.is_object(id), cls = 'on'; if (obj){
			if (obj.style.display == 'none'){ cls = 'on';
				obj.style.display = '';
			} else { cls = 'off';
				obj.style.display = 'none';
			}
		} return cls;
	},
	mulity : {
		apply : function(url){
			if (url != ''){
				displayer.apply(url);
			}
		}, display : function(url){
			if (url != ''){
				window.open(url);
			}
		}
	}
};
