
	var _post_popu_div="_post_popu_div";  
	var _post_mian_div="_post_mian_div";
	var _post_show_div="_post_show_div";
	var _post_selected_ul="_post_selected_ul";
	var _post_all_ul="_post_all_ul";
	var _post_show_ul="_post_show_ul";
	var _post_h1="_post_h1";
	
	var _post_typeid_index="_post_type_id_";
	var _post_checkboxid_index="_post_checkboxid_id_";
	var _post_showid_index="_post_show_id_";
	
	var _post_createliid_index = "_post_createliid_index_";
	var _post_createli_over = "POPDiv_over";
	
	var _post_newshowliid_index = "_post_newshowliid_index_";
	var _post_newshowboxid_index = "_post_newshowboxid_index_";
	var _post_big_class="POPDiv_areaTitle2";
	
	var _post_sle_ulid="_post_sle_ul_id_";
	var _post_sle_boxid="_post_sle_box_id_"
	var _jobstot_POPDiv_jobSort="POPDiv_jobSort";
	var _jobSortHit="jobSortHit";
	
	var _post_allow_num = 3;
	var _post_lable_id = "";
	var _post_valuesId = "";
	var _post_default_text = "选择/修改";
	var _post_english_title="";
	var _jobSort_language_type=2;
	var _jobSort_alertText="";
	var _jobsort_confirm_text="";
	var _jobsort_confirm_id="_jobsort_confirm_text";
	var _jobsort_selected_text="_jobsort_selected_text";
	var _jobsort_all_function="_jobsort_all_function";
	var _newjobsort_all_function="_newjobsort_all_function";
	var _jobsort_chosen_title="已选择岗位";
	var _jobsort_alljob_title="所有岗位";
	var _jobSortTitle="jobSortTitle";
	var _jobSortTitle2="jobSortTitle2";
	var _jobsort_over_class="POPDiv_over";
	var _jobSort_title="";
	
	
	function PostDialog(obj,title,valueIds){
		_post_allow_num = valueIds.length;
		_post_lable_id = obj;
		_post_valuesId = valueIds;
		_jobSort_title = title;
		_jobSort_language_type=2;
		_jobsort_confirm_text="确定";
		_jobsort_chosen_title="已选择岗位";
		_jobsort_alljob_title="所有岗位";
		
		this.setEnglish=function(){
			var last = "options";
			if(_post_allow_num<=1){
				last = "option";
			}
		    _post_english_title="please selected job function (No more than "+_post_allow_num+" "+last+")";
		    _jobSort_alertText="No more than "+_post_allow_num+" "+last;
		    _jobSort_language_type=3; 
		    _jobsort_confirm_text="confirm";
		 	_jobsort_confirm_id="_jobsort_confirm_text";
		 	_jobsort_chosen_title="Selected Function";
		 	_jobsort_alljob_title="All job functions";
		 	_post_default_text = "Select/Modify";
		};
		this.setDefaultText = function(text){
			_post_default_text=text;
		}
		
		
		_jobSort_alertText="您已经选择了"+_post_allow_num+"个岗位,不能再选择!";
		_post_english_title = "请选择工作岗位(您最多选择"+_post_allow_num+"项)";
		
		this.showPostDialog=initPostType;
		
		function initInfo(){
			document.getElementById(_post_selected_ul).innerHTML="";
			var texts = (id(_post_lable_id).value).split("+");
			for(var i=0;i<_post_allow_num;i++){
				
				var pid = id(_post_valuesId[i]).value.toString();
				if(pid!="" && pid!="0"){
					var liid=_post_sle_ulid+pid;
					var boxid=_post_sle_boxid+pid;
					var value =texts[i];
					
					var box = "<input type='checkbox' id='"+boxid+"' checked='checked' onclick=\"delectSelectPostById('"+liid+"')\" value='"+pid+
					"' class='"+value+"' />"+value;
					var li = document.createElement("li");
					li.id = liid;
					li.innerHTML=box;
					document.getElementById(_post_selected_ul).appendChild(li);
				}
			}
		
			id(_post_h1).innerHTML=_post_english_title;
			id(_jobsort_confirm_id).innerHTML=_jobsort_confirm_text;
			id(_jobsort_selected_text).innerHTML=_jobsort_chosen_title;
			id(_jobsort_all_function).innerHTML=_jobsort_alljob_title;
			
			
			var d = document.getElementById(_post_popu_div);
			d.style.width="100%";
			d.style.height=window.screen.clientHeight>$(document).height()?"100%":$(document).height()+"px";
			d.style.display="block";
			
			var main= document.getElementById(_post_mian_div);
			var scrollTop = 0;
		if(document.body.scrollTop>0) {
			scrollTop = document.body.scrollTop; //chrome
		}else {
			scrollTop = document.documentElement.scrollTop;
		}
			main.style.top=(scrollTop +10)+ "px";
			main.style.left=(document.documentElement.scrollLeft+50)+"%";
			main.style.display="block";
		}
		
		function initPostType(){
			initInfo();  
			id(_newjobsort_all_function).innerHTML="";
			
			for(var i=0;i<sortCount;i++){
				var node = sort[i];
				if(node[1]==0){
					var parentName = node[_jobSort_language_type];
					var parentId = node[0];
					var _index=parentId.toString().substring(0,2);
					
					var div = document.createElement("div");
						div.className=_jobstot_POPDiv_jobSort;
					 
						if(_jobSort_language_type ==2){
							if(node[5]==1){
								 parentName="研发";
							}else if(node[5]==10){
								parentName="生产技术";
							}else if(node[5]==15){
								parentName="销售市场";
							}else if(node[5]==17){
								parentName="售后服务";
							}else if(node[5]==18){
								parentName="职能类";
							}else if(node[5]==21){
								parentName="其他";
							}else{
								 parentName="";
							}
						}else{
							if(node[5]==1){
								 parentName="Research";
							}else if(node[5]==10){
								parentName="Production Technology";
							}else if(node[5]==15){
								parentName="Sales Market";
							}else if(node[5]==17){
								parentName="Service";
							}else if(node[5]==18){
								parentName="Functional class";
							}else if(node[5]==21){
								parentName="Other";
							}else{
								 parentName="";
							}
						}
					
					var pli = "<div class='"+_jobSortTitle+"'>"+ parentName+"</div>";
					 /*pli = pli + "<div class='"+_jobSortTitle+"'>"+ parentName+"</div>";*/
					var cli="";
					var bgli="";
					for(var j=0;j<sortCount;j++){
						
						var child = sort[j];
						var cid = child[1].toString();
						var name=child[_jobSort_language_type];
					    var boxid = _post_newshowboxid_index+child[0];
						var _cindex= cid.length>2?cid.substring(0,2):child[0].toString().substring(0,2);
						var check="";
						if(id(_post_sle_boxid+child[0])){
							check="checked='checked'";
						}
 
						if(_cindex==_index){
							var li = "";
							if(cid=="0"){
								pli = pli + "<div class='"+_jobSortTitle2+"'>"+   
								"<label  for='"+boxid+"'><input "+check+" type='checkbox' onclick='initSelectPost(this)' name='"+cid+"'  value='"+name+"' id='"+boxid+"' class='ea-bor' />"+
								name+"</label></div>";
								
							}
							else{
								li = "<li style='cursor:hand' "+
								" onmouseover=\"this.className='"+_jobsort_over_class+"'\" onmouseout=\"this.className=''\"><label for='"+boxid+"'>"+
								"<input "+check+" type='checkbox' onclick='initSelectPost(this)' name='"+cid+"' value='"+name+"' id='"+boxid+"' />"+name+"</label></li>";
								cli=cli+li;
							}
						}
					}
					cli="<ul>"+bgli+cli+"</ul>";
					var innerHTML = pli+cli;
					div.innerHTML=innerHTML;
					id(_newjobsort_all_function).appendChild(div);
				}
			}
		}
		
		
		
		
		//获取鼠标点击的坐标 IE or FF
		function mouseCoords(ev){  
			if(ev.pageX || ev.pageY){
				return {
					left:ev.pageX+"px", 
					top:ev.pageY+"px"
				};
			}
			return {
				top: event.clientY + document.documentElement.scrollTop + 'px',
			    left: event.clientX + document.documentElement.scrollLeft + 'px'
			};
		}
	 
		
		function isIE(){  //验证是否IE
			return document.all;
		}
		
		function id(id){
			return document.getElementById(id);
		}
		
	}
	
	function initSelectPost(obj){
		var parent_id = obj.name;
		var pid=obj.id.substring(_post_newshowboxid_index.length);
		var testid = pid.substring(2);
		var cid = pid.substring(0,2)+"00";
		var liid=_post_sle_ulid+pid;
		
		if(testid=="00"){ //如果是首选项
			clearChildPosts(pid); //清除子选项
		}
		else{//如果是非首选项
			clearBigPosts(parent_id);
		}
		
		
		if(obj.checked){  //如果选中则添加
		
			var elements = document.getElementById(_post_selected_ul).getElementsByTagName("li");
			if(elements.length>_post_allow_num-1){
				obj.checked=false;
				alert(_jobSort_alertText);
			//	document.getElementById(_post_show_div).style.display="none";
				return;
			}
			var p_id = obj.name;
			var value = obj.value;
			var boxid=_post_sle_boxid+pid;
			var box = "<input type='checkbox' id='"+boxid+"' name='"+p_id+"' checked='checked' onclick=\"delectSelectPostById('"+liid+"')\" value='"+pid+
			"' class='"+value+"' />"+value;
			var li = document.createElement("li");
			li.id = liid;
			li.innerHTML=box;
			document.getElementById(_post_selected_ul).appendChild(li);
		}
		else{//如果未选中 则删除
			delectSelectPostById(liid);
		}
	}
	
	function delectSelectPostById(id){ //跟li id 删除li,并取消选中
		 var rid = _post_newshowboxid_index+id.substring(_post_sle_ulid.length);
		 
		 var _element= document.getElementById(id);
		 if(_element){
					_element.parentNode.removeChild(_element);
		 }
		 
		 var box = document.getElementById(rid);
		 if(box){
		 	box.checked=false;
		 }
	}
	function clearBigPosts(cid){
		var did = _post_sle_ulid+cid;
		var tid = _post_newshowboxid_index+cid;
		var li = document.getElementById(tid);
		if(li.checked){
			li.checked=false;
			delectSelectPostById(did)
		}
	}
	function clearChildPosts(pid){
		var hid = pid.substring(0,2);
		for(var i=0;i<sortCount;i++){
			var post = sort[i];
			var gid = post[1].toString().substring(0,2);
			if(hid==gid){
				var id = post[0];
				var check_id = _post_newshowboxid_index+id;
				var box = document.getElementById(check_id);
				if(box){ 
				 box.checked = false;
				 delectSelectPostById(_post_sle_ulid+id);
				}
			}
		}
	}
	
	
	function getPostResult(){
		var nodes = document.getElementById(_post_selected_ul).getElementsByTagName("li");
		var length = nodes.length; 
		for(var i = 0;i<_post_allow_num;i++){
			document.getElementById(_post_valuesId[i]).value="";  //清空原来选项值
		}
		
		if(nodes && length>0){
			var lable="";
			for(var i=0;i<length;i++){
				var node = nodes[i].childNodes[0];
				var text = node.className;
				var value = node.value;
				var result = document.getElementById(_post_valuesId[i]);
				result.value = value;
				lable = i==0?text:(lable+"+"+text);
			}
			document.getElementById(_post_lable_id).value=lable;
			document.getElementById(_jobSort_title).title=lable;
			
		}
		else{
			document.getElementById(_post_lable_id).value=_post_default_text;
			document.getElementById(_jobSort_title).title=_post_default_text;
		}
	}
		
	function closePostDialog(){
		document.getElementById(_post_mian_div).style.display="none";
		document.getElementById(_post_popu_div).style.display="none";
		getPostResult();
	}