<?php
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
require(DIR_WS_INCLUDES."http.js"); 
echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post'); 
?>
<table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB; ?>">
<?php $serverDate = date('Y-m-d H:i:s',getServerDate(false)); 
// 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_payment.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
tep_output_differ_check();
?>
<?php
if(!isset($hide_row_top)) {
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
	}
?>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
	table_image_border_top(false, false, TABLE_HEADING_BILLING_ADDRESS);
} else {
?>
	<tr>
		<td>
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
			<tr>
				<td class="main"><b><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></b></td>
			</tr>
		</table>
		</td>
	</tr>
<?php
}
 if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {
?>
	<tr>
		<td>
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
			<tr>
				<td class="infoBoxHeadingPage"><?php echo '<span class="infoBoxHeadingPageTitle">' . tep_output_string_protected($error['title']) . '</span>'; ?></td>
			</tr>
		</table>
		</td>
	</tr> 
	<tr>
		<td>
		<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBoxNotice">
			<tr class="infoBoxNoticeContents">
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
						<td class="main" width="100%" valign="top"><?php echo $error['error']; ?></td>
						<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	</tr>
<?php
  }


// BOF: Lango Added for template MOD
?>
	<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><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
						<td class="main" width="50%" valign="top"><?php echo TEXT_SELECTED_BILLING_DESTINATION; ?><br><br><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . tep_template_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td>
						<td align="right" width="50%" valign="top">
						<table border="0" cellspacing="0" cellpadding="2">
							<tr>
								<td class="main" align="center" valign="top"><b><?php echo TITLE_BILLING_ADDRESS; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td>
								<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
								<td class="main" valign="top"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br>'); ?></td>
								<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></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>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_top(false, false, '<span class="infoBoxHeadingPageTitle">'.TABLE_HEADING_PAYMENT_METHOD.'</span>');
}else{
?>
	<tr>
		<td>
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
			<tr>
				<td class="main"><b><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></b></td>
			</tr>
		</table>
		</td>
	</tr>
<?php
}
// BOF: Lango Added for template MOD
?>
	<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">
					<?php 
					  $selection = $payment_modules->selection();
					  if (sizeof($selection) > 1) {
					?>
								  <tr>
									<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
									<td class="main" width="50%" valign="top"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></td>
									<td class="main" width="50%" valign="top" align="right"><b><?php echo TITLE_PLEASE_SELECT; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td>
									<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								  </tr>
					<?php
					  } else {
					?>
								  <tr>
									<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
									<td class="main" width="100%" colspan="2">
									<?php  if(sizeof($selection)>0)
												echo TEXT_ENTER_PAYMENT_INFORMATION; 
										 else
												echo TEXT_NO_PAYMENT_SELECTION;
									?></td>
									<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								  </tr>
					<?php
					  }
					  $flag='B';
					  $radio_buttons = 0;
					  $m = count($selection[0]['fields']);
					  $cnt = 0;
					  $barred=0;
					  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
					?>
					  <tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
						<td colspan="2">
						<table border="0" width="100%" cellspacing="0" cellpadding="2">
							<?php
						 if (!$selection[$i]['barred']){
							 if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) 
									echo '<tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ',\'', $selection[$i]['id'] . '\')">' . "\n";
							 else 
								   echo '<tr id="defaultunSelected" class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ',\'', $selection[$i]['id'] . '\')">' . "\n";
							?>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
									<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b>
									 <table border="0" cellpadding="0" cellspacing="0">
										<?php for($j=0;$j<$m;$j++){
										   while(list($k,$v) = each($selection[0]["fields"]["$j"])){
												  if($cnt%2==0)
													 //echo '<tr> ';
													//echo  '<td class="main">'.$v . '</td>';
													$cnt++;
												} 
											} ?>
									</table>
									</td>
				                    <td class="main" align="right">
									<?php $single_payment=false;
										if (sizeof($selection)>1) 
										  echo tep_draw_radio_field('payment', $selection[$i]['id'],(($i==0)?true:''));
										else {
										  $single_payment=true;
										  echo tep_draw_hidden_field('payment', $selection[$i]['id']);
										}
									?>
									</td>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								</tr>
								<?php
									if (isset($selection[$i]['error'])) {
								?>
												  <tr>
													<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
													<td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>
													<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
												  </tr>
								<?php
									} elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
								?>	
												  <tr <?php if(!$single_payment){?>id="<?php echo $selection[$i]['id'];?>" <?php echo (($payment!=$selection[$i]['id'])?'style="display:none"':'');}?>>
													<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
													<td colspan="4">
													<table border="0" cellspacing="0" cellpadding="2">
														<?php
															  for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
														?>
																			  <tr>
																				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
																				<td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
																				<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
																				<td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>
																				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
																			  </tr>
														<?php
															  }
														?>
													</table>
													</td>
													<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
						  						</tr>
								<?php
									} // fields,error
									
								} else { // barred
									echo '<tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ',\'', $selection[$i]['id'] . '\')">' . "\n";
								?>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
									<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b>
									 <table border="0" cellpadding="0" cellspacing="0">
										<?php for($j=0;$j<$m;$j++){
										   while(list($k,$v) = each($selection[0]["fields"]["$j"])){
												  if($cnt%2==0)
													 //echo '<tr> ';
													//echo  '<td class="main">'.$v . '</td>';
													$cnt++;
												} 
											} ?>
									</table>
									</td>
				                    <td class="main" align="right">
									<?php $single_payment=false;
										if (sizeof($selection) > 1) {
										  echo tep_draw_radio_field('payment', $selection[$i]['id'],false,' disabled="disabled" ');
										} else {
											$single_payment++;
										}
									?>
									</td>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
								</tr>
								  <tr>
									<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
									<td colspan="4" style="padding-left:10px">
									<table border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td class="smallText"><b><font color="red"><?php echo TEXT_PAYMENT_BARRED;?></font></b>
											</td>
										</tr>
										<tr>
											<td class="smallText"><?php echo sprintf(TEXT_PAYMENT_BARRED_REASON,tep_get_country_title($IP_COUNTRY));?>
											</td>
										</tr>
									</table>
									</td>
								</tr>	
								<?php 
									$barred++;
								} // barred?>
                		</table>
						</td>
                		<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				  </tr>
