    /**
     * addOption()
     * Takes the option from one SELECT list and adds it to another for user-friendly
     * search selection.  Updates a third field, a hidden field which the values in the
     * second select list for easier POSTING
     * @param string targetSelect
     * @param string sourceSelect
     * @param string hiddenField
     * @return void
     * @author Steven Mapes
     * @copyright 2007 StevenMapes.com - Do not use without written permisson
     **/
    function addOption(targetSelect,sourceSelect,hiddenField) {
        var z = document.getElementById(sourceSelect);
        if (z.selectedIndex > 0 ) {
            var display = z.options[z.selectedIndex].text;
            var option = z.options[z.selectedIndex].value;

            var y = document.createElement('option');
            y.text = display;
            y.value = option;

            var x = document.getElementById(targetSelect);

            try {
                x.add(y,null);
            }
            catch(ex) {
                x.add(y);
            }
            x.options[0].text = '* '+(x.length-1)+' selected *';

            // Set hidden field
            var h = document.getElementById(hiddenField);
            h.value = h.value+option+',';
        }
    }
    /**
     * removeOption()
     * Removed the selected option from a SELECT input as well as from an hidden
     * field.  I.E. Reverses addOption()
     * @param string selectBox
     * @param string hiddenField
     * @return void
     * @author Steven Mapes
     * @copyright 2007 StevenMapes.com - Do not use without written permisson
     **/
    function removeOption(selectBox,hiddenField) {
		try {
			var x = document.getElementById(selectBox);
		    if (x.selectedIndex > 0 ) {
		        // Remove from hidden field
		        var h = document.getElementById(hiddenField);
		        h.value = h.value.replace(','+x.options[x.selectedIndex].value+',',',');

		        x.remove(x.selectedIndex);
		        x.options[0].text = '* '+(x.length-1)+' selected *';
		        x.selectedIndex = 0;
		    }
		}
		catch (err) {
			// Do nothing
		}
    }

    function clearTextInput(textField){
		try {
	    	if (textField.value == 'Enter search keyword(s)') {
	            textField.value = '';
	        }
		}
		catch(err) {
			// Do nothing
		}
    }

    /**
     * Dynamically redefine the value of a syle
     * @return void
     * @author Steven Mapes
     **/
    function setStyleById(elementID, styleParam, stlyeValue) {
        try {
            var n = document.getElementById(elementID);
            n.style[styleParam] = stlyeValue;
        }
        catch(err) {
            handleMoonError(err.message());
        }
    }

    /**
     *
     * @access public
     * @return void
     **/
    function setCurrentElementStyle(anElement,styleParam, stlyeValue){
        try {
            anElement.style[styleParam] = stlyeValue;
        }
        catch(err) {
            handleMoonError(err.message());
        }
    }

	/**
	* Dynamically Toggle the CSS class used against an element based on the ID of that element
	* @author Steven Mapes <steve@stevenmapes.com>
	* @return void
	* @access public
	**/
	function toggleDisplay(anElement,aClassName) {
		try {
		if (document.getElementById(anElement)) {
		   n = document.getElementById(anElement);
		   n.className = aClassName;
		}
		}
		catch(err) {
			handleMoonError(err);
		}
	}

	/**
	 *
	 * @access public
	 * @return void
	 * @author Steven Mapes
	 * @access public
	 **/
	function handleMoonError(anErr){
		txt = "An error occured!\n\n  Please contact transformers@themoon.co.uk with the following debugging information.\n\n";
		txt += "\tError message: "+anErr.message+"\n";
		txt += "\tError name: "+anErr.name+"\n";
		txt += "\tError number: "+anErr.number +"\n";
		txt += "\tError description: "+anErr.description+"\n";
		txt += "\nClick OK to continue.";
        alert(txt);
	}

        /**
         *
         **/
        function moonException(aMessage,aName,aNumber,aDescripton) {
            aMessage = aMessage || false;
            aName = aName || false;
            aNumber = aNumber || false;
            aDescripton = aDescripton || false;

            this.message = aMessage;
            this.name = aName;
            this.number = aNumber;
            this.description = aDescripton;
        }

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function setStatus(statusMsg) {
        try {
    	    window.status = statusMsg;
    	    return true;
    	}
    	catch(err) {
    	   handleMoonError(err.message());
    	}
	}

    /**
     * toggleVideo()
     * Hides all video elements other than thhe one you want to display
     * @param integer	The id of the video element to display
     * @access public
     * @return void
     * @copyright 2007
     * @author Steven Mapes
     **/
	function toggleVideo(displayVid,numVideos) {
		var i;
		for( i=0;i<=numVideos;i++) {
			if (document.getElementById('video'+i)) {
				if (displayVid == i) {
					document.getElementById('video'+i).style.display = 'block';
				}
				else {
					document.getElementById('video'+i).style.display = 'none';
				}
			}
		}
	}

    /**
     * function_exists()
     * Replicates PHP function_exists call
     * @param mixed functionName    {string} The name of the function to look for {object} the function object
     * @return boolean
     * @author Steven Mapes
     * @access public
     **/
    function function_exists(functionName) {
        var result = false;
        if (typeof functionName == 'string' ) {
            if (typeof window[functionName] == 'function') {
                result = true;
            }
        } else {
            if (functionName instanceof Function) {
                result = true;
            }
        }
        return result;
    }

