// function for invoking the menu-code:
function menu(obj)
	{
	if (!obj.length) return;
	
	/* $(obj).find("ul").css({display:"none", opacity:1.0});  */ /* opc. setting breaks menu in IE8!!! */

	$(obj).find("ul").css({display:"none"});

	$(obj).hover( function() {
							 $(this).find('ul').stop(true,true).show();  /* before 22.11.2011: .slideDown(300); */
							 },
				  function() {
				  			 $(this).find('ul').stop(true,true).hide();	/* before 22.11.2011: .slideUp(300); */
							 }
				 );
	}


// function for invoking code for fades of the flip-a elements in the main teaser
function teaser_flips()
	{
	$('#teaser_flip_left, #teaser_flip_right').css({display:"none"});
	$('#teaser').hover( function() {
									$('#teaser_flip_left, #teaser_flip_right').stop(true,true).fadeIn(600);
									},
						function() {
									$('#teaser_flip_left, #teaser_flip_right').stop(true,true).fadeOut(600);
									}
					   );
					   
	
	// this pauses and resumes the animation of the teasers, while hovering/dehovering the flip a´s
	$('#teaser_flip_left, #teaser_flip_right').hover( function() {$('#teaser_slideshow').cycle('pause'); }, function() {$('#teaser_slideshow').cycle('resume');} );
	}

function teaser_flips_ie8()
	{
	$('#teaser_flip_left, #teaser_flip_right').css({display:"none"});
	$('#teaser').hover( function() {
									$('#teaser_flip_left, #teaser_flip_right').stop(true,true).show();
									},
						function() {
									$('#teaser_flip_left, #teaser_flip_right').stop(true,true).hide();
									}
					   );
					   
	
	// this pauses and resumes the animation of the teasers, while hovering/dehovering the flip a´s
	$('#teaser_flip_left, #teaser_flip_right').hover( function() {$('#teaser_slideshow').cycle('pause'); }, function() {$('#teaser_slideshow').cycle('resume');} );
	}



// serialize formdata into array and make ajax call...
function sendform (formid)
				  {
				  $('#form_response').html('<p><img src="images/ajax_loader.gif" />Bitte warten...</p>');
				  $('#form_response').show();
				  var formdata = $('#'+formid).serializeArray();
				  $('#form_response').load('anmeldung.php', formdata, function(response, status, xhr) {if (status=='error') {$('#form_response').html('<h3 class="response_error">Fehler</h3><p>Leider sind technische Probleme bei der Verarbeitung aufgetreten. Bitte laden Sie die Seite neu und versuchen Sie erneut Ihre Anmeldung abzuschicken. Vielen Dank für Ihr Verständnis!</p>')}  });
			  	return false;
				  }

	


// Main Initialising
$(document).ready( function() {
								// testing font detection
								
								// font.setup(); // run setup when the DOM is ready
								/*								
								if (!font.isInstalled('Calibri'))
									{
									$('body').css({fontSize: "13.6px"});
									}
								*/
								
								// do the cycle first -> anotherwise IE8 strange bugs!!
								$('#teaser_slideshow').cycle( {fx:'scrollHorz', /* fx:'fade',*/  pause: 1, speed: 1000, timeout: 10000, width: 1000, height: 324, next: '#teaser_flip_right', prev: '#teaser_flip_left', easing: 'easeInOutQuart' /*, cleartype:  true, cleartypeNoBg:  true*/ , containerResize: 0 }  );  // do the cycle first -> anotherwise IE8 strange bugs!!
								
								// get the menu working:
								menu($("#navigation ul li"));
							  
								// hiding img in blogposts after DOM Loaded (to avoid size flickering)
								$('div.container_posts img').css({display: "none"});
							  
								// get the fades for flip a´s working
								teaser_flips();
								
								// colorbox assigment for seminarpages links "info alternativtermin" & "info_rabatte"
								$(document).ready(function() {$('#link_alternativtermin').colorbox({width:"50%", inline:true, href:"#info_alternativtermin"});} );
								$(document).ready(function() {$('#link_rabatte').colorbox({width:"600px", inline:true, href:"#info_rabatte"});} );
								
								// Setting the bottom margin of last child of "fitbottom" blogpost_inner to 0 -> prevent whitespace between merging blogposts...
								$('.blog_post.fitbottom .blog_post_inner > :last-child').css({marginBottom: '0px'});
								// Setting the bottom margin of the last "fittop-blogpost" to 23 (because blog_post is shifted 13px down due to top:0 instead of -13px..
								$('.blog_post.fittop').filter(':last').css({marginBottom: '23px'});
								}
				  );
				  
// Init after Images (and everything else) loaded...
$(window).load ( function () {
							 // resize blog posts inner images via jquery plugin
							 $('div.container_posts img').resize({maxWidth: 456});
							 // show images again:
							 $('div.container_posts img').css({display: "inline"});
							 }
				);
