{include file="header.tpl"}
 
<div id="sidebar">
{include file="sidebar.tpl"}
</div>

<div class="mainContent">

<h1>{$smarty.const.ADD_LISTING_HEADER}</h1>

{if $success}
	<p class="green"><strong>{$success}</strong></p>
{elseif $error_message}
	<p class="red"><strong>{$error_message}</strong></p>
{/if}

{if $admin || $seller}
<fieldset>
	<legend>{$smarty.const.ADD_LISTING_LEGEND}</legend>
		<form action="addlisting.php" method="post">
			<h2>{$smarty.const.ADD_LISTING_FORM_HEADER}</h2>
			<p><label for="ad_title">{$smarty.const.AD_TITLE}</label>
			<input id="ad_title" name="ad_title" type="text" size="30" maxlength="25" value="" />
			</p>

			<p><label for="make">{$smarty.const.MANUFACTURER}</label>
			<select id="make" name="make" size="1">
			{foreach item="manufacturer" from=$manufacturerslist}
				<option value="{$manufacturer.manufacturer}">{$manufacturer.manufacturer}</option>
			{/foreach}
			</select>
			</p>
		
			<p><label for="model">{$smarty.const.MODEL}</label>
			<input id="model" name="model" type="text" size="30" maxlength="30" value="" />
			</p>
			
			<p><label for="vehicle_type">{$smarty.const.TYPE}</label>
			<select id="vehicle_type" name="vehicle_type" size="1">
			{foreach item="vehicle_type" from=$typeslist}
				<option value="{$vehicle_type.vehicle_type}">{$vehicle_type.vehicle_type}</option>
			{/foreach}
			</select>
			</p>
			
			<p><label for="doors">{$smarty.const.DOORS}</label>
			<select id="doors" name="doors" size="1">
				<option value="{$smarty.const.LISTING_FORM_DOORS_OPTION1}">{$smarty.const.LISTING_FORM_DOORS_OPTION1}</option>
				<option value="{$smarty.const.LISTING_FORM_DOORS_OPTION2}">{$smarty.const.LISTING_FORM_DOORS_OPTION2}</option>
				<option value="{$smarty.const.LISTING_FORM_DOORS_OPTION3}">{$smarty.const.LISTING_FORM_DOORS_OPTION3}</option>
				<option value="{$smarty.const.LISTING_FORM_DOORS_OPTION4}">{$smarty.const.LISTING_FORM_DOORS_OPTION4}</option>
				<option value="{$smarty.const.LISTING_FORM_DOORS_OPTION5}">{$smarty.const.LISTING_FORM_DOORS_OPTION5}</option>
			</select>
			</p>
			
			<p><label for="color">{$smarty.const.COLOR}</label>
			<input id="color" name="color" type="text" size="30" maxlength="30" value="" />
			</p>
			<p><label for="mileage">{$smarty.const.MILEAGE}</label>
			<input id="mileage" name="mileage" type="text" size="15" maxlength="10" value="" />
			</p>
			<p><label for="year">{$smarty.const.YEAR}</label>
			<input id="year" name="year" type="text" size="10" maxlength="4" value="" />
			</p>
		
			<p><label for="listing_condition">{$smarty.const.CONDITION}</label>
			<select id="listing_condition" name="listing_condition" size="1">
				<option value="{$smarty.const.LISTING_FORM_CONDITION_OPTION1}">{$smarty.const.LISTING_FORM_CONDITION_OPTION1}</option>
 				<option value="{$smarty.const.LISTING_FORM_CONDITION_OPTION2}">{$smarty.const.LISTING_FORM_CONDITION_OPTION2}</option>
 				<option value="{$smarty.const.LISTING_FORM_CONDITION_OPTION3}">{$smarty.const.LISTING_FORM_CONDITION_OPTION3}</option>
			</select>
			</p>

			<p><label for="engine">{$smarty.const.ENGINE}</label>
			<input id="engine" name="engine" type="text" size="30" maxlength="30" value="" />
			</p>
			
			<p><label for="trans">{$smarty.const.TRANS}</label>
			<select id="trans" name="trans" size="1">
				<option value="{$smarty.const.LISTING_FORM_TRANS_OPTION1}">{$smarty.const.LISTING_FORM_TRANS_OPTION1}</option>
				<option value="{$smarty.const.LISTING_FORM_TRANS_OPTION2}">{$smarty.const.LISTING_FORM_TRANS_OPTION2}</option>
			</select>
			</p>
		
			<p><label for="drive_train">{$smarty.const.DRIVETRAIN}</label>
			<select id="drive_train" name="drive_train" size="1">
			{foreach item="drive_train" from=$drivetrainlist}
				<option value="{$drive_train.drive_train}">{$drive_train.drive_train}</option>
			{/foreach}
			</select>
			</p>
			
			<p><label for="mpg">{$smarty.const.MPG}</label>
			<input id="mpg" name="mpg" type="text" size="5" maxlength="5" value="" />
			</p>
			<p><label for="price">{$smarty.const.PRICE}</label>
			<input id="price" name="price" type="text" size="15" maxlength="11" value="" />
			</p>
			<p><label for="adddesc">{$smarty.const.ADDDESC}</label>
			<textarea id="adddesc" name="adddesc" cols="35" rows="4">{$formmsg}</textarea>
			</p>

			<p><label for="features">{$smarty.const.FEATURES}</label>
			<select id="features" name="features[]" size="4" multiple="multiple">
			{foreach item="features" from=$featurelist}
				<option value="{$features.id}"{if $features.lists_default} selected="selected"{/if}>{$features.features}</option>
			{/foreach}
			</select>
			</p>

			<p><label for="vin">{$smarty.const.VIN}</label>
			<input id="vin" name="vin" type="text" size="30" maxlength="17" value="" />
			</p>
			
			<p><label for="stock">{$smarty.const.STOCK}</label>
			<input id="stock" name="stock" type="text" size="30" maxlength="30" value="" />
			</p>

			<h2>Add the location of your vehicle.</h2>
			<p><label for="state">{$smarty.const.STATE}</label>
			<select id="state" name="state" size="1">
			{foreach item="state" from=$stateslist}
				<option value="{$state.state_name}">{$state.state_name}</option>
			{/foreach}
			</select>
			</p>
			
			<p><label for="zip">{$smarty.const.ZIP}</label>
			<input id="zip" name="zip" type="text" size="6" maxlength="6" value="" />
			</p>
			
			{if $admin}
			<p><label for="drive_train">{$smarty.const.SELLER}</label>
			<select id="sellerid" name="sellerid" size="1">
			{foreach item="sellers" from=$sellerslist}
				<option value="{$sellers.id}">{$sellers.user}</option>
			{/foreach}
			</select>
			</p>
			<p>
			{else}
			<input name="sellerid" type="hidden" value="{$userdetails.0.id}" />
			<input name="seller" type="hidden" value="{$userdetails.0.user}" />			
			{/if}
			<input name="submit" type="submit" value="{$smarty.const.ADD_LISTING_FORM_SUBMIT_BUTTON}" />
			</p>
	</form>
</fieldset>
{/if}

</div>

{include file="footer.tpl"}