function validateForm()
{
	var name = document.mailinglist.name.value;
	var email = document.mailinglist.email.value;
	var submit = document.mailinglist.submit;
	
	firstpos=email.lastIndexOf('.')+1;
	lastpos=email.length;
	dot=email.substring(firstpos,lastpos);

	if (name == "")
	{
		alert('Enter your name');
		return false;
	}
	else if (email == "")
	{
		alert('Enter your email');
		return false;
	}
	else if (!(email.indexOf(".") > 2) || !(email.indexOf("@") > 0) || dot.length <= 0)
	{
		alert('Enter your valid email');
		return false;
	}
	
	submit.value = "Wait";
	submit.disabled = true;
	return true;
}

function addBBCode(code)
{
	var oldText = document.mailinglist.message.value;
	document.mailinglist.message.value = oldText + code;
}

function addLink()
{
	var code;
	var href = prompt("Enter link", "http://");
	var text = prompt("Enter text", "My Link");
	var oldText = document.mailinglist.message.value;
	if ((href != "" || href != "http://") && text != "")
		code = "<a href=\"" + href + "\">" + text + "</a>";
	else if ((href != "" || href != "http://") && text == "")
		code = "<a href=\"" + href + "\">" + href + "</a>";
	else
		code = "";
	document.mailinglist.message.value = oldText + code;
}