<?php
	$radio_buttons++;
  }
  if ($barred==count($selection)) $payment_barred=true;
 ?>
             </table>
			</td>
           </tr>
         </table>
		</td>
      </tr>
 <?php
if (MAIN_TABLE_BORDER == 'yes'){
	table_image_border_bottom();
}?>     
	  <tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	  </tr>
<script language="javascript">	
	previousPaymentSelected="<?php echo $payment;?>";
	if(!previousPaymentSelected && document.getElementById("defaultunSelected")) selectRowEffect(document.getElementById("defaultunSelected"),0,"<?php echo $selection[0]['id'];?>");
	function doComment(chk) { 
		if(document.getElementById("show_comments") && chk.checked)
			document.getElementById("show_comments").style.display="";
		else if(document.getElementById("show_comments") && !chk.checked)
			document.getElementById("show_comments").style.display="none";
	}
</script>
<?php  $coupon_check_qry = tep_db_query("select * from " . TABLE_COUPONS . " where '". $serverDate ."' <= coupon_expire_date and '". $serverDate ."' >= coupon_start_date and coupon_active='Y' ");
		if(tep_db_num_rows($coupon_check_qry)){
?>
	<tr>
		<td>
		<table cellspacing="0" cellpadding="0" width="100%" border="0">
	  <?php if (MAIN_TABLE_BORDER == 'yes'){ 
				echo table_image_border_top(false, false, '<span class="infoBoxHeadingPageTitle">'.TEXT_GIFT_VOUCHER.'</span>');
			}else {?>
				<tr>
			   		<td class="infoBoxHeadingPage">&nbsp;
				   		<img src="templates/osCommRes/images/arrow_1.gif" alt="" align="absmiddle" border="0" height="15" width="15">&nbsp;<?php echo TEXT_GIFT_VOUCHER;?>  
			   		</td>
			    </tr>	
			<?php }
			if (MAIN_TABLE_BORDER == 'yes'){
				table_image_border_bottom();
			}
			?>
			<tr id="gv_chk">
				<td class="main"><?php echo tep_draw_separator('pixel_trans.gif',30,1); ?><b><?php echo TEXT_REDEEM_YOUR_VOUCHER;?></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<?php echo  tep_draw_checkbox_field('coupon', '0',false,'onclick=javascript:hide_credit()');?> </td>
			</tr>	
			<tr>
				<td class="main">
				   <table border="0" cellpadding="0" cellspacing="0" width="100%">			  
				      <tr>
					    <td>
					      <div id="credit_result" class="smalltext" align="center" style="display:none;height:100;width:100%;"></div>	
					      <div id="credit" style="display:none;"><div id="error_span"></div><?php echo $order_total_modules->credit_selection(); ?></div>	
						 </td>
					  </tr>
					</table>
				</td>
			</tr>
      	</table>
	  </td>
      </tr>
<?php } ?>
<script language="javascript">
if(document.checkout_payment.coupon && document.checkout_payment.coupon.checked==true && document.getElementById("credit").style.display=='none'){
hide_credit();
}
</script>
	
      <tr>
        <td><table border="0" width="100%" cellspacing="2" cellpadding="2">
        <?php if (MAIN_TABLE_BORDER == 'yes'){ 
				echo table_image_border_top(false, false, '<span class="infoBoxHeadingPageTitle">'.TABLE_HEADING_COMMENTS.'</span>');
		 }else {?>
          <tr>
			   <td class="infoBoxHeadingPage">&nbsp;<img src="templates/osCommRes/images/arrow_1.gif" alt="" align="absmiddle" border="0" height="15" width="15">&nbsp;<?php echo TABLE_HEADING_COMMENTS;?></td> 
		  </tr>
		 <?php  } 
		  if (MAIN_TABLE_BORDER == 'yes'){
				table_image_border_bottom();
		  }?>
          <tr>
            <td class="main">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<b><?php echo TABLE_HEADING_COMMENTS_HERE .tep_draw_checkbox_field('comments_chkbox', '1',($comments)?true:false,'onclick=javascript:doComment(this)'); ?></a></b></td>
          </tr>
        </table></td>
      </tr>
<?php
//}
// BOF: Lango Added for template MOD
	if($comments!="")
		$comment_style="style='display:block'";
	else 
		$comment_style="style='display:none'";
			
?>
	<tr <?php echo $comment_style; ?> id="show_comments">
		<td>
		<table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox">
			<tr class="infoBoxContents">
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
					</tr>
					<tr>
						<td><?php echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
					</tr>
				</table>
				</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" width="100%" cellspacing="0" cellpadding="2">
						<tr>
							<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
							<td class="main"><b><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td>
							<td class="main" align="right"><?php if (!$USER_BARRED && !$payment_barred) 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>
      <tr>
        <td colspan="0"><?php //echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
		<tr>			
			<td>
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<tr>
					<td width="25%">
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
						<td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
						<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
						</tr>
					</table>
					</td>
					<td width="25%">
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
						<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
						<td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
						<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
						</tr>
					</table>
					</td>
					<td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
					<td width="25%">
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
							<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
						</tr>
					</table>
					</td>
				</tr>
				<tr>
					<td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
					<td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
					<td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
					<td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
				</tr>
			</table>
			</td>
		</tr>
</table>
</form>