  /**
                    This is a Javascript implementation of the Java Hashtable object.
                    
                    Contructor(s):
                     Hashtable()
                              Creates a new, empty hashtable
                    
                    Method(s):
                     void clear() 
                              Clears this hashtable so that it contains no keys. 
                     boolean containsKey(String key) 
                              Tests if the specified object is a key in this hashtable. 
                     boolean containsValue(Object value) 
                              Returns true if this Hashtable maps one or more keys to this value. 
                     Object get(String key) 
                              Returns the value to which the specified key is mapped in this hashtable. 
                     boolean isEmpty() 
                              Tests if this hashtable maps no keys to values. 
                     Array keys() 
                              Returns an array of the keys in this hashtable. 
                     void put(String key, Object value) 
                              Maps the specified key to the specified value in this hashtable. A NullPointerException is thrown is the key or value is null.
                     Object remove(String key) 
                              Removes the key (and its corresponding value) from this hashtable. Returns the value of the key that was removed
                     int size() 
                              Returns the number of keys in this hashtable. 
                     String toString() 
                              Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the 
                              ASCII characters ", " (comma and space). 
                     Array values() 
                              Returns a array view of the values contained in this Hashtable. 
                            
                */
                function Hashtable(){
                    this.clear = hashtable_clear;
                    this.containsKey = hashtable_containsKey;
                    this.containsValue = hashtable_containsValue;
                    this.get = hashtable_get;
                    this.isEmpty = hashtable_isEmpty;
                    this.keys = hashtable_keys;
                    this.put = hashtable_put;
                    this.remove = hashtable_remove;
                    this.size = hashtable_size;
                    this.toString = hashtable_toString;
                    this.values = hashtable_values;
                    this.hashtable = new Array();
                }                
                /*=======Private methods for internal use only========*/
                
                function hashtable_clear(){
                    this.hashtable = new Array();
                }
                
                function hashtable_containsKey(key){
                    var exists = false;
                    for (var i in this.hashtable) {
                        if (i == key && this.hashtable[i] != null) {
                            exists = true;
                            break;
                        }
                    }
                    return exists;
                }
                
                function hashtable_containsValue(value){
                    var contains = false;
                    if (value != null) {
                        for (var i in this.hashtable) {
                            if (this.hashtable[i] == value) {
                                contains = true;
                                break;
                            }
                        }
                    }
                    return contains;
                }
                
                function hashtable_get(key){
                    return this.hashtable[key];
                }
                
                function hashtable_isEmpty(){
                    return (this.size == 0) ? true : false;
                }
                
                function hashtable_keys(){
                    var keys = new Array();
                    for (var i in this.hashtable) {
                        if (this.hashtable[i] != null) 
                            keys.push(i);
                    }
                    return keys;
                }
                
                function hashtable_put(key, value){
                    if (key == null || value == null) {
                        throw "NullPointerException {" + key + "},{" + value + "}";
                    }else{
                        this.hashtable[key] = value;
                    }
                }
                
                function hashtable_remove(key){
                    var rtn = this.hashtable[key];
                    this.hashtable[key] = null;
                    return rtn;
                }
                
                function hashtable_size(){
                    var size = 0;
                    for (var i in this.hashtable) {
                        if (this.hashtable[i] != null) 
                            size ++;
                    }
                    return size;
                }
                
                function hashtable_toString(){
                    var result = "";
                    for (var i in this.hashtable)
                    {      
                        if (this.hashtable[i] != null) 
                            result += "{" + i + "},{" + this.hashtable[i] + "}\n";   
                    }
                    return result;
                }
                
                function hashtable_values(){
                    var values = new Array();
                    for (var i in this.hashtable) {
                        if (this.hashtable[i] != null) 
                            values.push(this.hashtable[i]);
                    }
                    return values;
                }
/* Sample:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title>Synovic.com</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<style type="text/css">
			@import "../style.css";
            td,th,button,input
            {
                font-size:11px;
                font-family:Georgia; 
            }
		</style>
        <script language="javascript" src="Hashtable.js"></script>
        <script language="javascript">
            var hash = new Hashtable();

            function addToHash(){
                try{
                    hash.put(document.getElementById("key").value, document.getElementById("value").value);
                    document.getElementById("key").value = ""; 
                    document.getElementById("value").value  = "";
                }catch(e){
                    alert(e);
                }
            }

            function getValue(){
                alert(hash.get(document.getElementById("key1").value));
            }

            function containsKey(){
                alert(hash.containsKey(document.getElementById("key2").value));
            }

            function containsValue(){
                alert(hash.containsValue(document.getElementById("value1").value));
            }

            function removesKey(){
                alert("removed:" + hash.remove(document.getElementById("key3").value));
            }

            function hashClear(){
                hash.clear();
            }

            function isEmpty(){
                alert(hash.isEmpty());
            }

            function keys(){
                alert(hash.keys());
            }

            function size(){
                alert(hash.size());
            }
            function hashToString(){
                alert(hash.toString());
            }
            function values(){
                alert(hash.values());
            }

        </script>
	</head>
	<body>
		<div class="header_small">
			<div class="welcome">Synovic.com</div>
		</div>
		<div class="articlesection">
			<div class="sectionheading">
				Hashtable
			</div>
			<div class="articlesectionblock">
            <p>A Hashtable implementation for JavaScript.</p>
            <p>Create your own key/value pairs for a simple test.</p>
            <table cellpadding=4 border=0 cellspacing=0>
            <tr>
                <th>Populate the Hashtable</th>
            <tr>
                <td>Key:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="key" />&nbsp;&nbsp;Value:&nbsp;&nbsp;<input type="text" id="value" /> <button onclick="addToHash();">Add</button></td>
            <tr>
                <th><br>Test the Hashtable</th>
            <tr>
                <td >Key:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="key1" /> <button onclick="getValue();">get(String key)</button></td>
            <tr>
                <td >Key:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="key2" /> <button onclick="containsKey();">containsKey(String key)</button></td>
            <tr>
                <td >Value:&nbsp;&nbsp;<input type="text" id="value1" /> <button onclick="containsValue();">containsValue(Object value)</button></td>
            <tr>
                <td >Key:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="key3" /> <button onclick="removesKey();">remove(String key)</button></td>
            <tr>
                <td >
                    <button onclick="hashClear();">clear()</button>
                    <button onclick="isEmpty();">isEmpty()</button>
                    <button onclick="keys();">keys()</button>
                    <button onclick="size();">size()</button>
                    <button onclick="hashToString();">toString()</button>
                    <button onclick="values();">values()</button>
                </td>
            </table>
            <p>Code:</p>
            <pre>
*/