var helpTopic = function(oQueue, oInfo, keywords)
{
        if (keywords == "" && hDB["home"] != null)
        {
                oInfo.innerHTML = hDB["home"]["title"];
                oQueue.innerHTML = hDB["home"]["topic"];
                oInfo.innerHTML += "&nbsp; (to exit help use <strong>home</strong>)";
        }
        else
        {
                if (hDB[keywords] != null)
                {
                        oInfo.innerHTML = hDB[keywords]["title"];
                        oQueue.innerHTML = hDB[keywords]["topic"];
                        oInfo.innerHTML += "&nbsp; (to exit help use <strong>home</strong> or other command)";
                }
                else
                {
                        oInfo.innerHTML = "The specified help topic does not exist.";
                }
        }

        return;
}

var h_home = function()
{
	var src = '';
	var divInfo = document.getElementById("divInfo");

	if (!isMobile)
	{
		src += '<pre>';
		src += '                                        _\n';
		src += '   ___ _ __ ___ __  _____ _ __ ___   __| |\n';
		src += '  / __| \'_ \' _ \\\\ \\/ / __| \'_ \' _ \\ / _\' |\n';
		src += ' | (__| | | | | |>  < (__| | | | | | (_| |\n';
		src += '  \\___|_| |_| |_/_/\\_\\___|_| |_| |_|\\__,_|\n';
		src += '</pre>';
	}
	
	src += ' <br /><br />';
	src += ' <br /><br />';
	src += 'If you are new to contactmatrix, or the cmxcmd, use<br /><strong>help</strong><br /><br />';
	src += '<br /><br />';
	src += 'To view entries use<br /><strong>e &lt;entry id&gt;</strong>';
	src += '<br />';
	
	divInfo.innerHTML = "CMXCMD Home";
	
	return src;
}

