﻿//-----------------------------------------------------------------------------------
//	Module:		Validation.js
//	Purpose:	Provides client side validation support for forms
//	History:
//		070906 JLB	Created file
//-----------------------------------------------------------------------------------

//----------------------------------------------
// Display upload message
//----------------------------------------------

function ValidateMessage() {
	var objError = document.getElementById(LAB_ERROR);
	objError.innerHTML = "Uploading, please wait ...";
	return true;
} //ValidateMessage

/*---------------------------------------------------------------------------------
Function:		ValidateRegistrationEdit
Purpose:		Queries any status change in when a registration is modified
---------------------------------------------------------------------------------*/

function ValidateRegistrationEdit()
{
	var blnAllow = true;
	var strMsg = "";
	var strCurrentStatus = document.getElementById(TXT_STATUS).value;
	var strNewStatus = GetSelectedRadioButton(GRP_STATUS);
	var blnCurrentAccepted = ((strCurrentStatus == "Client") || (strCurrentStatus == "Administrator"))
	var blnNewAccepted = ((strNewStatus == "Client") || (strNewStatus == "Administrator"))
	if ((blnCurrentAccepted) && (!blnNewAccepted)) {
		strMsg = "You are about to change the status of an existing user.\n";
		if (strNewStatus == "Rejected")
			strMsg+= " - A rejection email will be sent to the user.\n";
		strMsg+= " - The user's login will be removed from the system.\n\n";
		strMsg+= "Please confirm that you wish to proceed by clicking OK";
		blnAllow = confirm(strMsg);
	}
	else if ((blnNewAccepted) && (!blnCurrentAccepted)) {
		strMsg = "You are about to change the status of a pending or rejected user.\n";
		strMsg+= " - A new login will be created for the user.\n";
		strMsg+= " - An acceptance email with their login details will\n";
		strMsg+= "   be sent to the user.\n\n";
		strMsg+= "Please confirm that you wish to proceed by clicking OK";
		blnAllow = confirm(strMsg);
	}
	return blnAllow;
} //ValidateRegistrationEdit

/*---------------------------------------------------------------------------------
	Function:		ValidateDeleteClass
	Purpose:		Queries that the user wants to remove the class
	---------------------------------------------------------------------------------*/

function ValidateDeleteClass()
{
	var strMsg = "";
	strMsg = "You are about to remove a class from the fund.\n\n";
	strMsg+= "Please confirm that you wish to proceed by clicking OK";
	return confirm(strMsg);
} //ValidateDeleteClass

/*---------------------------------------------------------------------------------
	Function:		ValidateDeleteNewsletter
	Purpose:		Queries that the user wants to remove the newsletter
	---------------------------------------------------------------------------------*/

function ValidateDeleteNewsletter()
{
	var strMsg = "";
	strMsg = "You are about to remove a newsletter from the fund.\n\n";
	strMsg+= "Please confirm that you wish to proceed by clicking OK";
	return confirm(strMsg);
} //ValidateDeleteNewsletter

/*---------------------------------------------------------------------------------
	Function:		GetSelectedRadioButton
	Purpose:		Return value of selected radio button group
	---------------------------------------------------------------------------------*/

function GetSelectedRadioButton(strName)
{
	var aObjBtn = document.getElementsByName(strName);
	var objBtn = null;
	var strValue = "";
	for (var intIndex = 0;intIndex < aObjBtn.length;intIndex++) {
		objBtn = aObjBtn[intIndex];
		if (objBtn.checked == true)
			strValue = objBtn.value;
	}
	return strValue;
} //GetSelectedRadioButton

/*---------------------------------------------------------------------------------
	Function:		FundEdit
	Purpose:		Execute fund edit page
	---------------------------------------------------------------------------------*/

function FundEdit(intFundID, intClassID)
{
	document.location.href = "PerformanceEllerstonFundsEdit.aspx?f=" + intFundID + "&c=" + intClassID;
	return false;
} //FundEdit

/*---------------------------------------------------------------------------------
	Function:		ArchiveEdit
	Purpose:		Execute Archive edit page
	---------------------------------------------------------------------------------*/

function ArchiveEdit(intFundID, intArchiveID)
{
	document.location.href = "PerformanceEllerstonArchiveEdit.aspx?f=" + intFundID + "&a=" + intArchiveID;
	return false;
} //ArchiveEdit

/*---------------------------------------------------------------------------------
	Function:		PortfolioView
	Purpose:		Execute Portfolio view page
	---------------------------------------------------------------------------------*/

function PortfolioView(intUserID, intClassID)
{
	document.location.href = "PortfolioHolding.aspx?u=" + intUserID + "&c=" + intClassID;
	return false;
} //PortfolioView

/*---------------------------------------------------------------------------------
	Function:		PortfolioEdit
	Purpose:		Execute Portfolio edit page
	---------------------------------------------------------------------------------*/

function PortfolioEdit(intUserID, intClassID)
{
	document.location.href = "PortfolioHoldingEdit.aspx?u=" + intUserID + "&c=" + intClassID;
	return false;
} //PortfolioEdit

/*---------------------------------------------------------------------------------
	Function:		PortfolioDelete
	Purpose:		Execute Portfolio edit page
	---------------------------------------------------------------------------------*/

function PortfolioDelete(intUserID, intClassID)
{
	var strMsg = "";
	strMsg = "You are about to remove a holding from your portfolio.\n\n";
	strMsg+= "Please confirm that you wish to proceed by clicking OK";
	return confirm(strMsg);
} //PortfolioDelete

