jQuery(document).ready(function(){ 
	// PNG Fix sd
	//jQuery(document).pngFix();
	
	//content right margin-top 0
	jQuery('.offeredCourses ul li:last').css('margin-bottom', '0');
	
	//submit margin-top 8px
	jQuery('.csc-mailform-field:last').css('margin-top', '8px');
	
	// Navigation
	jQuery("ul#navigation li").hover(function(){
    	jQuery(this).addClass("hover");
    	jQuery('ul:first',this).show();
		 }, function(){
    	jQuery(this).removeClass("hover");
    	jQuery('ul:first',this).hide();
   	});
	
	
	jQuery("ul#navigation li").hover(function(){
    	jQuery(this).addClass("hover");
    	jQuery('ul:first',this).show();
		 }, function(){
    	jQuery(this).removeClass("hover");
    	jQuery('ul:first',this).hide();
   	});	
	

	//minigallery-start-up
	jQuery("#page_10 .imageGallery").prepend('<div class="container"></div>');
	jQuery("#page_10 .imageGallery li:even").hide();
	// thumbs-click-behaviour + fadein/fadeout
	jQuery("#page_10 .imageGallery li:odd").click(function() {
		var imgClone = jQuery(this).prev().find('img').clone();
		//füge das Bild in den Container, und gib Container Größe des Bildes
		jQuery("#page_10 .imageGallery .container").prepend(imgClone).css({width:imgClone.width(), height:imgClone.height()});
		//ist mehr als "kein" Bild im Container... :)
		if(jQuery("#page_10 .imageGallery .container").length != 0) {
			//Effekte (fadein-out)
			jQuery("#page_10 .imageGallery .container img:first-child").fadeIn(1000, function() {
				jQuery(this).next().fadeOut(1000, function() {
					//... entferne das ältere Bild.
					jQuery(this).remove();
				});
			});
		}				
	});
	//load first pic into container
	jQuery("#page_10 .imageGallery li:odd:first").click();
	//jQuery(".imageGallery .container").append(jQuery(".imageGallery li:first-child").find('img').clone());
	
	// search
	jQuery('.contentHeaderSidebar a', '.tx-macinasearchbox-pi1').click(function(){
		jQuery('#searchformOuter', '.tx-macinasearchbox-pi1').slideToggle();
	});
	
	//form validation
	 jQuery('.csc-mailform-field #mailformformtype_mail').click(function() { 		 
		 jQuery(".error").hide();
	        var hasError = false;
	        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	 
	        var emailaddressVal = $(".csc-mailform-field #mailformemail").val();
	        if(emailaddressVal == '') {
	        	jQuery(".csc-mailform-field #mailformemail").after('<span class="error">Bitte geben Sie Ihre E-Mail-Adresse ein.</span>');
	            hasError = true;
	        }	 
	        else if(!emailReg.test(emailaddressVal)) {
	        	jQuery(".csc-mailform-field #mailformemail").after('<span class="error">Bitte geben Sie eine gültige E-Mail-Adresse ein.</span>');
	            hasError = true;
	        }
	 
	        if(hasError == true) { return false; }
	 
	    });
});


  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-26297213-1']);
  _gaq.push (['_gat._anonymizeIp']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

