jQuery.ready
Drupal behaviors are used if your JavaScript needs to be executed on page load and after an AJAX request (some new elements added in your document/html).
Drupal.behaviors.yourmodulename = {
attach: function (context, settings) {
// Code to be run on page load, and
// on ajax load added here
}
};
yourmodulename: This is your namespace and should be unique. For example, this is typically the name of your module, but it isn't mandatory.
context: This is actually really really cool, on page load the context will contain the entire document and after an AJAX request will have all the newly loaded elements. This way you can treat content that is loaded in via AJAX differently than others.
settings: This contains information passed on to JavaScript via PHP, it is similar to accessing it via Drupal.settings.