/**
 * @link http://www.rybena.org.br
 */
var RybenaReader = function()
{
	this.sReaderUrl = 'http://www.rybena.org.br/rybena/default/player_rybena.jsp';
	this.sText = '';
	this.refreshSelection = function()
	{
		var iBrowser = 0;
		if ( document.selection )
		{
			this.sText = document.selection.createRange().text;
		}
		else if ( window.getSelection )
		{
			iBrowser = 1;
			this.sText = window.getSelection();
		}
		else if ( document.getSelection )
		{
			iBrowser = 2;
			this.sText = document.getSelection();
		}
		this.sText += '';
		if ( this.sText == '' )
		{
			var iLength = frames.length;
			for ( var iKey = 0; iKey < iLength; iKey++ )
			{
				this.sText += iBrowser == 0 ? frames[iKey].document.selection.createRange().text : frames[iKey].getSelection();
				if ( this.sText != '' )
				{
					break;
				}
			}
		}
	};
	this.read = function()
	{
		if ( this.sText == '' || this.sReaderUrl == '' )
		{
			alert('Selecione o Texto desejado em seguida clique aqui.');
			return;
		}
		var iLength = this.sText.length, sOut = '';
		for ( var iKey = 0; iKey < iLength; iKey++ )
		{
			sOut += this.sText.charAt( iKey ) == '\n' || this.sText.charCodeAt( iKey ) == 10 ? ' ' : this.sText.charAt( iKey );
		}
		var oWindow = window.open( this.sReaderUrl + "?msg=" + escape( this.sText ), 'Rybena', 'height=276,width=176,top=246,left=424,resizable=0,status=no' );
		oWindow.focus();
	};
}

Rybena = new RybenaReader();
