Create jQuery function

(function($) {
jQuery.fn.doSomething = function() {
return this.each(function() {
var $this = $(this);
$this.click(function(event) {
event.preventDefault();
// Your function goes here
});
});
};
})(jQuery);

$(document).ready(function() {
$('#div1').doSomething();
$('#div2').doSomething();
});

Simple login window popup system

var _initialize = function () {
_doc = jQuery(document);
_win = jQuery(window);
_docHeight = _doc.height();
_winHeight = _win.height();
_winWidth = _win.width();
_overlay = jQuery('#myoverlay');
_logw = jQuery('#loginWindow');
};
var _center = function (w, h) { //center aligning of window
return [(_docHeight > _winHeight) ? _winWidth/2 - w/2 - 18: _winWidth/2 - w/2, _doc.scrollTop() + _winHeight/2 - h/2];
};
var _show = function(){
_overlay.show();
var pos = _center(_logw.width(), _logw.height());
_logw.css({left: pos[0] + 'px',top: pos[1] + 'px'}).show();
};
var _hide= function(){
_logw.hide();
_overlay.hide();
};
var _login= function(){
_initialize();
if($('.notify').text().length > 0 || _logw.hasClass('passwordRemindForm')) {
_show();
}
var mouse_is_inside = false;
$('.openLogin').click(function(){
_show(); return false
});
_logw.live({mouseenter:function(){
mouse_is_inside=true;
}, mouseleave:function(){
mouse_is_inside=false;
}
});
$('body').click(function(){
if(!mouse_is_inside) {
if (_logw.is(':visible')) {
_hide();
}
}
});
if(_logw.hasClass('passwordRemindForm')) {
$('body').unbind('click');
}
$('.close').live('click', function(){
_hide(); return false;
});
};


$(document).ready(function(){
_login(); //init login popup system
});

Vertical aligning of images

function imgValignCenter(parent) {
var img = $(parent).find('img');
$(img).load(function() {
var wrHeight = $(parent).height();
var imgHeight = $(img).height();
var imgTopPos = (wrHeight - imgHeight)/2;
$(img).css('margin-top', imgTopPos+'px');
});
}

$(document).ready(function(){
$('.parentImgDiv').each(function(){
imgValignCenter($(this));
});
});

Remove http from website url

var url = $('.website a').text();
newurl = url.replace(/^https?:\/\//,'')
var urlarr = newurl.split('/');
if (urlarr.length > 1) newurl = urlarr[0];
$('.website a').text(newurl);