var h_reference = function()
{
	var src = '';
	var divInfo = document.getElementById("divInfo");
	
	src += 'REFERENCE<br />';
	src += '---------<br />';
	src += 'There are numerous variations of each command - typically a<br />';
	src += 'user friendly - intuitive command and a shorthand version. All<br />';
	src += 'alerts and error messages use the intuitive version of the commands<br />';
	src += 'in question, to get the shorthand version, use <strong>ref</strong><br /><br />';
	src += '<br />';

	src += '<strong>Up Arrow</strong><br />';
	src += '<em>Moves back within the command history</em><br /><br />';

	src += '<strong>Down Arrow</strong><br />';
	src += '<em>Moves forward within the command history</em><br /><br />';

	src += '<br />';

	src += '<strong>addentry</strong><br />';
	src += '<strong>adde</strong><br />';
	src += 'Attributes: <em>&lt;entrytype (notes|entry)&gt; &lt;entryname&gt;</em><br />';
	src += '<em>Creates a new entry within the user\'s contactmatrix database</em><br /><br />';

	src += '<strong>addfield</strong><br />';
	src += '<strong>addf</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt; &lt;caption&gt;</em><br />';
	src += '<em>Adds a field to the specified entry, fields can only be added to \'non notes\' entries</em><br /><br />';

	src += '<strong>close</strong><br />';
	src += '<strong>x</strong><br />';
	src += '<em>Exits the notes editing mode without saving changes. To save notes, use <strong>savenotes</strong> or <strong>sn</strong></em><br /><br />';

	src += '<strong>count</strong><br />';
	src += '<em>Gets the total number of entries within the user\'s contactmatrix database</em><br /><br />';

	src += '<strong>deleteentry</strong><br />';
	src += '<strong>dele</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt;</em><br />';
	src += '<em>Deletes the specified entry, this action cannot be undone</em><br /><br />';

	src += '<strong>deletefield</strong><br />';
	src += '<strong>delf</strong><br />';
	src += 'Attributes: <em>&lt;fieldid&gt;</em><br />';
	src += '<em>Deletes the specified field, this action cannot be undone</em><br /><br />';

	src += '<strong>entry</strong><br />';
	src += '<strong>e</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt;</em><br />';
	src += '<em>Displays the specified entry</em><br /><br />';

	src += '<strong>entryname</strong><br />';
        src += '<strong>rn</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt; &lt;entryname&gt;</em><br />';
	src += '<em>Allows users to change the specified entry\'s name</em><br /><br />';

	src += '<strong>entrynotes</strong><br />';
	src += '<strong>en</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt;</em><br />';
	src += '<em>Displays the specified entry notes within a notes editor, allowing users to update the notes</em><br /><br />';

	src += '<strong>entrytags</strong><br />';
	src += '<strong>et</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt; &lt;tags&gt;</em><br />';
	src += '<em>Allows users to update the specified entry\'s search tags</em><br /><br />';

	src += '<strong>favorite</strong><br />';
	src += '<strong>fav</strong><br />';
	src += 'Attributes: <em>&lt;entry id&gt; &lt;(true|false)&gt;</em><br />';
	src += '<em>Sets the specified entry as a \'favorite\' entry or not</em><br /><br />';

	src += '<strong>field</strong><br />';
	src += '<strong>f</strong><br />';
	src += 'Attributes: <em>&lt;fieldid&gt;</em><br />';
	src += '<em>Displays the specified field</em><br /><br />';

	src += '<strong>fieldcaption</strong><br />';
	src += '<strong>fc</strong><br />';
	src += 'Attributes: <em>&lt;fieldid&gt; &lt;caption&gt;</em><br />';
	src += '<em>Allows users to update the specified field caption</em><br /><br />';

	src += '<strong>fieldnotes</strong><br />';
	src += '<strong>fn</strong><br />';
	src += 'Attributes: <em>&lt;fieldid&gt;</em><br />';
	src += '<em>Allows users to update the specified field\'s notes</em><br /><br />';

	src += '<strong>fieldvalue</strong><br />';
	src += '<strong>fv</strong><br />';
	src += 'Attributes: <em>&lt;fieldid&gt; &lt;value&gt;</em><br />';
	src += '<em>Allows users to update the specified field\'s value</em><br /><br />';

	src += '<strong>gettingstarted</strong><br />';
	src += '<em>Displays the getting started information</em><br /><br />';

	src += '<strong>gui</strong><br />';
	src += '<em>Displays the contactmatrix graphical user interface</em><br /><br />';

	src += '<strong>history</strong><br />';
	src += '<strong>h</strong><br />';
	src += '<strong>search -h</strong><br />';
	src += '<em>Displays a history of the most recently viewed entries, by adding a number after the <strong>search -h</strong> command<br />users can specify how many history results to display</em><br /><br />';

	src += '<strong>home</strong><br />';
	src += '<strong>gh</strong><br />';
	src += '<em>Returns to the cmxcmd home page, when editing notes, changes are lost without saving - use saveentrynotes<br />';
	src += 'or savefieldnotes to save your changes before returning to the homepage</em><br /><br />';

	src += '<strong>info</strong><br />';
	src += '<strong>i</strong><br />';
	src += 'Attributes: <em>&lt;entryid&gt;</em><br />';
	src += '<em>Displays the specified entry\'s details, such as its type and tags etc</em><br /><br />';

	src += '<strong>login</strong><br />';
	src += 'Attributes: <em>&lt;email&gt; &lt;password&gt; &lt;remember (true|false)&gt;</em><br />';
	src += '<em>Logs the user in, if \'remember\' is set to true, the user is automatically logged in when they return</em><br /><br />';

	src += '<strong>logout</strong><br />';
	src += '<em>Logs the current user out</em><br /><br />';

	src += '<strong>movefield</strong><br />';
	src += '<strong>mf</strong><br />';
	src += 'Attributes: <em>&lt;source field id&gt; &lt;target field id&gt;</em><br />';
	src += '<em>Swaps the source field with the target field in its location within its parent entry</em><br /><br />';

	src += '<strong>news</strong><br />';
	src += '<em>Displays current cmxcmd news and updates</em><br /><br />';

	src += '<strong>ref</strong><br />';
	src += '<em>Displays the cmxcmd command reference</em><br /><br />';

        src += '<strong>register</strong><br />';
        src += 'Attributes: <em>&lt;username&gt; &lt;email&gt; &lt;password&gt;</em><br />';
        src += '<em>Allows new users to register with contactmatrix</em><br /><br />';

	src += '<strong>savenotes</strong><br />';
	src += '<strong>sn</strong><br />';
	src += '<em>Saves the updated notes</em><br /><br />';

	src += '<strong>search</strong><br />';
	src += '<strong>s</strong><br />';
	src += '<em>Searches the user\'s contactmatrix database</em><br /><br />';

        src += '<strong>searchresults</strong><br />';
        src += '<strong>sr</strong><br />';
        src += '<em>Restores the most recent search results</em><br /><br />';

        src += '<strong>up</strong><br />';
        src += '<em>Moves up to the parent of the currently displayed item.<br />' +
                'When viewing fields, notes or field notes up will move up to the<br />' +
                'field\'s/note\'s parent entry. When viewing entries, it loads the<br />' +
                'home page</em><br /><br />';
	
	src += '<br /><br />';
	
	divInfo.innerHTML = "CMXCMD Command Reference";

	return src;
}

