<!-- shoppingCart plugin -->

<tr>
	<td colspan="2">
		{assign var='shc_gf_name' value='listing_groups+name+shopping_cart'}
		{$lang[$shc_gf_name]}
		<div id="shc-group" class="hide" {if $config.locationFinder_position == 'bottom'}style="padding-top: 5px;"{/if}>
			{assign var='currency' value='currency'|df}
			<input type="hidden" name="fshc[shc_mode]" value="{if $smarty.post.fshc.shc_mode}{$smarty.post.fshc.shc_mode}{else}auction{/if}" id="sf_field_shc_mode" />

			<div class="tabs" id="shc_tabs">
				<ul class="tabs">
					<li lang="auction" class="active">{$lang.shc_mode_auction}</li>
					<li lang="fixed">{$lang.shc_mode_fixed}</li>
					<li lang="listing">{$lang.shc_mode_listing}</li>
				</ul>
				<div class="nav left"></div>
				<div class="nav right"></div>
			</div>
			<div class="tab_area">
				<div lang="auction" id="shc_fields_area">
					{include file=$smarty.const.RL_PLUGINS|cat:'shoppingCart'|cat:$smarty.const.RL_DS|cat:'admin'|cat:$smarty.const.RL_DS|cat:'fields.tpl'}	
				</div>
			</div>
		</div>
	</td>
</tr>

<script type="text/javascript">//<![CDATA[
var shcConfig = new Array();

shcConfig['containerPosition'] = '{$config.shc_fields_position}';
shcConfig['containerPositionType'] = '{$config.shc_fields_position_type}';

var listing_field_price = '{$config.shc_listing_field_price}';
var shc_mode = '{if $smarty.post.fshc.shc_mode}{$smarty.post.fshc.shc_mode}{else}auction{/if}';

{literal}

var shcReplaceFieldPrice = function()
{
	$('input[name="f[' + listing_field_price + '][value]"]').parent('td').parent('tr').remove();
}

var shcPriceFormatTabs = function(mode)
{
	$('#shc_tabs ul>li').each(function()
	{
		if($(this).attr('lang') == mode)
		{
			if(!$(this).hasClass('active'))
			{
		   		$(this).addClass('active');
			}
		}
		else
		{
			$(this).removeClass('active');
		}
	});

	$('input[name="fshc[shc_mode]"]').val(mode);
	$('#shc_fields_area').attr('lang', mode);

	$('#shc_fields_area table.form tr').each(function()
	{
		if($(this).hasClass(mode) || !$(this).attr('class'))
		{
			$(this).show();
		}
		else
		{
			$(this).hide();
		}
	});

	$('.price_item').each(function()
	{  
		if($(this).hasClass(mode) || !$(this).attr('class'))
		{
			$(this).show();
		}
		else
		{
			$(this).hide();
		}
	});

	if(mode == 'auction')
	{
		$('input[name="fshc[shc_quantity]"]').val(1);
		$('input[name="fshc[shc_quantity]"]').prop('disabled', true);
	}
	else if(mode == 'fixed')
	{
		$('input[name="fshc[shc_quantity]"]').prop('disabled', false);
	}
	else if(mode == 'listing')
	{
		$('input[name="fshc[shc_quantity]"]').val(1);
	}
}

$(document).ready(function() {
	if( listing_field_price == '' )
	{
		printMessage('warning', '{/literal}{$lang.shc_price_field_not_selected}{literal}');
	}
	else
	{
		/* assign group container */		
		if ( shcConfig['containerPosition'] == 'bottom' )
		{
			$('div#controller_area form table.submit:last').before($('#shc-group'));
		}
		else if ( shcConfig['containerPosition'] != 'top' )
		{
			if ( shcConfig['containerPositionType'] == 'prepend' )
			{
				$('div#fs_'+shcConfig['containerPosition']+' > div.body').prepend($('#shc-group'));
			}
			else
			{
				$('div#fs_'+shcConfig['containerPosition']+' > div.body').append($('#shc-group'));
			}
		}

		if(shc_mode)
		{
			shcPriceFormatTabs(shc_mode);
		}
		shcReplaceFieldPrice();
		
		$('#shc-group').show();
	}
});

{/literal}
//]]>
</script>

<!-- end shoppingCart plugin -->