$(document).ready(function(){
	
	/****************************************
	* Config								*
	****************************************/
	var baseUrl = 'http://www.text-team.de/';
	
	
	/****************************************
	* Internet Explorer Fixes				*
	****************************************/		
		if ($.browser.msie) {
			// Für alle IE Versionen:
			$('p + p, p + ul, ul + p').css({ 'margin-top': '1.5em' });
			$('#navigation ul li:last-child').css({ 'border-right': '1px solid rgb(220, 220, 220)' });
			$('#footer ul li:last-child').css({ 'background': 'none', 'margin': '0', 'padding': '0' });
			$('.news-list-item').css({
				'padding': '20px 0',
				'border-bottom': '1px solid rgb(220, 220, 220)'
			});
			$('.news-list-item:first-child').css({
				'padding': '0 0 20px',
				'border-bottom': '1px solid rgb(220, 220, 220)'
			});
			$('.news-list-item:last-child').css({ 'border': 'none' });
			
			// Zusätzlich für IE6 und drunter:
			if (parseInt($.browser.version) <= 6) {
				var imgSrc = $('#news a img').attr('src');
				$('#news a img').attr('src', baseUrl + imgSrc);
				$('#news').supersleight();
				$('#content').css('background', 'rgb(255, 255, 255)');
			}
		}
	
	
	/****************************************
	* DOM Manipulation						*
	****************************************/
	/* Externe Links Icon */
		$('#text a.external-link-new-window, #text a.external-link').append('<span class="extIcon"></span>');
	
	
	/****************************************
	* Fancybox								*
	****************************************/
	/* Bilder */
		$('img[alt*="fancyimage"]').parents('a').fancybox({ 'centerOnScroll': true });
		
	/* AJAX */
		$('a[title*="fancyiframe"]').fancybox({
			'type': 'iframe',
			'width': 750,
			'height': 535,
			'autoScale': false,
			'titleShow': false,
			'hideOnContentClick': true,
			'centerOnScroll': true
		});
	
	
	/****************************************
	* Animationen							*
	****************************************/
	/* Navigation Animation */
		$('#navigation ul li[class!=active] a').hover(function(){
			$(this).stop().animate({ 'backgroundColor': 'rgb(230, 0, 40)', 'color': 'rgb(255, 255, 255)' }, 500);
		}, function(){
			$(this).stop().animate({ 'backgroundColor': 'rgb(255, 255, 255)', 'color': 'rgb(115, 115, 115)' }, 500);
		});
		
	/* subNavigation Animation */
		$('#subNavigation ul li a').hover(function(){
			$(this).stop().animate({ 'backgroundColor': 'rgb(240, 240, 240)' }, 500);
		}, function(){
			$(this).stop().animate({ 'backgroundColor': 'rgb(220, 220, 220)' }, 500);
		});
		
	/* Anfragebutton Animation */
		$('#contact a, .tx-powermail-pi1 .tx_powermail_pi1_fieldwrap_html_submit input, .tx-powermail-pi1_mandatory input, #text p a.ctaButton').hover(function(){
			$(this).stop().animate({ 'backgroundColor': 'rgb(255, 255, 255)', 'color': 'rgb(115, 115, 115)' }, 500);
		}, function(){
			$(this).stop().animate({ 'backgroundColor': 'rgb(230, 0, 40)', 'color': 'rgb(255, 255, 255)' }, 500);
		});
		
	/* Textlink Animation */
		if ($.browser.msie && parseInt($.browser.version) <= 6) {
			$('#text p a').css({ 'background': 'rgb(255, 255, 255)', 'color': 'rgb(230, 0, 40)' });
			$('#text p a').hover(function(){
				$(this).animate({ 'backgroundColor': 'rgb(230, 0, 40)', 'color': 'rgb(255, 255, 255)' }, 250);			
			}, function(){
				$(this).animate({ 'backgroundColor': 'rgb(255, 255, 255)', 'color': 'rgb(230, 0, 40)' }, 250);
			});
		} else {
			$('#text p a[class!=ctaButton]').css({ 'background': 'url(\'fileadmin/template/images/link-background.gif\') repeat-x 0 1.5em' });
			$('#text p a[class!=ctaButton]').hover(function(){
				var i = 1.5;
				var r = 230;
				var g = 0;
				var b = 40;
				
				$(this).stop().animate({}, 0);
				
				while (i > 0) {
					$(this).animate({ 'background-position': '0 ' + i + 'em', 'color': 'rgb(' + r + ', ' + g + ', ' + b + ')' }, 1);
					r = r + 2;
					g = g + 17;
					b = b + 15;
					i = i - 0.1;
				}
				
			}, function(){
				var i = 0;
				var r = 255;
				var g = 255;
				var b = 255;
				
				$(this).stop().animate({}, 0);
				
				while (i <= 1.5) {
					$(this).animate({ 'background-position': '0 ' + i + 'em', 'color': 'rgb(' + r + ', ' + g + ', ' + b + ')' }, 1);
					r = r - 2;
					g = g - 17;
					b = b - 15;
					i = i + 0.1;
				}
				
			});
		}		
});