/**********************************************************************************************/
// function AddArticle_Validate(theform)
// - Validates AddArticle.asp fields
//
// Author: Ram Razavi
// Date: 11/15/2001
// Last Modified: 1/16/2002

function AddArticle_Validate(theform)
{
	var errormsg = '';

	if (theform.sectionid.value == '')
	{
		errormsg = errormsg + 'Please select a section for the article.\n';
	}
	
	if (theform.title.value == '')
	{
		errormsg = errormsg + 'Please provide a title for the article.\n';
	}
	
	if (theform.month.value == '')
	{
		errormsg = errormsg + 'Please provide the month.\n';
	}

	if (theform.day.value == '')
	{
		errormsg = errormsg + 'Please provide the day.\n';
	}

	if (theform.year.value == '')
	{
		errormsg = errormsg + 'Please provide the year.\n';
	}
	
	if ((theform.author.value != '') || (theform.author_title.value != '') || (theform.author_email.value != ''))
	{
		var arAuthorName = theform.author.value.split(';');
		var arAuthorTitle = theform.author_title.value.split(';');
		var arAuthorEmail = theform.author_email.value.split(';');
		
		var iAuthorNames = arAuthorName.length;
		var iAuthorTitles = arAuthorTitle.length;
		var iAuthorEmails = arAuthorEmail.length;
		
		if ((theform.author_title.value != '') && ((iAuthorTitles != iAuthorNames) || (theform.author.value == '')))
		{
			errormsg = errormsg + 'Please provide the same number of titles as authors. If an author\ndoes not have a title, just leave the title as a blank space.\n';
		}
		
		if ((theform.author_email.value != '') && ((iAuthorEmails != iAuthorNames) || (theform.author.value == '')))
		{
			errormsg = errormsg + 'Please provide the same number of E-mail addresses as authors. If an author\ndoes not have an E-mail address, just enter the E-mail address as a blank space.\n';
		}
	}

	if ((! theform.usefirstparagraph.checked) && (theform.summary.value == ''))
	{
		errormsg = errormsg + 'Please provide a summary or use the first paragraph of the article as the summary.\n';
	}
	
	if (theform.summary.value.length > 65535)
	{
		errormsg = errormsg + 'Please provide a summary that is no more than than 65535 characters in length. You\ncurrently have: ' + theform.summary.value.length + ' characters in this field.\n';
	}
	
	if (theform.body.value == '')
	{
		errormsg = errormsg + 'Please provide a body for the article.\n';
	}
	else if (theform.body.value.length > 65535)
	{
		errormsg = errormsg + 'Please provide a body that is no more than than 65535 characters in length. You\ncurrently have: ' + theform.body.value.length + ' characters in this field.\n';
	}
	
	if (errormsg != '')
	{
		window.alert(errormsg);
		return false;
	}
	else
	{
		// Enable all fields to pass all data
		for (var i = 0; i < theform.elements.length; i++)
		{
			theform.elements[i].disabled = false;
		}
		return true;
	}
}
