<!-- shoppingCart plugin -->

{if $listing_data.shc_mode == 'auction' || $listing_data.shc_mode == 'fixed'}
	<div class="shc-group ml_tabs_content">
		{if $listing_data.shc_mode == 'auction'}
			<table class="table">
				{if $listing_data.shc.time_left_value > 0 && $listing_data.shc_auction_status != 'closed'}
				<tr>
					<td class="name">{$lang.shc_time_left}:</td>
					<td class="value">
						{$listing_data.shc.time_left}
					</td>
				</tr>
				{/if}
				<tr>
					<td class="name">{if $listing_data.shc.total_bids > 0}{$lang.shc_current_bid}{else}{$lang.shc_starting_bid}{/if}:</td>
					<td class="value">
						{if $config.system_currency_position == 'before'}{$config.system_currency}{/if}<span id="current_price">{$listing_data.shc.current_bid|number_format:2:'.':','}</span>{if $config.system_currency_position == 'after'} {$config.system_currency}{/if}
						[ <a href="javascript:void(0);" id="bid_history"><span id="total_bids">{$listing_data.shc.total_bids}</span> {$lang.shc_bids}</a> ]
					</td>
				</tr>
				{if $winner_info}
				<tr>
					<td class="name">{$lang.shc_winner}:</td>
					<td class="value">
						{$winner_info.Full_name}
					</td>
				</tr>
				{/if}
				{if $listing_data.shc.time_left_value > 0 && $listing_data.shc_auction_status != 'closed'}
				<tr>
					<td class="name">{if $isLogin}<span id="shc_min_bid">{$lang.shc_min_bid|replace:'[total]':$listing_data.shc.min_rate_bid}</span>{/if}</td>
					<td class="value">
						{if $isLogin}
							<input type="text" class="numeric w70" name="rate_bid" id="rate_bid" />	
							<a class="button" href="javascript:void(0);" id="shc_add_bid">{$lang.shc_add_bid}</a>
						{else}
							{$shc_add_bid_not_login}
						{/if}
					</td>
				</tr> 
				<tr>
					<td class="name">{$lang.shc_price}</td>
					<td class="value" style="padding: 5px 0px 5px 0px;">
						<div id="price_buy_now" class="clearfix"></div>
						{if $listing_data.shc.time_left && $listing_data.shc_auction_status != 'closed'}
							<a class="button" href="javascript:void(0);" id="shc_by_now_item">{$lang.shc_buy_now}</a>
							{if $listing_data.shc_quantity > 0}
								<span>&nbsp;-&nbsp;{$lang.or}&nbsp;-&nbsp;</span>
								<a class="button add-to-cart" href="javascript:void(0);" id="shc-item-{$listing_data.ID}">{$lang.shc_add_to_cart}</a>
							{/if}
						{/if}
					</td>
				</tr>
				{else}
				<tr>
					<td></td>
					<td class="value closed"><span class="red">{$lang.shc_auction_closed}</span></td>
				</tr>
				{/if} 
				<tr>
					{assign var='shc_lf_name' value='listing_fields+name+shc_weight'}
					{assign var='shc_weight_unit' value='shc_weight_unit_'|cat:$config.shc_weight_unit}
					<td class="name">{$lang[$shc_lf_name]}</td>
					<td class="value">
						{$listing_data.shc_weight} {$lang[$shc_weight_unit]}
					</td>
				</tr>
				<tr>
					<td class="name">{$lang.shc_available_payment_gateways}</td>
					<td>
						{if $shc_payment_gateways}
						<ul class="shc-payment-gateways">
							{foreach from=$shc_payment_gateways item='pgateway'}
								<li>
									{if $pgateway.key == 'paypal'}
										<img alt="" src="{$smarty.const.RL_LIBS_URL}payment/paypal/paypal.png" />
									{elseif $pgateway.key == '2co'}
										<img alt="" src="{$smarty.const.RL_LIBS_URL}payment/2co/2co.png" />
									{elseif $pgateway.key == 'bankWireTransfer'}
										{include file=$smarty.const.RL_PLUGINS|cat:'shoppingCart'|cat:$smarty.const.RL_DS|cat:'bank_transfer_listing_details.tpl'}
									{else}
										<img alt="" src="{$smarty.const.RL_PLUGINS_URL}{$pgateway.key}/static/{$pgateway.key}.png" />
									{/if}
								</li>
							{/foreach}
						</ul>
						{else}
							<div class="notice">{$lang.shc_not_available_payment_gateways}</div>
						{/if}
					</td>
				</tr>
				<tr>
					<td class="name">{$lang.shc_available_shipping_methods}</td>
					<td>
						<table class="checkboxes fixed">
							{foreach from=$shc_shipping_methods item='method'}
								<tr>
									<td>
										<div class="checkbox_active" title="{$method.name}"><img alt="" src="{$rlTplBase}img/blank.gif">{$method.name}</div>
									</td>
								</tr>
							{/foreach}
						</table>
					</td>
				</tr>
			</table>
		{elseif $listing_data.shc_mode == 'fixed'}
			<table class="table">
				<tr>
					<td class="value" colspan="2">
						{if $listing_data.shc_quantity > 0}
							<a class="button add-to-cart" href="javascript:void(0);" id="shc-item-{$listing_data.ID}">{$lang.shc_add_to_cart}</a>
						{/if}
					</td>
				</tr> 
				<tr>
					{assign var='shc_lf_name' value='listing_fields+name+shc_weight'}
					{assign var='shc_weight_unit' value='shc_weight_unit_'|cat:$config.shc_weight_unit}
					<td class="name">{$lang[$shc_lf_name]}</td>
					<td class="value">
						{$listing_data.shc_weight} {$lang[$shc_weight_unit]}
					</td>
				</tr> 
				<tr id="df_field_shc_quantity">
					{assign var='shc_lf_name' value='listing_fields+name+shc_quantity'}
					<td class="name">{$lang[$shc_lf_name]}</td>
					<td class="value">
						{$listing_data.shc_quantity}
					</td>
				</tr> 
				<tr>
					{assign var='shc_lf_name' value='listing_fields+name+shc_available'}
					<td class="name">{$lang[$shc_lf_name]}</td>
					<td class="value">
						{if $listing_data.shc_available}{$lang.yes}{else}{$lang.no}{/if}
					</td>
				</tr>
				<tr>
					<td class="name">{$lang.shc_available_payment_gateways}</td>
					<td>
						{if $shc_payment_gateways}
						<ul class="shc-payment-gateways">
							{foreach from=$shc_payment_gateways item='pgateway'}
								<li>
									{if $pgateway.key == 'paypal'}
										<img alt="" src="{$smarty.const.RL_LIBS_URL}payment/paypal/paypal.png" />
									{elseif $pgateway.key == '2co'}
										<img alt="" src="{$smarty.const.RL_LIBS_URL}payment/2co/2co.png" />
									{elseif $pgateway.key == 'bankWireTransfer'}
										{include file=$smarty.const.RL_PLUGINS|cat:'shoppingCart'|cat:$smarty.const.RL_DS|cat:'bank_transfer_listing_details.tpl'}
									{else}
										<img alt="" src="{$smarty.const.RL_PLUGINS_URL}{$pgateway.key}/static/{$pgateway.key}.png" />
									{/if}
								</li>
							{/foreach}
						</ul>
						{else}
							<div class="notice">{$lang.shc_not_available_payment_gateways}</div>
						{/if}
					</td>
				</tr>
				<tr>
					<td class="name">{$lang.shc_available_shipping_methods}</td>
					<td>
						<table class="checkboxes fixed">
							{foreach from=$shc_shipping_methods item='method'}
								<tr>
									<td>
										<div class="checkbox_active" title="{$method.name}"><img alt="" src="{$rlTplBase}img/blank.gif">{$method.name}</div>
									</td>
								</tr>
							{/foreach}
						</table>
					</td>
				</tr>
			</table>
		{/if}
	</div>
	<script type="text/javascript">
	{literal}

	$(document).ready(function(){
		/* add item to my cart */
		$('a#shc_add_bid').each(function() {
			$(this).flModal({
				caption: '',
				content: '{/literal}{if $isLogin}{$lang.shc_do_you_want_to_add_bid}{/if}{literal}',
				{/literal}{if $isLogin}{literal}prompt: 'shcAddBid()'{/literal}{else}{literal}source:'#login_modal_source'{/literal}{/if}{literal},
				width: 'auto',
				height: 'auto'
			});
		});

		$('#bid_history').click(function()
		{
			$('#tab_shoppingCart').trigger('click');
		});

		/* buy now */
		$('#shc_by_now_item').click(function()
		{
			xajax_addItem('{/literal}{$listing_data.ID}{literal}');
			setTimeout('location.href="{/literal}{$rlBase}{if $config.mod_rewrite}{$pages.shc_my_shopping_cart}.html?item={$listing_data.ID}{else}?page={$pages.shc_my_shopping_cart}&amp;item={$listing_data.ID}{/if}{literal}"', 3000);
		});

		/* add price */		
		$('#price_buy_now').html($('#df_field_price').html());
	});

	var shcAddBid = function()
	{
		if($('#rate_bid').val() == '')
		{
			printMessage('error', '{/literal}{$lang.shc_empty_bid_value}{literal}');
			$('#rate_bid').focus();
			return;
		}

		xajax_addBid('{/literal}{$listing_data.ID}{literal}', $('#rate_bid').val());
	}

	{/literal}
	</script>
{/if}

<!-- end shoppingCart plugin -->