if (!window['google']) {
window['google'] = {};
}
if (!window['google']['loader']) {
window['google']['loader'] = {};
google.loader.ServiceBase = 'http://www.google.com/uds';
google.loader.GoogleApisBase = 'http://ajax.googleapis.com/ajax';
google.loader.ApiKey = 'notsupplied';
google.loader.KeyVerified = true;
google.loader.LoadFailure = false;
google.loader.Secure = false;
google.loader.ClientLocation = null;
google.loader.AdditionalParams = '';
google.loader.OriginalAppPath = 'http://fy.iciba.com/';
(function() {var e=false,g=null,h=true,i=encodeURIComponent,j=window,k=google,l=undefined,m=document;function n(a,b){return a.load=b}var o="push",p="length",q="prototype",r="setTimeout",t="replace",u="charAt",v="loader",w="substring",z="ServiceBase",A="name",B="getTime",C="toLowerCase";function D(a){if(a in F)return F[a];return F[a]=navigator.userAgent[C]().indexOf(a)!=-1}var F={};function G(a,b){var c=function(){};c.prototype=b[q];a.M=b[q];a.prototype=new c}
function H(a,b){var c=a.B||[];c=c.concat(Array[q].slice.call(arguments,2));if(typeof a.r!="undefined")b=a.r;if(typeof a.q!="undefined")a=a.q;var d=function(){var f=c.concat(Array[q].slice.call(arguments));return a.apply(b,f)};d.B=c;d.r=b;d.q=a;return d}function I(a){var b=new Error(a);b.toString=function(){return this.message};return b}function J(a,b){for(var c=a.split(/\./),d=j,f=0;f<c[p]-1;f++){d[c[f]]||(d[c[f]]={});d=d[c[f]]}d[c[c[p]-1]]=b}function K(a,b,c){a[b]=c}if(!L)var L=J;if(!aa)var aa=K;k[v].s={};L("google.loader.callbacks",k[v].s);var M={},N={};k[v].eval={};L("google.loader.eval",k[v].eval);
n(k,function(a,b,c){var d=M[":"+a];if(d){if(c&&!c.language&&c.locale)c.language=c.locale;if(c&&typeof c.callback=="string"){var f=c.callback;if(f.match(/^[[\]A-Za-z0-9._]+$/)){f=j.eval(f);c.callback=f}}var E=c&&c.callback!=g;if(E&&!d.o())throw I("Module: '"+a+"' must be loaded before DOM onLoad!");else if(E)d.k(b,c)?j[r](c.callback,0):d.load(b,c);else d.k(b,c)||d.load(b,c)}else throw I("Module: '"+a+"' not found!");});L("google.load",k.load);k.K=function(a,b){b?ba(a):O(j,"load",a)};
L("google.setOnLoadCallback",k.K);function O(a,b,c){if(a.addEventListener)a.addEventListener(b,c,e);else if(a.attachEvent)a.attachEvent("on"+b,c);else{var d=a["on"+b];a["on"+b]=d!=g?ca([c,d]):c}}function ca(a){return function(){for(var b=0;b<a[p];b++)a[b]()}}var P=[];
function ba(a){if(P[p]==0){O(j,"load",R);if(!D("msie")&&!(D("safari")||D("konqueror"))&&D("mozilla")||j.opera)j.addEventListener("DOMContentLoaded",R,e);else if(D("msie"))m.write("<script defer onreadystatechange='google.loader.domReady()' src=//:><\/script>");else(D("safari")||D("konqueror"))&&j[r](S,10)}P[o](a)}k[v].G=function(){var a=j.event.srcElement;if(a.readyState=="complete"){a.onreadystatechange=g;a.parentNode.removeChild(a);R()}};L("google.loader.domReady",k[v].G);var da={loaded:h,complete:h};
function S(){if(da[m.readyState])R();else P[p]>0&&j[r](S,10)}function R(){for(var a=0;a<P[p];a++)P[a]();P.length=0}
k[v].d=function(a,b,c){if(c){var d;if(a=="script"){d=m.createElement("script");d.type="text/javascript";d.src=b}else if(a=="css"){d=m.createElement("link");d.type="text/css";d.href=b;d.rel="stylesheet"}var f=m.getElementsByTagName("head")[0];f||(f=m.body.parentNode.appendChild(m.createElement("head")));f.appendChild(d)}else if(a=="script")m.write('<script src="'+b+'" type="text/javascript"><\/script>');else a=="css"&&m.write('<link href="'+b+'" type="text/css" rel="stylesheet"></link>')};
L("google.loader.writeLoadTag",k[v].d);k[v].H=function(a){N=a};L("google.loader.rfm",k[v].H);k[v].J=function(a){for(var b in a)if(typeof b=="string"&&b&&b[u](0)==":"&&!M[b])M[b]=new T(b[w](1),a[b])};L("google.loader.rpl",k[v].J);k[v].I=function(a){if((a=a.specs)&&a[p])for(var b=0;b<a[p];++b){var c=a[b];if(typeof c=="string")M[":"+c]=new U(c);else{var d=new V(c);M[":"+d[A]]=d}}};L("google.loader.rm",k[v].I);k[v].loaded=function(a){M[":"+a.module].i(a)};L("google.loader.loaded",k[v].loaded);
J("google_exportSymbol",J);J("google_exportProperty",K);function U(a){this.a=a;this.m={};this.b={};this.j=h;this.c=-1}
U[q].f=function(a,b){var c="";if(b!=l){if(b.language!=l)c+="&hl="+i(b.language);if(b.nocss!=l)c+="&output="+i("nocss="+b.nocss);if(b.nooldnames!=l)c+="&nooldnames="+i(b.nooldnames);if(b.packages!=l)c+="&packages="+i(b.packages);if(b.callback!=g)c+="&async=2";if(b.other_params!=l)c+="&"+b.other_params}if(!this.j){if(k[this.a]&&k[this.a].JSHash)c+="&sig="+i(k[this.a].JSHash);var d=[];for(var f in this.m)f[u](0)==":"&&d[o](f[w](1));for(f in this.b)f[u](0)==":"&&d[o](f[w](1));c+="&have="+i(d.join(","))}return k[v][z]+
"/?file="+this.a+"&v="+a+k[v].AdditionalParams+c};U[q].u=function(a){var b=g;if(a)b=a.packages;var c=g;if(b)if(typeof b=="string")c=[a.packages];else if(b[p]){c=[];for(var d=0;d<b[p];d++)typeof b[d]=="string"&&c[o](b[d][t](/^\s*|\s*$/,"")[C]())}c||(c=["default"]);var f=[];for(d=0;d<c[p];d++)this.m[":"+c[d]]||f[o](c[d]);return f};
n(U[q],function(a,b){var c=this.u(b),d=b&&b.callback!=g;if(d)var f=new W(b.callback);for(var E=[],s=c[p]-1;s>=0;s--){var x=c[s];d&&f.C(x);if(this.b[":"+x]){c.splice(s,1);d&&this.b[":"+x][o](f)}else E[o](x)}if(c[p]){if(b&&b.packages)b.packages=c.sort().join(",");if(!b&&N[":"+this.a]!=g&&N[":"+this.a].versions[":"+a]!=g&&!k[v].AdditionalParams&&this.j){var y=N[":"+this.a];k[this.a]=k[this.a]||{};for(var Q in y.properties)if(Q&&Q[u](0)==":")k[this.a][Q[w](1)]=y.properties[Q];k[v].d("script",k[v][z]+
y.path+y.js,d);y.css&&k[v].d("css",k[v][z]+y.path+y.css,d)}else if(!b||!b.autoloaded)k[v].d("script",this.f(a,b),d);if(this.j){this.j=e;this.c=(new Date)[B]();if(this.c%100!=1)this.c=-1}for(s=0;s<E[p];s++){x=E[s];this.b[":"+x]=[];d&&this.b[":"+x][o](f)}}});
U[q].i=function(a){if(this.c!=-1){X("al_"+this.a,"jl."+((new Date)[B]()-this.c),h);this.c=-1}for(var b=0;b<a.components[p];b++){this.m[":"+a.components[b]]=h;var c=this.b[":"+a.components[b]];if(c){for(var d=0;d<c[p];d++)c[d].F(a.components[b]);delete this.b[":"+a.components[b]]}}X("hl",this.a)};U[q].k=function(a,b){return this.u(b)[p]==0};U[q].o=function(){return h};function W(a){this.D=a;this.l={};this.n=0}W[q].C=function(a){this.n++;this.l[":"+a]=h};
W[q].F=function(a){if(this.l[":"+a]){this.l[":"+a]=e;this.n--;this.n==0&&j[r](this.D,0)}};function V(a){this.name=a[A];this.p=a.uri;this.z=a.ssl;this.v=a.key;this.A=a.version;this.L=a.deferred;this.w=a.params;this.t=this.g=e;this.h=[];k[v].s[this[A]]=H(this.i,this)}G(V,U);n(V[q],function(a,b){var c=b&&b.callback!=g;if(c){this.h[o](b.callback);b.callback="google.loader.callbacks."+this[A]}else this.g=h;if(!b||!b.autoloaded)k[v].d("script",this.f(a,b),c)});V[q].k=function(a,b){return b&&b.callback!=g?this.t:this.g};
V[q].i=function(){this.t=h;for(var a=0;a<this.h[p];a++)j[r](this.h[a],0);this.h=[]};var Y=function(a,b){return a.string?i(a.string)+"="+i(b):a.regex?b[t](/(^.*$)/,a.regex):""};
V[q].f=function(a,b){var c="";if(this.v)c+="&"+Y(this.v,k[v].ApiKey);if(this.A)c+="&"+Y(this.A,a);var d=k[v].Secure&&this.z?this.z:this.p;if(b!=g)for(var f in b)if(this.w[f])c+="&"+Y(this.w[f],b[f]);else if(f=="other_params")c+="&"+b[f];else if(f=="base_domain")d="http://"+b[f]+this.p[w](this.p.indexOf("/",7));k[this[A]]={};if(d.indexOf("?")==-1&&c)c="?"+c[w](1);X("el",this[A]);return d+c};V[q].o=function(){return this.L};function T(a,b){this.a=a;this.e=b;this.g=e}G(T,U);n(T[q],function(a,b){this.g=h;k[v].d("script",this.f(a,b),e)});T[q].k=function(){return this.g};T[q].i=function(){};T[q].f=function(a,b){if(!this.e.versions[":"+a]){if(this.e.aliases){var c=this.e.aliases[":"+a];if(c)a=c}if(!this.e.versions[":"+a])throw I("Module: '"+this.a+"' with version '"+a+"' not found!");}var d=k[v].GoogleApisBase+"/libs/"+this.a+"/"+a+"/"+this.e.versions[":"+a][b&&b.uncompressed?"uncompressed":"compressed"];X("el",this.a);return d};
T[q].o=function(){return e};var ea=e,Z=[],fa=(new Date)[B](),X=function(a,b,c){if(!ea){O(j,"unload",ga);ea=h}if(c){if(!k[v].Secure&&(!k[v].Options||k[v].Options.csi===e)){a=a[C]()[t](/[^a-z0-9_.]+/g,"_");b=b[C]()[t](/[^a-z0-9_.]+/g,"_");j[r](H($,g,"http://csi.gstatic.com/csi?s=uds&v=2&action="+i(a)+"&it="+i(b)),10000)}}else{Z[o]("r"+Z[p]+"="+i(a+(b?"|"+b:"")));j[r](ga,Z[p]>5?0:15000)}},ga=function(){if(Z[p]){$(k[v][z]+"/stats?"+Z.join("&")+"&nc="+(new Date)[B]()+"_"+((new Date)[B]()-fa));Z.length=0}},$=function(a){var b=new Image,
c=ha++;ia[c]=b;b.onload=b.onerror=function(){delete ia[c]};b.src=a;b=g},ia={},ha=0;J("google.loader.recordStat",X);J("google.loader.createImageForLogging",$);

}) ();google.loader.rm({"specs":["feeds",{"name":"books","uri":"http://books.google.com/books/api.js","ssl":null,"key":{"string":"key"},"version":{"string":"v"},"deferred":true,"params":{"callback":{"string":"callback"},"language":{"string":"hl"}}},{"name":"friendconnect","uri":"http://www.google.com/friendconnect/script/friendconnect.js","ssl":null,"key":{"string":"key"},"version":{"string":"v"},"deferred":false,"params":{}},"spreadsheets","gdata","visualization",{"name":"sharing","uri":"http://www.google.com/s2/sharing/js","ssl":null,"key":{"string":"key"},"version":{"string":"v"},"deferred":false,"params":{"language":{"string":"hl"}}},"search",{"name":"maps","uri":"http://maps.google.com/maps?file\u003dgoogleapi","ssl":"https://maps-api-ssl.google.com/maps?file\u003dgoogleapi","key":{"string":"key"},"version":{"string":"v"},"deferred":true,"params":{"callback":{"regex":"callback\u003d$1\u0026async\u003d2"},"language":{"string":"hl"}}},"language","earth",{"name":"annotations","uri":"http://www.google.com/reviews/scripts/annotations_bootstrap.js","ssl":null,"key":{"string":"key"},"version":{"string":"v"},"deferred":true,"params":{"callback":{"string":"callback"},"language":{"string":"hl"},"country":{"string":"gl"}}},"ads","elements"]});
google.loader.rfm({":feeds":{"versions":{":1":"1",":1.0":"1"},"path":"/api/feeds/1.0/c5e7ac02ef2afa36d43448eb335a2050/","js":"default+zh_CN.I.js","css":"default.css","properties":{":JSHash":"c5e7ac02ef2afa36d43448eb335a2050",":Version":"1.0"}},":search":{"versions":{":1":"1",":1.0":"1"},"path":"/api/search/1.0/8fbb68e81e7e7c137250781e24ce98ca/","js":"default+zh_CN.I.js","css":"default.css","properties":{":JSHash":"8fbb68e81e7e7c137250781e24ce98ca",":NoOldNames":false,":Version":"1.0"}},":language":{"versions":{":1":"1",":1.0":"1"},"path":"/api/language/1.0/d65235bddcd7631d84462e35f33bc682/","js":"default+zh_CN.I.js","properties":{":JSHash":"d65235bddcd7631d84462e35f33bc682",":Version":"1.0"}},":spreadsheets":{"versions":{":0":"1",":0.1":"1"},"path":"/api/spreadsheets/0.1/217f714e2931810693cd980edd44ad05/","js":"default.I.js","properties":{":JSHash":"217f714e2931810693cd980edd44ad05",":Version":"0.1"}},":annotations":{"versions":{":1":"1",":1.0":"1"},"path":"/api/annotations/1.0/2d5c6b4b6d5b6cf5a6eda70dd2f289d9/","js":"default+en.I.js","properties":{":JSHash":"2d5c6b4b6d5b6cf5a6eda70dd2f289d9",":Version":"1.0"}},":earth":{"versions":{":1":"1",":1.0":"1"},"path":"/api/earth/1.0/bd6682f8238442cc68413f5aaa472775/","js":"default.I.js","properties":{":JSHash":"bd6682f8238442cc68413f5aaa472775",":Version":"1.0"}},":ads":{"versions":{":1":"1",":1.0":"1"},"path":"/api/ads/1.0/e7f58d7238e6936cf054f87419e6aae1/","js":"default.I.js","properties":{":JSHash":"e7f58d7238e6936cf054f87419e6aae1",":Version":"1.0"}}});
google.loader.rpl({":scriptaculous":{"versions":{":1.8.2":{"uncompressed":"scriptaculous.js","compressed":"scriptaculous.js"},":1.8.1":{"uncompressed":"scriptaculous.js","compressed":"scriptaculous.js"}},"aliases":{":1.8":"1.8.2",":1":"1.8.2"}},":yui":{"versions":{":2.6.0":{"uncompressed":"build/yuiloader/yuiloader.js","compressed":"build/yuiloader/yuiloader-min.js"},":2.7.0":{"uncompressed":"build/yuiloader/yuiloader.js","compressed":"build/yuiloader/yuiloader-min.js"}},"aliases":{":2":"2.7.0",":2.7":"2.7.0",":2.6":"2.6.0"}},":swfobject":{"versions":{":2.1":{"uncompressed":"swfobject_src.js","compressed":"swfobject.js"}},"aliases":{":2":"2.1"}},":mootools":{"versions":{":1.2.1":{"uncompressed":"mootools.js","compressed":"mootools-yui-compressed.js"},":1.2.2":{"uncompressed":"mootools.js","compressed":"mootools-yui-compressed.js"},":1.11":{"uncompressed":"mootools.js","compressed":"mootools-yui-compressed.js"}},"aliases":{":1":"1.11"}},":jqueryui":{"versions":{":1.6.0":{"uncompressed":"jquery-ui.js","compressed":"jquery-ui.min.js"},":1.7.0":{"uncompressed":"jquery-ui.js","compressed":"jquery-ui.min.js"},":1.7.1":{"uncompressed":"jquery-ui.js","compressed":"jquery-ui.min.js"},":1.5.3":{"uncompressed":"jquery-ui.js","compressed":"jquery-ui.min.js"},":1.5.2":{"uncompressed":"jquery-ui.js","compressed":"jquery-ui.min.js"}},"aliases":{":1.7":"1.7.1",":1.6":"1.6.0",":1":"1.7.1",":1.5":"1.5.3"}},":prototype":{"versions":{":1.6.0.2":{"uncompressed":"prototype.js","compressed":"prototype.js"},":1.6.0.3":{"uncompressed":"prototype.js","compressed":"prototype.js"}},"aliases":{":1":"1.6.0.3",":1.6":"1.6.0.3"}},":jquery":{"versions":{":1.2.3":{"uncompressed":"jquery.js","compressed":"jquery.min.js"},":1.3.1":{"uncompressed":"jquery.js","compressed":"jquery.min.js"},":1.3.0":{"uncompressed":"jquery.js","compressed":"jquery.min.js"},":1.3.2":{"uncompressed":"jquery.js","compressed":"jquery.min.js"},":1.2.6":{"uncompressed":"jquery.js","compressed":"jquery.min.js"}},"aliases":{":1":"1.3.2",":1.3":"1.3.2",":1.2":"1.2.6"}},":dojo":{"versions":{":1.2.3":{"uncompressed":"dojo/dojo.xd.js.uncompressed.js","compressed":"dojo/dojo.xd.js"},":1.3.1":{"uncompressed":"dojo/dojo.xd.js.uncompressed.js","compressed":"dojo/dojo.xd.js"},":1.1.1":{"uncompressed":"dojo/dojo.xd.js.uncompressed.js","compressed":"dojo/dojo.xd.js"},":1.3.0":{"uncompressed":"dojo/dojo.xd.js.uncompressed.js","compressed":"dojo/dojo.xd.js"},":1.2.0":{"uncompressed":"dojo/dojo.xd.js.uncompressed.js","compressed":"dojo/dojo.xd.js"}},"aliases":{":1":"1.3.1",":1.3":"1.3.1",":1.2":"1.2.3",":1.1":"1.1.1"}}});
}

