//This script works in conjunction with the defaultloader script
var defaultValue = new Array(); // An array to hold the default values
var elementId = new Array(); // An array to hold the id values of the input fields
 
//clearDefaultValue is a function that takes the id of the input field as an input value
//then uses this to identify and clear the input field in focus
function clearDefaultValue (a){
	var x=document.getElementById(a).value; //use the id(a) to extract the default value
	var j = 0;
	for(var i=0; i < elementId.length; i++){
		if(a == elementId[i]){ //find the id in the elementId to get an index value to be used as location of the
			j = i;           //default value in the default value array
		}
	}

	if(x==defaultValue[j]){ //the current value in the input field (x) is then compared to the  									//default value (defaultValue[j]) if they are the same (equal) then the default value is
					//cleared and ready for your input
		document.getElementById(a).value=''; // this clears the input field
		document.getElementById(a).style.color ="#000000";
	}
}

//replaceDefaultValue is the function that replaces the default value in the input field if it remains empty onblur
//like the clearDefaultValue function it takes the input field id as an input 
function replaceDefaultValue (a){
	var j = 0;
	for(var i=0; i < elementId.length; i++){
		if(a == elementId[i]){
			j = i;
		}
	}
	var x=document.getElementById(a).value;
	if(x == ''){ //if the current value is empty then it is replaced by the default value onblur
		document.getElementById(a).style.color ="#646464"; //default colour value
		document.getElementById(a).value= defaultValue[j];

	}else{
		document.getElementById(a).style.color ="#000000";
	}
}
