function sms ( mailaddress ) { var thiscat = document.forms[0].thiscat.value; var thiscat2 = document.forms[0].thiscat2.value; var prefix = document.forms[0].db.value; var pos = prefix.lastIndexOf ( "/" ); var url = "/" + prefix.substring(0,pos) + "/hpi.nsf/sms?openform&sendto="+mailaddress+"&restricttocategory=" + thiscat+"~"+thiscat2; window.location.href = url; }