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();
        }
        if (document.rs_form){
        	document.rs_form.selectedtext.value = selectedString;
	        if (document.rs_form.url) {
	                if (!document.rs_form.url.value) {
	                        if (window.location.href)
	                        {
	                                document.rs_form.url.value=window.location.href;
	                        }
	                        else if (document.location.href)
	                        {
	                                document.rs_form.url.value=document.location.href;
	                        }
	                }
	        }
		}
}

function copyselected()
{
        setTimeout("rsTextSelection()",50);
        return true;
}

function openAndRead(b){
	if(!b){
		var a=document.getElementById("rs_button");
		if(a){
			b=a.getAttribute("href")
		} else {
			return true
		}
	}
	issuePOST(b)
}

function issuePOST(d) {
	var g=document.createElement("form");
	g.target="rs";
	g.method="post";
	g.style.display="none";
	var c=d.split("?");
	g.action="http://app.readspeaker.com/cgi-bin/rsent";
	var f=c[1].split("&");
	var e;
	for(e=0;e<f.length;e++) {
		var b=f[e].split("=");
		var h=document.createElement("input");
		h.setAttribute("name",unescape(b[0]));
		h.setAttribute("value",unescape(b[1]));
		g.appendChild(h)
	}
	document.body.appendChild(g);
	var a=window.open("","rs","width=310,height=120,toolbar=0");
	g.submit();
	document.body.removeChild(g)
}

document.onmouseup = copyselected;
document.onkeyup = copyselected;
