﻿var dict_is_ie = true;var dict_host = 'http://www.103.net';
var dict_help = 'http://www.103.net/dictengb/about.html';
var dict_partner = '';
var dict_enable = true;
var dict_old_word = '';
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_layer;
var dict_iframe;
function dictInit(){
	var agt = navigator.userAgent.toLowerCase();
	dict_is_ie = (agt.indexOf("msie")!=-1 && document.all);
	var h = '<div id="dict_layer" style="position:absolute;z-index:6000;display:none;filter:Alpha(Opacity=100);"><table width="230" cellspacing="0" cellpadding="0"><tr><td>';
	h += '<div align="center" width="100%" style="cursor:move;border:0px;" onmouseover="dict_onmove=1;" onmouseout="dict_onmove=0;">';
	h += '<table width="230" border="0" cellpadding="0" cellspacing="0"><tr>';
	h += '<td width="10"><img src="http://www.103.net/ftproot/grasp/01/corner1t.gif" width="10" height="26" /></td>';
	h += '<td width="26" bgcolor="#87b401"><a href="http://www.103.net" target="_blank"><img src="http://www.103.net/ftproot/grasp/01/topright.gif" width="17" height="17" border="0" /></a></td>';
	h += '<td bgcolor="#87b401" align="center"><a href="http://www.ce.cn" target="_blank" style="color:#FFFFFF;font-size:14px;text-decoration: none;font-weight: bold;font-family: 宋体;">中国经济网在线词典</a></td>';
	h += '<td width="14" bgcolor="#87b401"><a href="javascript:dictClose()" title="关闭"><img src="http://www.103.net/ftproot/grasp/01/close.gif" width="14" height="13" border="0" /></a></td>';
	h += '<td width="10" align="right"><img src="http://www.103.net/ftproot/grasp/01/corner2t.gif" width="10" height="26" /></td>';
	h += '</tr></table>';
	h += '</div>';
	h += '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center" onmouseover="dict_onlayer=1;" onmouseout="dict_onlayer=0;"><tr><td>';
	h += '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">';
	h += '<tr><td height="32" align="center" bgcolor="#f3f4ef"><a href="http://www.103.net" target="_blank" style="color:#CC0000;font-size:14px;text-decoration: none;font-family: 宋体;">说话词典 <img src="http://www.103.net/ftproot/grasp/01/book103.gif" width="25" height="21" border="0" /> 103.net</a></td></tr>';
	h += '<tr><td height="1" background="dot.gif" bgcolor="#f3f4ef"></td></tr>';
	h += '<tr><td width="100%"><iframe id="dictFrame" name="dictFrame" HEIGHT="180" src="about:blank" FRAMEBORDER="0" width="100%"></iframe></td></tr>';
	h += '<tr align="center"><td align="center" bgcolor="#f3f4ef"><a href="http://www.103.net" target="_blank"><div style="color:#CC0000;font-size:12px;text-decoration: none;font-family: 宋体;">103说话词典 www.103.net</div></a></td></tr>';
	h += '</table>';
	h += '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"><tr align="center"><td width="10"><img src="http://www.103.net/ftproot/grasp/01/corner4t.gif" width="10" height="10" /></td><td width="210" bgcolor="#f3f4ef"></td><td width="10" align="right"><img src="http://www.103.net/ftproot/grasp/01/corner3t.gif" width="10" height="10" /></td></tr></table>';
	h += '</td></tr></table>';
	h += '</td></tr></table></div>';  
	document.write(h);  dict_layer = document.getElementById('dict_layer');  dict_iframe = document.getElementById('dictFrame');  dictClose();  if (dictRCookie("dictstate") == '1' && dict_enable) dict_enable = false;  dictUpdateStatus();    if (dict_is_ie) {    document.attachEvent("onmousemove", dictMove);    document.attachEvent("ondblclick", dictQuery);    document.attachEvent("onmouseup", dictQuery);    document.attachEvent("onselectstart", dictSelect);    document.attachEvent("onmousedown", dictCheck);    window.attachEvent("onload", dictUpdateStatus);  }else {    document.addEventListener("mousemove", dictMove, true);    document.addEventListener("dblclick", dictQuery, true);    document.addEventListener("mouseup", dictQuery, true);    document.addEventListener("selectstart", dictSelect, true);    document.addEventListener("mousedown", dictCheck, true);    window.addEventListener("load", dictUpdateStatus, true);  }  var img = new Image();}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){  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;  }}function dictSelect(e){    if (dict_moving == 2)        return false;    else        return true;}function dictCheck(e) {    dictGetPos(e);    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;    }    if(dict_moving>0){        if(dict_onmove == 1){            dict_moving = 2;            dict_startx = dict_x;            dict_starty = dict_y;        }else if(dict_x < cx || dict_x > (cx + 240) || dict_y < cy || (!dict_onlayer && dict_y > (cy + 100) ) ){	    dictClose();        }else{                        dict_moving = 1;        }    }    }function dictQuery(e)  {    if(dict_moving == 1){        if (dict_is_ie) {            window.event.cancelBubble = true;            window.event.returnValue = false;        }else{            e.preventDefault();        }        return false;    }    if(dict_moving == 2) {        dict_cx = dict_x;        dict_cy = dict_y;        dict_moving = 1;        return false;    }    dictGetPos(e);    if (!dict_enable) return true;    var word = dictGetSel();    if(dict_is_ie) word=word.replace(/^\s*|\s*$/g,"");    if(word == "" || word.length > 16 || word == dict_old_word) return true;    dictShow(word);}function dictDisplay(){    var dx=262;    var dy=264;    dict_y += 8;    dict_x += 16;    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_cx = dict_x;    dict_cy = dict_y;    dict_startx = dict_x;    dict_starty = dict_y;    dict_layer.style.left = dict_cx+'px';    dict_layer.style.top = dict_cy+'px';    dict_layer.style.display="";    dict_moving = 1;}