String.prototype.trim=function(){ return this.replace(/(^\s*)|(\s*$)/g, "");　}
var config = {
	Paragraphs:{}
	,Paragraphslength:0
	,maxlength:384
	,transCursor:''
	,to_language:''
	,transCursor:0
	,translateresault:''
	,translatepage:0
	,isIE:null
	,slen:0
	,tlen:0
	,totalHeight:0
	,dicttrans:false
	,googletrans:false
}
function checkLanguage (content)
{
	var rex; 
	/*
	rex = /^[\u3040-\u309F\u30A0-\u30FF]+$/; 
	if (rex.exec(content)) { 
		return "ja"; 
	} 
	*/
	//content = content.substring(0,20);
	//alert(content.lenght content.replace(/[^\x00-\xff]/g,"**").length);
	var reg = /[a-zA-Z]+/g;
	var enWord = content.match(reg);
	if(enWord)var enNum = enWord.length;
	else var enNum=0;
	

	reg = /[\u4e00-\u9fa5]/g;
	var zhcnWord = content.match(reg);	
	if(zhcnWord)var zhcnNum = zhcnWord.length;
	else var zhcnNum=0;
	return enNum>zhcnNum?"en":"zh-CN";
	/*
	rex = /[\u4e00-\u9fa5]+/; 
		if (rex.exec(content)) { 
		return "zh-CN"; 
	} 
	*/
	/*
	rex = /^(\w)+$/; 
	if (rex.exec(content)) { 
		return "en"; 
	} 
	*/
	//return "en"; 
}
function translate()
{
	initTranslate();
	config.Paragraphs = new Array();
	config.Paragraphslength =0;	
	var text = $("content").value.trim();
	if(text=="")
	{
		alert("翻译原文不能为空");
		return false;
	}
	if($('iV4fySelect').value == 'auto')
	{
		config.from_language=checkLanguage(text);
		//alert(config.from_language);
		config.to_language = config.from_language=="zh-CN"?"en":"zh-CN";
		//config.from_language ="";
	}
	else{
		config.from_language  = $('sl').value;
		config.to_language  = $('tl').value;	
	}
	if(IsUrl(text))
	{
		//location.href="http://translate.google.cn/translate?hl=zh-CN&sl=en&u="+text+"&oi=translate&resnum=1&ct=result"
		location.href="http://translate.google.cn/translate?prev=hp&hl=zh-CN&js=n&u="+text.Trim()+"&sl="+config.from_language+"&tl="+config.to_language
		return false;
	}
	config.translateresault='';
	config.Paragraphs = getParagraphs(text);
	config.Paragraphslength = config.Paragraphs.length;	
	//$('contentout').value='感谢您使用爱词霸翻译产品,翻译中,请稍候...';
	$("comparetranslate").innerHTML='';
	config.transCursor=0;
	config.slen=0;
	$("comparesoure").innerHTML="<div id=\"comparesoure"+config.transCursor+"\" onmouseout=\"return mousefunc(0,"+config.transCursor+");\" onmouseover=\"return mousefunc(1,"+config.transCursor+");\">"+config.Paragraphs[config.transCursor]+"</div>";
	config.slen=getStrActualLen(config.Paragraphs[config.transCursor]);
	google.language.translate(config.Paragraphs[config.transCursor], config.from_language, config.to_language, setTranslateToText);	
	var str=( config.from_language +':'+  config.to_language);
	if(config.Paragraphslength==1&& (str=='en:zh-CN'|| str=='zh-CN:en') )dictTranslate();
}

