  var visible = false;
  
  $(document).ready(function(){
    $("#draggable").draggable();
	$(document).pngFix();
  });
 
  function getSelText()
  {
  	var txt = "";
  	
  	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;
    }
    
    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;
    }
    
    document.PlayerRybena.traduzir(txt);
  }
  
  function carregar()
  {
  	if (visible)
 		return;

    host = callback_host();
    
    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;
  }

 