// Navigation

$(document).ready(function(){ 
	$('a.hover img').hover(function() {
		$(this).attr('src', '_images/hover/' + $(this).attr('id') + '_.gif'); },
	function() {
		$(this).attr('src', '_images/hover/' + $(this).attr('id') + '.gif'); }); 
});

// Home page

$(document).ready(function(){ 
	$('#books a img').hover(function() {
		$(this).attr('src', '_furniture/books/' + $(this).attr('id') + '/featured_.jpg'); },
	function() {
		$(this).attr('src', '_furniture/books/' + $(this).attr('id') + '/featured.jpg'); });
});

// Book categories

$(document).ready(function(){ 
	$('#categories a img').hover(function() {
		$('#all').attr('src', '_furniture/bookshapes/' + $(this).attr('id') + '.gif'); },
	function() {
		$('#all').attr('src', '_furniture/bookshapes/allbooks.gif'); });
});

// Book titles in a category

$(document).ready(function(){ 
	$('#results a img').hover(function() {
		$('#nothing').attr('src', '_furniture/books/' + $(this).attr('id') + '/title.gif'); },
	function() {
		$('#nothing').attr('src', '_images/blank.gif'); });
});

// Medium images lightbox

$(function() {
    $('#mediums li a').lightBox();
});

// It's not from jQuery yet but we're going to add it here anyway!

function calcChar(fields,counters,maxLength) {
 clipped = false
 maxLength = maxLength
 
 if (fields.value.length > maxLength) {
   fields.value = fields.value.substring(0,maxLength)
   charleft = 0
   clipped = true
 } else {
   charleft = maxLength - fields.value.length
 }
   counters.value = charleft
   return clipped
}