function initTranslate()
{
		document.getElementById('dictTrans').style.display="none";
		document.getElementById('dict').style.height="212px";
		document.getElementById('contentout').style.height="212px";
		document.getElementById('slab').style.display="block";
		document.getElementById('contentout').style.display="block";
		document.getElementById('dict').style.color="#BFBFBF";
		document.getElementById('contentout').style.color="#BFBFBF";
		document.getElementById('contentout').value="感谢您使用爱词霸翻译产品,翻译中,请稍候...";
		config.googletrans=false;
		config.dicttrans=false;

}
function Statistics(l,g,n)
{
	JapStatistics();
	return ;//
	var str=document.getElementById('content').value;
	var url='./writeLog.new.php';
	var postStr='q='+getStrActualLen(str)+"&sl="+config.from_language+"&tl="+config.to_language+"&g="+g+"&n="+n+'&str='+encodeURIComponent(str);
	xmlhttp_request=InitAjax();//调用创建XMLHttpRequest的函数
	xmlhttp_request.open('POST', url, true);
	xmlhttp_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp_request.send(postStr);
}

//日语统计
function JapStatistics(){
	return;
	//原文是日语 845  译文是日语 846
	if(config.from_language=='ja')kdsStatistics(845);
	if(config.to_language=='ja')kdsStatistics(846);
}
function kdsStatistics(id){
	var aA=new Image(0,0);
	//aA.src="http://counter.kds.iciba.com/kds2_userinfo_record.php?p="+id;
	aA.src="http://counter.kds.iciba.com/kds2_userinfo_record.php?p="+id;
	var tmpId= _kds2_p;
	_kds2_p=id;
	var url='http://goto.www.iciba.com/kds2/kds2_record.js?rang='+Math.random();	
	//alert(url);
	JsLoad( url );
}
function dictTranslate()
{
	var str=document.getElementById('content').value.trim();
	/*var url='./dict.ajax.php';
	var postStr='q='+str+"&sl="+config.from_language+"&tl="+config.to_language;
	xmlhttp_request=InitAjax();//调用创建XMLHttpRequest的函数
	xmlhttp_request.open('POST', url, true);
	xmlhttp_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp_request.send(postStr);
	xmlhttp_request.onreadystatechange = showDictTranslate;*/

	//var itf=document.getElementById('webDictInterfase');	
	//alert(itf.src);
	jsFile='http://netdictweb.iciba.com:8080/iciba_netdict.php?type=js&q='+encodeURIComponent(str);
	JSLoad(jsFile);
	
}
function showDictTranslate()
{
	if (xmlhttp_request.readyState == 4) 
	{
		// 收到完整的服务器响应
		if (xmlhttp_request.status == 200) 
		{
			if(xmlhttp_request.responseText!="")
			{
				config.dicttrans = true;
				document.getElementById('dictTrans').style.display="inline";
				document.getElementById('dict').style.height="138px";
				document.getElementById('contentout').style.height="50px";
				document.getElementById('dict').style.color="#000";
				document.getElementById('dict').value=xmlhttp_request.responseText;
			}
			else
			{;}
		}
	}
}
function IsUrl (str_url) 
{ 
	var strRegex = /^http:\/\/[\w\/\.-]+[\.]+([a-zA-Z]{2,6})+[a-zA-Z0-9\/\.\-\+\?\=\_%\&]*$/g
	var re=new RegExp(strRegex); 	
	if (re.test(str_url.Trim())){
		return (true); 
	}else{ 
		return (false); 
	}
} 
function googleTranslate()
{	
	config.slen=0;
	if(encodeURI(config.Paragraphs[config.transCursor])!="%0D"){
		$("comparesoure").innerHTML=$("comparesoure").innerHTML+"<div id=\"comparesoure"+config.transCursor+"\" onmouseout=\"return mousefunc(0,"+config.transCursor+");\" onmouseover=\"return mousefunc(1,"+config.transCursor+");\">"+config.Paragraphs[config.transCursor]+"</div>";
		config.slen=getStrActualLen(config.Paragraphs[config.transCursor]);
		google.language.translate(config.Paragraphs[config.transCursor], config.from_language, config.to_language, setTranslateToText);
	}
	else
	{
		
		config.transCursor++;
		if(config.transCursor<config.Paragraphslength)
		{
			googleTranslate();
		}
		else
		{
			if(config.totalHeight<600)$("comparemain").style.height="600px";
			$("contentout").style.color = "#000";
			$("contentout").value=config.translateresault;
		}
	}
}
setTranslateToText = function(result)
{	
	config.tlen=0;
	if(config.transCursor>0)
	{
		config.translateresault=config.translateresault+"\n"+result.translation;
		$("comparetranslate").innerHTML=$("comparetranslate").innerHTML+"<div id=\"comparetranslate"+config.transCursor+"\" onmouseout=\"return mousefunc(0,"+config.transCursor+");\" onmouseover=\"return mousefunc(1,"+config.transCursor+");\">"+result.translation+"</div>";
		config.tlen=getStrActualLen(result.translation);
	}
	else
	{
		config.translateresault=result.translation;
		$("comparetranslate").innerHTML=$("comparetranslate").innerHTML+"<div id=\"comparetranslate"+config.transCursor+"\" onmouseout=\"return mousefunc(0,"+config.transCursor+");\" onmouseover=\"return mousefunc(1,"+config.transCursor+");\">"+result.translation+"</div>";
		config.tlen=getStrActualLen(result.translation);
	}
	var textlen = config.slen>config.tlen?config.slen:config.tlen;
	var tempHeight = getTextHeight(textlen);
	$("comparetranslate"+config.transCursor).style.height=tempHeight;
	$("comparesoure"+config.transCursor).style.height=tempHeight;
	config.transCursor++;
	if(config.transCursor<config.Paragraphslength)
	{		
		$('contentout').value=$('contentout').value+'...';
		if(($('contentout').value.length/40)>config.translatepage)
		{
			$('contentout').value=$('contentout').value+'\n';
			config.translatepage++;
		}
		googleTranslate();
	}
	else
	{
		$("contentout").style.color = "#000";
		//$("contentout").value=htmlspecialchars_decode(config.translateresault);
		$("contentout").value=config.translateresault.replace(/&#39;/g,"'").replace(/&quot;/g,"\"");
		if($("contentout").value==$("content").value&&config.dicttrans)
		{
			$("contentout").style.display='none';
			$("slab").style.display='none';
			document.getElementById('dict').style.height="212px";
			Statistics(getStrActualLen($("content").value),false,config.dicttrans);
		}
		else
		{
			Statistics(getStrActualLen($("content").value),true,config.dicttrans);
			//$("googleCopyRight").innerHTML='翻译结果由<a href="http://www.google.com" target="_blank"><img src="./img/v4/gg.gif" align="absmiddle"></a>提供';
		}
		
		if(config.totalHeight<300)$("comparesoure").style.height="300px";
		if(config.totalHeight<300)$("comparetranslate").style.height="300px";
		
	}
}
function getTextHeight (num)
{
	var lineNum = 62;
	var h = (Math.ceil(num/lineNum))*18;
	config.totalHeight=config.totalHeight+h;
	return h+"px";
}
function getStrActualLen (sChars){  
	sChars = sChars.replace(/(^[\\s]*)|([\\s]*$)/g, "");
	var len = 0;
	for(i=0;i<sChars.length;i++){
		iCode = sChars.charCodeAt(i);
		if((iCode>=0 && iCode<=255)||(iCode>=0xff61 && iCode<=0xff9f)){
			len += 1;
		}else{
			len += 2;
		}
	}
	return len;
}
/**
 *文章截取段落 按照空行截取
 */
function interceptionAtricle (str){
	var reg = /\n/g;
	str=str.split(reg); 
	return str;
}
//将需要翻译的文章按段落换行划分为小段
function getParagraphs (str)
{
	var tempParagraphs = interceptionAtricle(str);
	for(var i=0 ;i<tempParagraphs.length;i++)
	{
		//getStrActualLen
		if(getStrActualLen(tempParagraphs[i])>config.maxlength)cutTo2K(tempParagraphs[i]);
		else config.Paragraphs.push(tempParagraphs[i]);
	}
	return config.Paragraphs;
}
function cutTo2K(str)
{
	var temp			= "";
	var startIndex		= 0;
	var endIndex		= 0;
	var n				= 0;
	//var paragraphs		= interceptionAtricle(str);
	var reg				= /[.|。|！|\!|？|\?|,|，]/g
	var shortCutArray	=str.split(reg); 
	//	alert("d");
	for(var i=0;i <shortCutArray.length;i++){
		//alert(shortCutArray[i]);
		//endIndex = str.indexOf(shortCutArray[i]);
		
		//alert(endIndex);
		if (getStrActualLen(temp + shortCutArray[i])>config.maxlength){
			endIndex = startIndex+temp.length;
			config.Paragraphs.push(str.substring(startIndex,endIndex));
			startIndex		= endIndex;
			temp			= "";
		}else{
			temp += shortCutArray[i]+"/";
			//alert(" df" + temp);
		}
	} 
	config.Paragraphs.push(str.substring(startIndex,str.length));
	return config.Paragraphs;
}
/**
 * 最大段落不得超过2k 这里限制为2000字节。
 */
function wordCounter (str){
	if(encodeURI(str).length>1000)	return false;
	return true;
}
function $(lable)
{
	return document.getElementById(lable);
}
function compare()
{		
	
	function rand(a){return Math.floor(Math.random()*a)+1};
	var img = new Image(0,0);
	img.src="http://counter.kds.iciba.com/ds2rd.php?p=509&rand="+rand(9999);
	if($('content').value == "content"||$('content').value == "")return false;
	obj=$("forbid");
	var width=document.body.clientWidth;
	var height=(document.body.clientHeight<config.totalHeight)?(config.totalHeight-145):document.body.clientHeight;
	obj.style.width=width+"px";
	obj.style.height=height+"px";
	obj.style.visibility = "visible";
	$("compatearea").style.top = "134px";
	$("compatearea").style.display = "block";
	$("iV4fySelect").style.display = "none";
}
function copy()
{
	var data=$('contentout').value+"\n\n"+$('dict').value;
	copyToClipboard(data);
}
function reset()
{
	initTranslate ();
	$('content').style.color='#BFBFBF';
	$('contentout').style.color='#BFBFBF';
	$('content').value='在这里输入需要翻译的文字或网址';
	$('contentout').value='感谢您使用爱词霸翻译产品......';
	$('comparesoure').innerHTML='';
	$('comparetranslate').innerHTML='';
	$('compatearea').style.display='none';
}
function changeLang ()
{
	if($('sl').options[$('sl').selectedIndex].value=="auto")return false;
	var slText = $('sl').options[$('sl').selectedIndex].text;
	var tlText = $('tl').options[$('tl').selectedIndex].text;
	jsSelectItemByValue($('tl'),slText);
	jsSelectItemByValue($('sl'),tlText);
}
function jsSelectItemByValue (objSelect, objItemText) { 
    for (var i = 0; i < objSelect.options.length; i++) {        
        if (objSelect.options[i].text == objItemText) {        
            objSelect.options[i].selected = true;        
            isExit = true;        
            break;        
        }        
    }     
}    
var hotWord = '在这里输入需要翻译的文字或网址';
google.load("language", "1");
config.isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false;
String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }  
String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); }  
String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, ""); } 

