$(document).ready( function() {
							
var moreLink = '<a class="readMore" href="#">more</a>';





// Add "More" Link to anything with a div of .more in it
$('.more').each( function(i) {
	$(this).parent().append(moreLink);
})


// Show/hide .more
$('.readMore').live("click", function() {
	
	var cLink = $(this);
	var txt = cLink.text();
	var par = cLink.parent();
	var more = par.find('.more');
				 
	cLink.removeAttr("style");
	
	if ( !cLink.hasClass('open') ) {
		cLink.data("orgTxt", txt);
		if (more.length) {
			more.slideDown(200);
			cLink
				.text("Less")
				.css("background-position", "0px -88px")
				.addClass("open");
		
			return false;
		}
		else {
			return false;
		}
	}
	else {
		more.slideUp(200);
		cLink
			.text( cLink.data("orgTxt") )
			.removeClass("open");
		return false;
	}

});




// Search stuff
$('#s').focus( function() {
	$(this).val('').css('color', '#333');
});







// #################################################################
// ### Modal Stuff #################################################
// #################################################################

$('.modal').click(function(e) {
	var img = $(this).attr("href");
	var alt = $(this).find('img').attr('alt');
	var word = $('#wod .term').text();
	$('body').append('<div id="overlay" style="display:none;"></div><div id="modal" style="display:none;"><a href="javascript:void(0)"><span>X</span></a></div>');
	$('#modal').append('<img src="'+img+'" alt="'+alt+'" />').append('<p>'+word+'</p>');
	$('#overlay').fadeIn(100, function() {
		$('#modal').slideDown(100);
	});
	return false;
});


$('#modal a').live("click", function(e) {
	$("#modal").slideUp(100, function() {
		$("#overlay").fadeOut(100).remove();
		$(this).remove();						  
	});
	return false;
});

$("#overlay").live("click", function() {
	$("#modal").slideUp(100, function() {
		$("#overlay").fadeOut(100).remove();
		$(this).remove();						  
	});
});

$("html").live("keyup", function(event) {
	if ( event.keyCode == 27 ) { // escape key
		$("#modal").slideUp(100, function() {
			$("#overlay").fadeOut(100).remove();
			$(this).remove();							  
		});
	}
});
// #################################################################
// #################################################################
// #################################################################



}); // end doc ready
