
/////////////////////////////////////////////
// e-mail-results.js
// Copyright 2006, 1995 Sustainable By Design
/////////////////////////////////////////////


	/////////////////////////////////////////////////////////
	//
	//  FUNCTION:  EmailResults
	//
	/////////////////////////////////////////////////////////
	
		function EmailResults () {
		
			var f = document.theForm;
			
		// ---------------------------------------------
		// compute outputs
		// ---------------------------------------------
 
 			if (CheckInputs ()) {
 			
 				compute ();
 			}
 			
 			else {
 			
 				return false;
 			}
 			
		// ---------------------------------------------
		// get e-mail address
		// ---------------------------------------------
 
 			eMail = Trim (f.eMail.value);
 			
 			if (! Validate_Email_Address (eMail)) {
 			
 				alert ("Please enter the e-mail address to which you'd like the data to be sent, then click the SEND button. Enter a single address, with no spaces.");

				return false;
 			}

		// =============================================
		// ---------------------------------------------
		// outputs
		// ---------------------------------------------
		// =============================================


			// ---------------------------------------------
			// output
			// ---------------------------------------------
			
			var data = f.outputs.value;

		// ---------------------------------------------
		// create e-mail content
		// ---------------------------------------------

			var eMailSubject = "SunPosition data";

			var header = "\
-----------------------------------------\n\
SunPosition Results\n\
-----------------------------------------";

			var footer = Create_Email_Footer ('SunPosition', 'sunposition');

			var eMailBody = header + "\n\n" + data + "\n\n\n" + footer + "\n\n";

			var eMailData = eMail + "###" + eMailSubject + "###" + eMailBody;

			
		// ---------------------------------------------
		// send e-mail Ajax request
		// ---------------------------------------------

			Send_Email (eMailData);
		}
		

	/////////////////////////////////////////////////////////
	//
	//  FUNCTION:  AJAX_Handle_Response
	//
	/////////////////////////////////////////////////////////
	
		function AJAX_Handle_Response (response) {
		
			Send_Email_Feedback (response);
		}
 		