(function ($) {

	// TAALMENU
	Drupal.behaviors.taalmenu = {
		attach: function(context, settings) {
			
			$('#block-menu-menu-taalmenu ul.menu').hover(function () {
				$(this).addClass('over');
      }, function () {
				$(this).removeClass('over');
      });

    }
  }
	
	// EQUAL HEIGHT
	Drupal.behaviors.submenu = {
		attach: function(context, settings) {
			$(window).load(function(){

				var grootste = 0;
				$('#block-submenutree-0 .ds-layout-wieni .field-name-page-block a').each(function() {
					if($(this).height() > grootste) {
						grootste = $(this).height();
					}
				});
				$('#block-submenutree-0 .ds-layout-wieni .field-name-page-block a').height(grootste);
				$('#block-submenutree-0 .ds-layout-wieni:even').addClass('ds-layout-even');
			});

    }
  }

	// FAQ OPENKLAPPEN
	Drupal.behaviors.faq = {
		attach: function(context, settings) {
			
			$('.view-faq .group-middle-wrapper').hide();
			
			$(window).load(function(){
															
				$('.view-faq .group-header').click(function() {
					if(!$(this).hasClass('active')) {
						$('.view-faq .active').removeClass('active').next('.group-middle-wrapper').slideToggle('fast');
					}
					$(this).toggleClass('active').next('.group-middle-wrapper').slideToggle('fast');	
				})
															
			});

    }
  }

	// FOTOKAARTEN
	Drupal.behaviors.fotokaart = {
		attach: function(context, settings) {
			
			$('.view-fotokaarten div.views-row').hide();
			
			$(window).load(function(){
															
				$('.view-fotokaarten .view-header img').click(function() {
					if(!$(this).hasClass('active')) {
						var nidfull = $(this).parent('div').attr('class');
						var nidnr = nidfull.replace("nid-","");
						$('.view-fotokaarten .view-content div.views-row:visible').fadeOut();
						$('.view-fotokaarten .view-content div.views-row').find('.' + nidfull).parents('.views-row').fadeIn();
						$('.view-fotokaarten .view-header img.active').removeClass('active');
						$(this).addClass('active');
						$("#webform-client-form-1752 input[name='submitted[nid]']").val(nidnr);
					}
				})
		
				$('.view-fotokaarten .view-header .views-row-first img').click();												
	
			});
			
    }
  }

	// SPONSOREVENT
	Drupal.behaviors.sponsorevent = {
		attach: function(context, settings) {
			
			$('.view-fotokaarten div.views-row').hide();
			
			$(window).load(function(){
															
				$('.node-type-sponsorevent .region-content-bottom .block').each(function() {
					if($(this).find('input.error').length == 0) {
						$(this).find('.content').hide();
					}				
					$(this).find('h2.title').click(function() {
						$(this).siblings('.content').slideToggle('fast');					
					})
				});
	
			});
			
    }
  }
	
	// FORM INPUT TEXT REPLACE
	Drupal.behaviors.textreplace = {
		attach: function(context, settings) {
			
			$(window).load(function(){
															

				$('#block-wmcustom-wmcustom-mail-subscription input.form-text, #block-wmcustom-wmcustom-mail-subscription2 input.form-text, #block-webform-client-block-1752 input.form-text').each(function (i) {
					$(this).parents('.form-item').find('span').remove();
					$tekst = $(this).parents('.form-item').find('label').html().split(':');		
					$(this).parents('.form-item').find('label').hide();
					$(this).attr("labeltext",$tekst[0]);
					$(this).val($tekst[0]);
				});
			
			
				$('#block-wmcustom-wmcustom-mail-subscription input.form-text, #block-wmcustom-wmcustom-mail-subscription2 input.form-text, #block-webform-client-block-1752 input.form-text').focus(function () {
					if($(this).val() == $(this).attr('labeltext')) {
						$(this).val('');
						$(this).addClass('form-text-focus');
					}											   
				});
				 
				$('#block-wmcustom-wmcustom-mail-subscription input.form-text, #block-wmcustom-wmcustom-mail-subscription2 input.form-text, #block-webform-client-block-1752 input.form-text').keypress(function () {
					if($(this).val() == $(this).attr('labeltext')) {
						$(this).val('');
					}											   
				});
				 
				$('#block-wmcustom-wmcustom-mail-subscription input.form-text, #block-wmcustom-wmcustom-mail-subscription2 input.form-text, #block-webform-client-block-1752 input.form-text').blur(function () {
					if($(this).val() == '') {
						$(this).val($(this).attr('labeltext'));
						$(this).removeClass('form-text-focus');
					}											   
				});
			
			});			
			
    }
  }
	
})(jQuery);;

