function lib_popupDivR(o,hiddenN,dataArrN,pObj,genHTMLFN,onclickFN,onclickFN_p,showSelectedFN,objectP){
	this.ClientID = o;
	this.d = document.getElementById('popupDiv_'+this.ClientID);
	this.d2 = document.getElementById('itemDiv_'+this.ClientID);
	this.b = document.getElementById('button_'+this.ClientID);
	this.s = document.getElementById('pSel_'+this.ClientID);
	this.h = eval(hiddenN);
	this.da = eval(dataArrN);
	this.p = pObj?pObj:null;
	this.c = new Array();
	this.genHTML = genHTMLFN?'this.'+genHTMLFN+'()':null;
	this.onclick = onclickFN;
	this.onclickP = onclickFN_p?onclickFN_p:onclickFN;
	this.showSelected = showSelectedFN?showSelectedFN:null;
	this.objP = objectP?objectP:null;
	this.config = new Object();
	var T = this;
	if(this.p!=null) this.p.c[this.p.c.length] = T;
	this.B = function(e){T.clickB(e);};
	this.A(this.b,'click',this.B);
	if(this.s){
		this.S = function(){eval('T.'+genHTMLFN+'()');};
		this.A(this.s,'change',this.S);
	}
}

lib_popupDivR.prototype.clickB = function(e){
	if(document.getElementById('popupDivImg_'+this.ClientID)) this.i = document.getElementById('popupDivImg_'+this.ClientID);
	else this.i = null;
	if(this.d.style.visibility=='hidden' && this.genHTML!=null) eval(this.genHTML);
	var x=null,y=null;
	if(this.i!=null || this.config.x!='undefined'){
		x = ((this.i!=null)?getXY(this.i).x:0) + ((this.config.x!='undefined')?this.config.x:0);
		y = ((this.i!=null)?getXY(this.i).y:0) + ((this.config.y!='undefined')?this.config.y:0);
	}
	switchVisibility(this.d.id,e,x,y);
}

lib_popupDivR.prototype.passValue2Hidden = function(v){
	this.h.value = v;
}

lib_popupDivR.prototype.showName2Button = function(n){
	var tempN = n;
	
	//处理国籍
	if(this.ClientID.toLowerCase().indexOf('nationality')>-1) tempN = tempN.replace(/全国/,'中国');
	
	var name = (GetRealLength(tempN)<this.config.buttonVL)?tempN:subStringPro(tempN,this.config.buttonVL-2)+'...';
	this.b.value = name;
	this.b.title = tempN;
}

lib_popupDivR.prototype.initialize = function(v){
	var index = getIndexByValue(v,this.da);
	if(index!=null){
		this.showName2Button(this.da[index][2]);
	}
	this.initializeC2();
}

lib_popupDivR.prototype.iniCDiv = function(){
	if(this.c.length<1) return;
	var pIndex = getIndexByValue(this.h.value,this.da);
	var arrData = new Array(),i,j,flag=false,flag2=false;
	if(pIndex!=null){
		var pId = this.da[pIndex][3]?this.da[pIndex][3]:this.da[pIndex][0];
		//for(i=0;this.da[i];i++) if(this.da[i][1]==pId) arrData[arrData.length] = this.da[i];
	}
	for(i=0;this.c[i];i++){
		/*if(this.c[i].s){
			clearSelect(this.c[i].s);
			if(arrData.length){
				if(this.c[i].s.style.display!='none') for(j=0;arrData[j];j++) this.c[i].s.options[this.c[i].s.length] = new Option(arrData[j][2],arrData[j][0]);
				else this.c[i].s.options[0] = new Option(this.da[pIndex][2],pId);
				if(this.c[i].b) this.c[i].b.disabled=false;
			}
			else{
				if(this.c[i].b) this.c[i].b.disabled=true;
			}
		}*/
		if(this.c[i].s){
			clearSelect(this.c[i].s);
			if(this.c[i].s.style.display!='none'){
				if(!flag){
					for(j=0;this.da[j];j++) if(this.da[j][1]==pId) arrData[arrData.length] = this.da[j];
					flag=true;
				}
				for(j=0;arrData[j];j++) this.c[i].s.options[this.c[i].s.length] = new Option(arrData[j][2],arrData[j][0]);
				if(this.c[i].b){
					if(arrData.length==0) this.c[i].b.disabled=true;
					else this.c[i].b.disabled=false;
				}
			}
			else{
				if(pIndex!=null){
					this.c[i].s.options[0] = new Option(this.da[pIndex][2],pId);
					for(j=0;this.da[j];j++) if(this.da[j][1]==pId){flag2=true;break;}
				}
				if(this.c[i].b){
					if(!flag2) this.c[i].b.disabled=true;
					else this.c[i].b.disabled=false;
				}
			}
		}
		this.c[i].iniCDiv();
	}
}

