function startBold(){
	document.forms[0].message.value = document.forms[0].message.value + "<b>";
	document.forms[0].message.focus();
}	
function endBold(){
	document.forms[0].message.value = document.forms[0].message.value + "</b>";
	document.forms[0].message.focus();	
}	
function startItalic(){
	document.forms[0].message.value = document.forms[0].message.value + "<i>";
	document.forms[0].message.focus();
}	
function endItalic(){
	document.forms[0].message.value = document.forms[0].message.value + "</i>";
	document.forms[0].message.focus();	
}
function startCentre(){
	document.forms[0].message.value = document.forms[0].message.value + "\n<div align='center'>";
	document.forms[0].message.focus();	
}	
function endCentre(){
	document.forms[0].message.value = document.forms[0].message.value + "</div>\n";
	document.forms[0].message.focus();	
}	
function newLine(){
	document.forms[0].message.value = document.forms[0].message.value + "<br />\n";
	document.forms[0].message.focus();	
}	
function newPara(){
	document.forms[0].message.value = document.forms[0].message.value + "<p />\n\n";
	document.forms[0].message.focus();	
}
function validateEmailForm(){
	var submit;
	if (document.forms[0].to.value == "other"){
		if (document.forms[0].orto.value == ""){
			alert ("No email address or mailing list entered.");
			document.forms[0].orto.focus();	
			submit = "no";
		}else{
			var EmailAddress = document.forms[0].orto.value;		//Email address validation
			var atLocation = EmailAddress.indexOf("@",1);
			var dotLocation = EmailAddress.indexOf(".",atLocation+2);
			var length = EmailAddress.length
			if ((atLocation>0) && (dotLocation>0) && (length>dotLocation+2)) {
			}else{
				alert("Please enter your email address properly.");
				document.forms[0].orto.focus();	
				submit = "no";							
			}
		}
	}
	if (document.forms[0].to.value == ""){
			alert ("No email address or mailing list entered.");
			document.forms[0].orto.focus();	
			submit = "no";			
	}


	if (submit == "no"){
		return false;
	}else{
		if (document.post.alsoAddTo.value == ""){
			var answer;
			answer = confirm("Before you send this email, we had a thought! \nYour message would be communicated to a larger audience if you also added it to the News or Events section on the website. \nBut you didn't select that option. \n \nIf you like, you could click 'Cancel' then select the 'Also add to website' option. \nIt's an easy way shout your message even louder. \n \nOf course, you could just send the email anyway by hitting the ok button.  \n \nYour choice - Use it wisely!");
			if (answer == true){
				return true;
			}else{
				return false;
			}
		}
	}
}
function askAboutSpelling(){
	var answer;
	answer = confirm("If you have checked your spelling in a word processor, click 'OK'.\nIf you have not, please click 'Cancel' and spell check your document.");
	if (answer == true){
			document.forms[0].submit();
			return true;
	}else{
			return false;
	}
}

function selectAllTrusts(the_form, do_check, basename, min, max)
{
    for (var i = min; i < max; i++) {
        if (typeof(document.forms[the_form].elements[basename + i]) != 'undefined') {
            document.forms[the_form].elements[basename + i].checked = do_check;
        }
        if (typeof(document.forms[the_form].elements[basename + i + 'r']) != 'undefined') {
            document.forms[the_form].elements[basename + i + 'r'].checked = do_check;
        }
    }
    return true;
} 
function noLetterYet(){
		alert ("You have not written a letter yet. \nPlease click 'Write A Letter' at the top of this page");
		return false;
}
function alertCrapServer(){
		alert ("If you have selected a large number of Trusts, you may be asked to start downloading a 'PHP' file - don't bother, it won't work! \nThis may be because the server is running unusually slowly. \nPerhaps make batches of 10 trusts at a time.");
		return true;	
}

function visi(nr)
{
	if (document.layers)
	{
		vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'show'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'visible';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'visible';
		document.getElementById(nr).style.visibility = vista;

	}
}
function invisi(nr)
{
	if (document.layers)
	{
		vista = (document.layers[nr].visibility == 'hide') ? 'hide' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (document.all[nr].style.visibility == 'hidden') ? 'hidden'	: 'hidden';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'hidden' : 'hidden';
		document.getElementById(nr).style.visibility = vista;

	}
}

 
function hidecommitteeForm(){
	invisi("committeeForm");
} 
