/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

// ========================================================= */


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

	$.innerfade = function(container, options) {
		var settings = {
			'speed':            'normal',
			'timeout':          2000,
			'containerheight':  'auto',
			'runningclass':     'innerfade',
			'children':         null
		};
		if (options)
			$.extend(settings, options);
		if (settings.children === null)
			var elements = $(container).children();
		else
			var elements = $(container).children(settings.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();
			};
			this.ifchanger = setTimeout(function() {
				$.innerfade.next(elements, settings, 1, 0);
			}, settings.timeout);
			$(elements[0]).show();
		}
	};

	$.innerfade.next = function(elements, settings, current, last) {
		$(elements[last]).fadeOut(settings.speed);
		$(elements[current]).fadeIn(settings.speed, function() {
			removeFilter($(this)[0]);
		});
		
		if ((current + 1) < elements.length) {
			current = current + 1;
			last = current - 1;
		} else {
			current = 0;
			last = elements.length - 1;
		}
		
		this.ifchanger = setTimeout((function() {
			$.innerfade.next(elements, settings, current, last);
		}), settings.timeout);
	};
})(jQuery);

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

jQuery(document).ready(function() { 
	jQuery('ul#theFeature').innerfade({
		speed: 1000,
		timeout: 8000,
		containerheight: '250px'
	});
		
	jQuery('#mainFeature .links').children('li').children('a').attr('href', 'javascript:void(0);');
	jQuery('#mainFeature .links').children('li').children('a').click(function() {
		clearTimeout(jQuery.innerfade.ifchanger);
		for(i=1;i<5;i++) {
			jQuery('#the'+i+'feature').css("display", "none");
			jQuery('#the'+i+'title').children('a').css("background-color","#226478");
		}
		// if(the_widths[(jQuery(this).attr('rel')-1)]==960) {
		// 	jQuery("#vic").hide();
		// } else {
		// 	jQuery("#vic").show();
		// }
		
		jQuery('#the'+(jQuery(this).attr('rel'))+'title').css("background-color", "#286a7f");
		jQuery('#the'+(jQuery(this).attr('rel'))+'feature').css("display", "block");
	    clearTimeout(jQuery.innerfade.ifchanger);
	});
});