var Formfuncs = new Object();

Formfuncs.validateForm = function()
{

var Msg = "";

var nameStr = document.getElementById("pName");
parentName = nameStr.value;
var add1Str = document.getElementById("add1");
address1 = add1Str.value;
var add2Str = document.getElementById("add2");
address2 = add2Str.value;
var emailStr = document.getElementById("email");
email = emailStr.value;
var telStr = document.getElementById("tel");
telephone = telStr.value;


if (parentName == "" || parentName == null || parentName.charAt(0) == "")
{
	Msg +=  "Your name\r\n"
}

if (address1 == "" || address1 == null ||  address1.charAt(0) == "")
{
	Msg +=  "First line of address\r\n";
}

if (address2 == "" || address2 == null ||  address2.charAt(0) == "")
{
	Msg +=  "Second line of address\r\n";
}

if (telephone == "" || telephone == null ||  telephone.charAt(0) == "")
{
	Msg +=  "Your phone number\r\n";
}

if (email == "" || email == null ||  email.charAt(0) == "")
{
	Msg +=  "Your email\r\n";
}

if (email != "" && (email.indexOf("@") < 0 || email.indexOf(".")<0))
{
	Msg += "A VALID email address\r\n";
}

if (Msg == ""){
var send = document.getElementById("contactForm");
send.submit();
}

else{
alert('Please provide the following information:\r\n\r\n' + Msg);
}

}

Formfuncs.validateNewsAddition = function()
{

var Msg = "";

var aTitle = document.getElementById("aTitle");
articleTitle = aTitle.value;
var aIntro = document.getElementById("aIntro");
articleIntro = aIntro.value;
var aBody = document.getElementById("aBody");
articleBody = aBody.value;


if (articleTitle == "" || articleTitle == null || articleTitle.charAt(0) == "")
{
	Msg +=  "The article title\r\n"
}

if (articleIntro == "" || articleIntro == null ||  articleIntro.charAt(0) == "")
{
	Msg +=  "The article intro\r\n";
}

if (articleBody == "" || articleBody == null ||  articleBody.charAt(0) == "")
{
	Msg +=  "The main article text\r\n";
}



if (Msg == ""){
var send = document.getElementById("newsAddForm");
send.submit();
}

else{
alert('Please provide the following information:\r\n\r\n' + Msg);
}

}


Formfuncs.validateNewMember = function()
{

var Msg = "";

var sNamestr = document.getElementById("sname");
getSurname = sNamestr.value;
var fNamestr = document.getElementById("fname");
getFirstname = fNamestr.value;
var address = document.getElementById("add1");
getAddress = address.value;
var emailstr = document.getElementById("email");
getEmail = emailstr.value;



if (getSurname == "" || getSurname == null || getSurname.charAt(0) == "")
{
	Msg +=  "Your Surname\r\n"
}

if (getFirstname == "" || getFirstname == null ||  getFirstname.charAt(0) == "")
{
	Msg +=  "Your First Name\r\n";
}

if (getAddress == "" || getAddress == null ||  getAddress.charAt(0) == "")
{
	Msg +=  "Your Address\r\n";
}

if (getEmail == "" || getEmail == null ||  getEmail.charAt(0) == "")
{
	Msg +=  "Your email\r\n";
}

if (getEmail != "" && (getEmail.indexOf("@") < 0 || getEmail.indexOf(".")<0))
{
	Msg += "A VALID email address\r\n";
}



if (Msg == ""){
var send = document.getElementById("regForm");
send.submit();
}

else{
alert('Please provide the following information:\r\n\r\n' + Msg);
}

}


Formfuncs.validateMemoryAddition = function()
{

var Msg = "";

var getTitle = document.getElementById("mTitle");
memTitle = getTitle.value;
var getIntro = document.getElementById("mIntro");
memIntro = getIntro.value;
var getName = document.getElementById("mName");
memName = getName.value;
var gettheYear = document.getElementById("mYear");
memYear = gettheYear.value;
var getBody = document.getElementById("mBody");
memBody = getBody.value;


if (memTitle == "" || memTitle == null || memTitle.charAt(0) == "")
{
	Msg +=  "The memory title\r\n"
}

if (memIntro == "" || memIntro == null ||  memIntro.charAt(0) == "")
{
	Msg +=  "The memory intro\r\n";	
	
}
if (memName == "" || memName == null ||  memName.charAt(0) == "")
{
	Msg +=  "The memory submitter\r\n";
}

if (memYear == "" || memYear == null ||  memYear.charAt(0) == "")
{
	Msg +=  "The year of memory\r\n";
}

if (memBody == "" || memBody == null ||  memBody.charAt(0) == "")
{
	Msg +=  "The memory text\r\n";
}


if (Msg == ""){
var send = document.getElementById("memoryAddForm");
send.submit();
}

else{
alert('Please provide the following information:\r\n\r\n' + Msg);
}

}


function onSubmitForm() {
tinyMCE.triggerSave();
var Msg = "";

var aTitle = document.getElementById("aTitle");
articleTitle = aTitle.value;
var aIntro = document.getElementById("aIntro");
articleIntro = aIntro.value;
var aBody = document.getElementById("aBody");
articleBody = aBody.value;


if (articleTitle == "" || articleTitle == null || articleTitle.charAt(0) == "")
{
	Msg +=  "The article title\r\n"
}

if (articleIntro == "" || articleIntro == null ||  articleIntro.charAt(0) == "")
{
	Msg +=  "The article intro\r\n";
}

if (articleBody == "" || articleBody == null ||  articleBody.charAt(0) == "")
{
	Msg +=  "The main article text\r\n";
}

if (Msg == ""){
return true;
}

else{
alert('Please provide the following information:\r\n\r\n' + Msg);
return false;
}
}


