function IsDecimal(sText) { var regex = /^-?\d+(\.\d+)?$/ return regex.test(sText); } function IsPositiveDecimal(sText) { var regex = /^\d+(\.\d+)?$/ return regex.test(sText); } function IsInteger(sText) { var regex = /^-?\d+$/; // ^\d+$ any string containing one or more digits return regex.test(sText); } function IsPositiveInteger(sText) { var regex = /^\d+$/; // ^\d+$ any string containing one or more digits return regex.test(sText); } function IsFloat(sText) { return sText.length>0 && !(/[^0-9.]/).test(sText) && (/\.\d/).test(sText); } function IsPositiveFloat(sText) { if (IsFloat(sText) || IsInteger(sText)) if (Number(sText) >= 0) return true; return false; } function addLoan(loanid, productid, departmentid, amount, debug) { var redirecturl = 'http://loans.goodreturn.org.au/weal/scripts/doaction.aspx'; redirecturl += '?op=addloantobasket'; redirecturl += '&loanid=' + loanid; redirecturl += '&productid=' + productid; redirecturl += '&departmentid=' + departmentid; redirecturl += '&amount=' + amount; if (debug == 1) redirecturl += '&debug=1'; //alert(redirecturl); location.href = redirecturl; } function addDonationToBasket(productid, qty, departmentid, productcatalogueid, amount, recurringperiod, productsubtypeid, debug) { var redirecturl = 'http://loans.goodreturn.org.au/weal/scripts/doaction.aspx'; redirecturl += '?op=adddonationtobasket'; redirecturl += '&productid=' + productid; redirecturl += '&departmentid=' + departmentid; redirecturl += '&productcatalogueid=' + productcatalogueid; redirecturl += '&qty=' + qty; redirecturl += '&amount=' + amount; redirecturl += '&recurringperiod=' + recurringperiod; redirecturl += '&productsubtypeid=' + productsubtypeid; if (debug == 1) redirecturl += '&debug=1'; location.href = redirecturl; } function addOrUpdateGiftCertificateToBasket(ordersessionproductid, productid, departmentid, productcatalogueid, producttypeid, productsubtypeid, amount, gifthow, gifthowdate, giftto, giftemail, giftfrom, giftmessage, loantodonationattributeid, debug) { var redirecturl = 'http://loans.goodreturn.org.au/weal/scripts/doaction.aspx'; redirecturl += '?op=addorupdategiftcertificatetobasket'; redirecturl += '&ordersessionproductid=' + ordersessionproductid; redirecturl += '&productid=' + productid; redirecturl += '&departmentid=' + departmentid; redirecturl += '&productcatalogueid=' + productcatalogueid; redirecturl += '&producttypeid=' + producttypeid; redirecturl += '&productsubtypeid=' + productsubtypeid; redirecturl += '&amount=' + amount; redirecturl += '&gifthow=' + gifthow; redirecturl += '&gifthowdate=' + gifthowdate; redirecturl += '&giftto=' + giftto; redirecturl += '&giftemail=' + giftemail; redirecturl += '&giftfrom=' + giftfrom; redirecturl += '&giftmessage=' + escape(giftmessage); redirecturl += '&loantodonationattributeid=' + loantodonationattributeid; if (debug == 1) redirecturl += '&debug=1'; location.href = redirecturl; } function addBlogComment(blogentryid, constituentid, comment, debug) { var redirecturl = 'http://loans.goodreturn.org.au/weal/scripts/doaction.aspx'; redirecturl += '?op=addblogcomment'; redirecturl += '&blogentryid=' + blogentryid; redirecturl += '&constituentid=' + constituentid; redirecturl += '&comment=' + RemoveNewLines(comment); if (debug == 1) redirecturl += '&debug=1'; location.href = redirecturl; } function removeFromBasket(ordersessionproductid, debug) { var redirecturl = 'http://loans.goodreturn.org.au/weal/scripts/doaction.aspx'; redirecturl += '?op=removefrombasket'; redirecturl += '&ordersessionproductid=' + ordersessionproductid; if (debug == 1) redirecturl += '&debug=1'; location.href = redirecturl; } function CleanQueryString(strRawString) { return strRawString.replace(",","%2C").replace("&","%26").replace(" ","%20"); } function RemoveNewLines(strRawString) { return strRawString.replace("\n", "_|_"); } function validateMandatoryPositiveIntegerGreaterThanZero(fieldId,message) { // ensures that an integer >0 is entered into a text field if (document.getElementById(fieldId).value == "") { alert(message); document.getElementById(fieldId).select(); document.getElementById(fieldId).focus(); return false; } if (!IsPositiveInteger(document.getElementById(fieldId).value)) { alert(message); document.getElementById(fieldId).select(); document.getElementById(fieldId).focus(); return false; } if (document.getElementById(fieldId).value == 0) { alert(message); document.getElementById(fieldId).select(); document.getElementById(fieldId).focus(); return false; } return true; }