    //一下是代码复制部分
    function findobj(n, d) {
    var p, i, x;
    if(!d) d = document;
    if((p = n.indexOf("?"))>0 && parent.frames.length) {
      d = parent.frames[n.substring(p + 1)].document;
      n = n.substring(0, p);
    }
    if(x != d[n] && d.all) x = d.all[n];
    for(i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for(i = 0; !x && d.layers && i < d.layers.length; i++) x = findobj(n, d.layers[i].document);
    if(!x && document.getElementById) x = document.getElementById(n);
    return x;
    }

	function copycode(obj) {
	  var rng = document.body.createTextRange();
	  rng.moveToElementText(obj);
	  rng.scrollIntoView();
	  rng.select();
	  rng.execCommand("Copy");
	  rng.collapse(false);
   }

    function copy(id) {
	  var copytext=document.getElementById("contentout").innerHTML;
	  if(copytext==""){
		  alert("复制内容不能为空");
		  return false;
      }else{
		  alert("翻译结果已复制");
	      copycode(findobj(id));
	  }
	 	
	}

	//以上是代码复制部分

	

  
//以下是表单提交部分
function translate(){
	cValue = document.getElementById("content").value;		
	if(cValue == ""){
		alert("请填写要翻译的内容");
		return false;
	}
	var container = document.getElementById("contentout");		
	container.innerHTML = 'Loading...';
	//content提交的内同可以符合翻译要求，提交到google翻译
	getTransType();		
 }		
//以上是表单提交部分
  
//翻译的google ajax （以下）
function getTransType(){	
	var langpair = document.getElementById('langpair');
	var transType = langpair.options[langpair.selectedIndex].value.split('|');   
	var text = document.getElementById("content").value;
	google.language.translate(text, transType[0], transType[1], translated);
}

function translated(result) {
	if (!result.error) {
		var container = document.getElementById("contentout");		
		container.innerHTML = result.translation;
		container.style.width="95%";
		container.style.border = "1px solid #3399FF";
    }
	else{
		//如果google翻译失败了
		document.getElementById('contentout').innerHTML="提示:<br>文章无法翻译，<font color='red'>可能系统忙，请稍后再试。</font>"
   }
}
//翻译的google ajax  （以上）


  function clearall(){
      document.cookie = 'content='+"";
      document.getElementById('content').value="";
  }


  function h(obj,url){
        obj.style.behavior='url(#default#homepage)';
        obj.setHomePage(url);
        return false;
    }
	
     try {
        document.domain = 'iciba.com';
     }
     catch(e) {}
     
    function getStart(){
		getcontent=document.getElementById("content").value;		
		if(getcontent==""){
			document.getElementById("content").value="请输入您要翻译的文字。";
		}
	}

    function charchange(){
		cValue=document.getElementById("content").value;
		if(cValue=="请输入您要翻译的文字。"){			   
		  document.getElementById("content").value="";
		}
	}
    
	
 //以下是代码从新提交部分
	function wReLoad(){
	}
    
    function wReload(){
        document.getElementById("bTrans").disabled = false;
		translate();
    }

    var bg;
    var ii =7	;

    function bSearch_up(sElement){ 
		document.getElementById("bTrans").disabled = true;
        sElement = document.getElementById("bTransup");
        sElement.value =ii;
        bg = setInterval("sbegin_up()",1000);
    }

    function sbegin_up(){
        sElement = document.getElementById("bTransup");
        ii --;
        if( ii > 0 ){
            sElement.value = ii;
        } else {
            ii = 7 ;		
            sElement.disabled = false;		
            bStop();
            wReload();
        }
    }

    function bStop(){
        clearInterval(bg);
    }

    //以上是代码从新提交部分


//
var x,q;

function ctlent(e){
  if (document.all){
    x = window.event.keyCode;
    q = event.ctrlKey;
  } else {
    x = e.keyCode;
    q = e.ctrlKey;
  }
  if (q && x==13) {
    this.document.text_form.submit();
    this.document.text_form.Submit.disabled = true;
  }
  if (!document.all){
       window.captureEvents(Event.KEYPRESS);
       window.onkeypress = ctlent;
  }else{
       document.onkeypress = ctlent;
  }
}


function submitonce(form){
    for (var i=0;i<form.elements.length;i++) {
        var e=form.elements[i];
        if(e.type.toLowerCase()=="submit") e.disabled=true;
    }
}


//用于记录用户登录信息
function readCookie(name) {
	var cookieValue = "";
	var search = name + "=";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) {
				end = document.cookie.length;
			}
			cookieValue = document.cookie.substring(offset, end);
		}
	}
	return cookieValue;
}

function writeCookie(name, value, hours, domain, path) {
	var expire = "";
	if(hours != null) {
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
		if (domain) domain = "; domain=" + domain;
		if (path) path = "; path=" + path;
	}
	document.cookie = name + "=" + encodeURIComponent(value) + expire + domain + path;
}


//要求翻译的字数统计
function textCounter(sElement ) {
		field = sElement;
		document.getElementById("remLen").value =  field.value.length;
		CountChineseCharacters(sElement.value);
	}