// JavaScript Document
//checks a form for empty fields. 
function validate(f){
	//initalise vFlag 
	vFlag = true;
	//first get an array of all form elements.
	form = f.elements
	//the form elements that need validating have a div with an id name of 'fieldnameTip'.
	//so, to 'dynamically' find out which elements need validation, 'test' the existence
	//of a Div with the name 'fieldnameTip'. If the div exists, the form field needs validation. 
	for(i=0;i<form.length;i++){
		tipDiv = document.getElementById(form[i].name+"Tip");
		if(tipDiv != null){
			//div exists! so validate the element.
			if (checkForValue(form[i]) == false){
				vFlag = false;
				setTip("message","visible");
			}
		}
	}
	return vFlag;
}
//---------------------------------------------------------------------
function checkForValue(field){
	eFlag = true;
	if(field.value != ""){
		setTip((field.name+"Tip"),"hidden");
	}else{
		setTip((field.name+"Tip"),"visible");
		eFlag = false;
	}
	return eFlag;
}

//---------------------------------------------------------------------

function setTip(id,state){
	document.getElementById(id).style.visibility = state;		
}

//---------------------------------------------------------------------