/* =========================================================
// jquery.slider.js
// ========================================================= */

(function($) 
{
	$.fn.fadeSlider = function(options) 
    {
        return this.each(function() 
        {   
            $.fadeSlider(this, options);
        });
    };

    $.fadeSlider = function(container, options) 
    {
        var settings = {
            'containerheight':  'auto',
            'runningclass':     'innerfade'
	    };
        
        var elements = $(container).children();
        
        if (elements.length > 1) 
        {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) 
            {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            
            setTimeout(function() 
            {
            	$.fadeSlider.next(elements, 1, true);
            }, 9000);

            
            $(elements[0]).show();
        }
    };
    
    $.fn.manualGotoSlide = function (highlight)
    {
    	var elements = this.children();
    	$.fadeSlider.next(elements, highlight, false);
    	
    };
    
    $.fadeSlider.next = function(elements, current, continueAutoSlide) 
    {
        var last = $('div.controllBar ul li.active').attr("rel");
    	
        if (last != current)
        {
        	$(elements[last]).fadeOut(600);
        	$(elements[current]).fadeIn(600, function() { removeFilter($(this)[0]); });
        }
        
        $('div.controllBar ul li').removeClass("active");
        $('div.controllBar ul li[rel="' + current + '"]').addClass("active");
        
        setTimeout((function() 
        {
        	if (continueAutoSlide)
            {
	            if ((current + 1) < elements.length) 
	            {
	            	current = current + 1;
	            } 
	            else 
	            {
	            	current = 0;
	            }
	            
	            $.fadeSlider.next(elements, current, continueAutoSlide);
            }
                		
        }), 9000);
        

        
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}

