<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Santhosh Thomas Alexander<santhosh.thomas@armiasystems.com> |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com  2005                 |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";
if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
	$_SESSION = array_map('stripslashes_deep', $_SESSION);
}

if(isset( $_SESSION["sess_userid"]) and $_SESSION["sess_userid"]!= ""){
	$userid = $_SESSION["sess_userid"];
}
else
{
	header ("location:viewcart.php");
	exit;
}


  $digital_product_count    = digitalProductsCartCount($userid);

  $gift_product_count      = giftProductsCartCount($userid);

  if($digital_product_count==0 && $gift_product_count==0)
      {
         if($_SESSION["SHIPPING_TOTAL"]==0 || $_SESSION["SHIPPING_TOTAL"]=='')
             {
             header("Location:shipping_options.php");
             exit;
         }
  }

$giftCertificateFlag = 0;

$currency_attributes= displayCurrencyType();
$hide_shipping_division = hideShipping();
$adminCurrency	= GetAdminCurrency();

$storeOriginCountry=$_SESSION['store_origin_country'];
$storeOriginState=$_SESSION['store_origin_state'];
$txtBillingState =$_SESSION["sessBillingState"];
$txtBillingCountry = $_SESSION["sessBillingCountry"];
$txtShippingCountry = $_SESSION["sessShippingCountry"];
$txtShippingState = $_SESSION["sessShippingState"];
$txtShippingState = $_SESSION["sessShippingState"];

$sql = "SELECT *  FROM ".$tableprefix."settings ";
$res = mysql_query($sql);

if(mysql_num_rows($res)>0)
{
$row = mysql_fetch_array($res);


$siteurl=$row["site_url"];
//========================================Check Tax Settings for  Products
$enable_tax=$row["enable_tax"];
$default_tax_rate=$row['defaulttax_rate'];

$taxpercentage = $default_tax_rate;
//==============================================End Tax Check
$chkPaypal              = $row["enablepaypal"];
$chkWorldpay            = $row["enableworldpay"];
$chkGoogleCheckout      = $row["vgoogle_check_enable"];
$chkYourpay             = $row["vyourpay_enable"];
$chkAuthorize           = $row["vauthorize_enable"];
$chkGiftPay             = $row["venable_gift_payment"];
$chkCouponPay           = $row["venable_couponCode_payment"];
$enableBuyerToSeller    = $row["enable_buyerToseller"];
$chkBluepay             = $row["vbluepay_enable"];

if($enableBuyerToSeller=="Y"){
	$_SESSION['SESS_ARTISTID']= getArtistID($_SESSION["sess_userid"]);
	/*$row_paypal = mysql_fetch_assoc(mysql_query("SELECT enablepaypal FROM ".$tableprefix."artists WHERE artist_id=".$_SESSION['SESS_ARTISTID']));
	$chkPaypal=$row_paypal['enablepaypal'];*/
}


}
/*display the active template*/
$active_template = displayTemplate();
// Script for Gift Certificate Starts Here
if(isset($_POST['btngiftCode']) &&  $_POST['btngiftCode']=='Apply')
{
	 $txtGiftCode	=	$_POST['txtgiftCode'];

	 if($txtGiftCode=='')
	 {
	 	$message		= "Enter Gift Cerficate Code" ;
	 }
	 else
	 {

                 $sql_code="SELECT g.* FROM ".$tableprefix."giftcertificates g
                                        where g.vgift_coupon_code='".addslashes($txtGiftCode)."' ";
                 $rs_code  = mysql_query($sql_code) or die(mysql_error());

                if(mysql_num_rows($rs_code)>0)
                {

                                $rsobj=mysql_fetch_object($rs_code);

                                $sellerid=$rsobj->seller_id;

                                $sql_select_products 	= "SELECT p.product_id,p.product_name
                                                           FROM ".$tableprefix."product_options po
                                                           INNER JOIN ".$tableprefix."products p ON po.product_id = p.product_id
                                                           INNER JOIN ".$tableprefix."cart c ON c.product_option_id=po.product_option_id
                                                           WHERE c.user_id='".$userid."' and p.product_artist_id!='".$sellerid."' ";
                                $rs_select_products	 =	mysql_query($sql_select_products) or die(mysql_error());

                                if(mysql_num_rows($rs_select_products)>0)
                                {
                                        while($rows=mysql_fetch_array($rs_select_products))
                                        {
                                                $productnames[]=$rows['product_name'];

                                        }

                                        $products	=join(",",$productnames);

                                  $message = "Following products are not from ".getArtistName($sellerid)." , Please  delete them from cart to use this giftcertificate. <br> " ;
                                  $message.= $products;
                         }
                        else
                        {
                                        $avaibale_gift_amt		=	$rsobj->ngift_coupon_amount-$rsobj->nused_gift_amount;

                                        if($avaibale_gift_amt>0)
                                        {
                                            $_SESSION['sess_giftcertificate_available_amt'] = $avaibale_gift_amt;
                                            $_SESSION['sess_giftcertificate_code'] = $txtGiftCode;
                                            $success_message = "GiftCertificate Applied Successfully ,<b>&nbsp; amount will be deducted from your Giftcertificate.";
                                        }
                                        else
                                        {
                                                $_SESSION['sess_giftcertificate_available_amt']	='';
                                                $message = "This Giftcertificate Already Used , No  Balance in this Giftcertificate";
                                        }
                        }

                }

                else
                {
                        $message		= "Gift Certificate Code Does not Exists , Enter valid Gift Certificate Code" ;
                }

	 }

}


