function toggleDisplay(id, c, obj) {
	function toggleImage(c, x, obj) {
		switch(c) {
			case 1:
				obj.src = '/images/' + (x ? 'minimize_orange.jpg' : 'readmore_orange.jpg');
				break;
		}
	}
	var x;
	if(document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = '';
		x = true;
	} else {
		document.getElementById(id).style.display = 'none';
		x = false;
	}

	if(c && obj) {
		toggleImage(c, x, obj);
	}
}

//ajax?
function validateMailForm() {
	var nvalid = true;
	var evalid = true;
	
	mailForm = document.getElementById("mailForm");
	if(mailForm.fname.value == "" || mailForm.lname.value == "") {
		alert("Please enter your first and last name");
		nvalid = false;
	}
	else nvalid = true;
	if(!validateEmail(mailForm.email.value)) {
		alert("Please enter a valid email address");
		evalid = false;
	}
	else evalid = true;
	if(nvalid & evalid) {
		mailForm.url.value = window.location;
		mailForm.submit();
		document.getElementById("sub").disabled = "true";
		//alert("You have been sucessfully added to the CABEM mailing list")
	}
}

function validateEmail(email) {
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) {
		return false;
	}
	else
		return true;
}

function alreadyOnMailingList() {
	try {
		document.getElementById("mailForm").innerHTML = "Thanks for joining our mailing list";
	}
	catch(e) {
		
	}
}
