// on DOM ready
$(document).ready(function(){

	// Fancybox
	$("a.zoom").fancybox({ // single fancyboxes
		'overlayColor' 		: '#000',
		'padding'			: 20,
		'transitionIn' 		: 'elastic',
		'transitionOut' 	: 'elastic',
		'titlePosition' 	: 'inside',
		'changeSpeed' 		: 0,
		'overlayOpacity'	: 0.4
	});

	// Accordion Menues
	$('.accordion h4').each(function(){
		 $('.accordion div.teaserwrapper').not(':first').hide();
		 $('.accordion h4:first').addClass('down');
		 $(this).click(function() {
			 if($(this).next().is(':hidden')) {
			 } else {
				window.location.href = $('a', this).attr('href');
				return false;
			 }
		 });
	});

	/*$('.accordion.second h4').each(function(){
		 $('.accordion.second div.teaserwrapper').not(':first').hide();
		 $('.accordion.second h4:first').addClass('down');
	});
	$('.accordion').accordion({
        header: 'h4',
        active: ':first',
        autoheight: true
    });*/

	$('.accordion').accordion({
        header: 'h4',
        active: ':first',
        autoheight: true
    });



	/*$('.accordion.first h4').click(function() {
		if($(this).next().is(':hidden')) {
			$('.accordion.first h4', thisAccordion).removeClass('down');
			$(this).addClass('down');
			var thisAccordion = $(this).closest('.accordion');
			$('div.teaserwrapper', thisAccordion).slideUp('fast');
			$(this).next().slideToggle('fast');
		}
		return false;
	});

	$('.accordion.second h4').click(function() {
		if($(this).next().is(':hidden')) {
			$('.accordion.second h4', thisAccordion).removeClass('down');
			$(this).addClass('down');
			var thisAccordion = $(this).closest('.accordion');
			$('div.teaserwrapper', thisAccordion).slideUp('fast');
			$(this).next().slideToggle('fast');
		}
		return false;
	});
*/
	$('.toggle .textcontent').hide();
	$('.toggle .textteaser h4').click(function() {
		var state = $(this).next('div').is(':hidden');
		/*if(state == true) {
			$(this).css('margin','0 0 15px 0');
		} else {
			$(this).css('margin','0');
		}*/
		$(this).next('div').slideToggle();
		return false;
	});






	$('.searchfield').blur(function(){
		if(this.value==''){this.value='Suche';}
		$('.searchfield').css("color", "#999");
	});
	$('.searchfield').focus(function(){
		if(this.value=='Suche'){this.value='';}
		$('.searchfield').css("color", "#333");
	});

	$('#emailnewsletter').blur(function(){
		if(this.value==''){this.value='E-Mail';}
		$('#emailnewsletter').css("color", "#999");

	});
	$('#emailnewsletter').focus(function(){
		if(this.value=='E-Mail'){this.value='';}
		$('#emailnewsletter').css("color", "#333");
	});


	$('#myaccount').click(function(){
		$('#langselect').hide();
		if($('#kontooptions').is(':visible')){
			$('#kontooptions').hide();
		}
		else{
			$('#kontooptions').show();
		}
		return false;

	});


	$('#language').click(function(){
	  	$('#kontooptions').hide();
		if($('#langselect').is(':visible')){
			//$('#langselect').hide();
		}
		else{
			$('#langselect').show();
		}
		//return false;

	});


	$('body').click(function(){
		if($('#kontooptions').is(':visible')){$('#kontooptions').hide();}
		if($('#langselect').is(':visible')){$('#langselect').hide();}
	});

	$('#myaccount').click(function(event){
    	event.stopPropagation();
 	});
	$('#language').click(function(event){
    	event.stopPropagation();
 	});



});





