/* --------------------------------------------------------
 * MMGCMS - developed for Harold Mitchell Foundation
 * Copyright (C) 2004-2009 MMG interactive
 *
 * MMG interactive versioning:
 * ---------------
 * $Revision: 42 $
 * $Author: brandon $
 * $Date: 2009-05-20 14:57:52 +1000 (Wed, 20 May 2009) $
 *
 * --------------------------------------------------------
 */

function validateCreateNewUser()
{
	var frm = document.forms.frmNewUser;
	validateInit();

	validateElement(VAL_STR, frm.FirstName, "First Name", 1, 255, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.LastName, "Last Name", 1, 255, VAL_NOBLANKS);
	validateElement(VAL_EMAIL, frm.EmailAddress, "Email Address", 1, 255, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.UserPassword, "Password", 1, 50, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.UserPasswordConfirm, "Confirm Password", 1, 50, VAL_NOBLANKS);

	if (valid && frm.UserPassword.value != frm.UserPasswordConfirm.value)
	{
		alert("Passwords do not match!");
		frm.UserPassword.focus();
		valid = false;
	}

	if (valid)
	{
		frm.submit();
	}
}

function validateForgotPW()
{
	var frm = document.forms.frmForgotPW;
	validateInit();

	validateElement(VAL_EMAIL, frm.EmailAddress, "Email Address", 1, 255, VAL_NOBLANKS);

	if (valid)
	{
		frm.submit();
	}
}

