function add_line() {

for (var i = 2; i <= 4; i++) {
	 var id = 'line' + i;	
	 if (document.getElementById && document.getElementById(id) != null ) {
		if (document.getElementById(id).style.display != 'block') { 		
		document.getElementById(id).style.display = 'block';
		return false;	
		}	 	
	 }	 
}	
	
} // end  add_line() 

//////////////////////////////////////////////////////
// Remove a line 

function remove_line(id) {
 if (document.getElementById)  {
	document.getElementById(id).style.display = 'none';
	if (id != 'plus1') {removeHiddenFields(id)};
 }
 else if (document.all) {
	document.all[id].style.display = 'none';
	if (id != 'plus1') {removeHiddenFields(id)};
 }
 else {
	 alert ('This functionality available in \\n IE 5 (Mac) and IE and NS 6 (Mac & PC).')
}

} // end remove_line(id)

//////////////////////////////////////////////////////
// Set the field values to "" when X is clicked to hide field

function removeHiddenFields(id) {
var Num = id.substring(4);
alert
document.emailAFriend['to_name_0' + Num].value = '';	
document.emailAFriend['to_email_0' + Num].value = '';	

} // end removeHiddenFields(id)


//////////////////////////////////////////////////////
// This does some js validation before passing info on to cgi
function submitForm (form) {

var email_address = /@\w+\.\w+/;	

if (form.name == "emailAFriend") {

if (document.emailAFriend.from_name.value =="") {
	alert( "Please enter your name.");
	document.emailAFriend.from_name.focus();
	return false;
}

else if (! email_address.test(document.emailAFriend.from_email.value)) {
	alert( "Please enter a valid email address.");
	document.emailAFriend.from_email.focus();
	return false;
}

else if (document.emailAFriend.date_of_visit.value =="") {
	alert( "Please enter the date of your visit.");
	document.emailAFriend.date_of_visit.focus();
	return false;
}


else if (document.emailAFriend.to_name_01.value =="") {
	alert( "Please enter your friend's name.");
	document.emailAFriend.to_name_01.focus();
	return false;
}

else if (! email_address.test(document.emailAFriend.to_email_01.value)) {
	alert( "Please enter a valid email address for your friend.");
	document.emailAFriend.to_email_01.focus();
	return false;
}

else if (document.emailAFriend.contact.value =="") {
	alert( "Please enter your contact's name.");
	document.emailAFriend.contact.focus();
	return false;
}

else if (document.emailAFriend.text.value =="") {
	alert( "Please enter your message.");
	document.emailAFriend.text.focus();
	return false;
}


for (var i = 1; i <= 4; i++) {
	var id = 'line' + i;	
	if (document.getElementById && document.getElementById(id) != null ) {
		if (document.getElementById(id).style.display == 'block') {
		
			if (document.emailAFriend['to_name_0' + i].value == '') {
				alert( "Please enter your friend's name.");
				document.emailAFriend['to_name_0' + i].focus();
				return false;
			}
			
			if (! email_address.test(document.emailAFriend['to_email_0' + i].value)) {
				alert( "Please enter your friend's email address.");
				document.emailAFriend['to_email_0' + i].focus();
				return false;
			}
			
			
		}
	}
		
}	 		

} // end if (form.name == );	

}

