This is a template for creating jquery plugins. Also has an example.