/*
+--------------------------------------------------------
+	Copyright (c) 2004-2007 WeSofts
+	JavaScript Project for wespace
+	http://www.wesofts.com
+--------------------------------------------------------
*/
companylang = {
	'remail' : '您填写的邮箱已被其它用户占用, 请更新其它邮箱',
	'inemail' : '您输入的邮箱格式不正确, 请检查后再试',
	'inemailid' : '您输入的邮箱激活码不正确, 请检查后再试\n\n注意: 请从您的注册邮箱中查找激活码.',
	'pass_inold' : '您的旧密码不正确, 操作失败',
	'pass_nonew' : '您的新密码不正确, 长度不少于6个字符',
	'pass_unmach' : '您二次输入的新密码不匹配, 操作失败',
	'file_file' : '您还没有选择要上传的图片文件',
	'file_type' : '您选的图片文件格式, 系统暂不能存储',
	'file_size' : '您选的图片尺寸超过可上传的最大限额',
	'file_write' : '服务器暂不能存在您的图片文件, 请联系管理员',	
	'mulity_maxium_a' : '您最多可添加选项数',
	'mulity_maxium_b' : '项',
	'mulity_existed' : '该选项已经存在',

	'jobsp_jname' : '职位名称必须填写, 长度必须在60个字符以内',
	'jobsp_oid' : '您还没有选择当前发布的职位所属机构',
	'jobsp_jobskinds' : '您还没有选择职位性质',
	'jobsp_jajb' : '您还没有选择工作类别',
	'jobsp_people' : '您还没有填写招聘人数, 不限请留空',
	'jobsp_place' : '您还没有选择工作所在地',
	'jobsp_certid' : '您还没有填写图形码或图形码不正确, 或图形码已过期',

	'faced_subject' : '您还没有填写面试标题',
	'faced_message' : '您还没有填写面试内容',

	'basic_cname' : '您还没有填写企业名称, 长度在60个字符以内',
	'basic_property' : '您还没有选择你的企业性质',
	'basic_sizement' : '您还没有选择您的企业规模',
	'basic_industry' : '您还没有选择您的企业所属的行业',

	'organ_oname' : '您还没有填写机构名称',
	'organ_location' : '您还没有选择机构所在地',
	'organ_contact' : '您还没有填写联系人',
	'organ_phone' : '您还没有填写联系电话',

	'register_nouser' : '您还没有填写登陆用户名',
	'register_invalidu' : '用户名格式不正确',
	'register_repeatu' : '该用户已经存在',
	'register_noemail' : '您还没有填写注册邮箱',
	'register_invalide' : '您的注册邮箱格式不正确',
	'register_repeate' : '该注册邮箱已经存在',
	'register_nopasswd' : '您还没有填写登陆密码',
	'register_nopwdlen' : '登陆密码不符合要求',
	'register_norepass' : '您还没有填写验证密码',
	'register_notmatch' : '您的二次密码输入不一致',
	'user_unexists' : '该用户不正确',
	'user_uncreate' : '您暂不能添加管理成员',
	'user_unmodify' : '您暂不能修改管理成员权限',
	'user_undelete' : '您暂不能删除该管理成员',

	'resume_select_1'			: '性别',
	'resume_select_2'			: '年龄',
	'resume_select_3'			: '学历',
	'resume_select_4'			: '工作经验',
	'resume_select_5'			: '求职意向',
	'resume_select_6'			: '目前薪水',
	'resume_select_7'			: '所在地',
	'resume_select_8'			: '更新时间',
	'resume_select_9'			: '简历类别',

	'resume_search_nojtype'		: '您还没有选择工作类别',
	'resume_search_nojkind'		: '您还没有选择工作性质',
	'resume_schbox_unselect'	: '您还没有选择要删除的搜索器',
	'resume_schbox_success'		: '您选定的搜索器已经删除完成',
	'resume_schbox_maxium'		: '您可添加的搜索器最在限额已经用完',
	'resume_schbox_nodata'		: '暂无符合条件的简历',

	'login_uu'					: '您还没有填写您的用户名',
	'login_iu'					: '该用户不存在, 请检查您的输入是否有误',
	'login_up'					: '您还没有填写您的密码',
	'login_ip'					: '您的密码不正确, 请检查\n\n注意: 密码区分大小写',
	'login_uc'					: '您还没有填写图形码',
	'login_ic'					: '您的图形码不正确, 请检查\n\n注意: 单击图片替换图形码',

	'empty' : '必填资料不完整, 请完整后再提交',
	'unselect' : '您还没有选择要操作的记录',
	'filtrate' : '您的输入含有非法字符, 请检查后再提交'
}
function company_object(){
	this.contentid = 'companycontainer';
	this.loader = function(str){
		if (!str || str == ''){
			return false;
		}
		if (!browser.ishistory){
			browser.setter('company.loader',str);
		}
		Ajax.xml('company|' + str,this.contentid);
	}
	this.framer = function(str){
		if (!str || str == ''){
			return false;
		}
		Ajax.framer('company|' + str);
	}
	this.director = function(uri){
		window.location = uri;
	}
	this.collapsed = function(id,cp){
		if ($(id)){
			$(id).style.display = $(id).style.display == 'none' ? '' : 'none';
		}
	}
	this.ccpstyle = function(id,cls){
		if ($(id)){
			$(id).className = $(id).className.substr($(id).className.length - 2, 2) == '_e' ? cls : cls + '_e';
		}
	}
	this.stater = function(id,num){
		this.newid = 'stat_' + id;
		if ($(this.newid)){
			num = !isNaN(num) && num > 0 ? num : 0;
			$(this.newid).innerHTML = '[' + num + ']';
		}
	}
	this.idxsvc = function(id){
		for (var i = 1; i <= 5; i++){
			if ($('svcn' + i)){
				$('svcn' + i).className = i == id ? 't' : 'f';
			}
			if ($('svcw' + i)){
				$('svcw' + i).style.display = i == id ? '' : 'none';
			}
		}
	}
	this.alerter = function(results){
		this.tmpmsg = '';
		switch(results){
			case 'remail' : this.tmpmsg = companylang.remail; break;
			case 'inemail' : this.tmpmsg = companylang.inemail; break;
			case 'inemailid' : this.tmpmsg = companylang.inemailid; break;

			case 'pass_inold' : this.tmpmsg = companylang.pass_inold; break;
			case 'pass_nonew' : this.tmpmsg = companylang.pass_nonew; break;
			case 'pass_unmach' : this.tmpmsg = companylang.pass_unmach; break;

			case 'file_file' : this.tmpmsg = companylang.file_file; break;
			case 'file_size' : this.tmpmsg = companylang.file_size; break;
			case 'file_type' : this.tmpmsg = companylang.file_type; break;
			case 'file_write' : this.tmpmsg = companylang.file_write; break;

			case 'empty' : this.tmpmsg = companylang.empty; break;
			case 'unselect' : this.tmpmsg = companylang.unselect; break;
			case 'filtrate' : this.tmpmsg = companylang.filtrate; break;
			
		}
		if(this.tmpmsg != ''){
			alert(this.tmpmsg);
		}
	}
	this.vjobsp = function(results,keyid){
		var theform = document.wane_jobs;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'jname' : this.tmpmsg = companylang.jobsp_jname; this.focuser = 'jname'; break;
				case 'oid' : this.tmpmsg = companylang.jobsp_oid; this.focuser = 'oid'; break;
				case 'jobskinds' : this.tmpmsg = companylang.jobsp_jobskinds; this.focuser = 'jobskinds'; break;
				case 'jajb' : this.tmpmsg = companylang.jobsp_jajb; this.focuser = 'jb'; break;
				case 'people' : this.tmpmsg = companylang.jobsp_people; this.focuser = 'people'; break;
				case 'place' : this.tmpmsg = companylang.jobsp_place; this.focuser = ''; break;
				case 'certid' : this.tmpmsg = companylang.jobsp_certid; this.focuser = 'certid'; break;
				case 'filtrate' : this.tmpmsg = companylang.filtrate; this.focuser = keyid; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
			}
			theform.Submit.disabled = false;
		} else {
			if (theform.jname.value == ''){
				this.vjobsp('jname');
				return false;
			}
			if (theform.oid.value == 0){
				this.vjobsp('oid');
				return false;
			}
			if (theform.jobskinds.value == 0){
				this.vjobsp('jobskinds');
				return false;
			}
			if (theform.ja.value == 0 || theform.jb.value == 0){
				this.vjobsp('jajb');
				return false;
			}
			if (theform.people.value != '' && isNaN(theform.people.value)){
				this.vjobsp('people');
				return false;
			}
			if (theform.certid && theform.certid.value == ''){
				this.vjobsp('certid');
				return false;
			}
			category.mulitys(theform,'mulplace');
			theform.Submit.disabled = true;
		}
	}
	this.vfaced = function(results){
		var theform = document.wane_resumes;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'subject' : this.tmpmsg = companylang.faced_subject; this.focuser = 'subject'; break;
				case 'message' : this.tmpmsg = companylang.faced_message; this.focuser = 'message'; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}
			}
		} else {
			if (theform.subject.value == ''){
				this.vfaced('subject');
				return false;
			} else if (theform.message.value == ''){
				this.vfaced('message');
				return false;
			} else {
				theform.Submit.disabled = true;
			}
		}
	}
	this.vbasic = function(results,keyid){
		var theform = document.wane_basic;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'cname' : this.tmpmsg = companylang.basic_cname; this.focuser = keyid; break;
				case 'property' : this.tmpmsg = companylang.basic_property; this.focuser = 'property'; break;
				case 'sizement' : this.tmpmsg = companylang.basic_sizement; this.focuser = 'sizement'; break;
				case 'industry' : this.tmpmsg = companylang.basic_industry; this.focuser = 'industry'; break;
				case 'filtrate' : this.tmpmsg = companylang.filtrate; this.focuser = keyid; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
			}
		} else {
			if (theform.cname && theform.cname.value == ''){
				this.vbasic('cname');
				return false;
			}
			if (theform.property.value == 0){
				this.vbasic('property');
				return false;
			}
			if (theform.sizement.value == 0){
				this.vbasic('sizement');
				return false;
			}
			if (theform.industry.value == 0){
				this.vbasic('industry');
				return false;
			}
		}
	}
	this.vorgan = function(results,keyid){
		var theform = document.wane_organ;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'oname' : this.tmpmsg = companylang.organ_oname; this.focuser = 'oname'; break;
				case 'location' : this.tmpmsg = companylang.organ_location; this.focuser = 'pb'; break;
				case 'contact' : this.tmpmsg = companylang.organ_contact; this.focuser = 'contact'; break;
				case 'phone' : this.tmpmsg = companylang.organ_phone; this.focuser = 'phone'; break;
				case 'filtrate' : this.tmpmsg = companylang.filtrate; this.focuser = keyid; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
				theform.Submit.disabled = false;
			}
		} else {
			if (theform.oname.value == ''){
				this.vorgan('oname');
				return false;
			}
			if (theform.pa.value == 0 || theform.pb.value == 0){
				this.vorgan('location');
				return false;
			}
			if (theform.contact.value == ''){
				this.vorgan('contact');
				return false;
			}
			if (theform.phone.value == ''){
				this.vorgan('phone');
				return false;
			}
			theform.Submit.disabled = true;
		}
	}
	this.vlogo = function(results){
		var theform = document.wane_logo;
		if (results){
			this.tmpmsg = '';
			switch (results){
				case 'file' : this.tmpmsg = companylang.file_file; break;
				case 'type' : this.tmpmsg = companylang.file_type; break;
				case 'size' : this.tmpmsg = companylang.file_size; break;
				case 'write' : this.tmpmsg = companylang.file_write; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				theform.userfile.focus();
				theform.Submit.disabled = false;
			}
		} else {
			if (theform.userfile.value == ''){
				this.vlogo('file');
				return false;
			}
			theform.Submit.disabled = true;
		}
	}
	this.vuser = function(results){
		var theform = document.wane_register;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'nouser'		: this.tmpmsg = companylang.register_nouser;		this.focuser = 'username';		break;
				case 'invalidu'		: this.tmpmsg = companylang.register_invalidu;		this.focuser = 'username';		break;
				case 'repeatu'		: this.tmpmsg = companylang.register_repeatu;		this.focuser = 'username';		break;
				case 'noemail'		: this.tmpmsg = companylang.register_noemail;		this.focuser = 'email';			break;
				case 'invalide'		: this.tmpmsg = companylang.register_invalide;		this.focuser = 'email';			break;
				case 'repeate'		: this.tmpmsg = companylang.register_repeate;		this.focuser = 'email';			break;
				case 'nopasswd'		: this.tmpmsg = companylang.register_nopasswd;		this.focuser = 'password';		break;
				case 'nopwdlen'		: this.tmpmsg = companylang.register_nopwdlen;		this.focuser = 'password';		break;
				case 'norepass'		: this.tmpmsg = companylang.register_norepass;		this.focuser = 'repasswd';		break;
				case 'notmatch'		: this.tmpmsg = companylang.register_notmatch;		this.focuser = 'password';		break;
				case 'unexists'		: this.tmpmsg = companylang.user_unexists;			break;
				case 'uncreate'		: this.tmpmsg = companylang.user_uncreate;			break;
				case 'unmodify'		: this.tmpmsg = companylang.user_unmodify;			break;
				case 'undelete'		: this.tmpmsg = companylang.user_undelete;			break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser){
					eval('theform.' + this.focuser + '.focus()');
				}
			}
			theform.Submit.disabled = false;
			theform.Cancle.disabled = false;
		} else {
			theform.Submit.disabled = true;
			theform.Cancle.disabled = true;
		}
	}







	this.optiont = new Array();
	this.readeroptions = function(key,val){
		this.tmper  = '<' + 'select ' + 'name="selecthand' + key + '"' + ' onchange="company.changeoptions('+ key +',this.value)">';
		for (var i = 1; i <= 9; i++){
			if (i == val){
				this.tmper += '<option ' + 'value="' + i + '" selected>' + eval('companylang.resume_select_' + i) + '</option>';
			}else{
				this.isfound = false;
				for (var j = 0; j < this.optiont.length; j++){
					if (i == this.optiont[j]){
						this.isfound = true;
						break;
					}
				}
				if (!this.isfound){
					this.tmper += '<option ' + 'value="' + i + '">' + eval('companylang.resume_select_' + i) + '</option>';
				}
			}
		}
		this.tmper += '<' + '/' + 'select' + '>';
		$('selectwrap' + key).innerHTML = this.tmper;
	}
	this.changeoptions = function(key,val){
		theform = document.wane_resumes;
		this.cookier = theform.selecthand1.value + ',' + theform.selecthand2.value + ',' + theform.selecthand3.value + ',' + theform.selecthand4.value + ',' + theform.selecthand5.value;
		theform.selecthand1.disabled = true;
		theform.selecthand2.disabled = true;
		theform.selecthand3.disabled = true;
		theform.selecthand4.disabled = true;
		theform.selecthand5.disabled = true;
		this.cookies('rsms_lister_option',this.cookier);
		browser.ishistory = true;
		eval(this.selectrefresh);
	}
	this.cookies = function(name,value,hours){
		var expire = "";
		if (hours && hours > 0){
			expire = new Date((new Date()).getTime() + hours * 3600000);
		}else{
			expire = new Date((new Date()).getTime() + 24 * 365 * 3600000);
		}
		expire = "; expires=" + expire.toGMTString();
		document.cookie = name + "=" + escape(value) + expire + '; path=/';
	}

	/*
	+-------------------------------------------
	+	Load resume by search
	+-------------------------------------------
	*/
	this.vsearche = function(results){
		var theform = document.wane_resumes
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'jtype'	: this.tmpmsg = companylang.resume_search_nojtype; break;
				case 'maxbox'	: this.tmpmsg = companylang.resume_schbox_maxium; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
					if (theform.Boxmit){
						theform.Boxmit.disabled = false;
					}
				}
			}
		}else{
			category.mulitys(theform,'muljobstype|mulindustry');
			theform.Submit.disabled = true;
			if (theform.Boxmit){
				theform.Boxmit.disabled = true;
			}
		}
	}
	this.vsearchi = function(results){
		var theform = document.wane_resumes
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'jtype'	: this.tmpmsg = companylang.resume_search_nojtype; this.focuser = 'ja'; break;
				case 'jkind'	: this.tmpmsg = companylang.resume_search_nojkind; this.focuser = 'jobskinds'; break;
				case 'maxbox'	: this.tmpmsg = companylang.resume_schbox_maxium; break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
					if (theform.Boxmit){
						theform.Boxmit.disabled = false;
					}
				}
			}
		}else{
			if (theform.jobskinds.value == 0){
				this.vsearchi('jkind');
				return false;
			}
			if (theform.ja.value == 0){
				this.vsearchi('jtype');
				return false;
			}
			theform.Submit.disabled = true;
			if (theform.Boxmit){
				theform.Boxmit.disabled = true;
			}
		}
	}
	this.vsearchx = function(results,page){
		var theform = document.wane_resumes
		if (results){
			this.tmpmsg = '';
			this.isform = true;
			switch (results){
				case 'unselect' : this.tmpmsg = companylang.resume_schbox_unselect;							break;
				case 'success'	: this.tmpmsg = companylang.resume_schbox_success;	this.isform = false;	break;
				case 'nodata'	: this.tmpmsg = companylang.resume_schbox_nodata;	this.isform = false;	break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.isform){
					if (theform.Submit.disabled){
						theform.Submit.disabled = false;
					}
				}else{
					this.handler('resumes','search','schbox','page=' + page);
				}
			}
		}else{
			theform.Submit.disabled = true;
		}
	}



	this.vlogin = function(results,uri){
		var theform = document.wane_login;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'uu' : this.tmpmsg = companylang.login_uu; this.focuser = 'username';break;
				case 'iu' : this.tmpmsg = companylang.login_iu; this.focuser = 'username';break;
				case 'up' : this.tmpmsg = companylang.login_up; this.focuser = 'password';break;
				case 'ip' : this.tmpmsg = companylang.login_ip; this.focuser = 'password';break;
				case 'uc' : this.tmpmsg = companylang.login_uc; this.focuser = 'certid';break;
				case 'ic' : this.tmpmsg = companylang.login_ic; this.focuser = 'certid';break;
				case 'ss' : break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (this.focuser != ''){
					eval('theform.' + this.focuser + '.focus()');
				}
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}
			} else if (results == 'ss'){
				window.location = uri;
			}
		} else {
			if (theform.username.value == ''){
				this.vlogin('uu');
				return false;
			} else if (theform.password.value == '') {
				this.vlogin('up');
				return false;
			} else if (theform.certid && theform.certid.value == '') {
				this.vlogin('uc');
				return false;
			} else {
				theform.Submit.disabled = true;
			}
		}
	}

	this.vregnavs = function(id,form,results){
		if (form){
			var theform = document.wane_register;
			if (results){
				this.tmpmsg = '';
				this.focuser = '';
				switch (results){
					case 'uu' : this.tmpmsg = companylang.register_nouser; this.focuser = 'username'; break;
					case 'iu' : this.tmpmsg = companylang.register_invalidu; this.focuser = 'username'; break;
					case 'ru' : this.tmpmsg = companylang.register_repeatu; this.focuser = 'username'; break;
					case 'ue' : this.tmpmsg = companylang.register_noemail; this.focuser = 'email'; break;
					case 'ie' : this.tmpmsg = companylang.register_invalide; this.focuser = 'email'; break;
					case 're' : this.tmpmsg = companylang.register_repeate; this.focuser = 'email'; break;
					case 'up' : this.tmpmsg = companylang.register_nopasswd; this.focuser = 'password'; break;
					case 'ip' : this.tmpmsg = companylang.register_nopwdlen; this.focuser = 'password'; break;
					case 'mp' : this.tmpmsg = companylang.register_notmatch; this.focuser = 'repasswd'; break;
					case 'cn' : this.tmpmsg = companylang.basic_cname; this.focuser = 'cname'; break;
					case 'cp' : this.tmpmsg = companylang.basic_property; this.focuser = 'compro'; break;
					case 'cs' : this.tmpmsg = companylang.basic_sizement; this.focuser = 'comsize'; break;
					case 'ci' : this.tmpmsg = companylang.basic_industry; this.focuser = 'industry'; break;
					case 'cl' : this.tmpmsg = companylang.organ_location; this.focuser = 'pb'; break;
					case 'cc' : this.tmpmsg = companylang.organ_contact; this.focuser = 'contact'; break;
					case 'co' : this.tmpmsg = companylang.organ_phone; this.focuser = 'phone'; break;
				}
				if (this.tmpmsg != ''){
					alert(this.tmpmsg);
					if (this.focuser != ''){
						eval('theform.' + this.focuser + '.focus()');
					}
				}
				if (theform.Submit.disabled){
					theform.Submit.disabled = false;
				}				
			} else {
				theform.Submit.disabled = true;
			}
		} else {
			if (id == 1){
				$('stp1').className = 't';
				$('stp2').className = 'f';
				Ajax.xml('company|register|1',this.contentid);
			} else if (id == 2) {
				$('stp1').className = 'f';
				$('stp2').className = 't';
				Ajax.xml('company|register|2',this.contentid);
			}
		}
	}

}
company = new company_object();
Ajax.ismsger = true;
function checkall(fname){
	if (this.former = eval('document.' + fname)){
		this.box_num = 0;
		this.box_status = true;
		for (var i = 0; i < this.former.length; i++){
			if (this.former[i].type == 'checkbox'){
				if (this.former[i].name.substr(this.former[i].name.length - 2, 2) == '[]'){
					this.box_num++;
					if (this.box_num == 1){
						this.box_status = this.former[i].checked ? false : true;
					}
					this.former[i].checked = this.box_status;
				}
			}
		}
	}
}

