<?php
include_once dirname(__FILE__) . '/elements/header_menu.php';
$extra_per = __('extra_per', true);
$get = $controller->_get->raw();
$post = $controller->_post->raw();
?>

	<div class="crBox">
	<div class="crBoxTop">
		<div class="crBoxTopLeft"></div>
		<div class="crBoxTopRight"></div>
	</div>
	<div class="crBoxMiddle">
		<div class="cr3YourBooking">
			<div class="crBoxWTop"><?php __('front_3_booking'); ?></div>
			<div class="crBooking">
				<div class="crStep"><?php __('front_3_when'); ?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>" id="crBtnWhen"><?php __('front_3_change'); ?></a></div>
				<table class="crTableXtra" style="width: 100%">
					<tbody>
						<tr>
							<td class="crGray crALeft" ><?php __('front_3_pickup'); ?>:</td>
							<td><?php echo stripslashes($tpl['pickup_location']['name']); ?></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td><?php 
									$dt_from = $_SESSION[$controller->default_product][$controller->default_order]['date_from'] . " " . $_SESSION[$controller->default_product][$controller->default_order]['hour_from'] . ":" . $_SESSION[$controller->default_product][$controller->default_order]['minutes_from'] . ":00";
									echo date($tpl['option_arr']['o_date_format'], strtotime($dt_from)).', '.date($tpl['option_arr']['o_time_format'], strtotime($dt_from)); 
									?></td>
						</tr>
						<tr style="line-height:3px;">
							<td colspan="2">&nbsp;</td>
						</tr>
						<tr>
							<td class="crGray crALeft"><?php __('front_3_return'); ?>:</td>
							<td><?php echo isset($tpl['return_location']['name']) ? stripslashes($tpl['return_location']['name']) : stripslashes($tpl['pickup_location']['name']); ?></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td><?php
									$dt_to = $_SESSION[$controller->default_product][$controller->default_order]['date_to'] . " " . $_SESSION[$controller->default_product][$controller->default_order]['hour_to'] . ":" . $_SESSION[$controller->default_product][$controller->default_order]['minutes_to'] . ":00";
									echo date($tpl['option_arr']['o_date_format'], strtotime($dt_to)).', '.date($tpl['option_arr']['o_time_format'], strtotime($dt_to)); 
									?></td>
						</tr>
						<tr style="line-height:3px;">
							<td colspan="2">&nbsp;</td>
						</tr>
						<?php
						if($tpl['type_arr']['rent_type'] == 'day') {
							$days = $_SESSION[$controller->default_product][$controller->default_order]['rental_days'];
							?>
							<tr>
								<td class="crGray crALeft"><?php __('front_3_rental'); ?>:</td>
								<td><?php echo $days == 1 ? $days ." ". __('front_label_day',true) : $days ." ". __('front_3_days',true); ?></td>
							</tr>
							<?php
						} else {

							$rental_hours = $_SESSION[$controller->default_product][$controller->default_order]['rental_hours'];
							$hours = $rental_hours %24;
							$days = 0;
							if($hours == 0 ){
								$days = $rental_hours / 24;
							}
							else {
								$days = floor($rental_hours / 24);
							}

							?>
							<tr>
								<td class="crGray crALeft"><?php __('front_3_rental_duration'); ?>:</td>
								<td><?php echo $days > 0 ? ($days == 1 ? $days ." ". __('front_label_day',true) : $days ." ". __('front_3_days',true) ) : ''?><?php echo $days > 0 && $hours > 0 ? ' ' :'';?><?php echo $hours > 0 ?  $hours." ".__('front_3_hours',true) : ''?></td>
							</tr>
							<?php
						}
						?>
					</tbody>
				</table>
			</div>
			<div class="crBooking">
				<div class="crStep"><?php __('front_3_choise'); ?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>" id="crBtnChoise"><?php __('front_3_change'); ?></a></div>
				<div class="cr3imgBox">
					<img src="<?php echo is_file(@$tpl['type_arr']['thumb_path']) ? PJ_INSTALL_URL . $tpl['type_arr']['thumb_path'] : PJ_INSTALL_URL . PJ_IMG_PATH . 'frontend/dummy_1.png'; ?>" alt="" class="cr3Img" />
				</div>
				<div class="cr3Items">
					<p class=""><?php echo pjSanitize::clean(@$tpl['type_arr']['name']); ?></p>
					<p class="crGray">(<?php __('front_3_example'); ?>: <?php echo stripslashes(@$tpl['type_arr']['example']['make'] . " " . @$tpl['type_arr']['example']['model']); ?>)</p>

				</div>

			</div>
		</div>

		<div class="cr3Extras">
			<div class="crBoxWTop" style="margin-bottom:15px"><?php __('front_3_payment'); ?></div>
			<?php
			$rental_fee_detail = array();
			?>
			<table class="crExtraTable" cellspacing="0" cellpadding="0">
				<tbody>
					<tr>
						<td class="crKey"><span><?php __('front_3_rental_duration'); ?></span><br/><?php echo join(" + ", $rental_fee_detail);?></td>
						<td class="crValue">
							<?php echo $rental_duration = $days > 0 ? ($days == 1 ? $days ." ". __('front_label_day',true) : $days ." ". __('front_3_days',true) ) : ''?><?php echo $days > 0 && $hours > 0 ? ' ' :'';?><?php echo $hours > 0 ?  $hours." ".__('front_3_hours',true) : ''?>
						</td>
					</tr>
					<tr style="display:<?php echo in_array($tpl['option_arr']['o_booking_periods'], array('both', 'perday')) ? 'table-row' : 'none';?>">
						<td class="crKey"><span><?php __('front_3_price_per_day'); ?></span><br/><?php echo $tpl['cart']['price_per_day_detail']; ?></td>
						<td class="crValue">
							<?php echo $rental_fee_detail[] = pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['price_per_day']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
					<tr style="display:<?php echo in_array($tpl['option_arr']['o_booking_periods'], array('both', 'perhour')) ? 'table-row' : 'none';?>">
						<td class="crKey"><span><?php __('front_3_price_per_hour'); ?></span><br/><?php echo $tpl['cart']['price_per_hour_detail']; ?></td>
						<td class="crValue">
							<?php echo $rental_fee_detail[] = pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['price_per_hour']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
					<tr><td colspan="2" class="crLine"></td></tr>
					<tr>
						<td class="crKey"><span><?php __('front_3_price'); ?></span><br/><?php echo join(" + ", $rental_fee_detail);?></td>
						<td class="crValue">
							<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['car_rental_fee']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
					<tr>
						<td class="crKey"><span><?php __('front_3_extra_price'); ?></span></td>
						<td class="crValue">
							<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['extra_price']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
					<?php
					if ($tpl['option_arr']['o_insurance_payment'] > 0)
					{
						$insurance_types = __('insurance_type_arr', true, false);
						?>
						<tr>
							<td class="crKey"><span><?php __('front_3_insurance'); ?></span><br/>
								<?php
								switch ($tpl['option_arr']['o_insurance_payment_type']) {
									case 'perday':
										echo pjUtil::formatCurrencySign($tpl['option_arr']['o_insurance_payment'], $tpl['option_arr']['o_currency']) . ' ' . strtolower($insurance_types['perday']);
									;
									break;
									case 'percent':
										echo $tpl['option_arr']['o_insurance_payment'] . '% ' . __('front_label_of', true, false) . ' ' . pjUtil::formatCurrencySign($sum, $tpl['option_arr']['o_currency']);
									;
									break;
									case 'perbooking':
										echo pjUtil::formatCurrencySign($tpl['option_arr']['o_insurance_payment'], $tpl['option_arr']['o_currency']) . ' ' . strtolower($insurance_types['perbooking']);
									;
									break;
								}
								?>
							</td>
							<td class="crValue">
								<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['insurance']), 2), $tpl['option_arr']['o_currency'], " ");?>
							</td>
						</tr>
						<tr><td colspan="2" class="crLine"></td></tr>
						<?php
					}
					?>
					<tr>
						<td class="crKey crKeyBold"><span><?php __('front_3_sub_total'); ?></span></td>
						<td class="crValue crKeyBold">
							<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['sub_total']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
					<tr><td colspan="2" class="crLine"></td></tr>
					<?php
					if ($tpl['option_arr']['o_tax_payment'] > 0)
					{
						?>
						<tr>
							<td class="crKey"><span><?php __('front_3_tax'); ?></span><br/>
								<?php
								if($tpl['option_arr']['o_tax_type'] == '1')
								{
									echo $tpl['option_arr']['o_tax_payment'] . '% ' . __('front_label_of', true, false) . ' ' . pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['sub_total']), 2), $tpl['option_arr']['o_currency'], " ");
								}
								?>
							</td>
							<td class="crValue">
								<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['tax']), 2), $tpl['option_arr']['o_currency'], " ");?>
							</td>
						</tr>
						<?php
					}
					?>

					<tr>
						<td class="crKey crKeyBold crRed"><?php __('front_3_total_price'); ?></td>
						<td class="crValue crKeyBold">
							<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['total_price']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
					<tr><td colspan="2" class="crLine"></td></tr>
					<tr>
						<td class="crKey">
							<span><?php __('front_3_required_deposit'); ?></span><br/>
							<?php
							echo $tpl['option_arr']['o_deposit_payment'] . '% ' . __('front_label_of', true, false) . ' ' . pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['total_price']), 2), $tpl['option_arr']['o_currency']);
							?>
						</td>
						<td class="crValue crKeyBold">
							<?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['cart']['required_deposit']), 2), $tpl['option_arr']['o_currency'], " ");?>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<div style="clear:both;"></div>
		<form action="" method="post" class="crForm" id="crCheckoutForm" name="crCheckoutForm">
			<div class="crLegend">
				<span class="crLegendText"><?php __('front_4_personal'); ?></span>
			</div>

			<?php if (in_array($tpl['option_arr']['o_bf_include_title'], array(2, 3))) : ?>
			<div class="crLeft" >
				<p>
					<label class="crLabel"><?php __('front_4_title'); ?> <?php if ($tpl['option_arr']['o_bf_include_title'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<select name="c_title" class="crSelect cr4Select<?php echo ($tpl['option_arr']['o_bf_include_title'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_title'))); ?>">
						<option value=""><?php __('front_4_select_title'); ?></option>
						<?php
						foreach (__('_titles',true) as $k => $v)
						{
							?><option value="<?php echo $k; ?>"><?php echo $v; ?></option><?php
						}
						?>
					</select>
				</p>
			</div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_name'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php __('front_4_name'); ?> <?php if ($tpl['option_arr']['o_bf_include_name'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_name" class="crText abStretch cr4Text<?php echo ($tpl['option_arr']['o_bf_include_name'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_name'))); ?>" />
				</p>
			</div>
			<?php endif; ?>
			<?php if (in_array($tpl['option_arr']['o_bf_include_email'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_email'); ?> <?php if ($tpl['option_arr']['o_bf_include_email'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_email" class="crText cr4Text email crEmail<?php echo ($tpl['option_arr']['o_bf_include_email'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_email'))); ?>" />
				</p>
			</div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_phone'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php __('front_4_phone'); ?> <?php if ($tpl['option_arr']['o_bf_include_phone'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_phone" class="crText cr4Text phone crPhone<?php echo ($tpl['option_arr']['o_bf_include_phone'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_phone'))); ?>" placeholder="123-456-7899"/>
				</p>
			</div>
			<?php endif; ?>

			<div class="crClear"></div>
			<div class="crLegend">
				<span class="crLegendText"><?php __('front_4_driver_detail'); ?></span>
			</div>

			<?php if (in_array($tpl['option_arr']['o_bf_include_driver_license'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php __('front_4_driver_license'); ?> <?php if ($tpl['option_arr']['o_bf_include_driver_license'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_driver_license" class="crText abStretch cr4Text<?php echo ($tpl['option_arr']['o_bf_include_driver_license'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_driver_license'))); ?>" />
				</p>
			</div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_driver_license_date'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php __('front_4_driver_license_date'); ?> <?php if ($tpl['option_arr']['o_bf_include_driver_license_date'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" id="c_driver_license_date" name="c_driver_license_date" class="crTextDate crPointer crDate hasDatepicker" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_driver_license_date'))); ?>" />
				</p>
			</div>
			<div class="crClear"></div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_virgin_address'], array(2, 3))) : ?>
			<div>
				<p>
					<label class="crLabel"><?php __('front_4_virgin_address'); ?> <?php if ($tpl['option_arr']['o_bf_include_virgin_address'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_virgin_address" class="crText abStretch cr4Text<?php echo ($tpl['option_arr']['o_bf_include_virgin_address'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_virgin_address'))); ?>" />
				</p>
			</div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_arrival_detail'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php __('front_4_arrival_detail'); ?> <?php if ($tpl['option_arr']['o_bf_include_arrival_detail'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<textarea name="c_arrival_detail" class="crText abStretch cr4Text<?php echo ($tpl['option_arr']['o_bf_include_arrival_detail'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_arrival_detail'))); ?>"></textarea>
				</p>
			</div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_departure_detail'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php __('front_4_departure_detail'); ?> <?php if ($tpl['option_arr']['o_bf_include_departure_detail'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<textarea name="c_departure_detail" class="crText abStretch cr4Text<?php echo ($tpl['option_arr']['o_bf_include_departure_detail'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_departure_detail'))); ?>"></textarea>
				</p>
			</div>
			<?php endif; ?>

			<div class="crClear"></div>
			<div class="crLegend">
				<span class="crLegendText"><?php  __('front_4_billing'); ?></span>
			</div>
			<?php if (in_array($tpl['option_arr']['o_bf_include_company'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_company'); ?> <?php if ($tpl['option_arr']['o_bf_include_company'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_company" class="crText cr4Text<?php echo ($tpl['option_arr']['o_bf_include_company'] == 3) ? ' required' : NULL; ?>" />
				</p>
			</div>
			<?php endif; ?>
			<?php if (in_array($tpl['option_arr']['o_bf_include_address'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_address'); ?> <?php if ($tpl['option_arr']['o_bf_include_address'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_address" class="crText cr4Text<?php echo ($tpl['option_arr']['o_bf_include_address'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_address'))); ?>" />
				</p>
			</div>
			<?php endif; ?>

			<?php if (in_array($tpl['option_arr']['o_bf_include_city'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_city'); ?> <?php if ($tpl['option_arr']['o_bf_include_city'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_city" class="crText cr4Text<?php echo ($tpl['option_arr']['o_bf_include_city'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_city'))); ?>" />
				</p>
			</div>
			<?php endif; ?>
			<?php if (in_array($tpl['option_arr']['o_bf_include_state'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_state'); ?> <?php if ($tpl['option_arr']['o_bf_include_state'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_state" class="crText cr4Text<?php echo ($tpl['option_arr']['o_bf_include_state'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_state'))); ?>" />
				</p>
			</div>
			<?php endif; ?>
			<?php if (in_array($tpl['option_arr']['o_bf_include_zip'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_zip'); ?> <?php if ($tpl['option_arr']['o_bf_include_zip'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<input type="text" name="c_zip" class="crText cr4Text<?php echo ($tpl['option_arr']['o_bf_include_zip'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_zip'))); ?>" />
				</p>
			</div>
			<?php endif; ?>
			<?php if (in_array($tpl['option_arr']['o_bf_include_country'], array(2, 3))) : ?>
			<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_country'); ?> <?php if ($tpl['option_arr']['o_bf_include_country'] == 3) : ?><span class="crRed">*</span><?php endif; ?></label>
				</p>
				<p>
					<select name="c_country" class="crSelect cr4Select<?php echo ($tpl['option_arr']['o_bf_include_country'] == 3) ? ' required' : NULL; ?>" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_country'))); ?>">
						<option value=""><?php echo __('front_4_select_country'); ?></option>
						<?php
						foreach ($tpl['country_arr'] as $country)
						{
							?><option value="<?php echo $country['id']; ?>"><?php echo stripslashes($country['country_title']); ?></option><?php
						}
						?>
					</select>
				</p>
			</div>
			<?php endif; ?>

			<div class="crClear"></div>
			<?php
		
			if ($tpl['option_arr']['o_payment_disable'] === 'No' || $tpl['option_arr']['o_payment_disable'] === '0')
			{
               
				?>
				<div class="crLegend">
					<span class="crLegendText"><?php  __('front_4_payment'); ?></span>
				</div>
				<div class="crLeft">
				<p>
					<label class="crLabel"><?php  __('front_4_payment'); ?> <span class="crRed">*</span></label>
				</p>
				<p>
					<?php
					$plugins_payment_methods = pjObject::getPlugin('pjPayments') !== NULL? pjPayments::getPaymentMethods(): array();
					$haveOnline = $haveOffline = false;
					foreach ($tpl['payment_titles'] as $k => $v)
					{
					    if( $k != 'cash' && $k != 'bank' && $k != 'creditcard' )
					    {
					        if( (int) $tpl['payment_option_arr'][$k]['is_active'] == 1)
					        {
					            $haveOnline = true;
					            break;
					        }
					    }
					}
					foreach ($tpl['payment_titles'] as $k => $v)
					{
					    if( $k == 'cash' || $k == 'bank' || $k == 'creditcard' )
					    {
					        if( (int) $tpl['payment_option_arr'][$k]['is_active'] == 1)
					        {
					            $haveOffline = true;
					            break;
					        }
					    }
					}
					?>							
					<select name="payment_method" class="form-control required" data-msg-required="<?php echo htmlspecialchars(stripslashes(__('front_4_v_payment'))); ?>">
						<option value=""><?php echo __('front_4_select_payment'); ?></option>
						<?php
						
						if ($haveOnline && $haveOffline)
						{
						    ?><optgroup label="<?php __('script_online_payment_gateway', false, true); ?>"><?php
	                    }
	                    foreach ($tpl['payment_titles'] as $k => $v)
	                    {
	                        if($k == 'cash' || $k == 'bank' || $k == 'creditcard'){
	                            continue;
	                        }
	                        if (array_key_exists($k, $plugins_payment_methods))
	                        {
	                            if(!isset($tpl['payment_option_arr'][$k]['is_active']) || (isset($tpl['payment_option_arr']) && $tpl['payment_option_arr'][$k]['is_active'] == 0) )
	                            {
	                                continue;
	                            }
	                        }
	                        ?><option value="<?php echo $k; ?>"<?php echo isset($FORM['payment_method']) && $FORM['payment_method']==$k ? ' selected="selected"' : NULL;?>><?php echo $v; ?></option><?php
	                    }
	                    if ($haveOnline && $haveOffline)
	                    {
	                        ?>
	                    	</optgroup>
	                    	<optgroup label="<?php __('script_offline_payment', false, true); ?>">
	                    	<?php 
	                    }
	                    foreach ($tpl['payment_titles'] as $k => $v)
	                    {
	                        if( $k == 'cash' || $k == 'bank' || $k == 'creditcard' )
	                        {
	                            if( (int) $tpl['payment_option_arr'][$k]['is_active'] == 1)
	                            {
	                                ?><option value="<?php echo $k; ?>"<?php echo isset($FORM['payment_method']) && $FORM['payment_method']==$k ? ' selected="selected"' : NULL;?>><?php echo $v; ?></option><?php
	                            }
	                        }
	                    }
	                    if ($haveOnline && $haveOffline)
	                    {
	                        ?></optgroup><?php
	                    }
						?>
					</select>
				</p>
				</div>
				<div id="crBankData" style="display:none">
					<div class="crLeft100">
						<p>
							<label class="crLabel"><?php __('front_4_bank_account'); ?> </label>
						</p>
						<p>
							<span style=""><?php
							$text = trim($tpl['option_arr']['o_bank_account']); // remove the last \n or whitespace character
							$text = nl2br($text); //
							echo $text;
							?></span>
						</p>
					</div>
				</div>

				<div id="crCCData" style="display: none">
					<div class="crLeft100">
						<p>
							<label class="crLabel"><?php  __('front_cc_message'); ?></label><br /><br /><br />
						</p>
						<p>
							<label class="crLabel"><?php  __('front_4_cc_type'); ?> <span class="crRed">*</span></label>
						</p>
						<p>
							<select name="cc_type" class="crSelect cr4CCSelect" rev="<?php echo htmlspecialchars(__('front_4_v_cc_type')); ?>">
								<option value="">---</option>
								<?php
								foreach (__('front_4_cc_types',true) as $k => $v)
								{ 
                                    if(in_array($k,array('Maestro'))) continue;
									if (isset($_POST['cc_type']) && $_POST['cc_type'] == $k)
									{
										?><option value="<?php echo $k; ?>" selected="selected"><?php echo $v; ?></option><?php
									} else {
										?><option value="<?php echo $k; ?>"><?php echo $v; ?></option><?php
									}
								}
								?>
							</select>
						</p>
					</div>
					<div class="crLeft100">
						<p>
							<label class="crLabel"><?php echo __('front_4_cc_num'); ?> <span class="crRed">*</span></label>
						</p>
						<p>
							<input type="text" name="cc_num" class="crText cr4CCText" rev="<?php echo htmlspecialchars(__('front_4_v_cc_num')); ?>" />
						</p>
					</div>
					<div class="crLeft100">
						<p>
							<label class="crLabel"><?php echo __('front_4_cc_exp'); ?> <span class="crRed">*</span></label>
						</p>
						<p>
							<select name="cc_month" id="cc_month" class="crSelect cr4CCSelect">
								<?php foreach(range(1,12) as $item) { ?>
								<option value="<?php echo $item; ?>"><?php echo $item; ?></option>
								<?php } ?>
							</select>
							<select name="cc_year" id="cc_year" class="crSelect cr4CCSelect">
								<?php foreach(range(date('Y'),date('Y') + 10) as $item) { ?>
								<option value="<?php echo $item; ?>"><?php echo $item; ?></option>
								<?php } ?>
							</select>
						</p>
					</div>
					<div class="crLeft100">
						<p>
							<label class="crLabel"><?php echo __('front_4_cc_code'); ?> <span class="crRed">*</span></label>
						</p>
						<p>
							<input type="text" name="cc_code" class="crText cr4CCText" rev="<?php echo htmlspecialchars(__('front_4_v_cc_code')); ?>" />
						</p>
					</div>
				</div>
				<?php
			}
			?>
			<div class="crClear"></div>
			<div class="crLegend">
				<span class="crLegendText"><?php echo __('front_4_terms'); ?></span>
			</div>
			<p>
				<label class="crLabel">&nbsp;</label>
				<label><input type="checkbox" name="c_agree" value="1" class="required" rev="<?php echo htmlspecialchars(stripslashes(__('front_4_v_agree'))); ?>" /> <?php echo __('front_4_agree'); ?></label>
			</p>
			<p>
				<label class="crLabel">&nbsp;</label>
				<a href="<?php echo $_SERVER['PHP_SELF']; ?>" id="crBtnTerms"><?php echo __('front_4_click'); ?></a>
			</p>

			<!-- <p class="crFloatLeft crR10">
				<input type="button" value="<?php //  __('front_btn_back'); ?>" id="crBtnBack" class="crBtn crBtnBack crFloatLeft" />
			</p>
			<p class="crFloatLeft">
				<input type="button" value="<?php //  __('front_btn_confirm'); ?>" id="crBtnConfirm" class="crBtn crBtnDefault crBtnConfirm" />
			</p> -->

			<p class="crFloatLeft crR10">
				<input type="button" value="<?php  __('front_btn_back'); ?>" id="crBtnBack" class="crBtn crBtnBack crFloatLeft"/>
			</p>
			<p class="crFloatLeft">
				<input type="submit" value="<?php  __('front_btn_confirm'); ?>" id="crBtnConfirm" class="crBtn crBtnDefault crBtnConfirm"/>
			</p>

			<p class="crError" style="display: none"></p>
		</form>
	</div>
	<div class="crBoxBottom">
		<div class="crBoxBottomLeft"></div>
		<div class="crBoxBottomRight"></div>
	</div>
</div>
