//DECLARE ALL GLOBAL VARIABLE
var _fullName, _address, _city, _state, _zip, _phone, _email, confirmationPage = "", totalAmount = 0;

function submitForm()
{
  var selObj = document.getElementById('membership');
  var selIndex = selObj.selectedIndex;
  
  if(  selIndex == 0 ||
       document.registration.fullName.value == "" ||
       document.registration.phone.value == "" ||
       document.registration.address.value == "" ||
       document.registration.city.value == "" ||
       document.registration.state.value == "" ||
       document.registration.zip.value == "" ||
       document.registration.email.value == ""   )
  {
    alert("Error! Please check the form.");
    return false;
  }

  else
  {
    var selectedOption = selObj[selIndex].text;
    _fullName = document.registration.fullName.value;
    _phone = document.registration.phone.value;
    _address = document.registration.address.value;
    _city = document.registration.city.value;
    _state = document.registration.state.value;
    _zip = document.registration.zip.value;
    _email = document.registration.email.value;

    if( selectedOption == "Individual" )
      totalAmount += 130;
    else if( selectedOption == "Husband/Wife" )
      totalAmount += 150;
    else if( selectedOption == "Family" )
      totalAmount += 200;
    else
      totalAmount += 75;

	confirmationPage = "Please verify that the information you entered is correct before you proceed to paypal"
    confirmationPage += "<table><form name='confirmation'><tr><td>Full Name: </td><td>" + _fullName + "</td></tr>";
	confirmationPage += "<tr><td>Phone: </td><td>" + _phone + "</td></tr>";
    confirmationPage += "<tr><td>Address: </td><td>" + _address + "</td></tr>";
    confirmationPage += "<tr><td>City: </td><td>" + _city + "<td></tr>";
    confirmationPage += "<tr><td>State: </td><td>" + _state + "</td></tr>";
    confirmationPage += "<tr><td>Zip: </td><td>" + _zip + "</td></tr>";
    confirmationPage += "<tr><td>E-mail address: </td><td>" + _email + "</td></tr>";
    confirmationPage += "<tr><td>Type of Membership: </td><td>" + selectedOption + "</td></tr></form>";
    confirmationPage += "<tr><td></td><td><form name='_xclick' action='https://www.paypal.com/cgi-bin/webscr' target='paypal' method='post'>";
    confirmationPage += "<input type='hidden' name='cmd' value='_xclick'>";
    confirmationPage += "<input type='hidden' name='business' value='Jay@ehtc.net'>";
    confirmationPage += "<input type='hidden' name='item_name' value='" + selectedOption + " Membership'>";
    confirmationPage += "<input type='hidden' name='item_number' value=''>";
    confirmationPage += "<input type='hidden' name='amount' value='" + totalAmount + "'>";
    confirmationPage += "<input type='hidden' name='currency_code' value='USD'>";
    confirmationPage += "<input type='hidden' name='no_shipping' value='1'>";
    confirmationPage += "<input type='image' src='https://www.paypal.com/en_US/i/btn/x-click-but01.gif' border='0' name='submit' alt='Make payments with PayPal - it's fast, free and secure!'>";
    confirmationPage += "</form></td></table>";
    document.write(confirmationPage);
  }
}
