jQuery.fn.homeImages = function(settings) 
{
	return this.each( function()//do it for each matched element
	{
		
		settings = jQuery.extend(//provide default settings
		{
			timeout: 800
		} , settings);

		var parent = $(this);
		var images = new Array;
		var defImage = $("#defaultimage").attr('rel');
		var preloadImage = new Image();

		//get all images
		$(".thumbs a", parent).each(function(i)
		{
			images.push($(this).attr('rel'));
		});
		preloadImage.src = defImage;
		$(preloadImage).bind('load',function ()
		{
			$('.nextImg',parent).css('background-image','url(' + preloadImage.src + ')').width(preloadImage.width).height(preloadImage.height).css('opacity','0');
			$('.mainimage',parent).animate({width:preloadImage.width,height:preloadImage.height},settings.timeout,function(e) {
				$('.mainimage',parent).css('background-image','url(' + preloadImage.src + ')');
				$('.nextImg',parent).css('opacity','1');
			  });
			$('.nextImg',parent).animate({opacity:'1'},settings.timeout);
		});
		$(".thumbs a img").hover(function() {
			preloadImage.src = $(this.parentNode).attr('rel');
			},
			function() {
			preloadImage.src = defImage;
			}
		);
	});
};


