function rsTextSelection()
{
        if (document.getSelection) // older Mozilla versions
        {
                var selectedString = document.getSelection();
        }
        else if (document.all) // MSIE 4+
        {
                var selectedString = document.selection.createRange().text;
        }
        else if (window.getSelection) // recent Mozilla versions
        {
                var selectedString = window.getSelection();
        }
		else
		{
            var selectedString = undefined;
		}

		$('#rs_selectedtext').val(selectedString)

        if ($('#rs_url').length > 0) {
                if (!$('#rs_url').val()) {
                        if (window.location.href)
                        {
                                $('#rs_url').val(window.location.href);
                        }
                        else if (document.location.href)
                        {
                                $('#rs_url').val(document.location.href);
                        }
                }
        }
}

function rsSubmit()
{
	$('#rs_form').submit();
}

function copyselected()
{
        setTimeout("rsTextSelection()",50);
        return true;
}

function openAndRead() {
        window.open('','rs','width=380,height=180,toolbar=0');
        setTimeout("rsSubmit();",500);
}

document.onmouseup = copyselected;
document.onkeyup = copyselected;

$(document).ready(function(){
							
						$('#rs_form').attr({'target':'rs', 'name':'rs_form'});
						
						$('#readSpeaker').attr({'target':'rs'});
			});