var h_gettingstarted = function()
{
	var src = '';
	var divInfo = document.getElementById("divInfo");
	
	src += 'Getting Started<br /><br /><br />';
	src += 'If you haven\'t created a cmx account yet, use the gui command to<br />';
	src += 'enter the graphical version of contactmatrix, register, and activate your account<br />';
	src += 'then to return to cmxcmd, enter :cmd into the gui search textbox <br />';
	src += 'and hit the search button<br /><br />';
	src += 'Contactmatrix was originally designed as a bookmark/contacts manager.<br />';
	src += 'The idea was to allow the user to create entries within a <em>database</em>.<br />';
	src += 'Two types of entries can be created - standard entries and <em>notes</em><br />';
	src += 'entries. Standard entries contain any number of fields. Fields are created<br />';
	src += 'quickly and easily managed by the user. This allows the user to define<br />';
	src += 'whatever field/value sets they want for each entry.<br />';
	src += 'Even standard entries can have \'entry notes\' associated with them,<br />';
	src += 'but the notes are only visible using the <strong>entrynotes</strong><br />';
	src += 'command (refer to the command reference <strong>ref</strong> for more<br />';
	src += 'information)';
	src += '<br /><br />';
	src += 'Entries are accessed by either searching through the database or listing<br />';
	src += 'the most recently viewed entries. Both entries and fields can be called<br />';
	src += 'by their unique identifiers. For a complete reference of the commands<br />';
	src += 'available in cmxcmd, use:<br /><br />ref';
	src += '<br /><br />';
	src += 'Every time a command is executed, it is added to a history queue (up to<br />';
	src += '100 history items, before the oldest one falls away). This history can be<br />';
	src += 'accessed using the <strong>up</strong> and <strong>down</strong> arrows.';
	
	divInfo.innerHTML = "Getting Started With CMXCMD";

	return src;
}

var h_news = function()
{
	var src = '';
	var divInfo = document.getElementById("divInfo");

    src += '<strong>2008:11:24 &nbsp; Access Methods</strong><br />';
    src += 'I have finished updating the way entries and fields are accessed.<br />';
    src += 'These changes will have the biggest impact on larger cmx databases,<br />';
    src += 'Or in databases with many users accessing them.<br />';
    src += 'Entries are accessed via user defined aliases and fields are specified<br />';
    src += 'using indexes, but these are specific to the current entry, and not<br />';
    src += 'database wide.';
    src += '<br /><br />';
    
    src += '<strong>2008:02:05 &nbsp; Help System</strong><br />';
    src += 'The help system is finally being fleshed out more - at least for the cmxcmd.';
    src += '<br /><br />';

	src += '<strong>2007:17:11 &nbsp; User Experience</strong><br />';
	src += 'I have been working on the \'user experience\', trying to improve the<br />';
	src += 'intuitiveness of the cmxcmd. I would like to get it to a point where<br />';
	src += 'users can actually learn how to use cmxcmd simply by - trying to use it.<br />';
	src += 'This means using error messages as quick help references, and displaying<br />';
	src += 'brief help when certain tasks are performed. But I also have to be sure<br />';
	src += 'that these do not become obnoxious to experienced cmxcmd users.<br /><br />';

	src += '<strong>2007:15:11 &nbsp; Info Bar</strong><br />';
	src += 'The information bar has been added to the cmxcmd. This very news page<br />';
	src += 'has also been added to cmxcmd.';
	
	divInfo.innerHTML = "CMXCMD News";

	return src;
}
