Added code from the Joomla! Framework Sample Aplication by @dbhurley