 var jsLib='http://hanyu.iciba.com/huayi/wwwroot/js/';
 var plut_css='http://hanyu.iciba.com/huayi/wwwroot/ui/';
 var _jsInterFaceHost='http://hanyu.iciba.com/huayi/wwwroot/';
 var _icbaUiType=0;
 var _icibaLanguage="";
 document.write("<style>\r\n.iciba_hy_js12 {\r\ncolor:#666666;\r\nfont-family:Arial;\r\nfont-size:16px;\r\npadding-left:2px;\r\n}        \r\n.iciba_hy_js11 {\r\nfloat:left;\r\nfont-family:\"宋体\";\r\nfont-size:22px;\r\nfont-weight:bold;\r\npadding-left:2px;\r\n}\r\n.iciba_hy_js13 {\r\ncolor:#666666;\r\nfont-family:Arial;\r\nfont-size:16px;\r\n}\r\n.icibaItemContext a:hover,.icibaItemContext a:link,.icibaItemContext a:visited{font-size:12px;}\r\n#icibaTableBg{border-collapse:separate ;border-spacing:1px;}\r\n<\/style>\r\n<div id=\"iciba_plug\" name=\"iciba_plug\" style=\"top:10px;left:10px;display:none;z-index:5\">\r\n\r\n<object>\r\n<table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"1\" class=\"icibaTableBg\" id=\"icibaTableBg\">\r\n  <tr>\r\n    <td valign=\"top\"  class=\"icibaTdBg\">\r\n	\r\n	<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"icibaDrawBar\">\r\n      <tr class=\"icibaBarBg\">\r\n        <td   id=\"icibaBar\">     \r\n		<div id=\"icibaLogo\">爱词霸汉语 即划即译<\/div>		\r\n		<\/td>\r\n		<td width=\"60\">\r\n		<div id=\"icibaIcon\">\r\n		  <span title=\"关闭\" id=\"icibaClose\">关闭<\/span>\r\n		  <span title=\"放大\" id=\"icibaBig\" class=\"icibaBig1\">放大<\/span>\r\n		  <span title=\"定位\" id=\"icibaDw\" class=\"icibaDw\">定位<\/span>\r\n		  <div style=\"clear:both;\"><\/div>\r\n		<\/div>\r\n\r\n		<\/td>\r\n      <\/tr>\r\n    <\/table>\r\n\r\n      <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"icibaSearchToolBar\">\r\n	    \r\n        <tr class=\"icibaInputBg\">\r\n         <td>\r\n          <div id=\"icibaInputW\">\r\n			  <div id=\"icibaInput\">\r\n			    <INPUT TYPE=\"text\" NAME=\"icibaInputWord\" id=\"icibaInputWord\" style=\"width:210px;\"><span id=\"onOff\">on<\/span>\r\n				<div style=\"clear:both;\"><\/div>\r\n			  <\/div>\r\n		 <\/div>\r\n           <span id=\"icibaBotton\" class=\"icibaBotton\">搜索<\/span>            \r\n		<div style=\"clear:both;\"><\/div>\r\n\r\n		<\/td>          \r\n        <\/tr>\r\n      <\/table>\r\n\r\n      <table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding-top:10px;\">\r\n        <tr>\r\n          <td valign=\"top\">\r\n		  <div id=\"icibaContext\" >\r\n			<div id=\"icibaHy_context\" class=\"icibaItemContext\" style=\"text-align:left;\">Loading......<\/div>\r\n\r\n		  <\/div>\r\n\r\n		  <\/td>\r\n        <\/tr>\r\n      <\/table>\r\n	  <!-- ad -->\r\n      <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"icibaAdsBoot\">\r\n        <tr>\r\n		  <td><div id=\"icibaSkin\" title=\"点击换皮肤\" onclick=\"K.skinChangPlay()\" class=\"icibaSkinNo\">皮肤<\/div><\/td>\r\n          <td  id=\"icibaAdsBootLeft\"><a href=\"#\" target=\"_blank\" >牛津专业版优惠价!   牛津新词典<\/a><\/td>\r\n		  \r\n          <td   id=\"icibaAdsBootRight\" align=\"right\"><a href=\"http://hanyu.iciba.com/index.php?module=buchong&type=cz&word=%E6%B1%89%E8%AF%AD%E7%AB%99%E6%84%8F%E8%A7%81%E5%8F%8D%E9%A6%88\" target=\"_blank\" align=\"right\">问题反馈<\/a> 内容由<a href=\"http://hanyu.iciba.com/\" target=\"_blank\">ICIBA.COM爱词霸<\/a>提供 <\/td>\r\n        <\/tr>\r\n      <\/table>\r\n	  <!-- end ad -->\r\n	  <\/td>\r\n  <\/tr>\r\n<\/table>\r\n<\/object>\r\n<\/div>\r\n		\r\n<ul id=\"icibaHistory\" style=\"z-index:10\">\r\n<\/ul>\r\n<div id=\"icibaSkinChoice\" style=\"display:none;\"><\/div>\r\n<div id=\"kshyr\" style=\"display:none\"><\/div>\r\n<FORM METHOD=\"POST\" ACTION=\"\" target=\"_blank\" id=\"icibaForm\" style=\"display:none;\"><\/FORM>\r\n\r\n\r\n");

   /*--------------------------------------------------------------------------+
   | JSLoad (url           // String  - Scripts location (i.e. http:///a.js)
   |         [, container] // Object  - Window with script loading capability
   |         [, type]      // String  - Type of script (i.e. text/javascript)
   |         [, defer]     // Boolean - Flag for delaying script processing
   |         [, language]  // String  - Language script is written in.
   |         [, title])    // String  - Title for loaded script
   |+--------------------------------------------------------------------------+
   | 从新载入 js文件
   *--------------------------------------------------------------------------*/