// if Gift Certificate Order placed
if(checkGiftProductsExistsinCart($userid))
{
	
	cartClearDigital($userid);
}



// End

// Script for Gift Certificate Ends Herre

// End
// Scripts for coupon Code starts here
if(isset($_POST['couponCode'])){
$couponCode=trim($_POST['couponCode']);
$couponCode_det=checkValiditycouponCode($couponCode);
if(is_array($couponCode_det)){
		$totaltopay = number_format((getCartTotalcouponCode($userid,$couponCode_det)),2,".","");
	}else{
		$message="Invalid coupon code. Please contact administrator";
	}
	}else{
			if(isset($_SESSION['couponCode_det']) && $_SESSION['couponCode_det']!='' )
			{
				$totaltopay = number_format((getCartTotalcouponCode($userid,$_SESSION['couponCode_det'])),2,".","");
				$_POST['couponCode']=$_SESSION['couponCode_det']['ccCode'];
			}else{
			  $totaltopay = number_format((getCartTotal($userid)),2,".","");
			}
	}
include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/".$active_template[0]);

if(isset($_SESSION['SESS_google_checkout']))
{
if(function_exists('session_unregister'))
	session_unregister('SESS_google_checkout');

}
// find total cart amount

if(isset($_POST['couponCode']) && $_POST['couponCode']!=''){
$couponCode=trim($_POST['couponCode']);
$couponCode_det=checkValiditycouponCode($couponCode);
	if(is_array($couponCode_det))
	{
			$display_total=number_format(getCartTotalcouponCode($_SESSION["sess_userid"],$couponCode_det),2,".","");
			$_POST['couponCode']=$_SESSION['couponCode_det']['ccCode'];
			$success_message	= "Coupon Code '".$couponCode."' Applied Successfully . ";

			}else{
			$display_total=number_format(getCartTotal($_SESSION["sess_userid"]),2,".","");
			}
	}else
	{
		if(isset($_SESSION['couponCode_det']) && $_SESSION['couponCode_det']!='' )
			{
				$display_total=number_format((getCartTotalcouponCode($userid,$_SESSION['couponCode_det'])),2,".","");
			}else{
				$display_total=number_format(getCartTotal($_SESSION["sess_userid"]),2,".","");
			}
	}

//Shipping Total is calculated in shipping options page and passed as a session - Santhosh
$shipping_cost = $_SESSION["SHIPPING_TOTAL"];
$cartAmount=$display_total + $shipping_cost;

