var hex = 215; // Initial color value.
var status = 0;
var el;
var min;
var max;

function fade(s,ele,mi,ma){	
	min = mi;
	max = ma;
	el = document.getElementById(ele);
	if(s==1){
		status=1;
		fadeIn();
	}
	else if(s==2){
		status=2
		fadeOut();
	}
}

function fadeIn(){ 
  if(hex>=min&&status==1) { 	//If color is not black yet
    hex-=5; 				// increase color darkness
    el.style.color="rgb("+hex+","+hex+","+hex+")";
    setTimeout("fadeIn()",20); 
  }
}

function fadeOut(){ 
  if(hex<=max&&status==2) { 
    hex+=5;
    el.style.color="rgb("+hex+","+hex+","+hex+")";
    setTimeout("fadeOut()",20); 
  }
}

