
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++){
    inputs[i].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    inputs[i].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
  var selects = document.getElementsByTagName("select");
  for (var k=0; k<selects.length; k++){
    selects[k].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    selects[k].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
  var textareas = document.getElementsByTagName("textarea");
  for (var m=0; m<textareas.length; m++){
    textareas[m].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    textareas[m].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
}

addLoadEvent(prepareInputsForHints);

$(document).ready(function(){

  $('#headline').maxlength({
    events: [], // Array of events to be triggerd
    maxCharacters: 30, // Characters limit
    status: true, // True to show status indicator bewlow the element
    statusClass: "status", // The class on the status div
    statusText: " tecken kvar.", // The status text
    notificationClass: "notification",	// Will be added when maxlength is reached
    showAlert: false, // True to show a regular alert message
    alertText: "You have typed too many characters.", // Text in alert message
    slider: true // True Use counter slider
  });
  
$('#body').maxlength({
    events: [], // Array of events to be triggerd
    maxCharacters: 750, // Characters limit
    status: true, // True to show status indicator bewlow the element
    statusClass: "status", // The class on the status div
    statusText: " tecken kvar.", // The status text
    notificationClass: "notification",	// Will be added when maxlength is reached
    showAlert: false, // True to show a regular alert message
    alertText: "You have typed too many characters.", // Text in alert message
    slider: true // True Use counter slider
  });
  
});