lib_popupDivR.prototype.iniCButton = function(){
	if(this.c.length<1) return;
	for(i=0;this.c[i];i++){
		if(this.c[i].b){
			var showTxt = '选择/修改';
			if(this.c[i].config.pText && this.c[i].config.pText!=' ' && !this.c[i].b.disabled) showTxt = this.c[i].config.pText;
			this.c[i].b.value=showTxt;
			this.c[i].b.title=showTxt;
		}
		if(this.c[i].h) this.c[i].h.value='';
		if(this.c[i].objP && this.c[i].objP.province) this.c[i].objP.province.value='';
		this.c[i].iniCButton();
	}
}

lib_popupDivR.prototype.initializeC = function(){
	if(this.c.length<1) return;
	
	this.iniCButton();
	this.iniCDiv();
}

lib_popupDivR.prototype.initializeC2 = function(){
	if(this.c.length<1) return;
	
	this.iniCDiv();
}

lib_popupDivR.prototype.clickL = function(v,n){
	this.passValue2Hidden(v);
	this.showName2Button(n);
	this.initializeC();
	hideCurrentPopup();
}

lib_popupDivR.prototype.clickL2 = function(v,n){
	this.passValue2Hidden(n);
	this.initializeC();
	hideCurrentPopup();
}

lib_popupDivR.prototype.clickL3 = function(v,n,pV){
	this.passValue2Hidden(v);
	this.showName2Button(n);
	if(this.objP && this.objP.province && pV) this.objP.province.value=pV;
	this.initializeC();
	hideCurrentPopup();

	if(this.config && this.config.linkfn) eval(this.config.linkfn+'(v)');
}

lib_popupDivR.prototype.clickL3P = function(v,n){
	this.passValue2Hidden(v);
	this.showName2Button(n);
	if(this.objP && this.objP.province) this.objP.province.value=v;
	this.initializeC();
	hideCurrentPopup();

	if(this.config && this.config.linkfn) eval(this.config.linkfn+'(v)');
}

lib_popupDivR.prototype.clickLP_jobtype = function(o,subO,v,n){
	o.value = v;
	subO.value = '';
	this.showName2Button(n);
	hideCurrentPopup();
}

lib_popupDivR.prototype.clickLC_jobtype = function(o,subO,v,n,pV){
	if(typeof pV!='undefined') o.value = pV;
	subO.value = v;
	this.showName2Button(n);
	hideCurrentPopup();
}

lib_popupDivR.prototype.A = myAttachEvent;

lib_popupDivR.prototype.showSelectedItem = function(){
	if(this.config.selectedItem){
		var str = '';
		if(this.config.pText && this.config.pText!=' ' && this.h.value==''){
			str += '&nbsp;&nbsp;&nbsp;&nbsp;(当前选择的'+(this.config.name?this.config.name:'值')+'--<b title="'+this.config.pText+'">'+this.config.pText+'</b>)';//处理国籍
			this.config.selectedItem.innerHTML=str;
			return;
		}
		
		var index = getIndexByValue(this.h.value,this.da);
		if(index!=null){
			var name = (this.ClientID.toLowerCase().indexOf('nationality')>-1?this.da[index][2].replace(/全国/,'中国'):this.da[index][2]);
			var showNameL = this.config.showSelectedItemL?this.config.showSelectedItemL:30;
			var showName = (GetRealLength(name)<showNameL)?name:subStringPro(name,showNameL-2)+'...';
			str += '&nbsp;&nbsp;&nbsp;&nbsp;(当前选择的'+(this.config.name?this.config.name:'值')+'--<b title="'+name+'">'+showName+'</b>)';//处理国籍
			this.config.selectedItem.innerHTML=str;
		}
		else this.config.selectedItem.innerHTML='';
	}
}

