Issue: TypeError: $.widget is not a function

Issue: TypeError: $.widget is not a function

Hi,
I'm quite new to jQuery and jQuery UI development (and even JavaScript for that matter) and I've been trying out the examples from this tutorial:
<u><a href="http://youngisrael-stl.org/wordpress/understanding-jquery-ui-widgets-a-tutorial/">http://youngisrael-stl.org/wordpress/understanding-jquery-ui-widgets-a-tutorial/</a></u>
and midway through the tutorial, I came across this error while trying out the examples:
<span style="font-family: courier new,monospace;">TypeError: $.widget is not a function</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    at [Top-level script]() (TestJQueryProject/scripts/testwidget2.js:67)</span>
Here's the source code:
<i>example-jquery-ui-widget.html:</i>
<span style="font-family: courier new,monospace;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<a href="http://www.w3.org/TR/html4/strict.dtd">http://www.w3.org/TR/html4/strict.dtd</a>"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><html dir="ltr" lang="en"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    <head></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        <title>Example: jQuery UI Widget</title></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <script type="text/javascript" src="../lib/jquery/jquery.min.js"></script></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        <script type="text/javascript" src="../scripts/testwidget2.js"></script></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </head></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    <body></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <p class="target">This is a paragraph called with .green4({ </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                level:3, </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                greenlevels: ['#000', '#00f', '#088', '#0f0', '#880', '#f00', '#808', '#fff']</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            }).</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <input type="button" id="toggle" name="on" value="Turn green" /></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <input type="button" id="darker" name="darker" value="Darker" /></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        <input type="button" id="lighter" name="lighter" value="Lighter" /></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </body></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></html></span>
<br clear="all">and <i>testwidget2.js:</i>
<span style="font-family: courier new,monospace;">$(function() { </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    var STR_DARKER = "darker";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    var STR_LIGHTER = "lighter";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    var STR_OFF = "off";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    var BTN_LABEL_TURNGREEN = "Turn green";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    var BTN_LABEL_TURNOFF = "Turn off";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    $("#toggle").click(function() { </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        if ($(this).val() == BTN_LABEL_TURNGREEN) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            $(".target").green3();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            $(this).val(BTN_LABEL_TURNOFF);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        } else {     // ($(this).val() == BTN_LABEL_TURNOFF; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            $(".target").green3(STR_OFF);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            $(this).val(BTN_LABEL_TURNGREEN);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    });</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    $("#darker").click(function() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        $(".target").green3(STR_DARKER);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    });</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    $("#lighter").click(function() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        $(".target").green3(STR_LIGHTER);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    });</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">});</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">var Green3 = {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    _init: function() { </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        this.setLevel(15);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    }, </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    greenlevels: ["#000", "#010", "#020", "#030", "#040", "#050", "#060", "070", "#080", </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        "#090", "#0a0", "#0b0", "#0c0", "#0d0", "#0e0", "#0f0", "#fff"], </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    level: 0, </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    getLevel: function() { </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        return this.level;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    }, </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    setLevel: function(x) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        this.level = Math.floor(Math.min(this.greenlevels.length - 1, Math.max(0, x))); </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        this.element.css({ background: this.greenlevels[this.level] });</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    }, </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    darker: function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        this.setLevel(this.getLevel() - 1);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    }, </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    lighter: function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        this.setLevel(this.getLevel() + 1);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    }, </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    off: function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        this.element.css({ background: "none"});</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        this.destroy();     // use the predefined function</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">};</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace; background-color: rgb(255, 204, 204);">$.widget("ui.green3", Green3);     // create the widget (the error occurs at this line)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">$.ui.green3.getter = "getLevel";</span>
I'm using:
<b>Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009020911 Ubuntu/8.04 (hardy) Firefox/3.0.6</b>
Sorry if this turns out to be a simple typo error. I find it quite hard to debug JavaScript code.
Hope you may be able to help me. Thanks in advance.
--
Warm regards,
Reggie