  var visible = false;
  var anteriorX;
  var anteriorY;
  var atualX=0;
  var atualY=0;
  //$(document).ready(function(){
   // $("#draggable").draggable();
	//$(document).pngFix();
  //});

   function callback_host()
      {
        //return  "http://rybena.desenvolvimento.extracaixa/rybena_cef/";
		return  "http://www7.caixa.gov.br/rybena_cef/";
      }
  
  /*PEGAR POSICAO DO MOUSE*/
   if (window.captureEvents){
	window.captureEvents(Event.MOUSEUP);
	window.onmouseup=mouseUp;
	}
	else
	document.onmouseup=mouseUp;
	
  function mouseUp(e) {
	    if (window.getSelection){
			if (window.getSelection()!=""){
				//alert(window.getSelection()+"posicao x="+e.clientX+"posicao y="+e.clientY);
				if (atualX != 0 && atualY!=0){
					anteriorX = atualX;
					anteriorY = atualY;
				}
				atualX = e.pageX;
				atualY = e.pageY;
				//alert("x-" +anteriorX + "  y-" +anteriorY);
			}
		}else if (document.selection){
			if (document.selection.createRange().text != ""){
				//alert(document.selection.createRange().text+"posicao x="+event.clientX+"posicao y="+event.clientY);
				if (atualX != 0 && atualY!=0){
					anteriorX = atualX;
					anteriorY = atualY;
				}
				atualX = event.clientX + document.documentElement.scrollLeft;
				atualY = event.clientY + document.documentElement.scrollTop;
				//alert(document.body.scrollTop);
				//alert("x-" +anteriorX + "  y-" +anteriorY);
			}
		}			
	}
  /*[FIM] PEGAR POSICAO DO MOUSE*/

  function getSelText()
  {
  	var txt = "";
  	atualX=0;
  	atualY=0;
	//if (!visible)
  		//return;

    if (window.getSelection)
    {
        txt = window.getSelection();
        
    }
    else if (document.getSelection)
    {
        txt = document.getSelection();
        
    }
    else if (document.selection)
    {
        txt = document.selection.createRange().text;
        
    }
    else 
    {
      alert('Nenhum texto selecionado !');
      return;
    }
    
    if(txt == "")
    {
      alert('Nenhum texto selecionado !');
      return;
    }
    carregar();
	//alert("carreguei");
    document.PlayerRybena.traduzir(txt);
  }
  
  function getTxtBoxText()
  {
  	var txt = "";
  	
  	if (!visible)
  		return;

	var targetElement = document.getElementById("translate");
	txt = targetElement.value;
    
    if(txt == "")
    {
      alert('Nenhum texto selecionado !');
      return;
    }
    carregar();
    document.PlayerRybena.traduzir(txt);
  }
  
  function carregar()
  {
  	if (visible)
 		return;

    host = callback_host();
	
	/*POSICIONAMENTO ABSOLUTO RYBENA*/
		//document.getElementById("draggable").style.position ="absolute";
		//document.getElementById("draggable").style.z-index ="1;";
		document.getElementById("draggable").style.top =anteriorY+"px";
		document.getElementById("draggable").style.left =anteriorX+"px";
	/*FIM*/
    
    document.getElementById("draggable").innerHTML = "<div id='testediv' style='background:transparent'><div class='imgStyle' id='imgDiv'><IMG SRC='"+host+"close.png' alt='Fechar Janela' onclick='closeWindow()'/></div><div><SPAN style='position: absolute; top: 10px; left: 0px;width: 187px; height: 58px'><IMG SRC='"+host+"skin_top.png' ></SPAN><SPAN style='position: absolute; top: 68px; left: 0px;width: 21px; height: 235px'><IMG SRC='"+host+"skin_left.png' ></SPAN><SPAN style='position: absolute; top: 68px; left: 21px;width: 145px; height: 235px'><applet code='br.org.rybena.webplayer.WebPlayer.class' archive='"+host+"webplayer.jar' id='PlayerRybena' name='PlayerRybena' width='145' height='235' mayscript><PARAM NAME='host' VALUE='" + host + "'/><PARAM NAME='fontsize' VALUE='14'/><PARAM NAME='btnSpeedUp' VALUE='92,213,20,20'/><PARAM NAME='btnSpeedUpHlp' VALUE='-32,-20'/><PARAM NAME='btnSpeedDown' VALUE='115,213,20,20'/><PARAM NAME='btnSpeedDownHlp' VALUE='-63,-20'/><PARAM NAME='btnPlay' VALUE='6,213,20,20'/><PARAM NAME='btnPlayHlp' VALUE='0,-20'/><PARAM NAME='btnPause' VALUE='30,213,20,19'/><PARAM NAME='btnPauseHlp' VALUE='-20,-20'/><PARAM NAME='btnStop' VALUE='51,213,20,20'/><PARAM NAME='btnStopHlp' VALUE='-20,-20'/><PARAM NAME='imgDimensions' VALUE='145,190'/></applet></SPAN><SPAN style='position: absolute; top: 68px; left: 166px;width: 23px; height: 235px'><IMG SRC='"+host+"skin_right.png' ></SPAN><SPAN style='position: absolute; top: 303px; left: 9px;width: 171px; height: 17px'><IMG SRC='"+host+"skin_bottom.png' ></SPAN></div></div>";

	document.getElementById("testediv").style.visibility="visible";
    document.getElementById("imgDiv").style.visibility="visible";
	document.getElementById("PlayerRybena").style.visibility="visible";

    visible = true;
  }

   
  function closeWindow(){
  	document.PlayerRybena.parar();
  	document.getElementById("testediv").style.visibility="hidden";
    document.getElementById("imgDiv").style.visibility="hidden";
	document.getElementById("PlayerRybena").style.visibility="hidden";
	visible = false;
  }

 