String.prototype.trim = function () {return this.replace(/(^\s+)|(\s+$)/g, '')}

function dictShow(word){    dictDisplay();    try{		
				dict_iframe.src='about:blank';        	iframeWin = window.frames.dictFrame;        	iframeWin.document.open();        	iframeWin.document.write('<html><body bgcolor="#f3f4ef" style="font-size:12px;text-decoration: none;font-family: 宋体;"><b><font color="#666666">Word</font> <font color="green">'+word+':</b></font>');		 
		    iframeWin.document.write('<br>');		 
		
		    iframeWin.document.close();    }	catch(x){    }
    var strtemp=word+'';
    strtemp=strtemp.trim();
    dict_iframe.src='http://www.103.net/dictzh/grabword/'+  escape( strtemp);    if(dict_is_ie) dict_old_word = word;}function dictAdd(word){    dictDisplay();    try{        dict_iframe.src='about:blank';        iframeWin = window.frames.dictFrame;        iframeWin.document.open();        iframeWin.document.write('<html><body style="font-family: 宋体;font-size: 12px;color:#2EA8ED;"><center><b><font color="#666666">添加生词本:</font> <font color="green">'+word+'</font></b><br><br>生词上传中...<br>生词上传中...</center></body></html>');        iframeWin.document.close();    }catch(x){    }    dict_old_word = '';    dict_iframe.src=''+word;}function dictMove(e){    if(dict_moving==2) {        dictGetPos(e);        dict_x = dict_x-dict_startx+dict_cx;        dict_y = dict_y-dict_starty+dict_cy;        if (document.documentElement.scrollWidth - dict_x < 262) {            dict_x = document.documentElement.scrollWidth - 262;        }        dict_layer.style.left = dict_x+'px';        dict_layer.style.top = dict_y+'px';    }    }function dictClose() {    try    {        dict_moving = 0;        dict_onmove = 0;        dict_onlayer = 0;    	dict_layer.style.display="none";    }    catch (x)    {    }}function dictWCookie(name,value){    var date=new Date();    var now=date.getTime();    date.setTime(now+365*24*60*60*1000);    document.cookie=name+"="+value+"; path=/; expires="+date.toGMTString();}function dictRCookie(name){    var cookie=String(document.cookie);    var pos=cookie.indexOf(name+"=");    if(pos!=-1){        var end=cookie.indexOf("; ",pos);        return cookie.substring(pos+name.length+1,end==-1?cookie.length:end);    }    return "";}function dictEnable(){  if (dict_enable){    dict_enable = false;    dictWCookie("dictstate", '1');  }else{    dict_enable = true;    dictWCookie("dictstate", '0');  }  dictUpdateStatus();}function dictUpdateStatus(){  var el = document.getElementById('dict_status');  if(el){    el.innerHTML = dictStatus();  }}function dictStatus(){    if (dict_enable){       return '[<a href="'+dict_help+'" title="dictionary帮助" target=_blank><span sytle="color:#990000">Dictionary</span></a> <a href="javascript:dictEnable()" title="禁用dictionary"><span style="color:red">On</span></a>:Double-Click]';    }else{      return '[<a href="'+dict_help+'" title="dictionary帮助">Dictionary</a> <a href="javascript:dictEnable()" title="禁用dictionary"><span style="color:blue">Off</span></a>]';    }}
	dictInit();
