/*
 *Function: 關鍵字自動完成
 *Author:	ourac
 *Date:		2008-8-19
 *Modify:	2008-5-27
 *Modify:	2008-8-20 因加入了拼音匹配方式故去掉了前綴緩存判斷機制
 */
(function(){
	var ca = navigator.userAgent.toLowerCase();
	iBrowser = {
		I: ca.indexOf("msie")!=-1,
		M: ca.indexOf("mozilla") != -1,
		O: ca.indexOf("opera")!=-1,
		S: ca.indexOf("webkit") != -1
	}
	
	//數據提供對象
	window.DataProvide = function () {
		this.ajaxUrl = arguments[0] || '?';
		this.lang = arguments[1] || 'C';
		this.resWord = 'C' == this.lang ? '結果' : 'results';
		this.abuWord = 'C' == this.lang ? '約' : 'about';
		this.maxGetNum = 10;//數據提供接口每次提供的最大記錄數
		this.dataArr = [];
		this.rDataArr = function ( key , kwd , onFunc ) {
			kwd = trim( kwd , 'left' );//去掉左邊的空格
			var _kwd = '_' + kwd;
			var uKwd = window.encodeURIComponent ? encodeURIComponent( kwd ) : escape( kwd );
			if ( this.dataArr[_kwd] ) {//已緩存過,直接調用緩存記錄,不再重新發送http請求
				onFunc( key , kwd , this.dataArr[_kwd] );
			}
			else {
				//2008-8-20 liyao 因加入了拼音匹配方式故去掉了前綴緩存判斷機制
					document.domain = '51job.com';
					if ( !window.ajaxIfrqry || !ajaxIfrqry.contentWindow || !ajaxIfrqry.contentWindow.$ ) {//異常判斷
						onFunc( key , kwd , [] );
						return false;
					}
					ajaxIfrqry.contentWindow.$.ajax( {
						url: this.ajaxUrl + '&kwd=' + uKwd + '&broswer=0&ran=' + Math.random(),
						pObj: this,
						key: key,
						kwd: kwd,
						_kwd: _kwd,
						onFunc: onFunc,
						error: function () { this.onFunc( this.key , this.kwd , [] ); },
						success: function ( rTxt ) {
							this.pObj.dataArr[this._kwd] = [];
							if ( rTxt ) {
								rTxt = ( rTxt + '' ).split( "\r\n" );
								var len = rTxt.length;
								var subtmp = [];
								for ( var i = 0 ; i < len ; i++ ) {
									subtmp =  rTxt[i].split( "\t" );
									if ( subtmp[0] && subtmp[1] > 0 ) {
										this.pObj.dataArr[this._kwd].push( [subtmp[0], ' ' + this.pObj.abuWord + ' ' +  subtmp[1] + ' ' + this.pObj.resWord] );
									}
								}
							}
							this.onFunc( this.key , this.kwd , this.pObj.dataArr[this._kwd] );
						}
					} );
			}
		}
	}

	window.iCom = [];
	window.iTag = 'iCom';
	var da = new RegExp("^[\\s\\u1100-\\u11FF\\u3040-\\u30FF\\u3130-\\u318F\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uAC00-\\uD7A3\\uF900-\\uFAFF\\uFF65-\\uFFDC]+$");
	window.iPush = function () {
		var pLen = arguments.length,key = iTag + ++iCom.length,a;
		for ( var i = 0 ; i < pLen ; i++ ) {
			a = arguments[i];
			if ( a[0] && 'text' == a[0].type && a[1] && 'function' == typeof a[2] && a[1] instanceof DataProvide && iCheck( a[0] ) ) {//參數驗證
				if ( !document.getElementById( iTag + 'ui' ) ) {
					iCreateStyle();
				}
				iCom[key] = {};
				iCom[key]['iInput'] = a[0];
				iCom[key]['iDpqry'] = a[1];
				iCom[key]['iOnEvt'] = a[2];
				iCom[key]['iTbl'] = iCreateTbl();
				iCom[key]['iIfr'] = iCreateIfr();

				iClose( key );
				iResize( key );
				iGetPosPara( key );
				iSetPos( key );
				iSetAtt( key );
				iAttach( key );

				iCom[key]['sto'] = '';
			}
		}
	}

	function iSetAtt( key ) {
		var u = iCom[key]['iInput'];
		u.setAttribute( 'autocomplete' , 'off' );

		u.setAttribute( 'key' , key );//設置自定義屬性
		u.setAttribute( 'vIndex' , -1 );//設置自定義屬性 value in table row index
		u.setAttribute( 'preVal' , u.value );//設置自定義屬性 value in table row index

		var t = iCom[key]['iTbl'];
		t.setAttribute( 'key' , key );//rel key to input
		t.setAttribute( 'kwd' , '' );//table kwd
		t.setAttribute( 'hIndex' , -1 );//highlight table row index
	}

	function iAttach( key ) {
		var u = iCom[key]['iInput'];
		iAttEvt( u , 'keydown' , iSetPreVal );
		iAttEvt( u , 'focus' , iGetPosPara );
		iAttEvt( u , 'blur' , iClose );
		iAttEvt( u , 'keyup' , iKeyup );
		if ( iBrowser.I ) {
			iAttEvt( u , 'beforedeactivate' , iBefore );
		}	
	}

	window.iAttEvt = function( a , b , c ) {//綁定事件
		var d = 'on' + b;
		var isBubble = arguments[3] || false;
		if ( a.addEventListener ) {//ff opera
			a.addEventListener( b , c , isBubble );
		}
		else if ( a.attachEvent ) {//ie
			a.attachEvent( d , c );
		}
		else {
			a[d] = c;
		}
	}

	//判斷是否按上鍵
	function isUp( a ) { return a == 38 || a == 63232; }

	//判斷是否按下鍵
	function isDown( a ){ return a == 40 || a == 63233; }

	//判斷是否按右鍵
	function isRight( a ){ return a == 39; }

	//判斷是否按上下方向鍵
	function isUD( a ) { return isUp(a) || isDown(a); }

	//記錄前面的值
	function iSetPreVal( e ) {
		e = e || window.event;
		var u = e.srcElement || e.target;
		u.setAttribute( 'preVal' , u.value );
	}

	function iKeyup( e ) {
		e = e || window.event;
		var a = e.keyCode;
		var u = e.srcElement || e.target;

		var key = u.getAttribute( 'key' );
		var vIndex = u.getAttribute( 'vIndex' );
		var preVal = u.getAttribute( 'preVal' );

		var t = iCom[key]['iTbl'];
		var hIndex = t.getAttribute( 'hIndex' );
		var kwd = t.getAttribute( 'kwd' );

		var rKwd;
		if ( -1 == vIndex ) {
			rKwd = kwd;
		}
		else {
			rKwd = t.rows[vIndex] ? t.rows[vIndex].completeString : '';
		}
		
		if ( 27 == a || !trim( u.value ) ){//按esc鍵或者空值
			iClose( key );//關掉層
			return false;
		}

		if ( rKwd != u.value || ( isRight( a ) && -1 != vIndex ) || preVal != u.value ) {
			//如果數據不一致|按下右鍵並且值索引不為-1|值發生了改變,調用數據提供程序
			iCom[key]['iDpqry'].rDataArr( key , u.value , exec );
			return false;
		}

		if ( isUD( a ) ) {//只處理按了上下鍵的情況
			//直接處理顯示或者上下移動table選項
			iUpDown( key , a );
			return false;
		}

		return true;
	}

	function iClearTbl( t ) {
		while ( t.rows.length > 0 ) {
			t.deleteRow(-1);
		}
	}

	function exec( key , kwd , data ) {
		//填充層
		iFillTbl( key , kwd , data );
		//處理顯示層
		if ( iCom[key]['iTbl'].rows.length -1 ) {
			iOpen( key );
		}
		else {
			iClose( key );
		}
	}

	function iInsert( a , b ) {
		a.appendChild( document.createTextNode( b ) );
	}

	function iTrMDown() {
		var t = this.parentNode.parentNode;
		var key = t.getAttribute( 'key' );
		var u = iCom[key]['iInput'];
		u.value = this.completeString;
		u.setAttribute( 'vIndex' , this.rowIndex );
		function uf() {
			u.focus();
			if ( iBrowser.I ) {       
				var r = u.createTextRange();       
				r.moveStart('character', u.value.length);       
				r.collapse();       
				r.select();       
			}
		}
		setTimeout( uf , 10 );
		iCom[key]['iOnEvt']();
	}

	function iTrMOver() {
		var t = this.parentNode.parentNode;
		var key = t.getAttribute( 'key' );
		ChHigh( this.parentNode.parentNode , this.rowIndex );
	}

	function iFillTbl( key , kwd , b ) {
		var u = iCom[key]['iInput'];
		u.setAttribute( 'vIndex' , -1 );
		var a = iCom[key]['iTbl'];
		iClearTbl( a );
		a.style.width = u.offsetWidth + 'px';
		var bLen = b.length;
		a.setAttribute( 'kwd' , kwd );
		a.setAttribute( 'hIndex' , -1 );
		var e,f,h;
		for ( var d = 0 ; d < bLen ; ++d ) {
			e = a.insertRow( -1 );
			e.onmousedown = iTrMDown;
			e.onmouseover = iTrMOver;
			e.completeString = b[d][0];
			e.className = iTag + 'a';
			f = document.createElement( 'td' );
			iInsert( f , b[d][0] );
			f.className = iTag + 'c';
			if ( iBrowser.N && da.test( b[d][0] ) ) {
				f.style.paddingTop = '2px';
			}
			e.appendChild( f );
			h = document.createElement( 'td' );
			iInsert( h , b[d][1] );
			h.className = iTag + 'd';
			e.appendChild( h );
		}

		//關閉按鈕行暫時取消
		var m = a.insertRow( -1 );
		var k = document.createElement( 'td' );
		k.setAttribute( 'keep' , 'keep' );
		k.colSpan = 2;
		m.style.height = 0;
		m.appendChild( k );
		/*
		if ( !iBrowser.I ) {
			m.onmousedown = iCancel;
		}
		var k = document.createElement( 'td' );
		k.setAttribute( 'keep' , 'keep' );
		k.colSpan = 2;
		m.className = iTag + 'e';
		var D = document.createElement( 'span' );
		D.className = iTag + 'f';
		m.appendChild( k );
		k.appendChild( D );
		iInsert( D , '關閉' );
		D.onclick = iClose;
		*/

		iResize( key );
	}

	function iUpDown() {//上下導航鍵操作
		var key = arguments[0];
		var a = arguments[1] || 0;
		if ( !isUD( a ) ) {//非上下鍵
			return false;
		}

		var u = iCom[key]['iInput'];
		var vIndex = u.getAttribute( 'vIndex' );

		var t = iCom[key]['iTbl'];
		var hIndex = t.getAttribute( 'hIndex' );
		var kwd = t.getAttribute( 'kwd' );
		var rLen = t.rows.length;

		if ( !( rLen - 1 ) ) {//如果table中沒有數據,則關閉 table,返回
			iClose( key );
			return false;
		}
		
		if ( 'hidden' == t.style.visibility ) {//如果是關的,則打開
			ChHigh( t , vIndex );
			iOpen( key );
			return false;
		}

		hIndex1 = isDown( a ) ? hIndex - 0 + 1 : hIndex - 1;
		hIndex1 = hIndex1 < -1 ? rLen - 2 : ( hIndex1 > rLen - 2 ? -1 : hIndex1 );
		ChHigh( t , hIndex1 );
		u.value =  -1 == hIndex1 ? kwd : t.rows[hIndex1].completeString;
		u.setAttribute( 'vIndex' , hIndex1 );
	}

	function ChHigh( t , hIndex1 ) {
		var hIndex = t.getAttribute( 'hIndex' );
		var len = t.rows.length;
		if ( hIndex >=0 && hIndex <= len - 2 ) {
			t.rows[hIndex].className = iTag + 'a';
		}
		if ( hIndex1 >=0 && hIndex1 <= len - 2 ) {
			t.rows[hIndex1].className = iTag + 'b';
		}
		t.setAttribute( 'hIndex' , hIndex1 );
	}

	function iCancel( e ) {
		e = e || window.event;
		if ( iBrowser.O ) {
			var t = e.target || e.srcElement,key;
			while ( !( uokey = t.getAttribute( 'key' ) ) ) {
				t = t.parentNode;
			}
			function uo() {
				iOpen( uokey );
				iCom[uokey]['iInput'].focus();
			}
			setTimeout( uo , 10 );		
		}
		else {
			e.cancelBubble=true;
			e.returnValue=false;
			return false;
		}
	}

	function iCreateTbl( key ) {
		var t = document.createElement( 'table' );
		t.cellSpacing = ( t.cellPadding = "0" );
		t.className = iTag + 'm';
		t.style.visibility = 'hidden';
		t.style.zIndex = 999;
		document.body.appendChild( t );
		return t;
	}

	function iCreateIfr( key ) {
		var f = '';
		if ( iBrowser.I ) {//創建iframe
			var y;
			f = document.createElement( 'iframe' );
			y = f.style;
			y.zIndex = 998;
			y.position = 'absolute';
			y.display = 'block';
			y.borderWidth = 0;
			document.body.appendChild( f );
		}
		return f;
	}

	function iGetAbsPos( a ) {
		var w = h = 0;
		while ( a ) {
			w += a['offsetLeft'];
			h += a['offsetTop'];
			a = a.offsetParent;
		}
		return [w,h];
	}

	function iGetPosPara( e ) {
		if ( 'string' == typeof e ) {
			var key = e;
		}
		else {
			e = e || window.event;
			var u = e.srcElement || e.target;
			var key = u.getAttribute( 'key' );
		}
		var i = iCom[key]['iInput'];

		var iow = i.offsetWidth;
		var ioh = i.offsetHeight;

		var pos = iGetAbsPos( i );
		var iex = pos[0];
		var iey = pos[1] + ioh - 1;

		var bsw = document.body.scrollWidth || document.documentElement.scrollWidth;
		var bsh = document.body.scrollHeight || document.documentElement.scrollHeight;

		var bch = document.body.clientHeight || document.documentElement.clientHeight;

		iCom[key]['pospara'] = { iow: iow , ioh: ioh , iex: iex , iey: iey , bsw: bsw , bsh: bsh , bch: bch };
	}

	function iSetPos( e ) {
		if ( typeof e == 'string' ) {
			var key = e;
		}
		else {
			e = e || window.event;
			var u = e.srcElement || e.target;
			var key = u.getAttribute( 'key' );
		}
		var t = iCom[key]['iTbl'],f = iCom[key]['iIfr'];
		if ( !iCom[key]['pospara'] ) {//若因異常未計算好定位所需參數
			return ;
		}

		var iow = iCom[key]['pospara']['iow'];
		var ioh = iCom[key]['pospara']['ioh'];

		var iex = iCom[key]['pospara']['iex'];
		var iey = iCom[key]['pospara']['iey'];

		var bsw = iCom[key]['pospara']['bsw'];
		var bsh = iCom[key]['pospara']['bsh'];

		var bch = iCom[key]['pospara']['bch'];
		
		//滾動參數要實時統計
		var bst = document.body.scrollTop || document.documentElement.scrollTop;
		
		//自動完成table參數要實時統計
		var tow = t.offsetWidth;
		var toh = t.offsetHeight;
		
		/*******************計算左右停靠位置**********************/
		var tsl = iex + tow > bsw ? iex + iow - tow : iex;
		/*****************************************/
		
		/*******************計算上下停靠位置**********************/
		var tst;
		var up = iey - ioh + 2 - toh;
		if ( iey + 220 <= bst + bch ) {//下限未超出滾動條下邊界 停靠在輸入框下方
			tst = iey;
		}
		else {//下限超出滾動條下限
			if ( iey + 220 > bsh ) {//下限超出body下邊界 則不管是否會被隱藏都往上停靠
				tst = up;
			}
			else {//下限未超出整個body下邊界
				if ( iey - ioh + 2 - 220 >= bst ) {//往上依靠時沒有超出滾動條上邊界,則停靠在輸入框上方
					tst = up;
				}
				else {//否則停靠在輸入框下方
					tst = iey;
				}
			}
		}
		/*****************************************/

		t.style.left = tsl + 'px';
		t.style.top = tst + 'px';
		if ( f ) {
			f.style.left = t.style.left;
			f.style.top = t.style.top;		
		}
	}

	function iResize( key ) {
		var a = iCom[key]['iTbl'];
		var b = iCom[key]['iIfr'] || '';
		var c = iCom[key]['iInput'];
		a.style.width = Math.max( c.offsetWidth , a.offsetWidth ) + 'px';
		if ( b ) {//ie須遮住
			b.style.width = a.offsetWidth + 'px';
			b.style.height = a.offsetHeight + 'px';
		}	
	}

	function iBefore() {
		var e = window.event;
		if ( !e || !e.toElement ) {
			return false;
		}
		if ( 'keep' == e.toElement.getAttribute( 'keep' ) ) {
			e.cancelBubble=true;
			e.returnValue=false;
			return false;	
		}
	}

	function iClose( e ) {
		if ( typeof e == 'string' ) {
			var key = e;
		}
		else {
			e = e || window.event;
			var t = e.srcElement || e.target;
			var key;
			while ( t && !( key = t.getAttribute( 'key' ) ) ) {
				t = t.parentNode;
			}
		}
		iCom[key]['iTbl'].style.visibility = 'hidden';
		if ( iCom[key]['iIfr'] ) {
			iCom[key]['iIfr'].style.visibility = 'hidden';
		}
	}

	function iOpen( key ) {
		iSetPos( key );
		iCom[key]['iTbl'].style.visibility = 'visible';
		if ( iCom[key]['iIfr'] ) {
			iCom[key]['iIfr'].style.visibility = 'visible';
		}
	}

	function iCheck( obj ) {
		var iLen = iCom.length,key;
		for ( var i = 1 ; i <= iLen ; i++ ) {
			key = iTag + i;
			if ( iCom[key] && iCom[key]['iInput'] == obj ) {
				return false;
			}
		}
		return true;
	}

	function trim() {
		var str = ( arguments[0] || '' ) + '',l_r = arguments[1] || '',regExp1 = /^ */,regExp2 = / *$/;
		switch ( l_r ) {
			case 'left'		:return str.replace(regExp1,'');
			case 'right'	:return str.replace(regExp2,'');
			default			:return str.replace(regExp1,'').replace(regExp2,'');
		}
	}

	function iCreateStyle() {//創建樣式
		var a=document.body.dir=="rtl",b=a?"right":"left",c=a?"left":"right";
		var d=document.getElementsByTagName("head")[0],e=document.createElement("style"),f=null,h=null,m=false;
		e.id = iTag + 'ui';
		if(document.styleSheets){
			d.appendChild(e);
			m=true;
			f=e.sheet?e.sheet:e.styleSheet;
		}
		if(!f){
			h=document.createTextNode("");
			e.appendChild(h);
		}
		var k=function(D,E){
			var ma=D+" { "+E+" }";
			if(f){
				if(f.insertRule){
					f.insertRule(ma,f.cssRules.length);
				}
				else if(f.addRule){
					f.addRule(D,E);
				}
			}
			else{
				h.data+=ma+"\n";
			}
		};
		k("."+iTag+"m","font-size:13px;font-family:arial,sans-serif;cursor:default;line-height:17px;border:1px solid #7F9DB9;z-index:2;position:absolute;background-color:white;margin:0;");
		k("."+iTag+"a","cursor:pointer;");
		k("."+iTag+"b","background-color:#36c;color:white;cursor:pointer;");
		k("."+iTag+"c","white-space:nowrap;overflow:hidden;text-align:"+b+";padding-"+b+":3px;"+(iBrowser.I||iBrowser.O?"padding-bottom:1px;":""));
		k("."+iTag+"d","white-space:nowrap;overflow:hidden;text-align:"+c+";color:#0080FF;padding-"+b+":3px;padding-"+c+":3px;");
		k("."+iTag+"b td","color:white;");
		k("."+iTag+"e td","padding:0 3px 2px;text-align:"+c+";font-size:10px;line-height:15px;");
		k("."+iTag+"f","color:#ff7400;text-decoration:underline;cursor:pointer;");
		if ( !m ) {
			d.appendChild( e );
		} 
	}
})();



