<?php 


// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
include(DIR_WS_INCLUDES.'general.js');
include(DIR_WS_INCLUDES.'javascript/http.js');
echo tep_draw_form('account_edit', tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'), 'post', 'onSubmit="return check_form(account_edit);"') . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB; ?>">
<?php
// BOF: Lango Added for template MOD
if (SHOW_HEADING_TITLE_ORIGINAL == 'yes') {
$header_text = '&nbsp;'
//EOF: Lango Added for template MOD
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
<?php
// BOF: Lango Added for template MOD
}else{
$header_text = HEADING_TITLE;
}
// EOF: Lango Added for template MOD
?>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_top(false, false, $header_text);
}
// EOF: Lango Added for template MOD
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  if ($messageStack->size('account_edit') > 0) {
?>
      <tr>
        <td><?php echo $messageStack->output('account_edit'); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  }
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><b><?php echo MY_ACCOUNT_TITLE; ?></b></td>
                <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; 
				//print_r($account);?></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
              <tr class="infoBoxContents">
                <td><table border="0" cellspacing="2" cellpadding="2">
<?php
  if (ACCOUNT_GENDER == 'true') {
    if (isset($gender)) {
      $male = ($gender == 'm') ? true : false;
    } else {
      $male = ($account['customers_gender'] == 'm') ? true : false;
    }
    $female = !$male;
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_GENDER; ?></td>
                    <td class="main"><?php echo tep_draw_radio_field('gender', 'm', $male) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . tep_draw_radio_field('gender', 'f', $female) . '&nbsp;&nbsp;' . FEMALE . '&nbsp;' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>
                  </tr>
<?php
  }
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('firstname', $account['customers_firstname']) . '&nbsp;' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('lastname', $account['customers_lastname']) . '&nbsp;' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?></td>
                  </tr>
<?php
  if (ACCOUNT_DOB == 'true') {
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('dob', format_date($account['customers_dob'])) . '&nbsp;' . (tep_not_null(ENTRY_EVENT_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_EVENT_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td>
                  </tr>
<?php
  }
?>
<?php
  if (ACCOUNT_USERNAME == 'true') {
	  if ($account['customers_username']=="" || $username_edit=='Y'){
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_USERNAME; ?></td>
                    <td class="main">
						<?php 
								echo tep_draw_input_field('username', $account['customers_username']);
								echo tep_draw_hidden_field('username_edit','Y');
						?>
					</td>
                  </tr>
	<?php } else { ?>
                  <tr>
                    <td class="main" style="color:gray"><?php echo ENTRY_USERNAME; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('username', $account['customers_username'],' disabled style="color:gray"'); ?>
					</td>
                  </tr>
<?php
	}

  }
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('email_address', $account['customers_email_address']) . '&nbsp;' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr>
                		<td class="main"><?php echo ENTRY_CONFIRM_EMAIL_ADDRESS; ?></td>
                		<td class="main"><?php echo tep_draw_input_field('confirm_email_address',$account['customers_email_address']) . '&nbsp;' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>
              		</tr>
<?php
  if (ACCOUNT_SECOND_EMAIL == 'true') {
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_SECOND_EMAIL_ADDRESS; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('second_email_address', $account['customers_second_email_address'],'onkeyup="javascript:set_action(this);"') . '&nbsp;' . (tep_not_null(ENTRY_SECOND_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_SECOND_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr id="sec_email_address"  <?php echo ($account['customers_second_email_address']=='' && $HTTP_POST_VARS['second_email_address']=='' || $HTTP_POST_VARS['second_email_address']=='')?'style="display:none"':'';?>>
					    	<td class="main"><?php echo ENTRY_CONFIRM_EMAIL_ADDRESS;?></td> 
					    	<td class="main"><?php
					    	   	echo tep_draw_input_field('second_confirm_email_address',$account['customers_second_email_address'],'id="second_confirm_email_address"');	
					    	?></td>
    					</tr> 
<?php
  }
?>
	<script language="javascript">
    	function set_action(this_){
    		var sec=document.getElementById('sec_email_address');
    		var sec_box=document.getElementById("second_confirm_email_address");
    		sec.style.display="none";
    		if(this_.value=='') sec_box.value="";
    		if(this_.value) sec.style.display="";
    	}
    </script>
	<tr>      <td class="main"><?php echo ENTRY_COUNTRY; 				
				if($country!="") {
					  if(is_numeric($entry_state)) $account['entry_zone_id']=$entry_state;
					  else $account['entry_state']=$entry_state;
					  $account['entry_country_id']=$country;
				}
			   ?></td>
              <td class="main"><?php echo tep_get_country_list('country',$account['entry_country_id'],'id="country" onchange="javascript:show_state();"') . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>
              </tr>
              <?php if (ACCOUNT_STATE == 'true') { ?>
					  <tr>
						<td class="main"><?php echo ENTRY_STATE; ?></td>
						<td class="main">
				<?php 
				        $zones_array = array();
				        $zones_query = tep_db_query("select zone_name,zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$account['entry_country_id'] . "' order by zone_name");
				        $arr_found=false;
				        while ($zones_values = tep_db_fetch_array($zones_query)) {
				          $zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);				          
				          $arr_found=true;
				        }
						echo tep_draw_pull_down_menu('zone_id', $zones_array,$account['entry_zone_id'],'id="zone_id" '.((count($zones_array)<=0)?' style="display:none"':''));
				   		echo tep_draw_input_field('state',$account['entry_state'],'id="state"'.((count($zones_array)>0)?' style="display:none"':''));
				    	if (tep_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT;
				?>
				                </td>
				              </tr>       
			<?php
			  }
			?>
              <script language="javascript">//show_state();</script>
<?php
  if (ACCOUNT_TELEPHONE == 'true') {
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('telephone', $account['customers_telephone']) . '&nbsp;' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>
                  </tr>
<?php
  }
?>
<?php
  if (ACCOUNT_SECOND_PHONE == 'true') {
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_SECOND_TELEPHONE_NUMBER; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('second_telephone', $account['customers_second_telephone']) . '&nbsp;' . (tep_not_null(ENTRY_SECOND_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_SECOND_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>
                  </tr>
<?php
  }
?>
                  <tr>
                    <td class="main"><?php echo ENTRY_MOBILE_NUMBER; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('mobile', $account['customers_fax']) . '&nbsp;' . (tep_not_null(ENTRY_MOBILE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_MOBILE_NUMBER_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_bottom();
}
// EOF: Lango Added for template MOD
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_template_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
                <td align="right"><?php echo tep_template_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></form>
	
	<?php
	function sbs_get_zone_name($country_id, $zone_id) {
    $zone_query = tep_db_query("select zone_name,zone_id from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_id = '" . $zone_id . "'");
	//echo "select zone_name,zone_id from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_id = '" . $zone_id . "'";
    if (tep_db_num_rows($zone_query)) {
      $zone = tep_db_fetch_array($zone_query);
      return $zone['zone_name'];
    } else {      
      return $default_zone;
    }
  }
	
	 ?>
