/*
	Used to display innerHTML alerts and errors.
*/

//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////                             ///////////////////////////////////
//////////////////////////////////     Error Message Stack     ///////////////////////////////////
//////////////////////////////////                             ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////
// Notify
//////////////////////////////////////////////////////////////////////////////////////////////////

	function notifyErrors(id, errors, visibleStateCSS)
		{
		// Locate and update our popup window
		object = document.getElementById(id);
		object.innerHTML = '<img src="/messageStack/images/imgMsgRed.gif" /><b style="color:#CC0000; line-height:25px; padding: 0px 0px 10px 10px;">ERROR ALERT:</b><br />';
		object.innerHTML += errors.join("<br /><br />"); 
		object.innerHTML +=  '<div id="nav03content" class="bottom"><a href="javascript:;" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Close Window">Close</a></div>';
		object.className = visibleStateCSS;	
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Subscription / Profile Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkProfileFields()
	{
		errStack = [];
		var jsFirstname			= (document.getElementById('txtFirstname'));
		var jsLastname			= (document.getElementById('txtLastname'));
		var jsCust_Phone		= (document.getElementById('txtCust_Phone'));
		var jsAddress1			= (document.getElementById('txtAddress1'));
		var jsCity				= (document.getElementById('txtCity'));
		var jsState_Province	= (document.getElementById('txtState_Province'));
		var jsPostal_Code		= (document.getElementById('txtPostal_Code'));
		var jsCountrySelect		= (document.getElementById('txtCountrySelect'));
		var jsEmail_Address		= (document.getElementById('txtEmail_Address'));
		var jsEmail_Address_2	= (document.getElementById('txtEmail_Address2'));
		var jsPassword			= (document.getElementById('txtPassword'));
		var jsPassword_2		= (document.getElementById('txtPassword_2'));
		var jsPassword_Hint		= (document.getElementById('txtPassword_Hint'));
		var jsPayCC_Type		= (document.getElementById('txtPayCC_Type'));
		var jsPayCC_Name		= (document.getElementById('txtPayCC_Name'));
		var jsPayCC_Number		= (document.getElementById('txtPayCC_Number'));
		var jsPayCC_Month		= (document.getElementById('txtPayCC_Month'));
		var jsPayCC_Year		= (document.getElementById('txtPayCC_Year'));
		var jsOrder_Subtotal	= (document.getElementById('txtOrder_SubTotal'));
		var currentDateTime		= new Date();
		var cc_Date				= new Date();

		if(jsPayCC_Year && jsPayCC_Month)
		{
			cc_Date.setFullYear(jsPayCC_Year.value,jsPayCC_Month.value,1);
		}


		// List all fields not populated by the subscriber
		if(jsFirstname)
		{
			if(jsFirstname.value === "")
			{
				errStack.push('First Name');
			}
		}

		if(jsLastname)
		{
			if(jsLastname.value === "" )
			{
				errStack.push('Last Name');
			}
		}

		if(jsCust_Phone)
		{
			if(jsCust_Phone.value === "" )
			{
				errStack.push('Phone Number');
			}
		}

		if(jsAddress1)
		{
			if(jsAddress1.value === "" )
			{
				errStack.push('Billing Address');
			}
		}

		if(jsCity)
		{
			if(jsCity.value === "" )
			{
				errStack.push('Billing City');
			}
		}

		if(jsState_Province)
		{
			if(jsState_Province.value === "" )
			{
				errStack.push('Billing State');
			}
		}

		if(jsPostal_Code)
		{
			if(jsPostal_Code.value === "" )
			{
				errStack.push('Billing ZIP Code');
			}
		}

		if(jsCountrySelect)
		{
			if(jsCountrySelect.value === "" )
			{
				errStack.push('Billing Country');
			}
		}

		if(jsEmail_Address)
		{
			if(jsEmail_Address.value === "" )
			{
				errStack.push('E-mail Address');
			}
		}

		if(jsEmail_Address_2)
		{
			if(jsEmail_Address_2.value === "" )
			{
				errStack.push('Re-Enter E-mail');
			}
		}

		if(jsPassword)
		{
			if(jsPassword.value === "" )
			{
				errStack.push('Password');
			}
		}

		if(jsPassword_2)
		{
			if(jsPassword_2.value === "" )
			{
				errStack.push('Confirm Password');
			}
		}

		if(jsPassword_Hint)
		{
			if(jsPassword_Hint.value === "" )
			{
				errStack.push('Password Hint');
			}
		}


		if((jsOrder_Subtotal) && (jsOrder_Subtotal.value > 0))
		{
			if(jsPayCC_Type)
			{
				if(jsPayCC_Type.value === "" )
				{
					errStack.push('Credit Card Type');
				}
			}

			if(jsPayCC_Name)
			{
				if((jsPayCC_Name.value === "") || (!isNaN(jsPayCC_Name.value)))
				{
					errStack.push('Name on credit card');
				}
			}

			if(jsPayCC_Number)
			{
				var vPayCC_Number	=	(jsPayCC_Number.value.replace(/-/g,''));
				vPayCC_Number		=	(vPayCC_Number.replace(/ /g,''));
				if((jsPayCC_Name.value === "") || (isNaN(vPayCC_Number)))
				{
					errStack.push('Valid Credit Card Number');
				}
			}

			if(jsPayCC_Month)
			{
				if(jsPayCC_Month.value === "" )
				{
					errStack.push('Credit card Expire Month');
				}
			}

			if(jsPayCC_Year)
			{
				if(jsPayCC_Year.value === "" )
				{
					errStack.push('Credit card Expire Year');
				}
			}
		}


		// Verify e-mail and Passwords re-entry fields are correct
		if(errStack.length > 0)
		{
			if(errStack.length == 1)
			{
				errStack[0] = 'Please enter your ' + errStack[0];
			}
			else
			{
				errStack.unshift('Please enter the following: ');
			}
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}

		// Check that e-mail addresses match
		else if(jsEmail_Address.value != jsEmail_Address_2.value)
		{
			errStack.push('The "Re-Enter E-mail" field does not match the "E-mail Address" field.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		
		// check for valid e-mail address
		else if(! isValidEmailAddress(jsEmail_Address.value))
		{
			errStack.push('Please enter a valid e-mail address and continue.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}

		// Check that passwords match
		else if(jsPassword.value != jsPassword_2.value)
		{
			errStack.push('The "Confirm Password" field does not match the "Password" field.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}

		// check that password is at least 6 characters in length
		else if(jsPassword.value.length < 6)
		{
			errStack.push('The password needs to be at least 6 characters in length.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		
		// Check that Credit Card is not Expired
		else if((jsOrder_Subtotal) && (jsOrder_Subtotal.value > 0))
		{
			if(cc_Date <= currentDateTime)
			{
				errStack.push('You have entered an expired credit card date.');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
			}
			else
			{
				document.subscribeForm.submit();
			}
		}

		else
		{
			document.subscribeForm.submit();
		}
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Subscription Credit Card Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkCCerrors(jsError)
	{
		errStack = [];
		var sError			= (jsError);

		if(sError		==	1)
		{
			errStack.push('Your credit card failed.');
			errStack.push('Please verify all of your information is correct and resubmit your order.');
			errStack.push('Thank You!');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
		}

		else if(sError	==	2)
		{
			errStack.push('Your credit card transaction encountered an unexpected failure between AGES-online and the verification provider.');  
			errStack.push('AGES-online has been notified to review the failure and will contact you via e-mail.');
			errStack.push('Thank You!');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
		}
	}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Subscription Credit Card Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function isDuplicateEmail()
	{
		errStack = [];

		errStack.push('FREEZE!!! FBI...  You are fraudulantly attempting to use an existing e-mail address.');
		errStack.push('');
		errStack.push('');
		notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
	}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Username/Password Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkEmailPassword()
	{
		errStack = [];
		var jsEmail_Address		= (document.getElementById('txtEmail_Address'));
		var jsEmail_Address_2	= (document.getElementById('txtEmail_Address2'));
		var jsPassword			= (document.getElementById('txtPassword'));
		var jsPassword_2		= (document.getElementById('txtPassword_2'));
		var jsPassword_Hint		= (document.getElementById('txtPassword_Hint'));

		if(jsEmail_Address)
		{
			if(jsEmail_Address.value === "" )
			{
				errStack.push('E-mail Address');
			}
		}

		if(jsEmail_Address_2)
		{
			if(jsEmail_Address_2.value === "" )
			{
				errStack.push('Re-Enter E-mail');
			}
		}

		if(jsPassword)
		{
			if(jsPassword.value === "" )
			{
				errStack.push('Password');
			}
		}

		if(jsPassword_2)
		{
			if(jsPassword_2.value === "" )
			{
				errStack.push('Confirm Password');
			}
		}

		if(jsPassword_Hint)
		{
			if(jsPassword_Hint.value === "" )
			{
				errStack.push('Password Hint');
			}
		}

		if(errStack.length > 0)
		{
			if(errStack.length == 1)
			{
				errStack[0] = 'Please enter your ' + errStack[0];
			}
			else
			{
				errStack.unshift('Please enter the following: ');
			}
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		else if(! isValidEmailAddress(jsEmail_Address.value))
		{
			errStack.push('Please enter a valid e-mail address and continue.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		else if(jsEmail_Address.value != jsEmail_Address_2.value)
		{
			errStack.push('The re-entered e-mail address does not match the e-mail address');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		else if(jsPassword.value != jsPassword_2.value)
		{
			errStack.push('The confirmation password does not match the password');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		else if(jsPassword.value.length < 6)
		{
			errStack.push('The password needs to be at least 6 characters in length.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg04');
		}
		else
		{
			document.frmProfileEdit.submit();
		}
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
// File Extension Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkFileExtensionErrors(jsErrorCode,jsFileExtension,jsMessage1,jsMessage2,jsMessage3)
		{
		errStack = [];
		var eErrorCode			= (jsErrorCode);
		var eFileExtension		= (jsFileExtension);
		var eMessage1			= (jsMessage1);
		var eMessage2			= (jsMessage2);
		var eMessage3			= (jsMessage3);
		
		if(eErrorCode		== 1)
			{
			errStack.push("You have attempted to upload an invalid file type.<br />." + eFileExtension);
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		else if(eErrorCode	== 2)
			{
			errStack.push('Please enter a valid path and file name before clicking "Upload".');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		else if(eErrorCode	== 3)
			{
			errStack.push('Failed to Rescale Original file.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		else if(eErrorCode	== 4)
			{
			errStack.push('Failed to Create Thumb File.<br />' + eMessage1 + '<br />' + eMessage2 + '<br />' + eMessage3);
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		else if(eErrorCode	== 5)
			{
			errStack.push('Unable to Rename File.<br />' + eMessage1 + '<br />' + eMessage2 + '<br />' + eMessage3);
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		else if(eErrorCode	== 6)
			{
			errStack.push('You do not have enough storage space available to upload this image.<br /><br />Image size: ' + eMessage1 + ' bytes<br>Available space: ' + eMessage2 + '<br>' + eMessage3 + ' bytes');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Source Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkSourceErrors()
	{
		errStack = [];
		var vRepositoryName	= (document.getElementById('txtRepository_Name').value);
		var vIdSourceRepository	= (document.getElementById('txtIdSource_Repository').value);
		var vIdSourceRepositoryDropdown	= (document.getElementById('txtIdSource_Repository_Dropdown').value);

		if(vRepositoryName === "" && vIdSourceRepository >= 0 && vIdSourceRepositoryDropdown >= 0)
		{
			errStack.push('Please enter a <b>Repository Name</b> before saving the form.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg02');
		}
		else
		{
			document.frmInputSourceData.submit();
		}
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
// GEDCOM Import Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkGedcomForm() 
		{
			errStack = [];
			var filenameString 		= (document.frmUploadGedcom.file1.value);
			var lenFilenameString 	= (filenameString.length);
			var fileExtension 		= (filenameString.substring(lenFilenameString-4,lenFilenameString));
			fileExtension 			= (fileExtension.replace(/^\s+|\s+$/g, ''));

			if (fileExtension.toLowerCase() != ".ged") 
			{
				errStack.push('Please enter a Gedcom file.  Gedcom file names end with ".ged".');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
			else
			{
				document.frmUploadGedcom.submit();
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Display for IsPreferred Errors on Summary Delete
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkIsPreferredErrors(jsDetailPage,jsStatusGroupType,jsBirthGroupType,jsDeathGroupType,jsRelationshipGroupType,jsAdoptionGroupType,jsSealingGroupType,jsNameGroupType)
		{ 
		//Reset errStack Array to empty
		errStack = [];
		var eDetailPage				= (jsDetailPage);
		var eStatusGroupType		= (jsStatusGroupType);
		var eBirthGroupType			= (jsBirthGroupType);
		var eDeathGroupType			= (jsDeathGroupType);
		var eRelationshipGroupType	= (jsRelationshipGroupType);
		var eAdoptionGroupType		= (jsAdoptionGroupType);
		var eSealingGroupType		= (jsSealingGroupType);
		var eNameGroupType			= (jsNameGroupType);

		if(eDetailPage == 1)
			{
			if(eStatusGroupType == 1)
				{	
				errStack.push("You must select a <b>Relationship Status</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}

			else if(eBirthGroupType == 1)
				{
				errStack.push("You must select a <b>Birth</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}

			else if(eDeathGroupType == 1)
				{
				errStack.push("You must select a <b>Death</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}

			else if(eRelationshipGroupType == 1)
				{
				errStack.push("You must select a <b>Spousal Relationship</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}

			else if(eAdoptionGroupType == 1)
				{
				errStack.push("You must select an <b>Adoption</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}

			else if(eSealingGroupType == 1)
				{
				errStack.push("You must select a <b>Child Sealing</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}

			else
				{
				document.frmDetailChecked.submit();
				}
			}
		else if(eDetailPage == 2)
			{
			if(eNameGroupType == 1)
				{
				errStack.push("You must select a <b>Name</b> record to be displayed before deleting the currect Display record.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}
			
			else
				{
				document.frmNamesList.submit();
				}
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Display Date Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkDateErrors(jsDateError,jsDate,jsDateTo,jsMsgString)
	{ 
		//Reset errStack Array to empty
		errStack = [];
		var eDateError			= (jsDateError);
		var eDate				= (jsDate);
		var eDateTo				= (jsDateTo);
		var eMsgString			= (jsMsgString);

		switch(eDateError)
		{
			case	1:
			case	2:
			case	4:
			case	6:
			case	7:
				errStack.push('Please enter a valid date in the <b>' + eMsgString + '</b> field.<br/><br/>Valid formats are "M D Y", "M Y", <br/>"Y M D", "Y M" and "Y".');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg02');
				break;

			case	3:
			case	8:
				errStack.push('The date specified must be less than today\'s date. Please enter a valid date in the <b>' + eMsgString + '</b> field.<br/><br/>Valid formats are "M D Y", "M Y", <br/>"Y M D", "Y M" and "Y".');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg02');
				break;
			
			case	5:
				errStack.push('You have entered an invalid Gregorian overlap date. Please enter a valid date in the <b>' + eMsgString + '</b> field.<br/><br/>Valid formats are "M D Y", "M Y", <br/>"Y M D", "Y M" and "Y".');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg02');
				break;

			case	9:
				errStack.push('The <b>' + eMsgString + '</b> must be greater than or equal to ' + eDate + '.');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg02');
				break;
		}
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Display Family Event Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkFamilyErrors(jsFamilyError,jsNounString)
		{ 
		//Reset errStack Array to empty
		errStack = [];
		var eFamilyError		= (jsFamilyError);
		var eNounString			= (jsNounString);

		if(eFamilyError == 1)
			{
			errStack.push('Please select a ' + eNounString + ' from the "' + eNounString + ' Name" dropdown to complete this entry.');
			notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Display Errors based on Category
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkErrors(catagory) 
		{ 
		//Reset errStack Array to empty
		errStack = [];

		// Set High-level Variables
		var pSelectCategory = (catagory);

		// Category Specific Conditions

		if(pSelectCategory == 9) // Source or Repository
			{
			// Set Category Specific Variables
			var vRepositoryName	= (document.frmInputSourceData.txtRepository_Name.value);
			var vSourceRepository	= (document.frmInputSourceData.txtIDSource_Repository.value);

			if(vRepositoryName === "" && vSourceRepository >= 0)
				{
				errStack.push('Please enter a "Location Name" to complete this entry.');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}
			else
				{
				document.frmInputSourceData.submit();
				}
			}

		else if(pSelectCategory == 10)  // Citations
			{
			// Set Category Specific Variables
			var vSourceCertaintyType = (document.frmInputCitations.txtIDSource_Certainty_Type.value);

			if(vSourceCertaintyType < 1)
				{
				errStack.push("Please select citation accuracy from the Citation Accuracy dropdown to complete this entry.");
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
				}
			else
				{
				document.frmInputCitations.submit();
				}
			}

		}

//////////////////////////////////////////////////////////////////////////////////////////////////
// Web Preference URL Select Errors
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkURLerrors(jsURLerrorCode) 
		{
			errStack = [];
			var urlErrorCode 	= (jsURLerrorCode);

			if (urlErrorCode == 1)
			{
				errStack.push('That subdomain name is considered inappropriate and therefore is not allowed.');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
			else if (urlErrorCode == 2)
			{
				errStack.push('That subdomain is not available in combination with that domain name.  Please try again.');
				notifyErrors('notifyPopup', errStack, 'visibleErrorMsg01');
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////     Confirmation Message Stack     ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////
// Notify
//////////////////////////////////////////////////////////////////////////////////////////////////

	function notifyConfirmation(id, errors, vId, vAction, visibleStateCSS) 
		{
		// Locate and update our popup window
		object = document.getElementById(id);
		object.innerHTML = '<img src="/messageStack/images/imgMsgOrange.gif" /><b style="color:#FF6600; line-height:25px; padding: 0px 0px 10px 10px;">CONFIRMATION:</b><br />';

		if(vAction == 'delete')
			{
			object.innerHTML += errors.join("\n"); 
			object.innerHTML +=  '<div id="nav03content" class="bottom"><a href="/application/fgf/fgfMainAct.cfm?fgfAction=delete&idPerson='+ vId +'" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Delete This Person">&nbsp;OK&nbsp;</a><a href="javascript:;" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Close Window">Cancel</a></div>';
			object.className = visibleStateCSS;
			}
		else if(vAction == 'deleteAll')
			{
			object.innerHTML += errors.join("\n"); 
			object.innerHTML +=  '<div id="nav03content" class="bottom"><a href="/application/mainSideMenu/mainSideMenuAct.cfm?msmAction=DeleteAll" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Delete All Records">&nbsp;OK&nbsp;</a><a href="javascript:;" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Close Window">Cancel</a></div>';
			object.className = visibleStateCSS;
			}
		else if(vAction == 'deleteIsPreferred')
			{
			object.innerHTML += errors.join("\n"); 
			object.innerHTML +=  '<div id="nav03content" class="bottom"><a href="/application/editDetails/editEventsDetailsAct.cfm?msIdDetail='+ vId +'&msError=2&msForm=frmDetailChecked" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Delete Displayed Records">&nbsp;OK&nbsp;</a><a href="javascript:;" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Close Window">Cancel</a></div>';
			object.className = visibleStateCSS;
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// IsPreferred Delete Confirmation
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkIsPreferredConfirmation(jsIdDetail,jsRelationshipGroupType)
		{ 
		errStack = [];
		// Set Variables
		var vId						= (jsIdDetail);
		var eRelationshipGroupType	= (jsRelationshipGroupType);
		var vAction					= ('deleteIsPreferred');
		
		if(eRelationshipGroupType == 1)
			{
			errStack.push("Deleting this record will delete the relationship between the two individuals.  Are you Sure you want to proceed?");
			notifyConfirmation('notifyPopup', errStack, vId, vAction, 'visibleConfirmMsg01');
			}
		
		else
			{
			document.frmDetailChecked.submit();
			}
		}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Person Delete Confirmation
//////////////////////////////////////////////////////////////////////////////////////////////////

	function checkConfirmation(personId, action, type)
		{ 
		errStack = [];
		// Set Variables
		var vId = (personId);
		var vAction = (action);
		var vType = (type);
		// Determines the action and type of record in order to display correct errStack message and what css style to use for popup positioning.
		if(vAction == 'delete')
			{ 
			if(vType == 'focus')
				{
				errStack.push("Are you sure you want to delete this person and all associated records and images? This cannot be undone.");
				notifyConfirmation('notifyPopup', errStack, vId, vAction, 'visibleConfirmMsg01');
				}
			else if(vType == 'spouse')
				{
				errStack.push("Are you sure you want to delete this person and all associated records and images? This cannot be undone.");
				notifyConfirmation('notifyPopup', errStack, vId, vAction, 'visibleConfirmMsg02');
				}
			else if(vType == 'child')
				{
				errStack.push("Are you sure you want to delete this person and all associated records and images? This cannot be undone.");
				notifyConfirmation('notifyPopup', errStack, vId, vAction, 'visibleConfirmMsg03');
				}
			}
		else if (vAction == 'deleteAll')
			{
			errStack.push("Are you sure you want to delete all your records? This cannot be undone.");
			notifyConfirmation('notifyPopup',errStack, vId, vAction, 'visibleConfirmMsg01');
			}
		else
			{
			alert("variables failed");
			}
		}	



//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////           Notify Success           ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////
// Notify Success
//////////////////////////////////////////////////////////////////////////////////////////////////

	function notifySuccess(id, errors, visibleStateCSS)
	{
		// Locate and update our popup window
		object = document.getElementById(id);
		object.innerHTML = '<img src="/messageStack/images/imgMsgBlue.gif" /><b style="color:#333399; line-height:25px; padding: 0px 0px 10px 10px;">CONGRATULATIONS:</b><br /><br />';
		object.innerHTML += errors.join("<br /><br />");
		object.innerHTML +=  '<div id="nav03content" class="bottom"><a href="javascript:;" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Close Window">Close</a></div>';
		object.className = visibleStateCSS;	
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Confirm or Deny credit card
//////////////////////////////////////////////////////////////////////////////////////////////////

	function confirmCredit(jsConfirm)
	{
		errStack = [];
		var vConfirm	=	(jsConfirm);

		if(vConfirm ==	1)
		{
			errStack.push('Thank you for subscribing to AGES-online.  You will receive a receipt via e-mail.  ');
			errStack.push('Please ensure your spam blocker permits e-mails from the address ages.contact@ages-online.com and confirmation@ages-online.com.');
			notifySuccess('notifyPopup', errStack, 'visibleSuccessMsg01');
		}
	}



//////////////////////////////////////////////////////////////////////////////////////////////////
// GEDCOM Upload Success
//////////////////////////////////////////////////////////////////////////////////////////////////

	function confirmGedcom(jsConfirm)
	{
		errStack = [];
		var vConfirm	=	(jsConfirm);

		if(vConfirm ==	1)
		{
			errStack.push('Your GEDOM has been successfully imported.');
			errStack.push('Click on the Back to FGF icon in the top right corner of this form to get started.');
			notifySuccess('notifyPopup', errStack, 'visibleSuccessMsg01');
		}
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////        Notify Intermediate         ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////
// Notify Intermediate
//////////////////////////////////////////////////////////////////////////////////////////////////

	function notifyIntermediate(id, errors, visibleStateCSS)
	{
		// Locate and update our popup window
		object = document.getElementById(id);
		object.innerHTML = '<table><tr><td><img src="/messageStack/images/imgMsgBlue.gif" /></td><td><b style="font-size:13px; color:#333399; line-height:200%;">&nbsp;INFORMATION</b></td></tr></table><div id="idFootNote"></div>';
		object.innerHTML += errors.join("<br /><br />");
		object.innerHTML +=  '<div id="nav03content" class="bottom"><a href="javascript:;" onclick="javascript:document.getElementById(\'' + id + '\').className = \'hiddenState\';" value="Close Window">Close</a></div>';
		object.className = visibleStateCSS;	
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
// GEDCOM Upload Processing in Background
//////////////////////////////////////////////////////////////////////////////////////////////////

	function backgroundProcessGedcom(jsFilename)
	{
		errStack = [];
		
		errStack.push('Your file, ' + jsFilename + ' will take a while to upload. We will send you an e-mail when your data is uploaded. Please make sure your email program is set up to accept emails from confirmation@ages-online.com.');
		errStack.push('In the meantime, check out the Tutorial on the Help Guide menu to the right or the Learning Center on the top menu.');
		notifyIntermediate('notifyPopup', errStack, 'visibleSuccessMsg01');
	}


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////         Support Functions          ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////
// check valid email address
//////////////////////////////////////////////////////////////////////////////////////////////////

	function isValidEmailAddress(jsEmailAddress)
	{
		var period = -1;
		var atSymbol = jsEmailAddress.indexOf('@',1);

		if (atSymbol	>=	0)
		{
			period = jsEmailAddress.indexOf('.',atSymbol + 2);
		}
		
		if((atSymbol == -1) || (period == -1))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
//////////////////////////////////////////////////////////////////////////////////////////////////
//End

