$.fn.zoomtabs = function (zoomPercent, easing) {
        if (!zoomPercent) zoomPercent = 10;
        var timer = null;
        var currentTab = -1;
        var animated = true;
        return this.each(function () {
            var $zoomtab = $(this);
            var $tabs = $zoomtab.find('.tabs');
            
            var height = $tabs.height();
            
            var panelIds = $tabs.find('li').map(function () {
                return $(this).attr('href');
            }).get().join(',');
            
            $zoomtab.find('> div').scrollTop(0);
            
            var $panels = $(panelIds);
            var images = [];
            
            $panels.each(function () {
                var $panel = $(this),
                    bg = ($panel.css('backgroundImage') || "").match(/url\s*\(["']*(.*?)['"]*\)/),
                    img = null;
                
                if (bg !== null && bg.length && bg.length > 0) {
                    bg = bg[1];
                    img = new Image();
                    
                    $panel.find('*').wrap('<div style="position: relative; z-index: 2;" />');                    
                    $panel.css('backgroundImage', 'none');
                    
                    $(img).load(function () {
                        var w = this.width / 10;
                        var wIn = w / 100 * zoomPercent;
                        var h = this.height / 10;
                        var hIn = h / 100 * zoomPercent;
                        var top = 0;
                        
                        var fullView = {
                            height: h + 'em',
                            width: w + 'em',
                            top: top,
                            left: 0
                        };
                                                
                        var zoomView = {
                            height: (h + hIn) + 'em',
                            width: (w + wIn) + 'em',
                            top: top,
                            left: '-' + (wIn / 2) + 'em'
                        };
                        
                        $(this).data('fullView', fullView).data('zoomView', zoomView).css(zoomView);

                    }).prependTo($panel).css({'position' : 'absolute', 'top' : 0, 'left' : 0 }).attr('src', bg);
                    
                    images.push(img);
                }
            });
            
                     
            //$tabs.height(0).hide(); // have to manually set the initial state to get it animate properly.
            
            // this causes opear to render the images with zero height and width for the hidden image
            $panels.hide().filter(':first').show();
            var speed = 200;
            
            var hoverIntent = null;
            $tabs.find('li.item').hover(function () {
                clearTimeout(hoverIntent);
                var el = this;
                
                $tabs.find('li.item').removeClass('clicked');
                
                $(el).addClass('clicked');
                hoverIntent = setTimeout(function () {
                    $panels.hide().filter($(el).attr("href")).show();
                }, 0);
                animated  = false;
                clearTimeout(timer);
            }, function () {
            	if(animated == false)
            	{
	            	clearTimeout(hoverIntent);
	                currentTab = $tabs.find('li.item').index(this);
	                timer = setTimeout(rotate, 3000);
	                animated = true;
            	}   
            }).click(function () {
            	$(this).addClass('clicked');
            	return false;
            });
            
            $tabs.find('li:first').addClass('clicked');
            
            
            function rotate()
            {
            	currentTab = currentTab == 3 ? 0 : currentTab + 1;
            	
            	var tabs = $tabs.find('li.item');
            	$tabs.find('li.item').removeClass('clicked');
            	
            	$panels.hide().filter($(tabs[currentTab]).attr("href")).show();
            	$(tabs[currentTab]).addClass('clicked');
            	
            	timer = setTimeout(rotate, 3000);
            }
            
            timer = setTimeout(rotate, 3000);
            
        });
    };

