//###############################
//# Declarations                #
//###############################

//###############################
//# Functions                   #
//###############################
function _ecom_mfSave()
{
  //declarations
  var strErrors = '';
 
  if (document.getElementById('_ecom_ProductCustomerDetails_BillingAddressSame').checked)
  {
    document.getElementById('_ecom_ProductCustomerDetails_BillingAddress1').value = document.getElementById('_ecom_ProductCustomerDetails_DeliveryAddress1').value;
    document.getElementById('_ecom_ProductCustomerDetails_BillingAddress2').value = document.getElementById('_ecom_ProductCustomerDetails_DeliveryAddress2').value;
    document.getElementById('_ecom_ProductCustomerDetails_BillingTown').value = document.getElementById('_ecom_ProductCustomerDetails_DeliveryTown').value;
    document.getElementById('_ecom_ProductCustomerDetails_BillingCounty').value = document.getElementById('_ecom_ProductCustomerDetails_DeliveryCounty').value;
    document.getElementById('_ecom_ProductCustomerDetails_BillingPostCode').value = document.getElementById('_ecom_ProductCustomerDetails_DeliveryPostCode').value;
  }

  if (document.getElementById('_ecom_ProductCustomerDetails_Name').value == '') strErrors += 'You have not entered your name or company name\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_Email').value == '') strErrors += 'You have not entered your Email address.  This will be your login user name\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_Password1').value == '' || document.getElementById('_ecom_ProductCustomerDetails_Password1').value != document.getElementById('_ecom_ProductCustomerDetails_Password2').value) strErrors += 'You have not entered your password twice or the two do not match\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_TelNo').value == '') strErrors += 'You have not entered the telephone number.\n';

  if (document.getElementById('_ecom_ProductCustomerDetails_DeliveryAddress1').value == '') strErrors += 'You have not entered the 1st line of your delivery address\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_DeliveryTown').value == '') strErrors += 'You have not entered the delivery town\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_DeliveryCounty').value == '') strErrors += 'You have not entered the delivery county\n';

  if (document.getElementById('_ecom_ProductCustomerDetails_BillingAddress1').value == '') strErrors += 'You have not entered the 1st line of your billing address\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_BillingTown').value == '') strErrors += 'You have not entered the billing town\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_BillingCounty').value == '') strErrors += 'You have not entered the billing county\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_TR1').value == '') strErrors += 'You have not entered the first trade reference\n';
  if (document.getElementById('_ecom_ProductCustomerDetails_TR2').value == '') strErrors += 'You have not entered a second trade reference.\n';




  if (strErrors == '')
  {
    //Declarations  
    document.getElementById('_ecom_txtProductCustomerRegistration_Action').value="SAVE";
    if (document.forms[1] != null && document.forms[1].id == 'form1')
      document.forms[1].submit();
    else
      document.forms[0].submit();
  }
  else
    alert('We could not complete your registration due to the following:\n\n' + strErrors + '\nPlease resolve these issues and try again');

}

function _ecom_ShowHideBillingAddress(pobjCheckBox)
{

  if (pobjCheckBox.checked)
    document.getElementById('divBillingAddress').style.display='none';
  else
    document.getElementById('divBillingAddress').style.display='';
}