var rybenaServer = "http://www.rybenamobile.com.br/";

var soundEmbed = null;

function carregaRybenaLibras() {
	document.getElementById("libras").innerHTML =	
	"<div style='background-image: url(" + rybenaServer + "RybenaWEBServer/img/borda_libras.png); height: 297px; width: 190px;'> "
  + "	<div id='libras' class='drag' onclick='fechaLibras();' title='Fechar' " 
  + "		style='background-image: url(" + rybenaServer + "RybenaWEBServer/img/borda_fechar.png); height: 22px; width: 22px; position: relative; top: 3px; left: 162px;'> "
  + "	</div> "
  + "	<div style='position: relative; top: 10px; left: 10px;'> "
  + "		<applet id='rybenalibras' "
  + "		    	archive='" + rybenaServer + "RybenaWEBServer/RybenaApplet.jar' "
  + "			    code='br.com.cts.rybena.libras.applet.LibrasApplet' "
  + "			    width='170' "
  + "			    height='255'> "
  + "		   <param name='host' value='" + rybenaServer + "'> "
  + "		   <param name='tam' value='m'> "
  + "		</applet> "
  + "	</div> "
  + "</div> ";
}

function carregaRybenaVoz() {
	document.getElementById("voz").innerHTML =
	"<div id='voz' class='drag' style='background-image: url(" + rybenaServer + "RybenaWEBServer/img/borda_voz.png); height: 96px; width: 150px;'> "
  + "	<div id='libras' class='drag' onclick='fechaVoz();' title='Fechar' " 
  + "		style='background-image: url(" + rybenaServer + "RybenaWEBServer/img/borda_fechar.png); height: 22px; width: 22px; position: relative; top: 3px; left: 123px;'> "
  + "	</div> "
  + "	<div style='position: relative; top: 10px; left: 10px;'> "
  + "		<applet id='rybenaVoz' "
  + "				archive='" + rybenaServer + "RybenaWEBServer/RybenaApplet.jar' "
  + "				code='br.com.cts.rybena.voz.applet.VozApplet' "
  + "			 	width='130' "
  + "			 	height='55'> "
  + "			<param name='host' value='" + rybenaServer + "'> "
  + "  			<param name='tam' value='m'> "
  + "		</applet>"
  + "	</div> "
  + "</div>	";	
}

function fechaLibras() {
	document.getElementById("libras").style.visibility = "hidden";
}

function fechaVoz() {
	document.getElementById("voz").style.visibility = "hidden";
}

function libras() {
	var txt = "";
	if (window.getSelection) {
		txt = window.getSelection();
	} else if (document.getSelection) {
		txt = document.getSelection();
	} else if (document.selection) {
		txt = document.selection.createRange().text;
	} else {
		return;
	}

	if (txt == "") {
		alert("Por favor, selecione um texto para o Rybená traduzir.");
	} else {
		document.getElementById("libras").style.visibility = "visible";
		
		carregaRybenaLibras();
		var appletD = document.getElementById("rybenalibras");
		appletD.traduzir(txt);
	}
}

function voz() {
	var txt = "";
	if (window.getSelection) {
		txt = window.getSelection();
	} else if (document.getSelection) {
		txt = document.getSelection();
	} else if (document.selection) {
		txt = document.selection.createRange().text;
	} else {
		return;
	}

	if (txt == "") {
		alert("Por favor, selecione um texto para o Rybená falar.");
	} else {
		document.getElementById("voz").style.visibility = "visible";

		carregaRybenaVoz();
		var appletD = document.getElementById("rybenaVoz");
		appletD.falar(txt);
	}
}