lib_popupDivR.prototype.showSelectedItem_jobtype = function(o,subO){
	if(this.config.selectedItem){
		var index = getIndexByValue(subO.value,this.da);
		if(index==null) index = getIndexByValue(o.value,this.da);
		if(index!=null){
			var str = '';
			var name = this.ClientID.toLowerCase().indexOf('nationality')>-1?this.da[index][2].replace(/全国/,'中国'):this.da[index][2];
			var showNameL = this.config.showSelectedItemL?this.config.showSelectedItemL:30;
			var showName = (GetRealLength(name)<showNameL)?name:subStringPro(name,showNameL-2)+'...';
			str += '&nbsp;&nbsp;&nbsp;&nbsp;(当前选择的'+(this.config.name?this.config.name:'值')+'--<b title="'+name+'">'+showName+'</b>)';//处理国籍
			this.config.selectedItem.innerHTML=str;
		}
		else this.config.selectedItem.innerHTML='';
	}
}

lib_popupDivR.prototype.writeDivItem = function(){
	if(this.showSelected!=null) eval('this.'+this.showSelected);
	
	if(this.s) var pId = this.s.value;
	else var pId = '0';
	var arrData = this.da;
	var objDiv = this.d2;
	if(objDiv){
		var pIndex=null,str='',strTr='',strP='',i,j,t,u=-1,rowIndex=0,col=this.config.col?this.config.col:2,tdWF=this.config.tdWidthF?this.config.tdWidthF:'auto',tdTL=this.config.tdTextL?this.config.tdTextL:16,itemL=0;
		var tdWidth=parseInt(100/col)+'%';
		pIndex=getIndexByValue(pId,arrData);
		
		if(this.config.pText) strP = '<div style="margin:5 2;"><a href="#" class="blue14" onClick="'+this.ClientID+'.'+this.onclickP+(this.onclickP.toString().indexOf('(')>-1?'':'(')+'\'\',\''+this.config.pText.replace(/"/g,'&quot;')+'\');return false;">'+this.config.pText+'</a></div>';																																																																																																			  
		else if(pIndex!=null){
			strP = '<div style="margin:5 2;"><a href="#" class="blue14" onClick="'+this.ClientID+'.'+this.onclickP+(this.onclickP.toString().indexOf('(')>-1?'':'(')+'\''+arrData[pIndex][0].replace(/"/g,'&quot;')+'\',\''+arrData[pIndex][2].replace(/"/g,'&quot;')+'\');';
			if(this.objP && this.objP.linkedInstance && eval(this.objP.linkedInstance) && eval(this.objP.linkedInstance).h.value=='') strP += 'tempFN='+this.objP.linkedInstance+'.onclickP;'+this.objP.linkedInstance+'[tempFN]('+'\''+arrData[pIndex][0].replace(/"/g,'&quot;')+'\',\''+arrData[pIndex][2].replace(/"/g,'&quot;')+'\');';
			strP += 'return false;">'+(this.ClientID.toLowerCase().indexOf('nationality')>-1?arrData[pIndex][2].replace(/全国/,'中国'):arrData[pIndex][2])+'</a></div>';//处理国籍
		}																																																				  
																																																																																																					  
		for(i=0;arrData[i];i++)
			if(arrData[i][1]==pId){
				//国籍不显示国外
				if(this.ClientID.toLowerCase().indexOf('nationality')>-1 && arrData[i][0]==480) continue;
				
				u++;
				t=u%col;
				if(t==0){strTr += '<tr>';rowIndex++;}
				if(tdWF=='fixed') itemL=GetRealLength(arrData[i][2]);
				if(itemL>tdTL && t==col-1){strTr += '<td width="'+tdWidth+'"></td>';i--;}
				else{
					strTr += '<td'+(tdWF=='fixed'?' width="'+tdWidth+'"':'')+((tdWF=='fixed' && itemL>tdTL)?' colSpan="2"':'')+'><a href="#" class="blue12" onClick="'+this.ClientID+'.'+this.onclick+(this.onclickP.toString().indexOf('(')>-1?'':'(')+'\''+arrData[i][0].replace(/"/g,'&quot;')+'\',\''+arrData[i][2].replace(/"/g,'&quot;')+'\',\''+(pIndex!=null?arrData[pIndex][0].replace(/"/g,'&quot;'):pId.replace(/"/g,'&quot;'))+'\');';
					if(this.objP && this.objP.linkedInstance && eval(this.objP.linkedInstance) && eval(this.objP.linkedInstance).h.value=='') strTr += 'tempFN='+this.objP.linkedInstance+'.onclick;'+this.objP.linkedInstance+'[tempFN]('+'\''+arrData[i][0].replace(/"/g,'&quot;')+'\',\''+arrData[i][2].replace(/"/g,'&quot;')+'\',\''+(pIndex!=null?arrData[pIndex][0].replace(/"/g,'&quot;'):pId.replace(/"/g,'&quot;'))+'\');';
					strTr += 'return false;">'+(this.ClientID.toLowerCase().indexOf('nationality')>-1?arrData[i][2].replace(/全国/,'中国'):arrData[i][2])+'</a></td>';//处理国籍
				}
				if((!this.config.tdWidthF||(this.config.tdWidthF&&this.config.tdWidthF!='fixed')) && rowIndex==1 && t<col-1) strTr +='<td width="5" rowspan="999" style="border-right:#7176AB 1px dotted;"><img src="" width="1" height="1"></td><td width="5" rowspan="999"></td>';
				if(tdWF=='fixed' && itemL>tdTL && t<col-1) {u++;t++;}
				if(t==col-1) strTr += '</tr>';
			}
		str = strP+'<table width="100%" cellspacing="0" cellpadding="3" border="0">'+strTr+'</table>';
		if(typeof changeToggleSelectVisibility=='function') var objConDiv=this.d;
		if(objConDiv && objConDiv.style.visibility!='hidden') showAllHiddenToggleSelect();
		this.d2.innerHTML = str;
		if(objConDiv && objConDiv.style.visibility!='hidden') changeToggleSelectVisibility(objConDiv,'hidden');
	}
}


/*********************************
        utility routines
*********************************/
function getIndexByValue(value,arr){
	var i;
	for(i=0;i<arr.length;i++) if(value==arr[i][0] || (arr[i][3]&&value==arr[i][3])){return i;break;}
	return null;
}

function GetRealLength(strTemp){
 var i,sum=0;
 for(i=0;i<strTemp.length;i++){if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255)) sum=sum+1; else sum=sum+2;}
 return sum;
}
function subStringPro(str, length){
  var stri = '';
  for(i=0,j=0; j<length;){
    if((str.charCodeAt(i)>=0) && (str.charCodeAt(i)<=255)){stri+=str.charAt(i);j++;}
	else{stri += str.charAt(i);j += 2;}
    i++;}
  return stri;
}

function clearSelect(s){
    if(s) for(var i=s.options.length-1;i>-1;i--) s.options[i]=null;
}

function myAttachEvent(d,e,f){
	try {
		if(d.attachEvent) d.attachEvent("on"+e,f);
		else if(d.addEventListener) d.addEventListener(e,f,false);
		else{
			var oldF = eval('d.on'+e);
			if(typeof oldF!='function') eval('d.on'+e+'=f');
			else eval('d.on'+e)=function(){oldF();f();}
		}
	}
	catch (error){}
}

function residence_dCity(id){
	if(id!='' && typeof(locationF)!='undefined' && locationF.h && locationF.h.value==''){
		locationF.h.value = id;
		if(locationF.showSelected!=null) eval('locationF.'+locationF.showSelected);
		locationF.op4Child();
	}
}
