/* meta nav search input */
$(function () {
  var e = $('.metaNav input[type=text]');
	e.css({color: '#ccc'});
	var v = e.val();
  e.click(function () {
		if($(this).val() == v) {
			$(this).val('').css({color: '#000'});
		}	else {
			$(this).select();
		}
	});
	e.blur(function () {
		if($(this).val() == '') {
			$(this).css({color: '#ccc'}).val(v);
		}
	});
});

/**
 * Init-Function for Plugins & Feature List
 * Wrap up/down elements with class .wrapperPane inside of
 * .wrappableContent and toggle class of wrapperPaneOpen
 * to visualise up/down status in css.
 * Scrolling to the clicked item is disabled, see comment.
 */
$(function () {
  $(".wrappableContent .wrapperPane")
    .hide()
    .filter(":first")
      .show()
      .prev()
        .addClass('wrapperPaneOpenOpened');

  $(".wrappableContent .wrapperPaneOpen")
    .click(function() {
      $(this).next(".wrapperPane").slideToggle(400);
      $(this).toggleClass('wrapperPaneOpenOpened');
      // Disabled anoying scroll behaviour
	    //var o = $(this).offset().top;
	    //$('html,body').animate({scrollTop: o}, 400);
  });
});

/**
 * Init-Function for FAQ
 */
$(function () {
  $('.faqEntry a.more, .faqSearchResults a.more').click(function() {
    $(this).parent().next('.answer').toggle();
    return false;
  });
});
/**
 * Populate Newsletter Input
 */
$(function () {
	var v = $('.footerNewsletter .dialogInput');
	if(v.val() == '') {
		v.val(v.attr('title'));
	}
	$('.footerNewsletter .dialogInput').focus(function () {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}
	});
	$('.footerNewsletter .dialogInput').blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
		}
	});
});
/* feature list open/close */
$(function () {
  // close all feature lists
  $('.featList').addClass('featListClosed');
  $('.featList').children('.meat').hide();
  // create the open/close button
  $('.featList').append('<a class="featListOpener"></a>');
  // add toggle functionality
  $('.featList').bind('click', function () {
   var closed = false;
   if ($(this).hasClass('featListClosed')) {
    closed = true;
    $(this).removeClass('featListClosed');
   }
   $(this).children('.meat').slideToggle(400, function() {
      if(!closed) {
        $(this).parent().toggleClass('featListClosed');
      }
   });
  });
});