//=================================================Tax Calculation========================
if($enable_tax==1)
	{ // check enable tax
		 $sql="select * from ".$tableprefix."taxrate  WHERE (vState LIKE '%".$txtBillingState."%'
				 AND vtaxaddress = 'billing' AND vState!='1') OR (vState LIKE '%".$txtShippingState."%' AND vtaxaddress = 'shipping' AND vState!='1')
				 OR (vCountry LIKE '%".$txtBillingCountry."%' AND vtaxaddress = 'billing' AND vState='1') OR
				 (vCountry LIKE '%".$txtShippingCountry."%' AND vtaxaddress = 'shipping' AND vState='1') AND rate_enable='1' Limit 0,1";
		$rs=mysql_query($sql) or die(mysql_error());
		if(mysql_num_rows($rs)>0)
		{
			$rr=mysql_fetch_array($rs);
			$taxpercentage=$rr['ntaxrate'];
			$tname=stripslashes($rr['taxname']);
			$tbase=$rr['vtaxbase'];

	} // end row check


} // end enbale tax



// Calculate Tax
$_SESSION["TAX_DETAILS"] = array();
$_SESSION["TAX_TOTAL"] = 0;

$select_cart_details  = "SELECT c.*, p.product_name,(p.product_price+po.additional_price) AS product_price,po.discount,p.product_artist_id
					FROM ".$tableprefix."cart c
                                        INNER JOIN ".$tableprefix."product_options po ON po.product_option_id = c.product_option_id
                                        INNER JOIN ".$tableprefix."products p ON p.product_id = po.product_id
					WHERE c.user_id = '".addslashes($_SESSION["sess_userid"])."'";

$result_cart_details = mysql_query($select_cart_details) or die(mysql_error());

$product_price =0;
$product_rate  = 0;

while($rw = mysql_fetch_array($result_cart_details))
	{


                                 $conversionRate	= 	ConvertedCurrencyRate($currency_attributes[2]);
				 $converted_price 	= 	$rw['product_price'] * $conversionRate;

				 $product_rate = $converted_price;
				/*------------Multicart 2.0 Upgradation------------*/
                                $product_option_id = $rw["product_option_id"];
				$qty = $rw["quantity"];
				$product_price  = $qty * $product_rate;

				if($rw["discount"] !=0){

				$discountprice                  = $product_rate-($product_rate*$rw["discount"])/100;
				$discountrate                   = ($discountprice*$qty);
				$product_price                  = $discountrate;

				}


                               // echo "<br>".$_SESSION["SHIPPING_DETAILS"][$product_option_id]['rate'];

                                if($enable_tax=="1")
                                {
                                        if($tbase=="Subtotal")
                                        {
                                                $taxrate=$product_price * ($taxpercentage/100);
                                        }

                                        if($tbase=="Subtotal and Shipping")
                                        {
                                            if(!empty($_SESSION["SHIPPING_DETAILS"])) {
                                            $product_price = $product_price + $_SESSION["SHIPPING_DETAILS"][$product_option_id]['rate'] ;
                                            }

                                            $taxrate=$product_price * ($taxpercentage/100);
                                        }
                                }

                                 if($enable_tax=="2")
                                {

                                    $taxrate=$product_price*($taxpercentage/100);
                                }

                                $_SESSION["TAX_DETAILS"][$product_option_id]= number_format($taxrate,2,".","");

                                $_SESSION["TAX_TOTAL"]+=$_SESSION["TAX_DETAILS"][$product_option_id];


}

// End Tax
//=========================If rate per state is not activated and default rate is activated


$exchangeRate=getCurrencyrate($currency_attributes[2]);
//===========================================
if($_SESSION["TAX_TOTAL"]!=0)
{ // if tax rate is not null include tax rate

	$taxrates = $_SESSION["TAX_TOTAL"];
}

$_SESSION['session_taxrate']=$taxrates;


// if Gift Certificate Order placed
if(checkGiftProductsExistsinCart($userid))
{

	$_SESSION['session_taxrate']	='';
	$_SESSION['SHIPPING_TOTAL']	='';
	cartClearDigital($userid);
}



//===============================End Tax Calulation===================================

/*function call to fetch details from site settings*/


//echo "hi".$_SESSION['SESS_digital_product'];exit;

