// Functions for Premium Donations // Copyright (c) 2002 Covenant of the Goddess// Constants.// Set the premium donation date to today, formatted in IS0-8601 preferred format.function setDate(){  // Format the current date per ISO-8601 preferred format.  var now = new Date();  var today = now.getFullYear().toString() + "-";  if( now.getMonth() < 9 ) today += "0";  today += ( now.getMonth() + 1 ).toString() + "-";  if( now.getDate() < 10 ) today += "0";  today += now.getDate().toString();  document.premiums.premiumsdate.value = today;}// Validate the Premiums form.function preparePremiumsSubmission(){  result=false;  // Return false to prevent submit, true to allow submit to procede.  computeDonation();  result = validatePremiumsForm();  if( !result ) return result;  return true;}// Compute the total donation amount.function computeDonation(){  var totalDonation = 0.00;  var amt;  amt=eval( document.premium.Q_25.value);  if( amt != null && amt > 0.00 )     totalDonation += amt*eval( document.premium.P_25.value);  amt=eval( document.premium.Q_clois.value);  if( amt != null && amt > 0.00 )     totalDonation += amt*eval( document.premium.P_clois.value);  amt=eval( document.premium.Q_bowlSgr.value);  if( amt != null && amt > 0.00 )     totalDonation += amt*eval( document.premium.P_bowlSgr.value);  amt=eval( document.premium.Q_bowlSyl.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_bowlSyl.value);  amt=eval( document.premium.Q_bowlSbk.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_bowlSbk.value);  amt=eval( document.premium.Q_bowlStq.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_bowlStq.value);  amt=eval( document.premium.Q_bowlSany.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_bowlSany.value);	  	    amt=eval( document.premium.Q_01Tl.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_01Tl.value);	    amt=eval( document.premium.Q_01Tx.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_01Tx.value);	    amt=eval( document.premium.Q_01T2x.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_01T2x.value);	    amt=eval( document.premium.Q_01Swx.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_01Swx.value);	    amt=eval( document.premium.Q_book.value);  if( amt != null && amt > 0.00 )      totalDonation += amt*eval( document.premium.P_book.value);  document.premium.totalamt.value = totalDonation;}// Validate the form fields.function validatePremiumsForm(){  // Check for required fields that are empty.  var emptyFields = "";      if( document.premium.contactname.value == null || document.premium.contactname.value.length == 0 )  {    if( emptyFields.length > 0 ) emptyFields += ", ";    emptyFields += "Contact Person";   }      if( document.premium.address.value == null || document.premium.address.value.length == 0 )  {    if( emptyFields.length > 0 ) emptyFields += ", ";    emptyFields += "Street Address or Box #";   }      if( document.premium.city.value == null || document.premium.city.value.length == 0 )  {    if( emptyFields.length > 0 ) emptyFields += ", ";    emptyFields += "City";   }  if( document.premium.country.options[ document.premium.country.selectedIndex].value == "US" ||      document.premium.country.options[ document.premium.country.selectedIndex].value == "CA" )  {    // Must choose state / province if in US or Canada.    if( document.premium.state.selectedIndex < 1 )    {      if( emptyFields.length > 0 ) emptyFields += ", ";      emptyFields += "State/Province";     }  }  else  {    // If not in US or Canada, don't choose any state / province.    document.premium.state.selectedIndex = 0;  }      if( document.premium.zip.value == null || document.premium.zip.value.length == 0 )  {    if( emptyFields.length > 0 ) emptyFields += ", ";    emptyFields += "Zip/Postal Code";   }      if( document.premium.email.value == null || document.premium.email.value.length == 0 )  {    if( emptyFields.length > 0 ) emptyFields += ", ";    emptyFields += "Email of addressee";   }      if( document.premium.totalamt.value == null || document.premium.totalamt.value.length == 0 )  {    if( emptyFields.length > 0 ) emptyFields += ", ";    emptyFields += "Donation Amount";   }  // Check for credit card name.  var missingCreditCardName = false;  if( document.premium.ccfirstname.value == null || document.premium.ccfirstname.value.length == 0 ||      document.premium.cclastname.value == null || document.premium.cclastname.value.length == 0 )    missingCreditCardName = true;    // Assemble message string.    var messages = "";  if( emptyFields.length > 0 )  {    messages += "To enable your Premiums to be processed, please supply information for the following:\n  " + emptyFields + "\n";  }  if( missingCreditCardName )  {	messages += "In order to accept your Premiums payment, please supply a first name and a last name.\n";  }  // Display any messages to the user.     var result = true;  // If valid true, else false.  if( messages.length > 0 )  {    alert( messages );    result = false;  }    return result;}