// Configuration
var fadeSpeed = 100;
var fadeValue = 10;
var buttonPause = 4000;
var opacity = 100;
var currentDirection = 1;
var minOpacity = 20;
var targetId = 'emailAlertsBtn';

function fadeButton(delta) { 
 if (delta < 0 && opacity <= minOpacity) {
  return false;
 }

 if (delta > 0 && opacity >= 100) {
  return false;
 }

  opacity+=delta;
  var img = document.getElementById(targetId);

  if (img.filters) {
   var alpha = 'alpha(opacity=' + opacity + ')';
   img.style.filter = alpha;
  } else if (img.style.MozOpacity) {
   mozTrans = opacity/101;
   img.style.MozOpacity = mozTrans;
  } else {
   img.style.MozOpacity=opacity/101;
  }

 return true;
}

function fadeButtonOut() {
 if (fadeButton(-fadeValue)) {
  setTimeout("fadeButtonOut()", fadeSpeed);
 } else {
  setTimeout("fadeButtonIn()", fadeSpeed);
 }
}

function fadeButtonIn() {
 if (fadeButton(fadeValue)) {
  setTimeout("fadeButtonIn()", fadeSpeed);
 } else {
  setTimeout("fadeButtonOut()", buttonPause);
 }
}

setTimeout("fadeButtonOut()", buttonPause);

