///////////////////////////////    Create Multi-Message String     ///////////////////////////////
///////////////////////////////    Create Single-Message String    ///////////////////////////////
///////////////////////////////        Missing Data Errors         ///////////////////////////////
///////////////////////////////        Account Data Errors         ///////////////////////////////
///////////////////////////////      Duplicate Email Address       ///////////////////////////////
///////////////////////////////         Credit Card Errors         ///////////////////////////////
///////////////////////////////        Discount CodeErrors         ///////////////////////////////
///////////////////////////////            Login Errors            ///////////////////////////////
///////////////////////////////         Gedcom File Errors         ///////////////////////////////
///////////////////////////////      Multimedia Upload Errors      ///////////////////////////////
///////////////////////////////         Contact Us Errors          ///////////////////////////////
///////////////////////////////       E-mail Message Failure       ///////////////////////////////
///////////////////////////////     E-mail Message Successful      ///////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////    Create Multi-Message String     ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var createMultiMsgString = function(errStack)
{
	var jsMessage = "<div class=\"errMessage\">"; 
	jsMessage += errStack.join("</div><div class=\"listItem\">");
	jsMessage += "</div>";

	return jsMessage;
};




//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////    Create Single-Message String    ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var createSingleMsgString = function(errStack)
{
	var jsMessage = "<div class=\"errMessage\">";
	jsMessage	+=	errStack[0]; 
	jsMessage	+=	"</div>"; 

	return jsMessage;
};




