var xmlhttp;
function ajaxcreate(){
     if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
}
function ajaxtrans(){
   ajaxcreate();
   var source=document.getElementById("trancon").innerHTML
  
   var lang="auto"
  var url="fun/googletrans.php?s="+source+"&l="+lang+"&rnd="+Math.random();
    //var url="http://translate.google.com/translate_t?sl=auto&tl=zh-CN&rnd="+Math.random();
  xmlhttp.onreadystatechange=requestgoogle;
   xmlhttp.open("GET",url,true);
  // xmlhttp.open("POST",url,source,true);
   xmlhttp.send(null);
}

function closewindow()
{
rs.innerHTML=""
rs.style.cssText="background:none;border:none;"
document.body.removeChild(rs)
}


function requestgoogle(){
   if(xmlhttp.readystate==4){
     if(xmlhttp.status==200){
	  leftpx=(window.screen.width-300)/2-200
	  
	  var rbox=document.createElement("div")
	  rbox.id="rs"
	  rbox.style.cssText="height:300px; width:500px; position:absolute;top:80px;left:200px; background:#fff;text-align:center;border:2px solid #999;"
	  var result=document.createElement("div")
	  result.innerHTML=xmlhttp.responseText;
	  var closewindow=document.createElement("div")
      closewindow.innerHTML="<a href='#' onclick='closewindow()'>关闭</a>"
      rbox.appendChild(closewindow)
	  rbox.appendChild(result)
	   
	  document.body.appendChild(rbox)
	  }
   }
}