﻿(function($){	$.fn.swapContent = function(settings)	{		// Config Array		var config = 		{			contentStr:			'-content',			zoom: 				false,			container:  		'',			contentContainer:	''		}				// Update the config array with the settings passed in the function		if (settings) { $.extend(config, settings); }				var id;		var defaultID = new Array();				var ZOOM_ITEM 			= $('.zoom', config.container);		var SLIDER_HEIGHT		= $('.slider-bound', config.container).height();		var SLIDE_ITEM_WIDTH 	= $('.slideItem', config.container).width();					ZOOM_ITEM.css({opacity: "0"}).show();				// Slider Item Hover		this.hover(function()		{			// Add Hand Cursor			$(this).css({cursor: "pointer"});						// Position used to properly position popup if zoom is setup			if (config.zoom)			{				var holder_pos 	= $(this).parent().position();				var item_pos 	= $(this).position();				createZoom($(this).html(), holder_pos, item_pos);			}						// Hide all content slider item content holders			$('.slider-content', config.contentContainer).hide();						// The id allows to swap the corresponding content			id = $(this).attr('id');			$('#' + id + '-content').show();						// The defaultID allows to swap back to the default content			defaultID = id.split('-');			$('#' + defaultID[0] + '-content').hide();		}, function()		{			if (!config.zoom)			{				var id = $(this).attr('id');				$('#' + id + '-content').hide();								var defaultID = id.split('-');				$('#' + defaultID[0] + '-content').show();			}		});				// Body click will reset the content		// JS can be slow in certain browsers and if scroll too fast mouseout will not fire		$('body').click(function()		{			if (defaultID.length > 0)			{				resetContent();			}		});				// Create the zoom item 		function createZoom(html, hPos, iPos)		{						ZOOM_ITEM.html(html).stop().show().css({opacity: "0"}).animate({opacity: "1"});						var startLeft = hPos.left + 18 + iPos.left;			var finalLeft = startLeft - ((ZOOM_ITEM.width() - SLIDE_ITEM_WIDTH) / 2);						var finalTop = 0 - ((ZOOM_ITEM.height() - SLIDER_HEIGHT) / 2);			ZOOM_ITEM.parent().css({left: finalLeft + 'px', top: finalTop + 'px'});		}				if (config.zoom)		{			ZOOM_ITEM.hover(function()			{			}, function()			{				resetContent();			});		}				function resetContent()		{				$('#' + id + '-content').hide();			$('#' + defaultID[0] + '-content').show();			ZOOM_ITEM.css({opacity: "0"}).hide();		}	};	})(jQuery);