if(!checkGiftProductsExistsinCart($userid))
{
		if($_SESSION['SESS_upscost']!='')
		{
				if($_SESSION["sessBillingFirstName"]=='' || $_SESSION["sessBillingEmail"]=='' || $_SESSION["sessShippingFirstName"]=='' || $_SESSION["sessShippingEmail"]=='')
				{
					$_SESSION["sess_addresses_collected"] = false;

					header("Location:checkout.php");
					exit;

				}
		}
}


$digital_product_count    = digitalProductsCartCount($userid);

if($digital_product_count==1)
    {


    $_SESSION['SHIPPING_TOTAL']	='';

    $_SESSION["TAX_TOTAL"] = '';
    $_SESSION["SHIPPING_DETAILS"] = array();
}

?>

<script language="javascript">

function validateForm()
{
	if(confirm("<?php echo QTN_PROCEED_PAYMNT;?>"))
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>

			<div align="left" class="main_body">

			<!--mainbody area start -->

			<div align="left" id="body_left_area">
				<!--body left area start -->



			<!--categories area start -->

<?php

	//include_once("includes/categorylist.php");

?>

			<!--categories area end -->

			<!--body left area end -->
				</div>

		<!--center content area start-->

		<div align="left" id="item_details">


		<!--items display area start -->

		<div align="left" id="items_top_area">
				<div align="left" id="items_top_area_ttl"><?php echo TEXT_PAYMNT_OPT;?> <?php echo $adminCurrency['currency_code']?> )</div>
				
		</div>

		<div class="success_message"><?php echo $success_message ;?></div>

		<div class="text_information" align="center"><?php echo $message?></div>

		<table  cellpadding="2" cellspacing="2" width="100%" border="0">
		<tr>
		  <td align="center"><b><div class="payment_dtlhead"><?php echo TEXT_PAYMNT_DTLS;?></div></b></td>
		</tr>


		<?php


		// Scripts for Gift Certificate starts here.
		if($chkGiftPay=="Y" &&   !checkGiftProductsExistsinCart($userid) && digitalCart($userid)==0)
		{

		?>

		<tr>
		  <th align="center" style="border-bottom-style:dotted; border-top-style:dotted;">
		  <?php echo MSG_GIFT_CERT;?>
		  <br><br><form name="frmGiftCertificate" method="post">
		  <?php echo TEXT_GIFT_CERT;?> <?php echo TEXT_IF_ANY;?> &nbsp;
		  <input style="font-size:14px; font-weight:bold;" type="text" name="txtgiftCode" id="couponCode" size="40" class="textbox" maxlength="40" value="<?php echo $_POST['txtgiftCode'];?>">&nbsp;&nbsp;<input type="submit" name="btngiftCode" value="<?php echo BTN_APPLY;?>" class="button">
			  </form>
			  <br><br>
			  </th>
		</tr>
		<?php

                }
		// Scripts for Gift Certificate ends here.
		?>
		  	<?php
			// Scripts for coupon code starts here.

			if($chkCouponPay=="Y" && !checkGiftProductsExistsinCart($userid) && digitalCart($userid)==0){
			 ?>
		<tr>
		  <th align="center" style="border-bottom-style:dotted; border-top-style:dotted;"><br><br><form name="couponCodeForm" method="post">
		  Coupon code, if any &nbsp;
		  <input style="font-size:14px; font-weight:bold;" type="text" name="couponCode" id="couponCode" size="40" class="textbox" maxlength="40" value="<?php echo $_POST['couponCode'];?>">&nbsp;&nbsp;<input type="submit" name="couponCodeButn" value=" <?php echo BTN_RE_CAL;?>" class="button">
			  </form>
			  <br><br>
			  </th>
		</tr>
		<?php }
		// Scripts for coupon code ends here.
		?>
		<tr>
		  <td>
		  <div class="payments_styles">
		  <table width="100%"  border="0"  align="center" cellpadding="2" cellspacing="2">

			<?php if($_SESSION['couponCode_det']['ccDiscount']!='')
			{
			?>

			 <tr>
              <td width="56%" align="right"><?php echo TEXT_COUPON_CODE;?>' <?php echo $_SESSION['couponCode_det']['ccCode'] ?>' Discount  </td>
              <td width="44%">&nbsp;<?php echo $_SESSION['couponCode_det']['ccDiscount'];?> % </td>
            </tr>

			<?php } ?>

			<?php if(isset($_POST['couponCode']) && $_POST['couponCode']!=''){
			?>

				<tr>
              <td width="56%" align="right"><?php echo TEXT_ITEM_TOT_COST_AFDIS;?></td>
              <td width="44%">&nbsp; <?php echo $adminCurrency['currency_symbol'];?> <?php echo number_format(getCartTotalcouponCode($_SESSION["sess_userid"],$couponCode_det),2,".","");?>
			   <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			  {
			  ?>
			  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format(getUserCouponcodeCartTotal($_SESSION["sess_userid"],$couponCode_det),2,".","");?> )

			  <?php } ?>
			  </td>
            </tr>

			<?php  }
			 else { ?>
			<tr>
              <td width="56%" align="right"><?php echo TEXT_ITEM_TOT_COST;?> </td>
              <td width="44%">&nbsp; <?php echo $adminCurrency['currency_symbol'];?> <?php echo number_format(getCartTotal($userid),2,".","");?>
			   <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			  {
			  ?>
			  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format((getUserCurrencyCartTotal($userid)),2,".","");?> )

			  <?php } ?>
			  </td>
            </tr>
			 <?php
			 }
			if($hide_shipping_division==1)
			{ // check if the products are digital not  products
			if(!empty($shipping_cost))
			{ // check shipping cost available or not
			?>
            <tr>
              <td align="right"><?php echo TEXT_SHIP_COST;?> </td>
              <td>&nbsp;<?php echo $adminCurrency['currency_symbol'];?>

			  <?php
			  $usershipping	=number_format($shipping_cost,2,".","");
			  $display_user_shipping=ConvertedCurrencyRate($currency_attributes[2]) * $usershipping;
			  echo number_format($shipping_cost,2,".","");?>

			  <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			  {
			  ?>
			    &nbsp; ( <?php echo  $currency_attributes[0]."&nbsp;"?>
				<?php
					   echo number_format($display_user_shipping,2,".","");
				 ?> )
				<?php } ?>
			  </td>
            </tr>
			<?php
			}
				}

			// end check ?>


			<?php

                        if(checkGiftProductsExistsinCart($userid))
                        {
                                $shipping_cost =	0;
                                $taxrates		=	0;

                        }

			 if($enable_tax==1)
			 { // check taxrate activated for each state
					if($_SESSION["TAX_TOTAL"]!=0)
					{ // if tax rate is not null include tax rate

					?>
					<tr>
					  <td align="right"><?php echo $tname;?> <?php echo TEXT_INCLUD_TOT;?></td>
					  <td>&nbsp; <?php echo $adminCurrency['currency_symbol']."&nbsp;".number_format($_SESSION["TAX_TOTAL"],2,".","");?>
					   <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			 			 {
						 	$conversionRate	= 	ConvertedCurrencyRate($currency_attributes[2]);
							$converted_tax 	= 	$_SESSION["TAX_TOTAL"] * $conversionRate;
			 			 ?>
						  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format($converted_tax,2,".","");?> )

			       <?php } ?>

					  </td>
					</tr>
					<?php
					} // end if
				} // end if
		?>
		<?php
			 if($enable_tax==2)
			 { // check default tax rate activated
					if($_SESSION["TAX_TOTAL"]!=0)
					{ // if tax rate is not null include tax rate

					?>
					<tr>
					  <td align="right"> <?php echo TEXT_TAX_TOTAL;?></td>
					  <td>&nbsp;&nbsp; <?php echo  $adminCurrency['currency_symbol']."&nbsp;".number_format($_SESSION["TAX_TOTAL"],2,".","");?>
					   <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			 			 {
						 	$conversionRate	= 	ConvertedCurrencyRate($currency_attributes[2]);
							$converted_tax 	= 	$_SESSION["TAX_TOTAL"] * $conversionRate;
			 			 ?>
						  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format($converted_tax,2,".","");?> )

                                            <?php } ?>
					  </td>
					</tr>
					<?php
					} // end if
			} // end if



		?>



		 <tr>
              <td width="56%" align="right"><?php echo TEXT_ORDER_TOTAL;?>  </td>
              <td width="44%">&nbsp;<?php echo  $adminCurrency['currency_symbol']."&nbsp;".number_format($display_total+$shipping_cost+$_SESSION["TAX_TOTAL"],2,".","");?>
				  <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			 			 {
						 	$c_total			=	$display_total+$shipping_cost+$_SESSION["TAX_TOTAL"];
						 	$conversionRate		= 	ConvertedCurrencyRate($currency_attributes[2]);
							$converted_total 	= 	$c_total * $conversionRate;
			 			 ?>
						  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format($converted_total,2,".","");?> )

			       <?php } ?>
			  </td>
            </tr>

		<?php
			 if($_SESSION['sess_giftcertificate_available_amt']>0)
			{
			 ?>

			 <tr>
              <td width="56%" align="right"><?php echo TEXT_GIFT_CERT;?><?php echo TEXT_AMT;?> </td>
              <td width="44%">
			  &nbsp;<?php echo  $adminCurrency['currency_symbol']."&nbsp;".number_format($_SESSION['sess_giftcertificate_available_amt'],2,".","");?>
			  <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			 			 {
						 	$conversionRate_gift	= 	ConvertedCurrencyRate($currency_attributes[2]);
							$converted_gift_total 	= 	number_format($_SESSION['sess_giftcertificate_available_amt'],2,".","") * $conversionRate;
			 			 ?>
						  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format($converted_gift_total,2,".","");?> )

			       <?php } ?>

			  </td>
            </tr>
			<?php } ?>



		<tr>
			<td align="right"><strong><?php echo TEXT_AMT_PAY;?></strong></td>
			 <td>&nbsp;
			 <?php
			 $total_cost=$display_total+$shipping_cost+$_SESSION["TAX_TOTAL"];
					 // Gift Certificate Amount Calculation
					 if($_SESSION['sess_giftcertificate_available_amt']>0)
					 {

							 if($total_cost>$_SESSION['sess_giftcertificate_available_amt'])
							 {
								$total_display_cost					=	$total_cost - $_SESSION['sess_giftcertificate_available_amt'];

								$_SESSION['sess_gift_amount_used']	=			$_SESSION['sess_giftcertificate_available_amt'];

								$amount_to_pay						=		$total_display_cost;

							 }
							 else
							 {
									$_SESSION['sess_gift_amount_used']	=	$total_cost;
									$amount_to_pay						= 0;
							 }

					 }

					 else
					 {

						$amount_to_pay			=	$total_cost;
					 }
					$_SESSION['amount_paid']	= $amount_to_pay;
			 // End Gift Certificate Calculation
			  echo  $adminCurrency['currency_symbol']."&nbsp;".number_format($amount_to_pay,2,".","");?>

			    <?php if($adminCurrency['currency_code']!=$currency_attributes[2])
			 			 {
						 	$conversionRate				= 	ConvertedCurrencyRate($currency_attributes[2]);
							$converted_amount_to_pay 	= 	$amount_to_pay * $conversionRate;
			 			 ?>
						  &nbsp; ( <?php echo $currency_attributes[0]."&nbsp;".number_format($converted_amount_to_pay,2,".","");?> )

			       <?php } ?>

			  </td>
		    </tr>

                   

                   
          </table>
		  <div class="clear"></div>
		  </div>
		  </td>
		  </tr>
                  
		</table>

