function _dictInit(){
if(_dict_init==1){
_dictUpdateStatus();
return true;
}
if(! document || ! document.body || !document.body.firstChild){
setTimeout("_dictInit()",800);
return true;
}
var agt = navigator.userAgent.toLowerCase();
var b='border:none;padding:0px;margin:0px;';
var f='font-weight:normal;font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;';
_dict_is_ie = (agt.indexOf("msie")!=-1 && document.all);
_dict_opera = (agt.indexOf('opera')!=-1 && window.opera && document.getElementById);
var h = '
';
h += '';
h += '';
h += ' | ';
h += ' |
';
try{
var els=document.getElementsByTagName("*");
var zmax=97;
for(var i=0;i>4)+_dict_hexchars.charAt(n & 0xF);
}
var _dict_okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function _dict_toutf8(wide) {
var c, s;
var enc = "";
var i = 0;
while(i=0xDC00 && c<0xE000) continue;
if (c>=0xD800 && c<0xDC00) {
if (i>=wide.length) continue;
s= wide.charCodeAt(i++);
if (s<0xDC00 || c>=0xDE00) continue;
c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
}
// output value
if (c<0x80) enc += String.fromCharCode(c);
else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
}
return enc;
}
function _dict_encodeURIComponentNew(s) {
s = _dict_toutf8(s);
var c;
var enc = "";
for (var i= 0; i= 0 && ua.indexOf('opera') < 0) {
el.innerHTML = 'for IE
' + htmlCode;
el.removeChild(el.firstChild);
}
else {
var el_next = el.nextSibling;
var el_parent = el.parentNode;
el_parent.removeChild(el);
el.innerHTML = htmlCode;
if (el_next) {
el_parent.insertBefore(el, el_next)
} else {
el_parent.appendChild(el);
}
}
}
function _dictGetSel()
{
if (window.getSelection) return window.getSelection();
else if (document.getSelection) return document.getSelection();
else if (document.selection) return document.selection.createRange().text;
else return '';
}
function _dictGetPos(event){
try{
if(_dict_opera){
_dict_x = event.clientX + window.pageXOffset;;
_dict_y = event.clientY + window.pageYOffset;;
}else if (_dict_is_ie) {
_dict_x = window.event.clientX + document.documentElement.scrollLeft
+ document.body.scrollLeft;
_dict_y = window.event.clientY + document.documentElement.scrollTop
+ document.body.scrollTop;
}else {
_dict_x = event.clientX + window.scrollX;
_dict_y = event.clientY + window.scrollY;
}
}catch(x){}
if(!_dict_isInteger(_dict_x)) _dict_x = 200;
if(!_dict_isInteger(_dict_y)) _dict_y = 200;
}
function _dictKey(e){
_dictClose();
return true;
}
function _dictCheck(e) {
if(window.Event){
if(e.which == 2 || e.which == 3) {_dictClose(); return true;}
}else{
if(event.button == 2 || event.button == 3) {_dictClose(); return true;}
}
var cx = 0;
var cy = 0;
var obj = _dict_layer;
if (obj.offsetParent){
while (obj.offsetParent){
cx += obj.offsetLeft;
cy += obj.offsetTop;
obj = obj.offsetParent;
}
}else if (obj.x){
cx += obj.x;
cy += obj.y;
}
_dictGetPos(e);
if(_dict_moving>0){
_dict_startx = _dict_x;
_dict_starty = _dict_y;
if(_dict_onmove == 1){
_dict_moving = 2;
}else if(_dict_x < cx || _dict_x > (cx + 300) || _dict_y < cy || (!_dict_onlayer && _dict_y > (cy + 100) ) ){
_dictClose();
}else{
_dict_moving = 1;
}
}
}
function _dictQuery(e) {
if(window.Event){
if(e.which == 2 || e.which == 3) {_dictClose(); return true;}
}else{
if(event.button == 2 || event.button == 3) {_dictClose(); return true;}
}
if(_dict_moving == 1){
if (_dict_is_ie) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}else{
e.preventDefault();
}
return false;
}
_dictGetPos(e);
if(_dict_moving == 2) {
_dict_moving = 1;
_dict_cx = _dict_nx;
_dict_cy = _dict_ny;
return false;
}
if (!_dict_enable) return true;
var word = _dictGetSel();
if(document.f && document.f.q && document.f.q.value && word == document.f.q.value) return true;
word=""+word;
word=word.replace(/^\s*|\s*$/g,"");
if(word == "" || word.length > 76 || _dict_old_word == word) return true;
_dictShow(word);
}
function _dictDisplay(){
var dx=262;
var dy=264;
_dict_startx = _dict_x;
_dict_starty = _dict_y;
_dict_y += 8;
_dict_x += 16;
if(_dict_opera){
_dict_x -= 4;
}else if(_dict_is_ie){
if (document.documentElement.offsetHeight && document.body.scrollTop+document.documentElement.scrollTop+document.documentElement.offsetHeight - _dict_y < dy){
_dict_y = document.body.scrollTop+document.documentElement.scrollTop + document.documentElement.offsetHeight - dy;
_dict_x += 14;
}
if (document.documentElement.offsetWidth && document.body.scrollLeft+document.documentElement.scrollLeft+document.documentElement.offsetWidth - _dict_x < dx){
_dict_x = document.body.scrollLeft+document.documentElement.scrollLeft + document.documentElement.offsetWidth - dx;
}
}else{
dx-=1;
dy+=11;
if (self.innerHeight && document.body.scrollTop+document.documentElement.scrollTop + self.innerHeight - _dict_y < dy) {
_dict_y = document.body.scrollTop+document.documentElement.scrollTop + self.innerHeight - dy;
_dict_x += 14;
}
if (self.innerWidth && document.body.scrollLeft+document.documentElement.scrollLeft + self.innerWidth - _dict_x < dx) {
_dict_x = document.body.scrollLeft+document.documentElement.scrollLeft + self.innerWidth - dx;
}
}
_dict_nx = _dict_cx = _dict_x;
_dict_ny = _dict_cy = _dict_y;
_dict_layer.style.left = _dict_nx+'px';
_dict_layer.style.top = _dict_ny+'px';
_dict_layer.style.filter="Alpha(Opacity=96)";
_dict_layer.style.opacity = 0.96;
_dict_layer.style.display = "inline";
_dict_moving = 1;
}
function _dict_isInteger(s) {
return (s.toString().search(/^-?[0-9]+$/) == 0);
}
function dictShow(q){
if(_dict_mode != 1){
_dictSet(_dict_getObj('_dict_title'), '划词翻译 - Dict.CN');
_dict_mode = 1;
}
var d = _dict_getObj('_dict_add');
if(d){
d.href = _dict_host + 'scb/?utf8=1&word=' + q;
d.onclick = function(){ _dictScb(q); return false; };
}
d = _dict_getObj('_dict_detail');
if(d) d.href = _dict_host + 'search.php?q='+q;
if(_dict_moving==0)_dictDisplay();
_dict_iframe.src = _dict_host+'mini.php?utf8=1&q='+q;
}
function _dictShow(word){
var q = _dict_URL(word);
if(_dict_mode != 1){
_dictSet(_dict_getObj('_dict_title'), '划词翻译 - Dict.CN');
_dict_mode = 1;
}
var d = _dict_getObj('_dict_add');
if(d){
d.href = _dict_host + 'scb/?utf8=1&word=' + q;
d.onclick = function(){ _dictScb(q); return false; };
}
d = _dict_getObj('_dict_detail');
if(d) d.href = _dict_host + 'search.php?q='+q;
if(_dict_moving==0)_dictDisplay();
_dict_old_word = word;
_dict_iframe = false;
_dict_geturl(_dict_host+'mini.php?utf8=1&q='+q,word);
}
function _dict_geturl(u,word){
try{
if(_dict_frametimer){clearTimeout(_dict_frametimer);_dict_frametimer = 0;}
if(!_dict_iframe){
_dict_frameid ++;
_dictSet(_dict_getObj('_dictContent'),'');
_dict_iframe = _dict_getObj('_dictFrame'+_dict_frameid);
if(!_dict_iframe){
_dict_frametimer = setTimeout(function(){_dict_geturl(u,word)},1000);
return;
}
var iframeWin = window.frames['_dictFrame'+_dict_frameid];
// alert(iframeWin);
iframeWin.document.open();
iframeWin.document.write('Define '+word+' :
');
iframeWin.document.close();
}
}catch(x){
}
_dict_iframe.src = u;
}
function dictAdd(word,autoclose){
autoclose = (typeof autoclose == 'undefined') ? 0 : 1;
var q = _dict_URL(word.replace("%27","'"))
_dictScb(q, autoclose);
}
function _dictScb(word,autoclose){
if(word == "") return false;
autoclose = (typeof autoclose == 'undefined') ? 0 : 1;
if(_dict_mode != 2){
_dictSet(_dict_getObj('_dict_title'), '添加生词 - Dict.CN');
_dict_mode = 2;
}
var d = _dict_getObj('_dict_add');
if(d){
d.href = _dict_host + 'scb/';
d.onclick = function(){return true;};
}
d = _dict_getObj('_dict_detail');
if(d) d.href = _dict_host + 'search.php?utf8=1&q='+word;
if(_dict_moving ==0) _dictDisplay();
if(autoclose){
_dict_iframe.src = _dict_host+'scb/add.php?utf8=1&autoclose=1&word='+word;
}else{
_dict_iframe.src = _dict_host+'scb/add.php?utf8=1&word='+word;
}
}
function _dictScbclose(){
_dict_scbtimer = 0;
if(_dict_mode==2 && _dict_moving >0){
_dictClose();
}
}
var _dict_addscb_fade = {
'_timer':false,
'setopacity':function(el,opaval){
if(opaval<0 || opaval>100 || !el)return false;
try{
el.style.filter="Alpha(Opacity="+opaval+")";
el.style.opacity = opaval/100;
}
catch(e){}
return true;
},
'fading':function(el,opacity_start,step){
var now = opacity_start + step;
if(_dict_addscb_fade.setopacity(el,now))
_dict_addscb_fade._timer = setTimeout(function(){_dict_addscb_fade.fading(el,now,step)},100);
else {
_dictScbclose();
}
}
}
function _dictMove(e){
try{
if(_dict_moving==2) {
_dictGetPos(e);
_dict_nx = _dict_x-_dict_startx+_dict_cx;
_dict_ny = _dict_y-_dict_starty+_dict_cy;
if (!_dict_opera && document.documentElement.scrollWidth && document.documentElement.scrollWidth - _dict_nx < 262) {
_dict_nx = document.documentElement.scrollWidth - 262;
}
if(_dict_nx<0) _dict_nx = 0;
if(_dict_ny<0) _dict_ny = 0;
_dict_layer.style.left = _dict_nx+'px';
_dict_layer.style.top = _dict_ny+'px';
_dict_layer.focus();
_dict_layer.blur();
}
}catch (x)
{
}
}
function _dictClose() {
if(_dict_addscb_fade._timer){
clearTimeout(_dict_addscb_fade._timer);
_dict_addscb_fade._timer=false;
}
try
{
if(_dict_moving){
var scrOfY = 0;
if( document.body && document.body.scrollTop ) {
scrOfY = document.body.scrollTop;
} else if( document.documentElement && document.documentElement.scrollTop) {
scrOfY = document.documentElement.scrollTop;
}
if(scrOfY < 50 &&_dict_mode == 2 && document.f && document.f.q && document.f.q.value) document.f.q.focus();
_dict_moving = 0;
_dict_onmove = 0;
_dict_onlayer = 0;
_dict_mode = 0;
_dict_layer.style.display="none";
setTimeout(function(){_dict_old_word = "";},500);
}
}
catch (x)
{
}
}
function _dictRemove() {
try
{
_dict_moving = 0;
_dict_onmove = 0;
_dict_onlayer = 0;
_dict_mode = 0;
if(_dict_onselect){
document.onselectstart = _dict_oldselectstart;
_dict_onselect = 0;
}
_dict_enable = false;
_dict_layer.style.display="none";
_dict_status.style.display="none";
}
catch (x)
{
}
}
function _dictDisable(){
_dict_SetCookie("dicthuaci","off",30);
_dict_enable = false;
_dictUpdateStatus();
}
function _dictEnable(){
if (_dict_enable){
_dict_SetCookie("dicthuaci","off",30);
_dict_enable = false;
}else{
_dict_enable = true;
_dict_SetCookie("dicthuaci","",-1);
}
_dictUpdateStatus();
}
function dictRemove(){
_dictRemove();
}
function dictDisable(){
_dict_enable = false;
_dict_SetCookie("dicthuaci","off",30);
_dictUpdateStatus();
}
function dictEnable(){
_dict_enable = true;
_dict_SetCookie("dicthuaci","",-1);
_dictUpdateStatus();
}
function _dictUpdateStatus(){
var d = _dict_getObj('dict_status');
if(d){
if (_dict_enable){
_dictSet(d,'[划词翻译 开启]');
}else{
_dictSet(d,'[划词翻译 禁用]');
}
}
var h = _dict_getObj('huaci_status');
if(h){
if(_dict_enable){
h.href = "javascript:dictDisable()";
// h.onclick = function() {dictDisable();return false;};
h.innerHTML = "划词畢开";
}else{
h.href = "javascript:dictEnable()";
// h.onclick = function() {dictEnable();return false;};
h.innerHTML ="划词畢关";
}
}
h = _dict_getObj('huaci0_status');
if(h && h.tagName && h.tagName.toLowerCase() == "a"){
if(_dict_enable){
h.href = "javascript:dictDisable()";
// h.onclick = function() {dictDisable();return false;};
h.innerHTML = "划词畢开";
}else{
h.href = "javascript:dictEnable()";
// h.onclick = function() {dictEnable();return false;};
h.innerHTML ="划词畢关";
}
}
if(0){
_dict_status.style.display="inline";
_dictSet(_dict_status, _dictStatus());
}
}
function _dictStatus(){
var b='line-height:20px;background-color:#e7f7f7;font-weight:normal;padding:0px;margin:0px;font-size:14px;text-decoration:none;font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;';
var h='[划词翻译畢';
if (_dict_enable){
h += '开启';
}else{
h += '禁用';
}
h +=']
';
return h;
}
function _dict_load(){
if(! document || ! document.body || !document.body.firstChild){
if(document.addEventListener){
window.addEventListener("load", _dictInit, true);
}else if (document.attachEvent) {
window.attachEvent("onload", _dictInit);
}else{
var oldload = (document.onload) ? document.onload : function () {};
window.onload = function () {oldload(); _dictInit();};
}
}else{
_dictInit();
}
}
function dictInit(){
_dictInit();
}
if(typeof(_dict_loaded) != "string" || _dict_loaded != "yes"){
var _dict_is_ie = true;
var _dict_host = 'http://dict.cn/';
var _dict_help = "http://dict.cn/foot/help.htm";
var _dict_old_word = "";
var _dict_oldselectstart = function () {};
var _dict_onselect = 0;
var _dict_opera = 0;
var _dict_frameid = 0;
var _dict_frametimer = 0;
var _dict_scbtimer = 0;
var _dict_moving = 0;
var _dict_onmove = 0;
var _dict_onlayer = 0;
var _dict_startx = 0;
var _dict_starty = 0;
var _dict_cx = 0;
var _dict_cy = 0;
var _dict_x = 0;
var _dict_y = 0;
var _dict_nx = 0;
var _dict_ny = 0;
var _dict_enable = true;
var _dict_layer = null;
var _dict_status = null;
var _dict_iframe = null;
var _dict_mode = 0;
var _dict_init = 0;
var _dict_loaded = "yes";
_dict_load();
}else{
try{
_dict_enable = true;
_dictUpdateStatus();
if(_dict_onselect == 0){
document.onselectstart = function () {if (_dict_moving == 2) return false;};
_dict_onselect = 1;
}
}catch(x){;}
}
dict_enable = false;