// JavaScript Document
function checkLogin(form)
{
	if (form.txtName.value == '')
	{
		alert('Please enter your username.');
		form.txtName.focus();
		return false;
	}

	if (form.txtPass.value == '')
	{
		alert('Please enter your password.');
		form.txtPass.focus();
		return false;
	}

	return true;
}

function checkAddPage(form)
{
	if (form.txtPageName.value == '')
	{
		alert('Please enter a page name.');
		form.txtPageName.focus();
		return false;
	}

	if (form.txtMenuText.value == '')
	{
		alert('Please enter the text you would like to see in the menu.');
		form.txtMenuText.focus();
		return false;
	}

	if (form.txtTitleText.value == '')
	{
		alert('Please enter the title text for this page. This is the text that will appear in the title bar of the users browser.');
		form.txtTitleText.focus();
		return false;
	}

	return true;
}

function updateTitleText()
{
	ttEl = document.getElementById('txtTitleText');
	tt = 'David Antrobus Marketing, Integrity - Passion - Success';
	mt = document.getElementById('txtMenuText').value;

	if (mt.length > 0)
		tt += ' - ' + mt;

	ttEl.value = tt;

	return true;
}

function showMenuDropDown(form)
{
	secEl = form.selSection;
	sec = secEl.options[secEl.selectedIndex].value;
	selects = form.getElementsByTagName('select');

	for (var x = 0; x < selects.length; x++)
	{
		if (selects[x].id.substr(0, 9) == 'selOrder_')
			selects[x].style.display = 'none';
	}

	document.getElementById('selOrder_' + sec).style.display = '';

	return true;
}

function showHidePagesFor(form)
{
	secEl = document.getElementById('selSection');
	sec = secEl.options[secEl.selectedIndex].value;
	tables = document.getElementsByTagName('table');

	for (var x = 0; x < tables.length; x++)
		if (tables[x].id)
			if (tables[x].id.substr(0, 9) == 'pagesFor_')
				tables[x].style.display = 'none';

	document.getElementById('pagesFor_' + sec).style.display = '';

	return true;
}

function checkModPage(form)
{
	//Nothing required here
}

function popUp(page)
{
	popUp(page, '', '', 'popUpWindow')
}

function popUp(page, width, height)
{
	popUp(page, width, height, 'popUpWindow')
}

function popUp(page, width, height, windowName)
{
	popUp(page, width, height, windowName, 1)
}

var newwindow = '';
function popUp(page, width, height, windowName, scrollbars)
{
	if (isNaN(width) || width == '') { width = 500; }
	if (isNaN(height) || height == '') { height = 400; }

	if (!newwindow.closed && newwindow.location)
		newwindow.location.href = page;
	else
		newwindow = window.open(page, windowName,'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,menubar=0,status=0,scrollbars=' + scrollbars);

	if (!newwindow.opener)
		newwindow.opener = self;

	return true;
}

function checkEnquiry(form)
{
	if (form.txtName.value == '')
	{
		alert('Please enter your name.');
		form.txtName.focus();
		return false;
	}

	if (form.txtJobTitle.value == '')
	{
		alert('Please enter your job title.');
		form.txtJobTitle.focus();
		return false;
	}

	if (form.txtCompany.value == '')
	{
		alert('Please enter the name of the company you work for.');
		form.txtCompany.focus();
		return false;
	}

	if (form.txtEmail.value == '')
	{
		alert('Please enter your email address.');
		form.txtEmail.focus();
		return false;
	}

	if (form.txtEmail.value.indexOf('@') == -1 || form.txtEmail.value.lastIndexOf('.') < form.txtEmail.value.indexOf('@'))
	{
		alert('Please enter your email address. The address entered is not a valid email address.');
		form.txtEmail.focus();
		return false;
	}

	if (form.txtPhone.value == '')
	{
		alert('Please enter a contact telephone number.');
		form.txtPhone.focus();
		return false;
	}

	if (form.txtEnquiry.value == '')
	{
		alert('Please enter your enquiry.');
		form.txtEnquiry.focus();
		return false;
	}

	return true;
}

function checkAddDoc(form)
{
	if (form.txtFileName.value == '')
	{
		alert('Please select a document to upload.');
		form.txtFileName.focus();
		return false;
	}

/*	fileExt = form.txtFileName.value.substr(form.txtFileName.value.lastIndexOf('.') + 1).toLowerCase();
	if (fileExt != 'doc' && fileExt != 'pdf')
	{
		alert('Please select a different document to upload. Documents must be in either MS Word \'doc\' format or Adobe \'PDF\' format.');
		form.txtFileName.focus();
		return false;
	}
*/
	if (form.txtDispName.value == '')
	{
		alert('Please enter a display name for this document.');
		form.txtDispName.focus();
		return false;
	}

	if (form.txtDescription.value == '')
	{
		alert('Please enter a brief description of this document.');
		form.txtDescription.focus();
		return false;
	}

	return true;
}

function checkAddLink(form)
{
	if (form.txtLink.value == '')
	{
		alert('Please enter a link to add.');
		form.txtLink.focus();
		return false;
	}

	webLink = form.txtLink.value;

	if (webLink.substr(0, 4) != 'http')
		form.txtLink.value = 'http://' + form.txtLink.value;

/*	fileExt = form.txtFileName.value.substr(form.txtFileName.value.lastIndexOf('.') + 1).toLowerCase();
	if (fileExt != 'doc' && fileExt != 'pdf')
	{
		alert('Please select a different document to upload. Documents must be in either MS Word \'doc\' format or Adobe \'PDF\' format.');
		form.txtFileName.focus();
		return false;
	}
*/
	if (form.txtDispName.value == '')
	{
		alert('Please enter a display name for this link.');
		form.txtDispName.focus();
		return false;
	}

	if (form.txtDescription.value == '')
	{
		alert('Please enter a brief description of this link.');
		form.txtDescription.focus();
		return false;
	}

	return true;
}

function checkAddNews(form)
{
	if (form.txtShortHead.value == '')
	{
		alert('Please enter a short headline for this article. The short headline appears on the left hand side of the News Blog page.');
		form.txtShortHead.focus();
		return false;
	}

	if (form.txtFullHead.value == '')
	{
		alert('Please enter the full headline for this article. The full headline appears above the main article on the News Blog page.');
		form.txtFullHead.focus();
		return false;
	}

	if (form.txtStory.value == '')
	{
		alert('Please enter the body of the article.');
		form.txtStory.focus();
		return false;
	}

	return true;
}

function checkClient(form)
{
	if (form.txtFirstName.value == '')
	{
		alert('Please enter the clients first name.');
		form.txtFirstName.focus();
		return false;
	}

	if (form.txtSurname.value == '')
	{
		alert('Please enter the clients surname.');
		form.txtSurname.focus();
		return false;
	}

	if (form.txtUsername.value == '')
	{
		alert('Please enter a username for the client to use when logging in to the client area.');
		form.txtUsername.focus();
		return false;
	}

	if (form.txtPass.value == '')
	{
		alert('Please enter a password for the client to use when logging in to the client area.');
		form.txtPass.focus();
		return false;
	}

	if (form.txtCompanyName.value == '')
	{
		alert('Please enter the clients company name.');
		form.txtCompanyName.focus();
		return false;
	}

	if (form.txtDesc.value == '')
	{
		alert('Please enter a welcome message / description for the clients company.');
		form.txtDesc.focus();
		return false;
	}

	return true;
}