The basics of theming in the developer guide
The 9-piece image border is crucial for proper themeing
Themes can have a radical impact on performance, you should review this if your theme seems to have such an impact