$(document).ready(function () {

	var swfColor;
	var swfText;
	var swfWidth;
	var swtHeight;

	// Replace Headers with Sifr Font
    $.fn.sifr = function() {
    	$(this).css('float', 'left');
    	swfColor = 'ffffff';
    	swfText = $(this).text().toUpperCase();
    	swfWidth = $(this).width();
    	swtHeight = $(this).height();
	    $(this).flash({
			flashvars: 'textcolor='+swfColor+'&txt='+encodeURIComponent(swfText)+'&w='+swfWidth+'&h='+swtHeight,
			swf: '/wp-content/themes/djones/swf/titles.swf',
			width: swfWidth,
			height: swtHeight,
			wmode: 'transparent'
		});
    	$(this).css('float', 'none');
    	$(this).append('<span class="altText">'+swfText+'</span>');
	}
	$('.page #content h1, .page #content h2, .page #content h3, .page #content h4').each(function() {
		$(this).sifr();
	});

	// Use label text as the default value of the input field
	$('#sidebar .mc_merge_var input').each(function(i) {
		this.defaultValue = $(this).siblings('label').text();
		$(this).siblings('br').remove();
		$(this).siblings('label').hide();
	});
	$('#sidebar .mc_merge_var input, #sharecomment').focus(function() {
		if(this.value == this.defaultValue) {
			this.value = '';
		}
	}).blur(function() {
		if(!this.value.length) {
			this.value = this.defaultValue;
		}
	});
	$('#commentform').submit(function(){
		var comment = document.getElementById('sharecomment');
		if ($('#sharecomment').val() == comment.defaultValue) {
			alert('Please enter a comment first.');
			return false;
		}
	});
	
	//adding a BR to the caption of ties titles
	$('.page-id-1151 .caption').css('font-size','20px');

});
