/*
 *
 * Copyright (c) 2006 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */

/*
 * Converts image and link elements to thumbnails
 *
 * @name     jThumb
 * @author   Joan Piedra (http://www.joanpiedra.com)
 * @example  $("a.thumb, img.thumb").thumbs();
 *
 */ 
j$.fn.thumbs = function()
{
	return this.wrap('<div class="thumb-img"><div class="thumb-inner">' + '</div></div>');
}

/*
 * Absolute positions the image in the middle of the thumbnail frame
 *
 * @name     jThumbImg
 * @author   Joan Piedra (http://www.joanpiedra.com)
 * @example  $("a.thumb img, img.thumb").thumbsImg();
 *
 */
j$.fn.thumbsImg = function() {
	return this.each(
		function()
		{
			j$(this).css('position','absolute');
			var thisWidth = j$(this).width();
			var thisHeight = j$(this).height();
			var offsetWidth = parseInt(thisWidth / 2);
			var offsetHeight = parseInt(thisHeight / 2);
			j$(this).css('left','-' + offsetWidth + 'px');
			j$(this).css('top' ,'-' + offsetHeight + 'px');
			j$(this).css('margin-left', '50%' );
			j$(this).css('margin-top', '40%' );
		}
	)
}