/*
 *Author	ourac 
 *Date		2008-8-19
 *Function	關鍵字自動完成
*/
 

function initAutoCom(pagetype,lang) {
	
	//判斷域名,只有二級域名相同才方便跨域調用ajax
	var domainArr = document.domain.split( '.' );
	if ( '51job.com' != domainArr[domainArr.length-2] + '.' + domainArr[domainArr.length-1] ) {
		return false;
	}

	//創建iframe對象
	window.ajaxIfrqry = document.createElement( 'iframe' );
	ajaxIfrqry.style.display = 'none';

	ajaxIfrqry.src = 'http://big5.51job.com/gate/big5/kwdsrv.51job.com/kwdAjaxIframe.html';
	document.body.appendChild( ajaxIfrqry );
	window.ajaxIfrqry = ajaxIfrqry;

	var kwdProVideUrl = 'http://big5.51job.com/gate/big5/kwdsrv.51job.com/Default.aspx?kwdType=';

	window.iDpqry = [];
	iDpqry[0] = new DataProvide( kwdProVideUrl + 0 , lang );
	iDpqry[1] = new DataProvide( kwdProVideUrl + 1 , lang );
	iDpqry[2] = new DataProvide( kwdProVideUrl + 2 , lang );
	
	switch ( pagetype ) {
		case '0' :
			var kwdObj = [document.frmKeywordSearch['keyword']];
			if(Jtrim(document.frmKeywordSearch['keywordtype'].value)=="" || Jtrim(document.frmKeywordSearch['keywordtype'].value)=="all")
		 	{
		 		document.frmKeywordSearch['keywordtype'].value=2;
		 	}
			var kTypeIndexs =[document.frmKeywordSearch['keywordtype'].value];
			clkFunc = [function() { document.frmKeywordSearch.submit(); }];
			var kTypeChgs = [ 0 ];
			break;	
		case '1' :
		 var kwdObj = [document.frmKeywordSearch['keyword'] , document.frmQuickSearch['keyword']];
		 var fq_keywordtype;
		 for(var i=0;i < 2;i++){
		  if(document.frmQuickSearch['keywordtype'][i].checked == true){
		   	fq_keywordtype=document.frmQuickSearch['keywordtype'][i].value;
		   	break;
		  }
		 }
		 if(Jtrim(document.frmKeywordSearch['keywordtype'].value)=="")
		 {
		 		document.frmKeywordSearch['keywordtype'].value=2;
		 }
		 var kTypeIndexs =[document.frmKeywordSearch['keywordtype'].value,fq_keywordtype];
		 clkFunc = [function() { document.frmKeywordSearch.submit(); },function() { document.frmQuickSearch.submit(); }];
		 var kTypeChgs = [ 0 ,1];						
		 break;
	 case '2' :
			var kwdObj = [document.pmcform['keyword']];
			var kTypeIndexs =[2];
			clkFunc = [function() { document.pmcform.submit(); }];
			var kTypeChgs = [ 0 ];
			break;
	 case '3' :
			var kwdObj = [document.advance_search_form['keyword']];
			var kTypeIndexs =[document.advance_search_form['keywordtype'].value];
			clkFunc = [function() { if( chkPersearch() ){ subPmcForm( document.getElementById( 'jobarea' ).value , document.getElementById( 'issuedate' ).value , document.getElementById( 'workyear' ).value , document.getElementById( 'degree' ).value , '' , document.getElementById( 'funtype' ).value , document.getElementById( 'industrytype' ).value , document.getElementById( 'cotype' ).value , document.getElementById( 'salary' ).value , document.getElementById( 'worktype' ).value , document.getElementById( 'keyword' ).value , document.getElementById( 'keywordtype' ).value , 2 ) }else{ return false; }}];
			var kTypeChgs = [ 0 ];
			break;
		default : break;
	}
	
	var kwdLen = kwdObj.length;
	for ( var i = 0 ; i < kwdLen ; i++ ) {
		iPush( [kwdObj[i] , iDpqry[kTypeIndexs[i]] , clkFunc[i]] );
	}

	for ( var j = 0 ; j < kwdLen ; j++ ) {
		if ( 0 == kTypeChgs[j] ) {
			/*關鍵字類型圖文切換綁定相應事件*/
			var kwdtypes = ['keyword_type_company' , 'keyword_type_job' , 'keyword_type_all'];
			for ( var i = 0 ; i < kwdtypes.length ; i++ ) {
				var tmpObj = document.getElementById( kwdtypes[i] );
				tmpObj.setAttribute( 'kType' , i );
				tmpObj.setAttribute( 'iComKey' , j + 1 );
				iAttEvt( tmpObj , 'click' , 
					function( event ) {
						var e = event || window.event;
						var eobj = e.target || e.srcElement;
						while ( eobj && !( eobj.id == 'keyword_type_company' || eobj.id == 'keyword_type_job' || eobj.id == 'keyword_type_all' ) ) {
							eobj = eobj.parentNode;	
						}
						if ( !eobj ) {
								return false;
						}
						iCom[( iTag + eobj.getAttribute( 'iComKey' ) )]['iDpqry'] = iDpqry[eobj.getAttribute( 'kType' )];
					},
					true
				);
			}	
		}
		else {
			/*關鍵字類型radio切換綁定相應事件*/
			var ktobj = document.frmQuickSearch.keywordtype;
			var ktlen = ktobj.length;
			for ( var i = 0 ; i < ktlen ; i++ ) {
				ktobj[i].setAttribute( 'iComKey' , j + 1 );
				iAttEvt( ktobj[i] , 'click' , function( event ) { 
					var e = event || window.event;
					var eobj = e.target || e.srcElement;
					iCom[( iTag + eobj.getAttribute( 'iComKey' ) )]['iDpqry'] = iDpqry[eobj.value]; 
					} 
				);
			}
		}
	}
}

//解決ie下光標定位到最後一個字符的問題-ourac
function FocusEnd(u)
{
	u.focus();
	if ( iBrowser.I ) {
		var r = u.createTextRange();
		r.moveStart('character', u.value.length);
		r.collapse();
		r.select();
	}
}