// For ApplicationCategoryID = 1
function doSaveApplicant1(nApplicationID, nNextStep, nQuit, nPartialSave) 
{
	var frm = document.forms.frmApplicant;
	validateInit();

	var bAllowBlanks = VAL_NOBLANKS;

	if (nPartialSave == 1)
	{
		bAllowBlanks = VAL_ALLOWBLANKS;
	}

	validateElement(VAL_STR, frm.ApplicantName, "Applicant Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ApplicantTitle, "Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantPositionTitle, "Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.ApplicantEmailAddress, "Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantAreaCode, "Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantTelephone, "Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.ApplicantTelephone, "Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantMobile, "Mobile", 1, 50, VAL_ALLOWBLANKS);

	if (valid)
	{
		if (nQuit == 1)
		{
			frm.Quit.value = 1;
		}
		frm.action = "Applications.asp?Action=SaveApplicant&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();
	}	
}

// For ApplicationCategoryID = 2
function doSaveApplicant2(nApplicationID, nNextStep, nQuit, nPartialSave) 
{
	var frm = document.forms.frmApplicant;
	validateInit();

	var bAllowBlanks = VAL_NOBLANKS;

	if (nPartialSave == 1)
	{
		bAllowBlanks = VAL_ALLOWBLANKS;
	}

	validateElement(VAL_STR, frm.ApplicantName, "Applicant Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ApplicantTitle, "Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantPositionTitle, "Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.ApplicantEmailAddress, "Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantAreaCode, "Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantTelephone, "Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.ApplicantTelephone, "Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantMobile, "Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.OrgName, "Organisation Name", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgDivision, "Organisation Division", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgABN, "Organisation ABN", 1, 50, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgWebsite, "Organisation Website", 1, 255, VAL_ALLOWBLANKS);

	validateRadio(frm.TaxConcessionCharity, "TCC endorsement", bAllowBlanks);
	validateRadio(frm.DeductibleGiftRecipient, "DGR endorsement", bAllowBlanks);

	/*if (valid)
	{
		if (frm.DeductibleGiftRecipient[0].checked)
		{
			validateRadio(frm.DGRProvisionItem, "DGR provision");
		}
	}*/
	
	validateElement(VAL_STR, frm.CEOName, "CEO Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.CEOTitle, "CEO Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOPositionTitle, "CEO Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.CEOEmailAddress, "CEO Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOAreaCode, "CEO Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOTelephone, "CEO Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.CEOTelephone, "CEO Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOMobile, "CEO Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.OrgAddress1, "Adress", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgAddress2, "Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgSuburb, "Suburb", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.OrgStateID, "State", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgPostcode, "Postcode", 4, null, bAllowBlanks);
	validateElement(VAL_NUM, frm.OrgPostcode, "Postcode", 0, 9999, bAllowBlanks);

	validateElement(VAL_STR, frm.OrgPostalAddress1, "Postal Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostalAddress2, "Postal Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostalSuburb, "Postal Suburb", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_SELECT, frm.OrgPostalStateID, "Postal State", null, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostalPostcode, "Postal Postcode", 4, null, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.OrgPostalPostcode, "Postal Postcode", 0, 9999, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.SignatoryName, "Signatory Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.SignatoryTitle, "Signatory Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryPositionTitle, "Signatory Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.SignatoryEmailAddress, "Signatory Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryAreaCode, "Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryTelephone, "Signatory Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.SignatoryTelephone, "Signatory Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryMobile, "Signatory Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.ContactName, "Contact Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ContactTitle, "Contact Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactPositionTitle, "Contact Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.ContactEmailAddress, "Contact Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactAreaCode, "Contact Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactTelephone, "Contact Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.ContactTelephone, "Contact Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactMobile, "Contact Mobile", 1, 50, VAL_ALLOWBLANKS);

	if (valid)
	{
		if (nQuit == 1)
		{
			frm.Quit.value = 1;
		}
		frm.action = "Applications.asp?Action=SaveApplicant&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();
	}	
}

// For ApplicationCategoryID = 3
function doSaveApplicant3(nApplicationID, nNextStep, nQuit, nPartialSave) 
{
	var frm = document.forms.frmApplicant;
	validateInit();

	var bAllowBlanks = VAL_NOBLANKS;

	if (nPartialSave == 1)
	{
		bAllowBlanks = VAL_ALLOWBLANKS;
	}

	validateElement(VAL_STR, frm.ApplicantName, "Applicant Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ApplicantTitle, "Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantPositionTitle, "Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.ApplicantEmailAddress, "Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantAreaCode, "Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantTelephone, "Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.ApplicantTelephone, "Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.ApplicantMobile, "Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.OrgName, "Organisation Name", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgDivision, "Organisation Division", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgABN, "Organisation ABN", 1, 50, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgWebsite, "Organisation Website", 1, 255, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.CEOName, "CEO Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.CEOTitle, "CEO Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOPositionTitle, "CEO Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.CEOEmailAddress, "CEO Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOAreaCode, "CEO Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOTelephone, "CEO Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.CEOTelephone, "CEO Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOMobile, "CEO Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.OrgAddress1, "Adress", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgAddress2, "Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgSuburb, "Suburb", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.OrgStateID, "State", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgPostcode, "Postcode", 4, null, bAllowBlanks);
	validateElement(VAL_NUM, frm.OrgPostcode, "Postcode", 0, 9999, bAllowBlanks);

	validateElement(VAL_STR, frm.OrgPostalAddress1, "Postal Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostalAddress2, "Postal Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostalSuburb, "Postal Suburb", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_SELECT, frm.OrgPostalStateID, "Postal State", null, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostalPostcode, "Postal Postcode", 4, null, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.OrgPostalPostcode, "Postal Postcode", 0, 9999, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.ContactName, "Contact Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ContactTitle, "Contact Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactPositionTitle, "Contact Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.ContactEmailAddress, "Contact Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactAreaCode, "Contact Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactTelephone, "Contact Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.ContactTelephone, "Contact Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactMobile, "Contact Mobile", 1, 50, VAL_ALLOWBLANKS);

	if (valid)
	{
		if (nQuit == 1)
		{
			frm.Quit.value = 1;
		}
		frm.action = "Applications.asp?Action=SaveApplicant&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();
	}	
}

function doApplicantBack(nApplicationID, nNextStep)
{
	var frm = document.forms.frmApplicant;
	validateInit();

	validateElement(VAL_STR, frm.ApplicantName, "Applicant Name", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_SELECT, frm.ApplicantTitle, "Title", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.ApplicantPositionTitle, "Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.ApplicantEmailAddress, "Email Address", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.ApplicantAreaCode, "Area Code", 2, 2, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.ApplicantTelephone, "Telephone", 1, 10, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.ApplicantTelephone, "Telephone", 1, 9999999999, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.ApplicantMobile, "Mobile", 1, 50, VAL_ALLOWBLANKS);

	if (valid)
	{
		frm.action = "Applications.asp?Action=SaveApplicant&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();
	}
}

function doSaveAuspice(nApplicationID, nNextStep, nQuit, nPartialSave) 
{
	var frm = document.forms.frmAuspice;
	validateInit();

	var bAllowBlanks = VAL_NOBLANKS;

	if (nPartialSave == 1)
	{
		bAllowBlanks = VAL_ALLOWBLANKS;
	}

	validateElement(VAL_STR, frm.OrgName, "Organisation Name", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgDivision, "Organisation Division", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgABN, "ABN", 1, 50, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgWebsite, "Website", 1, 255, VAL_ALLOWBLANKS);

	validateRadio(frm.TaxConcessionCharity, "TCC endorsement", bAllowBlanks);
	validateRadio(frm.DeductibleGiftRecipient, "DGR endorsement", bAllowBlanks);

	/*if (valid)
	{
		if (frm.DeductibleGiftRecipient[0].checked)
		{
			validateRadio(frm.DGRProvisionItem, "DGR provision");
		}
	}*/

	validateElement(VAL_STR, frm.CEOName, "CEO Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.CEOTitle, "CEO Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOPositionTitle, "CEO Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.CEOEmailAddress, "CEO Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOAreaCode, "CEO Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOTelephone, "CEO Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.CEOTelephone, "CEO Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.CEOMobile, "CEO Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.OrgAddress1, "Adress", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgAddress2, "Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgSuburb, "Suburb", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.OrgStateID, "State", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.OrgPostcode, "Postcode", 4, null, bAllowBlanks);
	validateElement(VAL_NUM, frm.OrgPostcode, "Postcode", 0, 9999, bAllowBlanks);

	validateElement(VAL_STR, frm.SignatoryName, "Signatory Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.SignatoryTitle, "Signatory Title", 1, null, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryPositionTitle, "Signatory Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.SignatoryEmailAddress, "Signatory Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryAreaCode, "Signatory Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryTelephone, "Signatory Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.SignatoryTelephone, "Signatory Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.SignatoryMobile, "Signatory Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.ContactName, "Contact Name", 1, 255, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ContactTitle, "Contact Title", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.ContactPositionTitle, "Contact Position Title", 1, 255, bAllowBlanks);
	validateElement(VAL_EMAIL, frm.ContactEmailAddress, "Contact Email Address", 1, 255, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactAreaCode, "Contact Area Code", 2, 2, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactTelephone, "Contact Telephone", 1, 10, bAllowBlanks);
	validateElement(VAL_NUM, frm.ContactTelephone, "Contact Telephone", 1, 9999999999, bAllowBlanks);
	validateElement(VAL_STR, frm.ContactMobile, "Contact Mobile", 1, 50, VAL_ALLOWBLANKS);
	
	if (valid)
	{
		if (nQuit == 1)
		{
			frm.Quit.value = 1;
		}
		frm.action = "Applications.asp?Action=SaveAuspicePartner&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();		
	}	
}

function doAuspiceBack(nApplicationID, nNextStep)
{
	validateInit();
	var frm = document.forms.frmAuspice;
	
	validateElement(VAL_STR, frm.OrgName, "Organisation Name", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgDivision, "Organisation Division", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgABN, "ABN", 1, 50, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgWebsite, "Website", 1, 255, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.CEOName, "CEO Name", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_SELECT, frm.CEOTitle, "CEO Title", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CEOPositionTitle, "CEO Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.CEOEmailAddress, "CEO Email Address", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CEOAreaCode, "CEO Area Code", 2, 2, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.CEOTelephone, "CEO Telephone", 1, 10, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.CEOTelephone, "CEO Telephone", 1, 9999999999, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.CEOMobile, "CEO Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.OrgAddress1, "Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgAddress2, "Adress", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgSuburb, "Suburb", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.OrgPostcode, "Postcode", 4, null, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.OrgPostcode, "Postcode", 0, 9999, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.SignatoryName, "Signatory Name", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_SELECT, frm.SignatoryTitle, "Signatory Title", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.SignatoryPositionTitle, "Signatory Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.SignatoryEmailAddress, "Signatory Email Address", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.SignatoryAreaCode, "Signatory Area Code", 2, 2, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.SignatoryTelephone, "Signatory Telephone", 1, 10, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.SignatoryTelephone, "Signatory Telephone", 1, 9999999999, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.SignatoryMobile, "Signatory Mobile", 1, 50, VAL_ALLOWBLANKS);

	validateElement(VAL_STR, frm.ContactName, "Contact Name", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_SELECT, frm.ContactTitle, "Contact Title", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.ContactPositionTitle, "Contact Position Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_EMAIL, frm.ContactEmailAddress, "Contact Email Address", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.ContactAreaCode, "Contact Area Code", 2, 2, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.ContactTelephone, "Contact Telephone", 1, 10, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.ContactTelephone, "Contact Telephone", 1, 9999999999, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.ContactMobile, "Contact Mobile", 1, 50, VAL_ALLOWBLANKS);

	if (valid)
	{
		frm.action = "Applications.asp?Action=SaveAuspicePartner&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();
	}
}

function doSaveProject(nApplicationID, nNextStep, nQuit, nPartialSave) 
{
	validateInit();
	var frm = document.forms.frmProject;
	
	var bAllowBlanks = VAL_NOBLANKS;

	if (nPartialSave == 1)
	{
		bAllowBlanks = VAL_ALLOWBLANKS;
	}

	validateElement(VAL_STR, frm.ProjectTitle, "Project Title", 1, 255, VAL_NOBLANKS);

	validateElement(VAL_SELECT, frm.ProjectStartDate_Day, "Commencement Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ProjectStartDate_Month, "Commencement Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ProjectStartDate_Year, "Commencement Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ProjectEndDate_Day, "Completion Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ProjectEndDate_Month, "Completion Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ProjectEndDate_Year, "Completion Date", 1, null, bAllowBlanks);

	if (valid && !bAllowBlanks)
	{
		var date1 = new Date(frm.ProjectStartDate_Year.value, frm.ProjectStartDate_Month.selectedIndex, frm.ProjectStartDate_Day.value);	
		var date2 = new Date(frm.ProjectEndDate_Year.value, frm.ProjectEndDate_Month.selectedIndex, frm.ProjectEndDate_Day.value);
		var currentDate = new Date()

		if (date1 < currentDate)
		{
			alert('Project Commencement date cannot be before the current date');
			frm.ProjectStartDate_Day.focus();
			valid = false
		}

		if (valid && (date1.getTime() > date2.getTime()))
		{
			alert('Project Completion date must be after the commencement date');
			frm.ProjectEndDate_Day.focus();
			valid = false;		
		} 
	}

	validateRadio(frm.PreviousUndertaking, "Previous Undertaking", bAllowBlanks);

	validateElement(VAL_NUM, frm.ProjectTotalCost, "Total Project Cost", null, null, bAllowBlanks);
	validateElement(VAL_NUM, frm.ProjectAmountSought, "Amount Sought", null, null, bAllowBlanks);

	if (valid && !bAllowBlanks)
	{
		if (parseInt(frm.ProjectAmountSought.value) > parseInt(frm.ProjectTotalCost.value))
		{
			valid = false;
			alert("Amount Sought cannot be more than the Total Project Cost");
			frm.ProjectAmountSought.focus();
		}
	}

	validateElement(VAL_SELECT, frm.ApplicationResultDate_Day, "Last Notification Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ApplicationResultDate_Month, "Last Notification Date", 1, null, bAllowBlanks);
	validateElement(VAL_SELECT, frm.ApplicationResultDate_Year, "Last Notification Date", 1, null, bAllowBlanks);

	if (valid && !bAllowBlanks)
	{
		var date1 = new Date(frm.ProjectStartDate_Year.value, frm.ProjectStartDate_Month.selectedIndex, frm.ProjectStartDate_Day.value);	
		var date2 = new Date(frm.ApplicationResultDate_Year.value, frm.ApplicationResultDate_Month.selectedIndex, frm.ApplicationResultDate_Day.value);
		var currentDate = new Date()

		if (date2 < currentDate)
		{
			alert('Last Notification Date cannot be before the current date');
			frm.ApplicationResultDate_Day.focus();
			valid = false
		}

		if (valid && (date1.getTime() < date2.getTime()))
		{
			alert('Last Notification Date must be before commencement date');
			frm.ApplicationResultDate_Day.focus();
			valid = false;		
		} 
	}

/*
	//frm.CurrentSummary.value = document.getElementById('TextEdit1').contentWindow.document.body.innerHTML;
	frm.CurrentDescription.value = document.getElementById('TextEdit2').contentWindow.document.body.innerHTML;
	frm.CurrentCriteria.value = document.getElementById('TextEdit3').contentWindow.document.body.innerHTML;
	frm.CurrentFunding.value = document.getElementById('TextEdit4').contentWindow.document.body.innerHTML;
	frm.CurrentUsageShortfall.value = document.getElementById('TextEdit5').contentWindow.document.body.innerHTML;	

	validateElement(VAL_STR, frm.CurrentSummary, "Project Summary", 1, null, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.CurrentUsageShortfall, "Funding Usage", 1, null, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.CurrentDescription, "Project Description", 1, null, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.CurrentCriteria, "Criteria Fulfillment", 1, null, VAL_NOBLANKS);	
	validateElement(VAL_STR, frm.CurrentFunding, "Other Funding", 1, null, VAL_NOBLANKS);
*/
/*
	frm.CurrentDescription.value = tinyMCE.get('Editor_CurrentDescription').getContent();	
	frm.CurrentCriteria.value = tinyMCE.get('Editor_CurrentCriteria').getContent();	
	frm.CurrentFunding.value = tinyMCE.get('Editor_CurrentFunding').getContent();	
	frm.CurrentUsageShortfall.value = tinyMCE.get('Editor_CurrentUsageShortfall').getContent();	
*/
	validateElement(VAL_STR, frm.CurrentSummary, "Project Summary", 1, 1500, bAllowBlanks);
	validateElement(VAL_STR, frm.CurrentUsageShortfall, "Funding Usage", 1, 3500, bAllowBlanks);
	validateElement(VAL_STR, frm.CurrentDescription, "Project Description", 1, 10000, bAllowBlanks);
	validateElement(VAL_STR, frm.CurrentCriteria, "Criteria Fulfillment", 1, 5000, bAllowBlanks);	
	validateElement(VAL_STR, frm.CurrentFunding, "Other Funding", 1, 2000, bAllowBlanks);
	

	var confirmStr = "Selecting \"OK\" will finalise your application. You will not be able to make changes beyond this point. ";
	confirmStr += "If you still wish to make changes click \"Cancel\", otherwise click \"OK\" to submit your application.";

	if (valid)
	{
		if (nQuit == 1)
		{
			frm.Quit.value = 1;
			frm.action = "Applications.asp?Action=SaveProject&ID=" + nApplicationID + "&NextStep=" + nNextStep;
			frm.submit();
		}
		else
		{
			if (bAllowBlanks)
			{
				frm.action = "Applications.asp?Action=SaveProject&ID=" + nApplicationID + "&NextStep=" + nNextStep;
				frm.submit();
			}
			else
			{
				if (confirm(confirmStr))
				{	
					frm.action = "Applications.asp?Action=SaveProject&ID=" + nApplicationID + "&NextStep=" + nNextStep;
					frm.submit();
				}
			}
		}
	}	

}

function doProjectBack(nApplicationID, nNextStep)
{
	validateInit();
	var frm = document.forms.frmProject;
	
	validateElement(VAL_STR, frm.ProjectTitle, "Project Title", 1, 255, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.ProjectTotalCost, "Total Project Cost", null, null, VAL_ALLOWBLANKS);
	validateElement(VAL_NUM, frm.ProjectAmountSought, "Amount Sought", null, null, VAL_ALLOWBLANKS);

	if (valid)
	{
		if (parseInt(frm.ProjectAmountSought.value) > parseInt(frm.ProjectTotalCost.value))
		{
			valid = false;
			alert("Amount Sought cannot be more than the Total Project Cost");
			frm.ProjectAmountSought.focus();
		}
	}
	/*
	frm.CurrentDescription.value = document.getElementById('TextEdit2').contentWindow.document.body.innerHTML;
	frm.CurrentCriteria.value = document.getElementById('TextEdit3').contentWindow.document.body.innerHTML;
	frm.CurrentFunding.value = document.getElementById('TextEdit4').contentWindow.document.body.innerHTML;
	frm.CurrentUsageShortfall.value = document.getElementById('TextEdit5').contentWindow.document.body.innerHTML;	

	validateElement(VAL_STR, frm.CurrentSummary, "Project Summary", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CurrentUsageShortfall, "Funding Usage", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CurrentDescription, "Project Description", 1, null, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CurrentCriteria, "Criteria Fulfillment", 1, null, VAL_ALLOWBLANKS);	
	validateElement(VAL_STR, frm.CurrentFunding, "Other Funding", 1, null, VAL_ALLOWBLANKS);
	*/
	validateElement(VAL_STR, frm.CurrentSummary, "Project Summary", 1, 1500, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CurrentUsageShortfall, "Funding Usage", 1, 3500, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CurrentDescription, "Project Description", 1, 10000, VAL_ALLOWBLANKS);
	validateElement(VAL_STR, frm.CurrentCriteria, "Criteria Fulfillment", 1, 5000, VAL_ALLOWBLANKS);	
	validateElement(VAL_STR, frm.CurrentFunding, "Other Funding", 1, 2000, VAL_ALLOWBLANKS);

	if (valid)
	{
		frm.action = "Applications.asp?Action=SaveProject&ID=" + nApplicationID + "&NextStep=" + nNextStep;
		frm.submit();
	}
}

function doFinalize(id) 
{
	if(confirm("* this will immediately finalize the application and notify all relevant parties of it's completion whilst also preventing all further updates, would you like to proceed?")) 
	{
		window.location='Applications.asp?Action=Finalize&ID='+id;
	}
}

function imagePopup(frm, fldid, fldname, fldimage, fldtype, disptype) 
{
	var strAction = 'ImageSelect.asp?form=' + frm + '&field=' + fldid + '&name=' + fldname + '&image=' + fldimage + '&type=' + fldtype + '&disptype=' + disptype;
	PopupWindow(strAction, 750, 550); 

}

function PopupWindow(strAction, nWidth, nHeight) 
{ 
	var strSettings = 'width=' + nWidth + ',height=' + nHeight + ',scrollbars=yes,menubar=no,toolbar=no,status=yes';
	g_popupWin = window.open(strAction, 'remote', strSettings);
}

function doToggle(id,nType)
{
	if (document.getElementById(id))
	{
		var elem = document.getElementById(id);
		var pic = document.getElementById(id + '_img');
		
		if(nType == 2)
		{
			var picfile = Right(pic.src,9);
			pic.src = (Right(pic.src,9) == 'open1.gif') ? pic.src.replace(picfile,'shut1.gif') : pic.src.replace(picfile,'open1.gif');
		}
		else if(nType == 1)
		{
			var picfile = Right(pic.src,8);
			pic.src = (Right(pic.src,8) == 'open.gif') ? pic.src.replace(picfile,'shut.gif') : pic.src.replace(picfile,'open.gif');		
		}

		pic.alt = (pic.alt == 'close') ? 'open' : 'close';
		pic.title = (pic.title == 'close') ? 'open' : 'close';
		elem.style.display = (elem.style.display == 'none') ? '' : 'none';
	}
}

function doTextDisplay(nID){
	if (nID == 1) 
	{
		var elem = document.getElementById('summary');
		elem.style.display = (elem.style.display == 'none') ? '' : 'none';
	}
	else if(nID == 2) 
	{
		var elem = document.getElementById('criteria');
		elem.style.display = (elem.style.display == 'none') ? '' : 'none';
	}
	else if(nID == 3) 
	{
		var elem = document.getElementById('funding');
		elem.style.display = (elem.style.display == 'none') ? '' : 'none';
	}
}

function doSectionDisplay(nID)
{
	if(nID == 1) 
	{
		setActiveTab("Step1", "");
		setActiveTab("Step2", "progressMenuOn");
		setActiveTab("Step3", "");
		setActiveTab("Step4", "");
		setActiveTab("Step5", "");
		document.getElementById('project').style.display = 'none';
		document.getElementById('appdetail').style.display = 'none';		
		document.getElementById('applicant').style.display = 'none';
		document.getElementById('auspice').style.display = '';
	}
	else if(nID == 2) 
	{
		setActiveTab("Step1", "");
		setActiveTab("Step2", "");
		setActiveTab("Step3", "progressMenuOn");
		setActiveTab("Step4", "");
		setActiveTab("Step5", "");
		document.getElementById('project').style.display = 'none';
		document.getElementById('applicant').style.display = '';
		document.getElementById('auspice').style.display = 'none';	
		document.getElementById('appdetail').style.display = 'none';			
	}
	else if(nID == 3) 
	{
		setActiveTab("Step1", "");
		setActiveTab("Step2", "");
		setActiveTab("Step3", "");
		setActiveTab("Step4", "progressMenuOn");
		setActiveTab("Step5", "");
		document.getElementById('project').style.display = '';
		document.getElementById('applicant').style.display = 'none';
		document.getElementById('auspice').style.display = 'none';	
		document.getElementById('appdetail').style.display = 'none';	
	}
	else 
	{
		setActiveTab("Step1", "progressMenuOn");
		setActiveTab("Step2", "");
		setActiveTab("Step3", "");
		setActiveTab("Step4", "");
		setActiveTab("Step5", "");

		document.getElementById('appdetail').style.display = '';	
		document.getElementById('project').style.display = 'none';
		document.getElementById('applicant').style.display = 'none';
		document.getElementById('auspice').style.display = 'none';					
	}
}

function Left(str, n)
{
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n)
{
    if (n <= 0)
	{
       return "";
    }
	else if (n > String(str).length)
    {   
		return str;
	}
    else 
	{
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function doEmailSend(nID)
{
	var frm = document.forms.frmApplication;

	var dropdownIndex = frm.EmailTemplateID.selectedIndex;
	var dropdownValue = frm.EmailTemplateID[dropdownIndex].value;

	if (dropdownIndex < 1)
	{
		alert("Please select an email type to send.");
	}
	else
	{
		frm.method = "post";
		frm.action = "Applications.asp?Action=DoEmailSend&ID=" + nID;
		frm.submit();
	}
}

function doLogout()
{
	if (confirm("Are you sure you want to logout?  All unsaved progress will be lost."))
	{
		window.location = "Applications.asp";
	}
}

function toggle_visibility(id,lid) 
{
    var e = document.getElementById(id);
	
    if(e.style.display == 'block')
	{
	   document.getElementById(lid).innerHTML = 'View&nbsp;Project&nbsp;Description';
       e.style.display = 'none';

	}
    else
	{
	   document.getElementById(lid).innerHTML = 'Hide&nbsp;Project&nbsp;Description';
       e.style.display = 'block';
	}
}

function setActiveTab(tabID, newClassName) 
{
	var currTabElem = document.getElementById(tabID);

	currTabElem.setAttribute("class", newClassName);
	currTabElem.setAttribute("className", newClassName);
	return;
} 

function validateStep1(nQuit)
{
	validateInit();
	var frm = document.forms.frmApplication;
	var confirmStr = "";
	
	validateElement(VAL_STR, frm.ProjectTitle, "Project Title", 1, 255, VAL_NOBLANKS);
	validateElement(VAL_STR, frm.ApplicantName, "Applicant Name", 1, 255, VAL_NOBLANKS);
	validateElement(VAL_SELECT, frm.ApplicationTypeID, "Project Type", 1, null, VAL_NOBLANKS);

	validateRadio(frm.ApplicationCategoryID, "Applicant Category", VAL_NOBLANKS);

	if (valid)
	{
		if (parseInt(getRadioValue(frm.ApplicationCategoryID)) == 2)
		{
			confirmStr = "PLEASE NOTE THE FOLLOWING BEFORE PROCEEDING WITH YOUR APPLICATION\n\n";
			confirmStr += "You will be able to save your application during various stages of completion and we encourage you to do this. "; 
			confirmStr += "If you do not save after the completion of a particular section the session will time-out after one hour and any data that you have entered will be lost.\n\n";

			if (!confirm(confirmStr))
			{				
				valid = false; 
			}	
		}
		else if (parseInt(getRadioValue(frm.ApplicationCategoryID)) == 1 || parseInt(getRadioValue(frm.ApplicationCategoryID)) == 3)
		{
			confirmStr = "PLEASE NOTE THE FOLLOWING BEFORE PROCEEDING WITH YOUR APPLICATION\n\n";
			confirmStr += "You will be able to save your application during various stages of completion and we encourage you to do this. "; 
			confirmStr += "If you do not save after the completion of a particular section the session will time-out after one hour and any data that you have entered will be lost.\n\n";
			confirmStr += "To continue your application you must have an auspice funding organisation endorsed with the appropriate ATO registrations. ";
			confirmStr += "Please refer to the \"How to Qualify\" section of the website.\n\n";

			if (!confirm(confirmStr))
			{				
				valid = false; 
			}	
		}		
	}

	if (valid)
	{
		if (nQuit == 1)
		{
			frm.Quit.value = 1;
		}
		frm.submit();
	}
}

function countCharacters(currentElement, messageElement, maxCharacters)
{
	var str = new String(currentElement.value);
	var len = str.length;

	var showstr = len + " characters of " + maxCharacters + " entered";
	
	if (len > maxCharacters) {
		showstr += "<br>Some information will be lost, please revise your entry";
	}

	document.getElementById(messageElement).innerHTML = showstr;
}

