jQuery.expr[':'].regex = function(elem, index, match) {
   var matchParams = match[3].split(','),
   validLabels = /^(data|css):/,
   attr = {
      method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr',
      property: matchParams.shift().replace(validLabels,'')
   },
   regexFlags = 'ig',
   regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
   return regex.test(jQuery(elem)[attr.method](attr.property));
}

$(document).ready(function(){
    $("div:regex(id, post_message_) img").css('max-width','640px');
});

$(window).load(function(){
    $("div:regex(id, post_message_) img").each(function(n,image){
	    if ($(image).width() >= 640) {
	        image.width = 640;
	        $(image).css('cursor','pointer').click(function(){
	            jQuery.slimbox(image.src);
	        });	
	    }
   });
});


