#!/bin/sh
# $Id: scaleplus,v 1.3 2004-02-06 00:31:05 ianb-guest Exp $
# elvis: scaleplus	-- Search Australian Law using ScalePlus (scaleplus.law.gov.au)
. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_scaleplus_results $SURFRAW_results
def   SURFRAW_scaleplus_search search
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search words]...
Description:
  Surfraw search Australian Law using ScalePlus (scaleplus.law.gov.au)
Local options:
  -results=NUM                  Number of search results returned
                                Default: $SURFRAW_scaleplus_results
                                Environment: SURFRAW_scaleplus_results
EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
	-results=*) setopt   SURFRAW_scaleplus_results $optarg	;;
	*) return 1 ;;
    esac
    return 0
}

w3_config
# disable requoting, doesn't work with this elvi.
SURFRAW_quote_ifs=0
w3_parse_args "$@"
# w3_args now contains a list of arguments
if test -z "$w3_args"; then
    w3_browse_url "http://scaleplus.law.gov.au/"
else
    escaped_args=`w3_url_of_arg $w3_args`
    w3_browse_url "http://scaleplus.law.gov.au/cgi-bin/topicSrch.pl?Action=Search&SearchPage=%2FWelcome97.html&ResultTemplate=scaleresults.hts&ViewTemplate=scaleview.hts&ResultMaxDocs=${SURFRAW_scaleplus_results}&querytext=${escaped_args}&category=CL&category=CC&category=SL&category=SC&category=OT&category=HD"
fi
