// This is far from a polished solution.  It's more of an itch-scratching in progress.
// If it doesn't scratch yours, then improve it... and send me the results.
// Current features:
//    + Keep relative time stamps up-to-date
//    + Change reply to a "quick" (AJAX-style) reply link for all messages (CTRL+click to use old message form)
//    + Change modify to a "quick" (AJAX-style) modify link for all messages (CTRL+click to use old message form)
//    + Change new to a "quick" (AJAX-style) new thread link for forums that support it
//    + Multiple signatures for Quick Reply
//    + Shortcut keys for moving between posts and threads
//    + WYSIWYG post composition
//
// You'll note that the code itself is fairly brief. This is because the bulk of the code is loaded from a file stored on the Code Project server. 
// This is done to allow me to fix bugs or add small features without requiring everyone to update to a new version of this script. 
//
// Latest Changes:
// [6/1/2005]
//    + Ensure posts are visible when first expanded
//    + Fixed extraction of subject and usernames
//    + Added Linkification buttons
//    + Rework quick reply form (takes up less space)
// [6/6/2005]
//    + Initial sig rotation implementation
//    + Improved tab order of quick reply form
// [6/7/2005]
//    + Improved random sig selection
// [6/15/2005]
//    + Fix problem where Re: wouldn't be added to some reply subjects.
// [8/25/2005]
//    + Added support for new message board feature (message type)
//    + Added "Quick thread" feature
// [8/26/2005]
//    + Fixed problems when running under Deer Park Alpha 2
// [11/30/2005]
//    + Fixed problems with Firefox 1.5
// [2/1/2006]
//    + Added preferences for editing format, sig state
// [5/19/2006]
//    + New preferences system
// [5/25/2006]
//    + Fixed code that retrieves username and email
//    + Added non-www domain names to default include list
// [7/12/2006]
//    + Work around "issues" w/ Fx 2 Beta 1
// [8/2/2006]
//    + Retrieve username and email every time - avoid annoying problems with cached credentials.
// [7/4/2007]		- David Stone
//    + Move prefs into global storage (places a minimum requirement that the user uses Fx 2.0)
//		+ Moved script details into their own storage rather than prefs...which is a silly place to put them
//		+ Added ForumWatch functionality to watch forums in the sidebar (which we moved to the right)
//		+ Added QuickBio functionality to load a small bio-preview pane when you click on someone's username
//		+ Slight speed improvements in minor areas
//		+ Added a dependency on jQuery and the Dimensions and Interface plugin
//		+ New plugin architecture that we're not really doing anything with just yet. :-p
//		+ This will be the last update to this file, as we've achieved bootstrapping nirvana and shouldn't ever have to update this file again
// [12/10/2007]
//    + Updated paths to work with CodeProject 2
//    + Killed old preferences system
//    + Misc. load-speed enhancements.
//
// - Joshua Heyer, May 24th, 2006
//   shognine@gmail.com
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.6.4 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "CPhog", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          CPhog
// @author        Joshua Heyer
// @namespace  	http://shog9.com/greasemonkey/scripts/
// @description   deal with things that annoy me on the Code Project website
// @version        1.12.10
// @include       http://*.codeproject.com/*
// @include       http://*.codetools.com/*
// @include       http://*.thecodeproject.com/*
// @include       http://codeproject.com/*
// @include       http://codetools.com/*
// @include       http://thecodeproject.com/*
// ==/UserScript==
//

// change these before release
var details = 
{
	Version: 11210,
	ScriptPath: "http://www.codeproject.com/script/Membership/Uploads/20101/",
	ImagePath: "http://www.codeproject.com/script/Membership/Uploads/20101/",
	ScriptExt: ".js.txt",
	StyleExt: ".css.txt"
};

// no sense loading anything if this isn't even a forum - do a quick test for a forum table
var forumTable = document.evaluate("//table[@id='ForumTable']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if ( forumTable && forumTable.snapshotLength > 0 )
{
   // hold scripts so that they can all be inserted at once
   var scripts = document.createDocumentFragment();
   
	// Create the CPhog object with our details JSON
   var detailX = document.createElement("script");
   detailX.innerHTML = "var cphog = " + details.toSource();
   detailX.language = "javascript";
   scripts.appendChild(detailX);
	
	// *THE* script
   var greaseSrc = details.ScriptPath + "FreshGrease" + details.ScriptExt;
   
   // load our code
   var theScript = document.createElement("script");
   theScript.src = greaseSrc;
   theScript.language = "javascript";
   scripts.appendChild(theScript);
   
   document.body.insertBefore(scripts, document.body.firstChild);
}
