jQuery(document).ready(function () {

// COLOR EFFECT
  // capture the rainbow element
  var rainbow = document.getElementById('gradient'), 
    lastPos, // stores the last scrollLeft position
    width = 6000; // the repeating point on the background
  
  // we always reset when the page reloads so that the background is always the same
  rainbow.scrollLeft = width;
  
  // use an interval to scroll the rainbow
  setInterval(function () {
    // subtract to make the background scroll from left to right
    rainbow.scrollLeft -= 10;
    
    // if we've hit the beginning then the lastPos will be the same as the scrollLeft
    if (lastPos == rainbow.scrollLeft) {
      // reset
      rainbow.scrollLeft = width;
    }
    
    lastPos = rainbow.scrollLeft;
  }, 100); // the combination of milliseconds 
  
// SLIDESHOW
     jQuery('.gallery').galleria({
    	autoplay: 6000,
        image_crop: true,
        transition: 'fadeslide',
        transition_speed: 1000,
        preload: 1
    });
    
    jQuery('.homegallery').galleria({
    	autoplay: 4000,
        image_crop: true,
        transition: 'fade',
        transition_speed: 1000,
        preload: 1
    });

// KEINE TOOLTIPS IN NAVIGATION	
    jQuery('#nav a').removeAttr('title');
    
    
// LINKAUSZEICHUNGEN

	jQuery('#canvasLeft a').addClass('link');
	jQuery('.homewrap a').addClass('link');
	
// MUSICPLAYER
	
	jQuery('.page-item-54 a').click(function(event){
        window.open(this.href, 'music', 'width=506,height=690,scrollbars=no');
        event.preventDefault();
    });
    
    jQuery('.page-item-246 a').click(function(event){
        window.open(this.href, 'music', 'width=506,height=690,scrollbars=no');
        event.preventDefault();
    });
    
    jQuery('.page-item-247 a').click(function(event){
        window.open(this.href, 'music', 'width=506,height=690,scrollbars=no');
        event.preventDefault();
    });

// HOME SLIDER

	//To switch directions up/down and left/right just place a '-' in front of the top/left attribute
	//Vertical Sliding
	
	
	jQuery('.boxgrid.slidedown').hover(function(){
		jQuery('.cover', this).fadeOut(800);
	}, function() {
		jQuery('.cover', this).fadeIn(800);
	});

  
// FORM VALIDATION

	jQuery('select.empty_value option:first').replaceWith('<option value="" selected>bitte w&auml;hlen...</option>');

/* 	jQuery('.wpcf7-form input[type=text], .wpcf7-form textarea, .wpcf7-form select, .wpcf7-form input[type=radio], .wpcf7-form input[type=file], #acceptance, .newsletterform input, .simplr input').addClass('required'); */
	jQuery('.wpcf7-validates-as-required').addClass('required');
	
		
	jQuery.extend(jQuery.validator.messages, {
        required: '<strong>*</strong>'
    });

	jQuery('.wpcf7-form').validate({
		messages: {
			input: '*'
		}
	});
	
	jQuery('.newsletterform').validate({
		rules: {
			ne: {
				required: true,
				email: true
			}
		},
		messages: {
			input: '*',
			ne: '*'
		}
	});
	
	jQuery('.simplr').validate({
		rules: {
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			input: '*',
			email: '*'
		}
	});

// SCROLL TO TOP

	jQuery('a#top').click(function(){
        jQuery('html, body').animate({scrollTop:0}, 'easeInOutQuart');
        return false;
    });



// DROPDOWN MENU
	var site = function() {
		this.navLi = jQuery('#nav li').children('ul').hide().end();
		this.init();
	};
	site.prototype = {
	 	init : function() {
	 		this.setMenu();
	 	},
	 	// Enables the slidedown menu, and adds support for IE6
	 	setMenu : function() {
	 	jQuery.each(this.navLi, function() {
	 		if ( jQuery(this).children('ul')[0] ) {
	 			jQuery(this)
	 				.append('<span />')
	 				.children('span')
	 					.addClass('hasChildren')
	 		}
	 	});
	 		this.navLi.hover(function() {
	 			// mouseover
				jQuery(this).find('> ul').stop(true, true).slideDown(600, 'easeOutCubic');
	 		}, function() {
	 			// mouseout
	 			jQuery(this).find('> ul').stop(true, true).hide(); 		
			});	
	 	} 
	}
	new site();
	
   	

   	
// CLOSING DOCUMENT READY FUNCTION 
});