function copyToClipboard (txt) {
	if(window.clipboardData) {
		window.clipboardData.clearData();
		try{
			window.clipboardData.setData("Text", txt);
			alert("复制成功！");
		}catch(e){
		}
	} else {

	}
} 

//对比
function iciba_fy_Compare (){
	$('compare').style.display="block";
}


function InitAjax()
{
    var http_request = false;

    if (window.XMLHttpRequest)
    {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
        {
            http_request.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject)
    {
        try
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {}
        }
    }
    if (!http_request)
    {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    return http_request;
}


function mousefunc(type,objid)
{
	//alert(document.getElementById("comparesoure"+objid).style.height+" "+document.getElementById("comparetranslate"+objid).style.height);
	if(type==1)
	{
		addClass(document.getElementById("comparesoure"+objid),"comparediv");
		document.getElementById("comparesoure"+objid).style.backgroundColor="#EAF1F7";
		addClass(document.getElementById("comparetranslate"+objid),"comparediv");
		document.getElementById("comparetranslate"+objid).style.backgroundColor="#EAF1F7";
	}
	else
	{
		removeClass(document.getElementById("comparesoure"+objid),"comparediv");
		document.getElementById("comparesoure"+objid).style.backgroundColor="#fff";
		removeClass(document.getElementById("comparetranslate"+objid),"comparediv");
		document.getElementById("comparetranslate"+objid).style.backgroundColor="#fff";
	}
}
function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
function charchange(){
	cValue=document.getElementById("content").value;
	if(cValue == "在这里输入需要翻译的文字或网址") {			   
		document.getElementById("content").value="";
		document.getElementById("content").style.color = "#666";
	}
	else{
		document.getElementById("content").style.color = "#666";
	}
}

/**
 * 切换语言
 * author wanghaizhou@gmail.com
 * date 2008-8-18
 */
function v4SetLang(val)
{
	var sl = null;
	var tl = null;
	if (val == 'gb2ko' )
	{
		sl = 'zh-CN';
		tl = 'ko';
	}
	else if( val == 'en2gb' )
	{
		sl = 'en';
		tl = 'zh-CN';	
	}
	else if( val == 'gb2en' )
	{
		sl = 'zh-CN';
		tl = 'en';	
	}
	else if( val == 'ko2gb' )
	{
		sl = 'ko';
		tl = 'zh-CN';	
	}
	else if(val == 'gb2big')
	{
		sl = 'zh-CN';
		tl = 'zh-TW';			
	}
	else if(val == 'big2gb')
	{
		sl = 'zh-TW';
		tl = 'zh-CN';		
	}
	else if(val == 'gb2ja')
	{
		sl = 'zh-CN';
		tl = 'ja';		
	}
	else if(val == 'ja2gb')
	{
		sl = 'ja';
		tl = 'zh-CN';		
	}
	else if(val == 'all')
	{

		document.getElementById('iV4fySelect').style.display ='none';		
		document.getElementById('allselect').style.display = 'inline';
		document.getElementById('shortcut').style.width = '0px';
		return;
	}
	document.getElementById('sl').value= sl;
	document.getElementById('tl').value= tl;
}

function showpost(a,b)
{
     
    var menuObj = document.getElementById(b);
    var titleObj = document.getElementById(a);
    var posObj = new findPos(titleObj);
    var menu_left = posObj.left;
    var menu_top = posObj.top + parseInt(titleObj.offsetHeight);

    menuObj.style.position = 'absolute';
    menuObj.style.display  = '';
    
    // 计算显示位置
    if (posObj.left + menuObj.offsetWidth >= document.body.clientWidth && 0)
    {
        menu_left = parseInt(posObj.left) - parseInt(menuObj.offsetWidth) + parseInt(titleObj.offsetWidth);
    }
    if (posObj.top + menuObj.offsetHeight >= document.body.clientHeight && 1)
    {
        menu_top = parseInt(posObj.top) - parseInt(menuObj.offsetHeight);
    }
    
    menuObj.style.left =  (menu_left - 36) + "px";
    menuObj.style.top = menu_top + "px";
}

function hiddenpost(a,b)
{
    str=document.getElementById(a).value;
    chkarr = str.split(' ');
    if(chkarr.length==3)ckid=1;
    if(ckid==1) document.getElementById(b).style.display='none';
}

function closepost(b)
{
    document.getElementById(b).style.display='none';
}
function findPos(o)     { 
    this.top  = o.offsetTop;
    this.left = o.offsetLeft;
    while(o = o.offsetParent)
    {
        this.top  += o.offsetTop;
        this.left += o.offsetLeft;
    }
}
//以下EF操作
function changeOp()
{
    var zt=document.getElementById("changee").src;
	/*if((document.getElementById('chatroom').innerHTML == ''))
	{
		document.getElementById('barAd').style.top = (document.getElementById('fyad').style.display == 'none') ? '-401px' : '-220px';
	}
	else
	{
		document.getElementById('barAd').style.top = (document.getElementById('fyad').style.display == 'none') ? '-681px' : '-416px';
	}*/
	//alert('asdf');
	document.getElementById('barAd').style.top = (document.getElementById('fyad').style.display == 'none') ? '-402px' : '-214px';
	document.getElementById('fyad').style.display = (document.getElementById('fyad').style.display == 'none') ? 'block' : 'none';
	document.getElementById("changee").src = (document.getElementById('fyad').style.display == 'none') ? './img/v4/open.jpg' : './img/v4/close.jpg';
	document.getElementById('changee').style.display="none";
	document.getElementById('changee').style.height="0px";
}

function UaaRand(num) {
    return Math.floor(Math.random()*num)+1;
}
function closeChatRoom()
{
	if((document.getElementById('fyad').style.display == 'none'))
	{
		$("barAd").style.top="-218px";
	}
	else
	{
		$("barAd").style.top="-497px";
	}
	$("chatroom").style.height="0px"
	$("chatroom").innerHTML = "";
}



var webDictCallback=function(str){
	
	if(str=='') return ;
	var obj= eval(str);
	var out='';
	//alert(config.to_language);
	//return ;
	for(i=0;i<obj.length;i++){
		out+= obj[i].word+"\n";
		//alert( typeof obj[i].detail );
		if(typeof obj[i].detail !='undefined'){
			for(j=0;j<obj[i].detail.length;j++){
				//out+=obj[i].detail[j].
				//if(config.to_language=='en')
				out+= (j+1)+'.';
				out+= config.to_language=='en'?obj[i].detail[j].en:obj[i].detail[j].cn;
				out+="\n";
			}
			out+="\n";
		}
	}
	config.dicttrans = true;
	document.getElementById('dictTrans').style.display="inline";
	document.getElementById('dict').style.height="138px";
	document.getElementById('contentout').style.height="50px";
	document.getElementById('dict').style.color="#000";
	document.getElementById('dict').value=out;
}

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);
   }
//end EF
