<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php
?>
<script language="javascript" type="text/javascript"><!--
var form = "";
var submitted = false;
var error = false;
var error_message = "";
function check_input(field_name, field_size, message) {
  if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    var field_value = form.elements[field_name].value;
    if (field_value == '' || field_value.length < field_size) {
      error_message = error_message + "* " + message + "\n";
      error = true;
    }
  }
}
function check_radio(field_name, message) {
  var isChecked = false;
  if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    var radio = form.elements[field_name];
    for (var i=0; i<radio.length; i++) {
      if (radio[i].checked == true) {
        isChecked = true;
        break;
      }
    }
    if (isChecked == false) {
      error_message = error_message + "* " + message + "\n";
      error = true;
    }
  }
}
function check_select(field_name, field_default, message) {
  if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    var field_value = form.elements[field_name].value;
    if (field_value == field_default) {
      error_message = error_message + "* " + message + "\n";
      error = true;
    }
  }
}
function check_password(field_name_1, field_name_2, field_size, message_1, message_2) {
  if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
    var password = form.elements[field_name_1].value;
    var confirmation = form.elements[field_name_2].value;
    if (password == '' || password.length < field_size) {
      error_message = error_message + "* " + message_1 + "\n";
      error = true;
    } else if (password != confirmation) {
      error_message = error_message + "* " + message_2 + "\n";
      error = true;
    }
  }
}
function check_password_new(field_name_1, field_name_2, field_name_3, field_size, message_1, message_2, message_3) {
  if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
    var password_current = form.elements[field_name_1].value;
    var password_new = form.elements[field_name_2].value;
    var password_confirmation = form.elements[field_name_3].value;
    if (password_current == '' || password_current.length < field_size) {
      error_message = error_message + "* " + message_1 + "\n";
      error = true;
    } else if (password_new == '' || password_new.length < field_size) {
      error_message = error_message + "* " + message_2 + "\n";
      error = true;
    } else if (password_new != password_confirmation) {
      error_message = error_message + "* " + message_3 + "\n";
      error = true;
    }
  }
}
function check_form(form_name) {
  if (submitted == true) {
    alert("<?php echo JS_ERROR_SUBMITTED; ?>");
    return false;
  }
  error = false;
  form = form_name;
  error_message = "<?php echo JS_ERROR; ?>";
<?php if ((MEMBER_GENDER == 'true')&&(MEMBER_GENDER_REQ=='true')) echo '  check_radio("gender", "' . TYPE_IN_GENDER_ERROR . '");' . "\n"; ?>
  check_input("firstname", <?php echo TYPE_IN_FIRST_NAME_MIN_LENGTH; ?>, "<?php echo TYPE_IN_FIRST_NAME_ERROR; ?>");
  check_input("lastname", <?php echo TYPE_IN_LAST_NAME_MIN_LENGTH; ?>, "<?php echo TYPE_IN_LAST_NAME_ERROR; ?>");
<?php if ((MEMBER_DOB == 'true')&&(MEMBER_DOB_REQ=='true')) echo '  check_input("dob", ' . TYPE_IN_DOB_MIN_LENGTH . ', "' . TYPE_IN_DATE_OF_BIRTH_ERROR . '");' . "\n"; ?>
  check_input("email_address", <?php echo TYPE_IN_EMAIL_ADDRESS_MIN_LENGTH; ?>, "<?php echo TYPE_IN_EMAIL_ADDRESS_ERROR; ?>");
<?php if ((MEMBER_COMPANY == 'true')&&(MEMBER_COMPANY_REQ=='true')) echo '  check_input("company", "' . TYPE_IN_CITY_MIN_LENGTH . '","'.TYPE_IN_COMPANY_ERROR.'");' . "\n"; ?>
	
  check_input("street_address", <?php echo TYPE_IN_STREET_ADDRESS_MIN_LENGTH; ?>, "<?php echo TYPE_IN_STREET_ADDRESS_ERROR; ?>");
<?php if ((MEMBER_SUBURB == 'true')&&(MEMBER_SUBURB_REQ=='true')) echo '  check_input("suburb", "' . TYPE_IN_CITY_MIN_LENGTH . '","'.TYPE_IN_SUBURB_ERROR.'");' . "\n"; ?>
	
  check_input("postcode", <?php echo TYPE_IN_POSTCODE_MIN_LENGTH; ?>, "<?php echo TYPE_IN_POST_CODE_ERROR; ?>");
  check_input("city", <?php echo TYPE_IN_CITY_MIN_LENGTH; ?>, "<?php echo TYPE_IN_CITY_ERROR; ?>");
<?php if ((MEMBER_STATE == 'true')&&(MEMBER_STATE_REQ=='true')) echo '  check_input("state", ' . TYPE_IN_STATE_MIN_LENGTH . ', "' . TYPE_IN_STATE_ERROR . '");' . "\n"; ?>
  check_select("land", "", "<?php echo TYPE_IN_LAND_ERROR; ?>");
  <?php if(MEMBER_TEL == 'true' && MEMBER_TEL_REQ == 'true') {?>
  check_input("telephone", <?php echo TYPE_IN_TELEPHONE_MIN_LENGTH; ?>, "<?php echo TYPE_IN_TELEPHONE_NUMBER_ERROR; ?>");
  <?php 
  }?>
  <?php if(REFERRAL_REQUIRED == 'true' && REFERRAL_REQUIRED_REQ == 'true') {?>
  check_select("source", "", "<?php echo TYPE_IN_SOURCE_ERROR; ?>");
  if(document.getElementsByName("source")[0].value == '9999') {
	  check_input("source_other", 2, "<?php echo TYPE_IN_SOURCE_OTHER_ERROR; ?>");
  }
  <?php 
  }?>
  check_password("password", "confirmation", <?php echo TYPE_IN_PASSWORD_MIN_LENGTH; ?>, "<?php echo TYPE_IN_PASSWORD_ERROR; ?>", "<?php echo TYPE_IN_PASSWORD_ERROR_NOT_MATCHING; ?>");
  check_password_new("password_current", "password_new", "password_confirmation", <?php echo TYPE_IN_PASSWORD_MIN_LENGTH; ?>, "<?php echo TYPE_IN_PASSWORD_ERROR; ?>", "<?php echo TYPE_IN_PASSWORD_NEW_ERROR; ?>", "<?php echo TYPE_IN_PASSWORD_NEW_ERROR_NOT_MATCHING; ?>");
  if (error == true) {
    alert(error_message);
    return false;
  } else {
    submitted = true;
    return true;
  }
}
//--></script>
