$(document).ready(function(){
	function replaceLinkWithVideo() {
		var $that = $(this);
		var txt = $(this).html();
		var vid = txt.match(/((\?v=)(\w[\w|-]*))/g);
		
		var vidWidth = 425;
		var vidHeight = 344;
		
		var e1 = '<object width="' + vidWidth + '" height="' + vidHeight + '"><param name="movie" value="http://www.youtube.com/v/';
		var e2 = '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess"'+'value="always"></param><em'+'bed src="http://www.youtube.com/v/';
		var e3 = '&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+vidWidth+'"'+' height="'+vidHeight+'"></embed></object> ';
		
		$.each(vid, function(i){
			var ytid = this.replace(/\?v=/,'');
			$that.html(""+e1+ytid+e2+ytid+e3).attr("style","text-align: center;");
		});
	}
	
	$('.entryContent p:contains("youtube.com/watch")').each(replaceLinkWithVideo);
});
