/**
 * Javascript - jQuery enabled
 * 
 * @package WPFramework
 * @subpackage Media
 */


// Dropdown menu using superfish
jQuery(document).ready(function($) {
	
	
	$('.blink_liste').hover(
		function() { $(this).addClass('slide_hover'); },
		function() { $(this).removeClass('slide_hover'); }
	);
	$('.blink_head').hover(
		function() { $(this).css('border-left-color','#f6e51e'); $('a', this).css('background','#f6e51e'); },
		function() { $(this).css('border-left-color','#fff'); $('a', this).css('background','#fff'); }
	);
	$('.blink_blue a').hover(
		function() { $(this).parent().addClass('blink_blue_hover'); },
		function() { $(this).parent().removeClass('blink_blue_hover'); }
	);
	

	
	$('#rotation').innerfade({
		animationtype:    'slideOver',
		speed: 'slow',
		timeout: 5000,
		type: 'sequence',
		containerheight: '300px',
		leaveclass: '.themen_mehr',
		mainclass: '.themen_rotate'
	});

	
	$('area[rel*=facebox]').facebox();
	$('a[rel*=facebox]').facebox();
	
	$('.fb_form_submit').live("mouseover", function() {
		$(this).css('border-left-color','#4173A1'); 
	});
	$('.fb_form_submit').live("mouseout", function() {
		$(this).css('border-left-color','#777877'); 
	});
	$('.fb_close').live("mouseover", function() {
		$(this).css('border-left-color','#4173A1'); 
	});
	$('.fb_close').live("mouseout", function() {
		$(this).css('border-left-color','#777877'); 
	});
	

	$('form.search').submit(function() {
		window.location = '/search/' + $('input', this).val();
		return false;
	});
	$('a.search').click(function() {
		window.location = '/search/' + $(this).prev('input').val();
	});
	$('input.search').keyup(function(e) {
		if(e.keyCode == 13) {
			window.location = '/search/' + $(this).val();
			return false;
		}
	});
	$('input.search').focus(function() {
		if ($(this).val() == 'Suche ...')
			$(this).val('');
	});
	
	
	
	
	$('.fb_switch').live("click", function () {
		$('.fb_container .fb_scroll:visible').fadeToggle('normal', 'linear', function() {
			$('.fb_container .fb_scroll').not(this).fadeToggle('normal');
		});
	});
	
	
	$('.fb_page_select').live("click", function () {
		selector = $(this).attr("rel");
		$('.fb_container .fb_profil:visible').fadeToggle('normal', 'linear', function() {
			$('.fb_container .fb_'+selector+' ').fadeToggle('normal');
		});
		
		$('.fb_container .fb_icons').fadeToggle('normal', 'linear', function() {
			$('.fb_container .fb_icon').removeClass('hide');
			$('.fb_container .fb_selector_'+selector+' ').addClass('hide');
			$('.fb_container .fb_icons').fadeToggle('normal');
		});

	});


	
	
	
	$("#presse-menu dd:not(:first)").hide();
	if ( $('.toggler_current').length > 0) {
		$("#presse-menu dd:visible").hide();
		$('.toggler_current').next().show();
	};
	$("#presse-menu dt").click(function(){
		if ($(this).next().is(':hidden')) {
			$("#presse-menu dd:visible").slideUp("slow");
			$(this).next().slideDown("slow", function() { $(this).css('display','inline'); } );
		};
		return false;
	});


	$('.mdep-finder_select1').hover(
		function(){	$('.mdep-finder_thema').hide(); $('ul',this).slideDown(100);  },
		function(){	$('ul',this).slideUp(100); $('.mdep-finder_thema').show();	}
	);
	
	$('.mdep-finder_select2').hover(
		function(){	$('ul',this).slideDown(100); },
		function(){	$('ul',this).slideUp(100); }
	);


	$('.mdep_carousel').infiniteCarousel();
	
	
	
	$('area').hover(
		function(){	selector = $(this).attr("class"); $('li.'+selector).fadeIn(100); $('.blink2 li[rel='+selector+']').addClass('blink_blue_hover'); },
		function(){	$('.map_hovers li').fadeOut(100);  $('.blink2 .blink_blue').removeClass('blink_blue_hover'); }
	);
	
	$('.blink2 .blink_blue > a').hover(
		function(){	selector = $(this).parent().attr("rel"); $('li.'+selector).fadeIn(100); },
		function(){	$('.map_hovers li').fadeOut(100); }	
	);

	$("[title]").tooltip({ 
		track: true,
		delay: 1500,
		showURL: false
	});
	
	$('.truncateText').truncateText();
	
	$('.fb_form_submit a').live("click", function() {
		validate_error =0;
		var params = {send: 1};
		params['click'] = $(this).attr('class');
		
		$('form.ajaxform > *').each(function() {
			$(this).removeClass('form_required_marker');
			if ($(this).hasClass('form_required') && !$(this).val() )
			{
				$(this).addClass('form_required_marker');
				validate_error =1;
			}
			params[$(this).attr('name')] = $(this).val();
		});
		
		
		
		if (validate_error) {
			$('.ajaxformRespond').html('<span class="error">Bitte f&uuml;hlen Sie alle Pflichtfelder aus!</span>');
			$('.ajaxformRespond:hidden').fadeIn(200);
		}
		else		
			$.post('/formular', params, function(txt) {
				$('.ajaxformRespond').html(txt);
				$('.ajaxformRespond:hidden').fadeIn(200);
			});
	});
	
	
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
};


function openMdEP(url) {
	jQuery.facebox(function() { 
		jQuery.get(url, function(data) {
			jQuery.facebox(data);
		});
	});
};



$(function(){
	if ( !jQuery.browser.msie ) return;
	$('object, embed, applet').each(function() {
		this.outerHTML = this.outerHTML;
	});
});