/*
 * Generic functionality and prototypes to use
 * 
 */

// This extends the array prototype to check if a given object is present in the array.
Array.prototype.contains = function(obj) {
  var i = this.length;
  while (i--) {
    if (this[i] === obj) {
      return true;
    }
  }
  return false;
}

function setFeedback(theMessage) {
	var defaultMessage = "Welkom op de website van Limburgsewallen.nl";
	var feedbackDivID  = "#feedback";
	var currentMessageLength = 0;
	
	if ($(feedbackDivID).html()) {
		currentMessageLength = $(feedbackDivID).html().length();
	}
	
	//hide current message (fade if already filled else just hide)
	if (currentMessageLength > 0){
		$(feedbackDivID).fadeOut('fast', function() {
			//animation complete
		});
	} else {
		$(feedbackDivID).hide();
	}
	
	//set message
	if (theMessage) {
		$(feedbackDivID).html(theMessage);
	} else {
		$(feedbackDivID).html(defaultMessage);
	}
	
	//show message
	$(feedbackDivID).fadeIn('slow', function() {
		//animation complete
		});	
	
}