//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////        Missing Data Errors         ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var errMissingData	= function(jsErrorCodeArray)
{
	errStack = new Array();
	var msgType			=	1;
	var msgTitle		=	'Missing Data!';
	var msgWidth		=	250;
	var msgHeight		=	'auto';

	for(nextError=0; nextError < jsErrorCodeArray.length; nextError++)
	{
		switch(jsErrorCodeArray[nextError])
		{
			case	19:
				errStack.push('&bull;  Account Nickname');
				break;
			
			case	1:
				errStack.push('&bull;  First Name');
				break;
			
			case	2:
				errStack.push('&bull;  Last Name');
				break;

			case	3:
				errStack.push('&bull;  Phone Number');
				break;

			case	4:
				errStack.push('&bull;  Billing Address');
				break;

			case	5:
				errStack.push('&bull;  Billing City');
				break;

			case	6:
				errStack.push('&bull;  Billing State');
				break;

			case	7:
				errStack.push('&bull;  Billing Postal Code');
				break;

			case	8:
				errStack.push('&bull;  Billing Country');
				break;

			case	9:
				errStack.push('&bull;  E-mail Address');
				break;

			case	10:
				errStack.push('&bull;  Re-Enter E-mail');
				break;

			case	11:
				errStack.push('&bull;  Password');
				break;

			case	12:
				errStack.push('&bull;  Confirm Password');
				break;

			case	13:
				errStack.push('&bull;  Password Hint');
				break;

			case	14:
				errStack.push('&bull;  Credit Card Type');
				break;

			case	15:
				errStack.push('&bull;  Name on credit card');
				break;

			case	16:
				errStack.push('&bull;  Valid Credit Card Number');
				break;

			case	17:
				errStack.push('&bull;  Credit card Expire Month');
				break;

			case	18:
				errStack.push('&bull;  Credit card Expire Year');
				break;

			default:
		}
	}

	errStack.unshift('Please enter the following: ')

	var msgString = createMultiMsgString(errStack);
	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);
};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////        Account Data Errors         ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var errAccountData	= function(jsErrorCode)
{
	errStack = new Array();
	var msgType			=	1;
	var msgTitle		=	'Error!';
	var msgWidth		=	300;
	var msgHeight		=	'auto';

	switch(jsErrorCode)
	{
		// E-mail addresses don't match
		case	101:
			errStack.push('The "Re-Enter E-mail" field does not match the "E-mail Address" field.');
			break;
		
		case	102:
			errStack.push('You have Entered an Invalid E-mail Address.');
			break;

		// Passwords don't match
		case	103:
			errStack.push('The "Confirm Password" field does not match the "Password" field.');
			break;
		
		// Password is less than 6 characters in length
		case	104:
			errStack.push('The password needs to be at least 6 characters in length.');
			break;

		case	105:
			errStack.push('You have Entered an Invalid E-mail Address.');
			break;

		default:
	}

	var msgString = createSingleMsgString(errStack);
	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);

};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////      Duplicate Email Address       ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var errDuplicateEmail	= function(jsErrorCode)
{
	errStack = [];
	var msgType			=	4;
	var msgTitle		=	'Existing Account?';
	var msgWidth		=	300;
	var msgHeight		=	'auto';
	var msgConfirm		=	'';

	if (jsErrorCode	==	102)
	{
		// Duplicate e-mail address
		errStack.push("Do you currently have an account established with AGES-online as an Owner or a username set up on someone else's account?");
		msgConfirm = "<div class=\"ok-modal bottom\"><a href=\"javascript:;\" title=\"Yes\" onclick=\"document.subscribeForm.submit();modalWindow.close();\">Yes<\/a><a href=\"javascript:;\" title=\"No\" onclick=\"javascript:modalWindow.close();errAccountData(" + jsErrorCode + ");\">No<\/a><\/div>";
	}
	var msgString = createSingleMsgString(errStack);
	openConfirmModal(msgType,msgTitle,msgString,msgWidth,msgHeight,msgConfirm);
};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////         Credit Card Errors         ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var errCreditCard	= function(jsErrorCode)
{
	errStack = new Array();
	var msgType			=	1;
	var msgTitle		=	'Error!';
	var msgWidth		=	300;
	var msgHeight		=	'auto';

	switch(jsErrorCode)
	{
		// Invalid Credit Card Number
		case	106:
			errStack.push('Please enter a vaild Credit Card number');
			break;

		// Invalid Credit Card Type
		case	107:
			errStack.push('Please select a vaild Credit Card Type');
			break;
		
		// Expired Credit Card 
		case	108:
			errStack.push('You have entered an expired Credit Card date.');
			break;

		default:
	}
	var msgString = createSingleMsgString(errStack);
	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);
};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////        Discount CodeErrors         ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var errDiscountCode	= function(jsErrorCode)
{
	errStack = new Array();
	var msgType			=	1;
	var msgTitle		=	'Error!';
	var msgWidth		=	300;
	var msgHeight		=	'auto';

	switch(jsErrorCode)
	{
		// Invalid Credit Card Number
		case	109:
			errStack.push('Please enter a vaild Promotion Code.');
			break;

		default:
	}
	var msgString = createSingleMsgString(errStack);
	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);
};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////            Login Errors            ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var errLogin	= function(jsErrorCode)
{
	errStack = new Array();
	var msgType			=	1;
	var msgTitle		=	'Login Failed!';
	var msgWidth		=	300;
	var msgHeight		=	'auto';

	switch(jsErrorCode)
	{
		// Invalid Username 
		case	201:
			errStack.push('You have entered an invalid username or password, please try again.');
			break;

		// Invalid Password
		case	202:
			errStack.push('You have entered an invalid username or password, please try again.');
			break;

		// Inactive account
		case	203:
			errStack.push('The account which you are attempting to access is inactive.');
			break;
		
		case	204:
			errStack.push('Your access has been deactivated by the account owner.');
			break;
		
		case	205:
			errStack.push('The account which you are attempting to access is inactive.');
			break;
		
		case	206:
			errStack.push('You have entered an invalid username, please try again.');
			break;
		
		default:
	}
	var msgString = createSingleMsgString(errStack);
	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);
};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////         Gedcom File Errors         ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var gedcomFileError	= function(errMsg)
{
	var msgType			=	1;
	var msgTitle		=	'Gedcom Import Failed!';
	var msgWidth		=	300;
	var msgHeight		=	'auto';

	var msgString = "<div class=\"errMessage\">" + errMsg + "</div>";

	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);
	
};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////      Multimedia Upload Errors      ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var multimediaUploadError	= function(jsErrorCode,jsFileExtension,jsMessage1,jsMessage2,jsMessage3)
{
	var msgType				=	1;
	var msgTitle			=	'Multimedia Upload Failed!';
	var msgWidth			=	300;
	var msgHeight			=	'auto';

	var msgString			=	"<div class=\"errMessage\">";
	var eFileExtension		= (jsFileExtension);
	var eMessage1			= (jsMessage1);
	var eMessage2			= (jsMessage2);
	var eMessage3			= (jsMessage3);

	switch(jsErrorCode)
	{
		case "1":
			msgString	=	msgString + "You have attempted to upload an invalid file type, ." + eFileExtension + ".<br />";
			break;
			
		case "5":
			msgString	=	msgString + 'The file name has a "&" in the title.  Please rename the file and try again.<br />' + eMessage1 + '<br />' + eMessage2 + '<br />' + eMessage3;
			break;
			
		case "6":
			msgString	=	msgString + 'You do not have enough storage space available to upload this image.<br /><br />Image size: ' + eMessage1 + ' bytes<br />Available space: ' + eMessage2 + ' bytes';
			break;
			
		default:
			msgString	=	msgString + 'The application encountered an unknown error.  An email has been sent to AGES Support for resolution.<br />';
	}
	
	msgString	=	msgString + "</div>";
	openMsgModal(msgType,msgTitle,msgString,msgWidth,msgHeight);

};


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////         Contact Us Errors          ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var	contactUsErrors = function(jsErrorCode)
{
	var errorCode	=	(jsErrorCode);
	var msgType		=	1;
	var msgWidth	=	300;
	var msgHeight	=	'auto';
	var msgString	=	"";

	switch(errorCode)
	{
		case	1:
			msgString = 'Please enter your Name and click "Submit".';
			break;
	
		case	2:
			msgString = 'Please enter your E-mail address and click "Submit".';
			break;
		
		case	3:
			msgString = 'Please enter your Phone number and click "Submit".';
			break;
		
		case	4:
			msgString = 'Please enter message text and click "Submit".';
			break;
		
		case	5:
			msgString = 'Please enter a valid email address and click "Submit".';
			break;
		
		case	6:
			msgString = 'The Character Mix you entered is incorrect, please refresh your screen and try again.';
			break;

		default:
			msgString = 'Please verify all fields are populated correctly.';
	}
	msgString		=	"<div class=\"errMessage\">" + msgString + "</div>";
	openMsgModal(msgType,'Error Alert!',msgString,msgWidth,msgHeight);
}


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////       E-mail Message Failure       ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var	emailSentFail = function()
{
	var msgType		=	1;
	var msgWidth	=	300;
	var msgHeight	=	'auto';

	var msgString	= 'The email server has encountered a problem.<br /><br />  Sorry for the inconvenience, please try again later.';
	msgString		=	"<div class=\"errMessage\">" + msgString + "</div>";
	openMsgModal(msgType,'Error Alert!',msgString,msgWidth,msgHeight);
}


//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////                                    ///////////////////////////////
///////////////////////////////     E-mail Message Successful      ///////////////////////////////
///////////////////////////////                                    ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

var	emailSentSuccess = function()
{
	var msgType		=	2;
	var msgWidth	=	300;
	var msgHeight	=	'auto';

	var msgString	=	'Your message has been submitted successfully!';
	msgString		=	"<div class=\"errMessage\">" + msgString + "</div>";
	openMsgModal(msgType,'Success',msgString,msgWidth,msgHeight);
}