<?php if($amount_to_pay>0) {

?>

		<div>
<?php
	if($enableBuyerToSeller == "Y"){
?>
		<table cellpadding="0" border="0" cellspacing="0" width="100%">
<?php

	if($chkPaypal == "Y")
	{
 ?>
		<tr>
		  <td align="center">Click here to complete Paypal order payment</td>
		  </tr>
		<tr>
			<td align="center">

		<a href="paypal-parallel-payment.php?paymentMethod=PP"><img src="images/pp.jpg" alt="Click here to complete Paypal order payment" border="0" title="Make payments with PayPal - it's fast, free and secure! " ></a>

<br>
<?php echo MSG_MAKE_SURE;?>
                        </td>
                </tr>
        <?php
	 }
?>

<?php

	if($chkPaypal != "Y" && $chkWorldpay  != "Y" && $chkGoogleCheckout != "Y" && $chkYourpay != "Y" && $chkAuthorize != "Y")
	{
?>


		<tr>
			<td class="text_information"><?php echo MSG_CONT_ADMIN;?></td>
		</tr>
		<tr>
			<td align="center"><input type="button" class="button" name="back" value="Back" onClick="Javscript:history.go(-1);"></td>
		</tr>
<?php

	}

?>

		<tr>
			<td>&nbsp;</td>
		</tr>

</table>

<?php }else {?>
<table cellpadding="0" border="0" cellspacing="0" width="100%">
<?php

	if($chkPaypal == "Y")
	{
 ?>
		<tr>
		  <td align="center"><?php echo ALT_CLK_PAYPAL;?></td>
		  </tr>
		<tr>
			<td align="center">

		<a href="pay.php?paymentMethod=PP"><img src="images/pp.jpg" alt="<?php echo ALT_CLK_PAYPAL?> " ></a>

<br>
<?php echo MSG_MAKE_SURE;?>
                        </td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
<?php
	 }

	if(($chkAuthorize == "Y" || $chkYourpay=="Y" || $chkBluepay=="Y" ) &&   $adminCurrency['currency_code']=='USD'){
 ?>

	<tr>
            <td align="center">
                              Click here to use a credit card for payment <br><br>
    <?php
                    $secureurl = SECURE_SITE_URL."/payment.php";
    ?>
                    <a href="<?php echo $secureurl?>"><img src="images/cc.gif" valign="top" title="Pay with Credit Card" border="0" ></a>
            </td>
	</tr>
        <tr>
			<td>&nbsp;</td>
	</tr>
<?php
	}

?>
		<?php if($chkWorldpay =="Y" && $enableBuyerToSeller == "N") {?>
		<tr>
                    <td align="center">
                    <a href="worldpaypayment.php?payment=WP"><img src="images/worldpay.gif" width="139" height="33" border="0"  title="Make payments with WorldPay - it's fast, free and secure"></a>
                    </td>
		</tr>
		<tr>
		  <td align="center">&nbsp;		    </td>
		</tr>
		<?php
		}
                if($chkGoogleCheckout  =="Y" && $enableBuyerToSeller == "N" && ($adminCurrency['currency_code']=='USD' || $adminCurrency['currency_code']=='GBP')) {
                ?>
		<tr>
			<td align="center">
                                <a href="google_checkout_payment.php"><img src="images/google_checkout.gif"  border="0" title="Google Checkout Payment Gateway"></a>
                        </td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
                <?php
                }
                if($chkGiftPay == "Y" && $_SESSION['gift_certificate_flag'] == "N")
                {
                ?>
		<tr>
			<td align="center"><a href="giftcoupon_payment.php"><img src="images/giftcoupon_payment.jpg" border="0" title="Pay with Gift Certificate"></a></td>
		</tr>
                <?php
                }
               if($chkPaypal != "Y" && $chkWorldpay  != "Y" && $chkGoogleCheckout != "Y" && $chkYourpay != "Y" && $chkAuthorize != "Y")
                {
                ?>
		<tr>
			<td class="text_information"><?php echo MSG_CONT_ADMIN;?></td>
		</tr>
		<tr>
			<td align="center"><input type="button" class="button" name="back" value="<?php echo BTN_BACK;?>" onClick="Javscript:history.go(-1);"></td>
		</tr>
                <?php
                }
                ?>
		<tr>
			<td>&nbsp;</td>
		</tr>

</table>
<?php }?>

</td>
</tr>
</table>

</div>
<?php
}
else
{
?>
  <div class="payments_styles">
<form method="post" action="completeorder.php">
<table cellpadding="0" cellspacing="0" border="0" width="50%" align="center">
<tr>
<td align="center">
<input type="submit"  name="btnCompleteOrder" value="Complete Order" class="button" onClick="return validateForm();" tabindex="5">
 </td>
</tr>
</table>
</form>
</div>
<?php
}
?>
	<div align="left" class="float_clear1"></div>
	 <!--items display area end -->
	  </div>
	<!--center content area end-->
	<div align="left" class="clear"></div>
	<!--mainbody area end -->
	</div>
	<div align="left" class="clear"></div>
<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>