var K2 = K2 || {};
if(typeof(iciba_param)=="undefined") iciba_param=new Array();

   function JSLoad(url, container, type, defer, language, title)
   {
      // verify / attain container
      if(container == undefined || container == null) container = this;

      // setup container
      if(typeof container.write == "undefined")
         if(typeof container.document != "undefined")
            container = container.document;
         else throw "Invalid container. Unable to load [" + url + "]";

      // no type set
      if(type == undefined || type == null)
      {
         type = '';

         // no language so set default type
         if(language == undefined || language == null)
         {
            language = undefined;
            type = "text/javascript";
         }
      }

      // set default language
      if(language == undefined || language == null) language = "JavaScript";

      // set title
      if(title == undefined || title == null) title = '';

      // set defer
      if(defer == undefined) defer = false;

      // build the script object
      var script = container.createElement("script");
      script.defer = defer;
      script.language = language;
      script.title = title;
      script.type = type;
      script.charset = "UTF-8";//charset="UTF-8"
      script.src = url;

      // dynamically load the script via it's container
      var head = container.getElementsByTagName("head")[0];
      head.appendChild(script);
   }

   //载入css文件
   function CssLoad(url,container){
	   if(container == undefined || container == null) container = this;

      // setup container
      if(typeof container.write == "undefined")
         if(typeof container.document != "undefined")
            container = container.document;
         else throw "Invalid container. Unable to load [" + url + "]";
      var css = container.createElement("link");
      css.rel = "stylesheet";
      css.type = "text/css";
      css.href = url;      
      css.id = 'icibaCssDefault';      
      var head = container.getElementsByTagName("head")[0];
      head.appendChild(css);
   }

   function isEnglish(name) //英文值检测
   {
	   if(name.length == 0)return false;
	   for(i = 0; i < name.length; i++) {
		   if(name.charCodeAt(i) > 128)
			   return false;
		}
	    return true;
	}

  

 //翻译
   K2.translateRest= function (result) {	  
	  if (!result.error) {
		  K.$('icibaFy_context').innerHTML=(result.translation);
		  K.$('icibaFy_context').style.display='block';
		  callBackIsDisplay('icibaFy');
		}else{
			alert(result.error);
		}
   }
  K2.translate= function (s,from_language,to_language){  
	   try{
		   
		   google.language.translate(s,from_language,to_language,  K2.translateRest);
	   }catch(e){
		    K.$('icibaFy_context').style.display='none';
		    K.$('icibaFy').style.display='none';
	   }
   }
  // end 翻译

  //翻译2
   function fyCallback(str){
	   K.$('icibaFy_context').innerHTML=str;
	   K.$('icibaFy_context').style.display=str==''?'none':'block';
	   callBackIsDisplay('icibaFy');
   }
   // end 翻译2

  

  //短句
  function djCallback(str){
	  try{
		  K.$('icibaDj_context').innerHTML=str;
		  K.$('icibaDj_context').style.display= str==''?'none':'block';
		  if(K.$('icibaDj'))K.$('icibaDj').style.display= str==''?'none':'block';
		  if(str!='')callBackIsDisplay('icibaDj');
		  K.observe(K.$('icibaDjMore'),'click',K.regDjMore);
	  }catch(e){
	  }
  }
  //end 短句
  function hyCallback(str)
  {
	try{		 
		  //str.replace('asdfasdf',iciba_param['adid']);

		    q=(K.$('icibaInputWord').value);
			if(typeof(iciba_param['descid'])!="undefined")
			{
				if(str=='')
				{
					str="没有查到相关词!<br />";
				}
				else
				{
					str=str+'<br /><a href="http://hanyu.iciba.com/hy/'+q+'/" target="_blank">详细解释</a>&nbsp;&nbsp;&nbsp;';
				}
			}
			else
			{
				if(str=='')
				{
					str="没有查到相关词!<br />";
				}
				else
				{
					str=str+"<br />";
				}
				
			}

			iciba_param['code']="UTF-8";

			if(typeof(iciba_param['baiduid'])!="undefined")
			{
				str=str+'<a href="http://www.baidu.com/s?tn='+iciba_param['baiduid']+'&ie='+iciba_param['code']+'&word='+encodeURIComponent(q)+'" target="_blank">去百度搜索</a>&nbsp;&nbsp;&nbsp;';
			}
			if(typeof(iciba_param['googleid'])!="undefined")
			{
				if(iciba_param['code']!="UTF-8")
				google_bianma="ie="+iciba_param['code'];
				else
				google_bianma="";
				str=str+'<a href="http://www.google.cn/search?q='+encodeURIComponent(q)+'&client='+iciba_param['googleid']+google_bianma+'&hl=zh-CN" target="_blank" >去谷歌搜索</a>&nbsp;&nbsp;&nbsp;';
			}
			if(typeof(iciba_param['sosoid'])!="undefined")
			{
				str=str+'<a href="http://www.soso.com/q?w='+encodeURIComponent(q)+'&client='+iciba_param['googleid']+'&ie='+iciba_param['code']+'&oe='+iciba_param['code']+'&hl=zh-CN" target="_blank" >去SOSO搜索</a>&nbsp;&nbsp;&nbsp;';
			}
			if(typeof(iciba_param['sogouid'])!="undefined")
			{
				if(iciba_param['code']=="UTF-8")
				{
					iciba_param['code']="utf8";
				}
				str=str+'<a href="http://www.sogou.com/sogou?query='+encodeURIComponent(q)+'&ie='+iciba_param['code']+'&pid='+iciba_param['googleid']+'" target="_blank" >去搜狗搜索</a>&nbsp;&nbsp;&nbsp;';
			}
			
		  K.$('icibaHy_context').innerHTML=str;
		  K.$('icibaHy_context').style.display= str==''?'none':'block';
          if(str!=''){
				  //添加生词本 事件	
				  K.observe(K.$('icibaScb'),'click',K.addWordToScb);
				  K.observe(K.$('icibaExplain'),'click',K.toExplain);
				 // K.observe(K.$('icibaCopy'),'click',K.copy);
				  if(K.$('icibaCopy')){
					  K.$('icibaCopy').style.display=K.is_ie?'block':'none';
					  if(K.is_ie)K.observe(K.$('icibaCopy'),'click',K.copy);
				  }
				  
			  }
		
		  if(K.$('icibaHy'))K.$('icibaHy').style.display= str==''?'none':'block';
		  if(str!='')callBackIsDisplay('icibaHy');

	  }catch(e){
	  }
  
  }
  function En2enCallback(str){
	  try{
		 
		  K.$('icibaEnen_context').innerHTML=str;
		  K.$('icibaEnen_context').style.display= str==''?'none':'block';
		  if(K.$('icibaEnen'))K.$('icibaEnen').style.display= str==''?'none':'block';
		  if(str!='')callBackIsDisplay('icibaEnen');

	  }catch(e){
	  }
  }

  //查词
  function dictCallBack(str){
	  try{
		  K.$('icibaDict_context').innerHTML=str;
		  K.$('icibaDict_context').style.display= str==''?'none':'block';
		  if(K.$('icibaDict'))K.$('icibaDict').style.display= str==''?'none':'block';
		  if(str!=''){
			  //添加生词本 事件
			  K.observe(K.$('icibaScb'),'click',K.addWordToScb);
			  K.observe(K.$('icibaExplain'),'click',K.toExplain);
			 // K.observe(K.$('icibaCopy'),'click',K.copy);
              if(K.$('icibaCopy')){
				  K.$('icibaCopy').style.display=K.is_ie?'block':'none';
				  if(K.is_ie)K.observe(K.$('icibaCopy'),'click',K.copy);
			  }
			  
		  }else{
			  //当是搜狐邮箱的时候
			  if(_icbaUiType==3){
				  K.$('icibaFy_src').style.display='block';
				  K.$('icibaFy_line').style.display='block';
				  if(K.$('icibaFy_context'))K.$('icibaFy_context').setAttribute('isGo',"true");
				  if(K.$('icibaDict_context'))K.$('icibaDict_context').setAttribute('isGo',"false");
				  K.$(K.config.icibaDiv).style.width= K.config.oObjWidth+'px';
				  K.$('icibaContext').style.height= K.config.oObjHeight+'px';
				  //翻译
				  if( Loading('icibaFy_context') ){
					  var q=K.$(K.config.icibaDiv).content;					 
					  if(isEnglish(q)) K2.translate(q,"en", "zh-CN");else  K2.translate(q, "zh-CN","en");
				  }
			  }
		  }

		  if(_icbaUiType==2 || _icibaLanguage=='en'){
			   if(K.$('icibaScb'))K.$('icibaScb').title='Add to New Word List';
			   if(K.$('icibaCopy'))K.$('icibaCopy').title='Copy';
			   if(K.$('icibaExplain'))K.$('icibaExplain').innerHTML='Details';
			  if(K.$('icibaExplain'))K.$('icibaExplain').title='Details';
	      }
	  }catch(e){
	  }
	  callBackIsDisplay('icibaDict');
  }
  //end 查词

  //同反
  function tfCallback(str){
	  try{
		  if(str!=''){
			  //$str=strtr($str,array('反义词'=>'Antonyms','同义词'=>'Synonyms'));
			  if(_icbaUiType==2 || _icibaLanguage=='en'){
				  str=str.replace('反义词','Antonyms');
				  str=str.replace('同义词','Synonyms');
			  }
		  }
		  K.$('icibaTf_context').innerHTML=str;
		  K.$('icibaTf_context').style.display= str==''?'none':'block';
		  if(K.$('icibaTf'))K.$('icibaTf').style.display= str==''?'none':'block';
		  if(_icbaUiType==2 || _icibaLanguage=='en'){
			  if(K.$('icibaDjMore')){
				  K.$('icibaDjMore').innerHTML='More';
				  K.$('icibaDjMore').title='';
			  }
		  }
		  callBackIsDisplay('icibaTf');
	  }catch(e){
	  }
  }

  function LoveCallback(str){
	  //alert(str);
	  K.$('icibaLove_context').style.display= str==''?'none':'block';
	  if(K.$('icibaLove'))K.$('icibaLove').style.display= str==''?'none':'block';
	  if(str=='')return ;
	  //alert('asdf');
	  try{
		    K.$('icibaLove_context').innerHTML=str;
			 callBackIsDisplay('icibaLove');
	  }catch(e){
	  }
  }

  //判断
  function Loading(divStr){
	  try{
		  document.getElementById(divStr).innerHTML='Loading.......';  
		 if(document.getElementById(divStr).getAttribute('isGo')=='false') {
			 document.getElementById(divStr).style.display='none';
			 return false;
		 }
		 document.getElementById(divStr).style.display='block';
		  return true;
	  }catch(e){
		 return false;
	  }
  }

  function callBackIsDisplay(divStr){
	  try{
	  	  if(K.$(divStr+'_context').getAttribute('isDisplay')=='none'){
			 var temIds= K.$(divStr).getElementsByTagName('span');//tagName 
			temIds[0].className="icibaItemIcon_2";//icibaItemIcon_2
			  K.$(divStr+'_context').style.display='none';
		  }
	  }catch(r){}
  }

  //判断是否在
  function isOnDiv(id){
	 
	  if(!K.config.isSelfDeter) return false;
	  if(id=='icibaDj_context') return true;
	  if(id=='icibaFy_context') return true;
	  //if(id=='icibaTf_context') return true;
	  if(id=='icibaDict_context') return true;
	  if(id=='icibaLove_context') return true;
	  if(id=='icibaEnen_context') return true;
	  if(id=='icibaFy_src') return true;

	  return false;
  }

  function inputKey(q){
	  if(q=='') return;
	  try{		  
		  if(K.$('icibaInputWord'))K.$('icibaInputWord').value=q;
		  if(K.$('icibaOutWord') && q!='')K.$('icibaOutWord').value=q;
	  }catch(e){
	  }
	  K.$(K.config.icibaDiv).content=q;
  }

  //初始化查询历史
  initHistory=function(){
	  if(!K.$('icibaHistory')) return ;
	  var cookie=(K.rCookie('historyT'));
	var str='';
	var arr=cookie.split('/===/');
	//alert(arr.length);
	iK=0;
	for(i =0;i<arr.length;i++){
		w=arr[i];
		if(w.replace(/^\s+/,"")!=''){
			str+='<li title="'+w+'" onclick="HistoryQuery(event);" class="icibaItem" onmousemove="mmove(event)" onmouseout="mout(event)">'+w+'</li>' +K.$('icibaHistory').innerHTML;
            iK++;
		}
		//if(iK>=5) break;
	}
	K.$('icibaHistory').innerHTML=str;
  }
  HistoryQuery=function(e){
	  e = e || window.event;
	  var src = e.srcElement || e.target;
	  closeHistory();
	  K.Search(e,src.innerHTML,false);
  }
  function mmove(e){	  
	  e = e || window.event;
	  var src = e.srcElement || e.target;
	  src.className='icibaItem2';
  }
  function mout(e){
	  e = e || window.event;
	  var src = e.srcElement || e.target;
	  src.className='icibaItem';
  }
  function addHistory(w){
	  if(_icbaUiType==3) {K.wCookie('historyT','');return ;}
	  if(w.length>20) return;
	  if(!K.$('icibaHistory')) return ;
	  if(w.replace(/^\s+/,"")!=''){
		  var historyT= w+'/===/'+ K.rCookie('historyT');
		  //alert(historyT.split('/===/').length+"**"+K.config.historyMax);
		  if(historyT.split('/===/').length>K.config.historyMax){
			  var tArr=historyT.split('/===/');			 
			  cont="";
			  historyT='';
			  for(i=0;i<K.config.historyMax;i++){
				  historyT+= cont + tArr[i];
				    cont='/===/';
			  }
		  }
		  K.wCookie('historyT',historyT);
		  K.$('icibaHistory').innerHTML= '<li title="'+w+'" onclick="HistoryQuery(event);" class="icibaItem" onmousemove="mmove(event)" onmouseout="mout(event)">'+w+'</li>' +K.$('icibaHistory').innerHTML;
	 }
  }
  function closeHistory(){
	  if(K.$('icibaSkinChoice')){
		  K.$('icibaSkinChoice').style.display='none';
		  K.$('icibaSkin').className='icibaSkinNo';
	  }
	   if(!K.$('icibaHistory')) return ;
	  K.$('icibaHistory').style.display = 'none' ;
  }
  regShowHistory=function(e){
	  if(!K.$('icibaHistory')) return ;
	e = e || window.event;
	var src = e.srcElement || e.target;
	var xy=K.getCoords(src);
	//alert(xy.x);
	var icibaHistory=K.$('icibaHistory');	
	icibaHistory.style.display= icibaHistory.style.display=='block'?"none":'block';
	K.$('icibaHistory').style.width= (K.$('icibaInputWord').clientWidth+K.$('onOff').clientWidth)+'px';
	K.$('icibaHistory').style.left=(K.getCoords(K.$('icibaInputWord')).x-1)+"px";
	K.$('icibaHistory').style.top=(K.getCoords(K.$('icibaInputWord')).y+K.$('icibaInputWord').clientHeight-1)+"px";
   if(K.is_ie){
	   if(icibaHistory.style.display!='none')K.flashDisplay('none');else K.flashDisplay('');
   }
 }

 
 isOnHistory=function(id){
	 if(id=='icibaHistory') return true;
	 return false;
	

 }
  //end 历史  

  //再链接
  function searchDictByWord(e){
	  e = e || window.event;
	  var src = e.srcElement || e.target;	  
	  var q=(src.innerHTML);
	  if(q.replace(/^\s+/,"") =='') {
		  return ;
	  }
	  K.Search(e,q,false);
	  addHistory(q);
  }
  
  isFy=true;
  if( typeof(iciba_param['context']) !='undefined' ){
	   isFy=false;
	  for(i=0;i<iciba_param['context'].length;i++){
		  if(iciba_param['context'][i][0]=='Fy'){ isFy=true;break;}
	  }
  }   

  if(typeof(iciba_param['isPopIcon']) !='undefined' && iciba_param['isPopIcon']=='1'){
		if( typeof(iciba_param['isPopStyle']) =='undefined' ) iciba_param['isPopStyle']='4';
		switch(iciba_param['isPopStyle']){
			case '1':
				style='background-position:-20px -10px;  width:18px;height:24px;';
			break;
			case '2':
				style='background-position:-20px -40px;  width:18px;height:18px;';
			break;
			case '3':
				style='background-position:-20px -70px;  width:18px;height:18px;';
			break;
			case '4':
				style='background-position:-20px -100px;  width:20px;height:20px;';
			break;
			case '5':
				style='background-position:-20px -130px;  width:22px;height:22px;';
			break;
			default: 
				style='background-position:-20px -100px;  width:20px;height:20px;';
		}
		document.write('<div id="icibaPopIcon" style="'+style+';display:none" >译</div>');
	}


  //if(K.$('icibaCssInterface')==null)
  if(document.getElementById('icibaCssInterface')==null){
	  if(_icbaUiType==2)CssLoad(plut_css+'hangban.css');
	  else CssLoad(plut_css+'plug.css');
  }
  JSLoad(jsLib+'K.js');
  
