function clearField(ctl,val,fill){
	if (ctl.value==val)
	{ctl.value=fill;
	setStyle(ctl);
	}
}
function setStyle(ctl){
    ctl.style.color = '#595959';
	
}
function fillField(ctl,val){
	if (ctl.value=='')
	{ctl.value=val;
	    ctl.style.color = '#595959';
	}
}
			
function clearFieldReg(ctl,val,fill){
	if (ctl.value==val)
	{ctl.value=fill;
	setStyleReg(ctl);
	}
}

function fadeBG(id, firstCol, lastCol, speed, directions) {
	var obj = document.getElementById(id)
	var isChanging = false;
	var finalColour = "";
	var directionsStr = "new Array(";
	if(!directions) {
		directions = new Array()
	}
	for(i=0; i<6; i++) {
		var firstNum = parseInt(firstCol.charAt(i), 16);
		var lastNum = parseInt(lastCol.charAt(i), 16);
		if(!directions[i]) {
			if(firstNum < lastNum) {
				directions[i] = 1
			} else {
				directions[i] = -1
			}
		}
		if(directions[i] < 0 && firstNum > lastNum) {
			firstNum -= 1
			isChanging = true;
		} else
		if(directions[i] > 0 && firstNum < lastNum) {
			firstNum += 1
			isChanging = true;
		}
		finalColour += firstNum.toString(16);
		directionsStr += directions[i] + ", ";
	}
	if(isChanging){
		directionsStr = directionsStr.substring(0, directionsStr.lastIndexOf(", "))
		directionsStr += ")"
		if(!speed) {
			speed = 30;
		}
		setTimeout("fadeBG('" + id + "', '" + finalColour + "', '" + lastCol + "', " + speed + ", " + directionsStr + ")",speed);
	}
	obj.style.backgroundColor = "#" + finalColour;
}