// JavaScript Document

$(document).ready(function(){
		
	/* Tourdaten */
	

   $('#hm_tour .line1').hover(
      function () {
			
			var entry = $(this).parent('.date');
			
			if( $('.line2', entry).css("display") != "block" )
			{
				$( this).css("background", "#d7d7d7" );
			}
			
			$('.open', this).css("text-decoration", "underline" );
			

      },  function () {
        		
			$( this).css("background", "none" );
			$('.open', this).css("text-decoration", "none" );
      }
   );
	 
	 
	$('#hm_tour .line1').click(function() {
		
		var entry = $(this).parent('.date');
		
		if( $('.line2', entry).css("display") != "block" ) {
			
			$('#hm_tour .date .line2').css("display", "none" );
			$('#hm_tour .date .open').text(  'mehr' );
			
			$('.line2', entry).css("display", "block" );
			$('.open', entry).text(  'zuklappen' );
			$('.open', entry).css("text-decoration", "none" );
			$('.line1', entry).css("background", "none" );
		
		} else {
			
			$('.line2', entry).css("display", "none" );
			$('.open', entry).text(  'mehr' );
			$('.open', entry).css("text-decoration", "none" );
			$('.line1', entry).css("background", "none" );
			
		}
		
  });


	/*------------------------------------------------------------------------------------------------------*/
	
	/* Infobox (Ernährung und Presse) */
	
	$('.table_head > a').click(function() {
			
		var id = this.id.substr(9)-0;
		
		$('.table_content .table_category').css("display", "none" );
		
		$('.table_content #cat' + id).css("display", "block" );
		
		switch(id) {
			case 1:
				table_header_y = 0;
				break;
			case 2:
				table_header_y = 54;
				break;
			case 3:
				table_header_y = 36;
				break;
			case 4:
				table_header_y = 18;
				break;
		}
				
		
		$('.table_head').css("background-position", '0px ' + table_header_y + 'px');
				
	});
	
	
	/*------------------------------------------------------------------------------------------------------*/
	
	/* Gewinnspiel */
	
	$('#hm_gewinnspiel .btn .clickArea').click(function() {
		
	
		
		var btn = $(this).parent('.btn');
		
		$('#hm_gewinnspiel .btn .checkbox').css("background-position", '0px 0px');
		

		$('.checkbox', btn).css("background-position", '0px 28px');
		
		
		
		$("#antwort").val( $('.title', btn).text() ); 
		
													
	});
	
	$('#hm_gewinnspiel #send').click(function() {
				
		if( $("#antwort").val() ) {
				
			$('#gewinnspielform').submit()	
				
				
		} else {
			
			$('#hm_gewinnspiel .btn .checkbox').css("background-position", '0px -28px');
			
			$(".sendinfo").text ('Sie haben noch keine Auswahl getroffen.');
			$(".sendinfo").addClass('error'); 
		}	
										
															 
	});
	
	$('#hm_gewinnspiel #anmelden').click(function() {

		$('#registerform').submit()	
															 
	});
	
	$('#hm_gewinnspiel #agbs_btn').click(function() {
		
		 $("#viewagbs").val( '1' ); 
		
		$('#registerform').submit()	
															 
	});
		
	/* */
	
	$('body').find('.teaser').each(function(i) {
		
		var teaser = $(this)
		
	
		$(teaser).after('<span class="content_teaser"><span class="'+  $(teaser).text() +'"></span></span>');
		
		$('.content_teaser .forum').append('<a href="http://www.patric-heizmann.de/?page_id=174"></a>');
		
		$('.content_teaser .glueckschmeckt').append('<a href="http://www.glueck-schmeckt.de" target="_blank"></a>');
		
		$('.content_teaser .hoerbuch').append('<a href="http://www.patric-heizmann.de/?p=1294&cat_=18" class="btn1"></a><a href="javascript:shop(\'http://heizmann.e-vendo.de/e-vendo.php?shop=heizmann&SessionId=&a=article&ProdNr=40276\');"  class="btn2"></a>');
		
		$('.content_teaser .euhr').append('<a href="http://www.patric-heizmann.de/?page_id=779" class="btn1"></a><a href="javascript:shop(\'http://heizmann.e-vendo.de/e-vendo.php?shop=heizmann&SessionId=&a=article&ProdNr=1024\');" class="btn2"></a>');
		
		$(teaser).remove(); 
			
		
	});
	



	
	 
});



