Cufon.replace('.page-title');

$(document).ready(function() {
	
	// fix html5 placeholder attr in older browsers
	$('[placeholder]').focus(function() {
		var input = $(this);
		if (input.val() == input.attr('placeholder')) {
			input.val('');
			input.removeClass('placeholder');
		}
	}).blur(function() {
		var input = $(this);
		if (input.val() == '' || input.val() == input.attr('placeholder')) {
			input.addClass('placeholder');
			input.val(input.attr('placeholder'));
		}
	}).blur();
	$('[placeholder]').parents('form').submit(function() {
		$(this).find('[placeholder]').each(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
				input.val('');
			}
		})
	});
	
	// add pesky popular posts widget description ;)
	$('<p class="widget-desc">The posts that readers love the most</p>').prependTo('#popular-posts-widget ul');
	
	var $d = $('.coursebookm').dialog({
			modal: true,
			autoOpen: false,
			width: 660
		});
	
	$('.coursebooklink').click(function(e) {
	 	e.preventDefault();
		$d.dialog('open');
	});
	
	$('.coursebookm .gfield_radio label').click(function() {
		$(this).parent().find(":radio").attr("checked",true);
	});
	
	$('#buy-book, #readers-login').append('<span class="hover"></span>').each(function() {
		var $span = $('> span.hover', this).css('opacity', 0);
		$(this).hover(function() {
			$span.stop().fadeTo(300,1);
		}, function() {
			$span.stop().fadeTo(300,0);
		});
	});
	
	// overwrite handling of menus
	$('#menu li ul').css({left: '-10px'}).hide();
	$('#menu li').hover(function() {
		$('ul', this).stop(true, true).slideDown(300);
	}, function() {
		$('ul', this).stop(true, true).slideUp(300);
	});
});
