e@extends('account.my-account')

<style>
	.loader-wrap {
		min-height: 70vh;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>

@section('account-content')
	{{-- @include('common.spacer') --}}
	<div class="">
		<div class="">
			<div class="">
				
				@include('post.inc.notification')

				<div class="">
						<h5>
							@if ($id ==154)
								<span>Post Used Car For Sell</span>	
							@elseif ($id ==156)
								<span>Post Damaged Car For Sell</span>	
							@elseif ($id ==157)
								<span>Post Damaged Car For Auction</span>
							@elseif ($id ==158)
								<span>Request Quote for Spare Parts</span>		
							@endif
						</h5>
					<div class="main_profile_rightbox">
						<div class="clearfix maincar">
							<div class="">
								
								<form class="form-horizontal" id="postForm" method="POST" action="{{ url()->current() }}" enctype="multipart/form-data">
									{!! csrf_field() !!}
									<fieldset>

										<!-- parent_id -->
										<?php $parentIdError = (isset($errors) and $errors->has('category_id')) ? ' is-invalid' : ''; ?>

										<div class="form-group label-font row required"  style="display:none;">
											<label class="col-md-3 col-form-label{{ $parentIdError }}">{{ t('Category') }} <sup>*</sup></label>
											<div class="col-md-8">
												<select name="parent_id" id="parentId" class="form-control selecter{{ $parentIdError }}">
													<option value="0" data-type=""
															@if (old('parent_id')=='' or old('parent_id')==0)
																selected="selected"
															@endif
													> {{ t('Select a category') }} </option>
													@foreach ($categories as $cat)
														<option value="{{ $cat->tid }}" data-type="{{ $cat->type }}"
																@if ($parent_id_data==$cat->tid)
																	selected="selected"
																@endif
														> {{ $cat->name }} </option>
													@endforeach
												</select>
												<input type="hidden" name="parent_type" id="parentType" value="{{ old('parent_type') }}">
											</div>
										</div>

										<!-- category_id -->
										<?php $categoryIdError = (isset($errors) and $errors->has('category_id')) ? ' is-invalid' : ''; ?>
										<div id="subCatBloc" class="form-group label-font row required subcat"  
										>
											<label class="col-md-3   col-form-label{{ $categoryIdError }}">{{ t('Sub-Category') }} <sup>*</sup></label>
											<div class="col-md-8">
												<select name="category_id" id="categoryId" class="form-control selecter{{ $categoryIdError }}">
													<option value="0" data-type=""
															@if (old('category_id')=='' or old('category_id')==0)
																selected="selected"
															@endif
													> {{ t('Select a sub-category') }} </option>
												</select>
												<input type="hidden" name="category_type" id="categoryType" value="{{ old('category_type') }}">
											</div>
										</div>
										@if ($id !=158)

										<!-- title -->
										<?php $titleError = (isset($errors) and $errors->has('title')) ? ' is-invalid' : ''; ?>
										<div class="form-group label-font required">
											<label class="" for="title">{{ t('Title') }} <sup>*</sup></label>
											<div class="">
												<input id="title" name="title" placeholder="{{ t('Ad title') }}" class="form-control input-md{{ $titleError }}"
													   type="text" value="{{ old('title') }}">
												<small id="" class="form-text text-muted">{{ t('A great title needs at least 60 characters.') }}</small>
												<input name="post_type_id" id="postTypeId-2" value="2" type="hidden">
											</div>
										</div>

										<!-- post_type_id -->
										 {{-- <?php //$postTypeIdError = (isset($errors) and $errors->has('post_type_id')) ? ' is-invalid' : ''; ?>
										<div id="postTypeBloc" class="form-group label-font required">
											<label class="">{{ t('Type') }} <sup>*</sup></label>
											<div class="">
												@foreach ($postTypes as $postType)
												<div class="form-check form-check-inline pt-2">
													<input name="post_type_id"
														id="postTypeId-{{ $postType->tid }}"
														value="{{ $postType->tid }}"
														type="radio"
														class="form-check-input{{ $postTypeIdError }}" {{ (old('post_type_id')==$postType->tid) ? 'checked="checked"' : '' }}
													>
													<label class="form-check-label" for="postTypeId-{{ $postType->tid }}">
														{{ $postType->name }}
													</label>
												</div>
											</div>
										</div>  --}}
				
										@endif
										
										<!-- customFields -->
										<div class="custom-field-wrapper">
											<div id="customFields">
												<div id="loader-wrap" class="loader-wrap">
													<svg xmlns="http://www.w3.org/2000/svg" style="margin: auto; background: rgb(255, 255, 255); display: block; shape-rendering: auto;" width="150px" height="150px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
													  <g transform="rotate(0 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#fe718d">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(30 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#f47e60">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(60 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#f8b26a">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.75s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(90 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#abbd81">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(120 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#849b87">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(150 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#6492ac">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(180 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#637cb5">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(210 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#6a63b6">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(240 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#fe718d">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.25s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(270 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#f47e60">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(300 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#f8b26a">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"></animate>
														</rect>
													  </g><g transform="rotate(330 50 50)">
														<rect x="47" y="20" rx="3" ry="6" width="6" height="12" fill="#abbd81">
														  <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="0s" repeatCount="indefinite"></animate>
														</rect>
													  </g>
													</svg>
												</div>
											</div>
										</div>
										@if ($id ==158)
											<input id="title" name="title" type="hidden" value="spare part">
											<input name="post_type_id" id="postTypeId-2" value="2" type="hidden">
											<!-- Spare Parts -->
											<?php $sparepartError = (isset($errors) and $errors->has('sparepart')) ? ' is-invalid' : ''; ?>
											<div id="priceBloc" class="form-group label-font">
												<label class="" for="sparepart">Did not find your part in above list, then enter the part name here.</label>
												<div class="input-group">
													{{-- <div class="input-group-prepend">
														<span class="input-group-text">{!! config('currency')['symbol'] !!}</span>
													</div> --}}
													
													<input id="sparepart"
														name="sparepart"
														class="form-control{{ $sparepartError }}"
														type="text" value="{{ old('sparepart') }}"
													>
												</div>
											</div>
										@else
											<!-- price -->
											<?php $priceError = (isset($errors) and $errors->has('price')) ? ' is-invalid' : ''; ?>
											<div id="priceBloc" class="form-group label-font">
												<label class="" for="price">{{ t('Price') }}</label>
												<div class="my-future-ddm input-group">
													<div class="input-group-prepend">
														<span class="input-group-text">{!! config('currency')['code'] !!}</span>
													</div>
													
													<input id="price"
														name="price"
														class="form-control{{ $priceError }}"
														placeholder="{{ t('e.i. 15000') }}"
														type="text" value="{{ old('price') }}"
														onkeyup="this.value = addCommas(this.value)"
													>
												</div>
											</div>
										@endif
										@if ($id != 158)
											<!-- city_id -->
											<?php $cityIdError = (isset($errors) and $errors->has('city_id')) ? ' is-invalid' : ''; ?>
											<div id="cityBox" class="form-group label-font required">
												<label class="{{ $cityIdError }}" for="city_id">{{ t('City') }} <sup>*</sup></label>
												
													<select id="cityId" name="city_id" class="form-control sselecter{{ $cityIdError }}">
														<option value="0" {{ (!old('city_id') or old('city_id')==0) ? 'selected="selected"' : '' }}>
															{{ t('Select a city') }}
														</option>
													</select>
												
											</div>											
										@endif
							     
										@if($id =='157') 
											<div id="" class="form-group label-font">
												<label class="" for="">Auction start date</label>
												<div class="input-group">
													<div class="input-group-prepend">
													</div>			
													<input id=""
														name="auction_start_date"
														class="form-control"
														type="date"
													>	
												</div>
											</div>
											<div id="" class="form-group label-font">
												<label class="" for="">Auction start time</label>
												<div class="input-group">
													<div class="input-group-prepend">	
													</div>			
													<input id=""
														name="auction_start_time"
														class="form-control"
														type="time"
													>
												</div>
											</div>
											<div id="" class="form-group label-font">
												<label class="" for="">Auction end date</label>
												<div class="input-group">
													<div class="input-group-prepend">
													</div>			
													<input id=""
														name="auction_end_date"
														class="form-control"
														type="date"
													>
												</div>
											</div>
											<div id="" class="form-group label-font">
												<label class="" for="">Auction end time</label>
												<div class="input-group">
													<div class="input-group-prepend">
													</div>			
													<input id=""
														name="auction_end_time"
														class="form-control"
														type="time"
													>
												</div>
											</div>
										@endif

										<!-- description -->
										<?php $descriptionError = (isset($errors) and $errors->has('description')) ? ' is-invalid' : ''; ?>
										<div class="form-group label-font required">
											<?php
												$descriptionErrorLabel = '';
												if (config('settings.single.simditor_wysiwyg')) {
													$descriptionErrorLabel = $descriptionError;
												}
											?>
											@if ($id == 158)
												<label class="{{ $descriptionErrorLabel }}" for="description">Please Comment Here
												</label>
											@else
												<label class="{{ $descriptionErrorLabel }}" for="description">
													{{ t('Description') }} <sup>*</sup>
												</label>
											@endif
											<div class="">
												<textarea class="textarea-comment form-control{{ $descriptionError }}"
														  id="description"
														  name="description"
														  rows="5"
														  placeholder="text between 10 to 600 characters"
												>{{ strip_tags(old('description', $cat->description)) }}</textarea>
												<small id="" class="form-text text-muted">{{ t('Describe what makes your ad unique') }}...</small>
											</div>
										</div>
										
										
										@if (isset($picturesLimit) and is_numeric($picturesLimit) and $picturesLimit > 0)
											<!-- pictures -->
											<?php $picturesError = (isset($errors) and $errors->has('pictures')) ? ' is-invalid' : ''; ?>
											<div class="form-group label-font required" id="picturesBloc">
												<label class="{{ $picturesError }}" for="pictures">
													{{ t('Pictures') }}
													@if (config('settings.single.picture_mandatory') && $id != 158)
														<sup>*</sup>
													@endif
												</label>
												<div class="gray-form">
													@for($i = 1; $i <= $picturesLimit; $i++)
														<div class="mb-2 <?php echo ($errors->has('pictures.'.$i)) ? 'is-invalid' : ''; ?>">
															<div class="{{-- file-loading --}}">
																<input id="picture{{ $i }}"
																	   name="pictures[]"
																	   type="file"
																	   class="{{-- file post-picture --}}"
																	   accept="image/*"
																	   data-msg-placeholder="{{ t('Picture #:number', ['number' => $i]) }}"
																>
															</div>
														</div>
													@endfor
													<small id="" class="form-text text-muted">
														{{ t('Add up to :pictures_number pictures. Use real pictures of your product, not catalogs.', [
															'pictures_number' => $picturesLimit
															]) }}
													</small>
												</div>
											</div>
										@endif
										
										<!-- country_code -->
										<?php $countryCodeError = (isset($errors) and $errors->has('country_code')) ? ' is-invalid' : ''; ?>
										@if (empty(config('country.code')))
											<div class="form-group label-font row required">
												<label class="col-md-3 col-form-label{{ $countryCodeError }}" for="country_code">{{ t('Your Country') }} <sup>*</sup></label>
												<div class="col-md-8">
													<select id="countryCode" name="country_code" class="form-control sselecter{{ $countryCodeError }}">
														<option value="0" {{ (!old('country_code') or old('country_code')==0) ? 'selected="selected"' : '' }}> {{ t('Select a country') }} </option>
														@foreach ($countries as $item)
															<option value="{{ $item->get('code') }}" {{ (old('country_code', (!empty(config('ipCountry.code'))) ? config('ipCountry.code') : 0)==$item->get('code')) ? 'selected="selected"' : '' }}>{{ $item->get('name') }}</option>
														@endforeach
													</select>
												</div>
											</div>
										@else
											<input id="countryCode" name="country_code" type="hidden" value="{{ config('country.code') }}">
										@endif
										
										<?php
										/*
										@if (\Illuminate\Support\Facades\Schema::hasColumn('posts', 'address'))
										<!-- address -->
										<div class="form-group label-font required <?php echo ($errors->has('address')) ? ' is-invalid' : ''; ?>">
											<label class="col-md-3 control-label" for="title">{{ t('Address') }} </label>
											<div class="col-md-8">
												<input id="address" name="address" placeholder="{{ t('Address') }}" class="form-control input-md"
													   type="text" value="{{ old('address') }}">
												<span class="help-block">{{ t('Fill an address to display on Google Maps.') }} </span>
											</div>
										</div>
										@endif
										*/
										?>
										
										@if (config('country.admin_field_active') == 1 and in_array(config('country.admin_type'), ['1', '2']))
											<!-- admin_code -->
											<?php $adminCodeError = (isset($errors) and $errors->has('admin_code')) ? ' is-invalid' : ''; ?>
											<div id="locationBox" class="form-group label-font row required">
												<label class="col-md-3 col-form-label{{ $adminCodeError }}" for="admin_code">{{ t('Location') }} <sup>*</sup></label>
												<div class="col-md-8">
													<select id="adminCode" name="admin_code" class="form-control sselecter{{ $adminCodeError }}">
														<option value="0" {{ (!old('admin_code') or old('admin_code')==0) ? 'selected="selected"' : '' }}>
															{{ t('Select your Location') }}
														</option>
													</select>
												</div>
											</div>
										@endif


										<!-- tags -->
										<?php $tagsError = (isset($errors) and $errors->has('tags')) ? ' is-invalid' : ''; ?>
										{{-- <div class="form-group label-font row">
											<label class="col-md-3 col-form-label" for="tags">{{ t('Tags') }}</label>
											<div class="col-md-8">
												<input id="tags"
													   name="tags"
													   placeholder="{{ t('Tags') }}"
													   class="form-control input-md{{ $tagsError }}"
													   type="text"
													   value="{{ old('tags') }}"
												>
												<small id="" class="form-text text-muted">{{ t('Enter the tags separated by commas.') }}</small>
											</div>
										</div> --}}										
										
										
										{{-- <div class="content-subheading" style="display: none">
											<i class="icon-user fa"></i>
											<strong>{{ t('Seller information') }}</strong>
										</div> --}}
										
										
										<!-- contact_name -->
										<?php $contactNameError = (isset($errors) and $errors->has('contact_name')) ? ' is-invalid' : ''; ?>
										@if (auth()->check())
											<input id="contact_name" name="contact_name" type="hidden" value="{{ auth()->user()->name }}">
										@endif
									
										<!-- email -->
										<?php $emailError = (isset($errors) and $errors->has('email')) ? ' is-invalid' : ''; ?>
										<div class="form-group label-font row required" style="display: none">
											<label class="col-md-3 col-form-label" for="email"> {{ t('Email') }} </label>
											<div class="input-group col-md-8">
												{{-- <div class="input-group-prepend">
													<span class="input-group-text"><i class="icon-mail"></i></span>
												</div> --}}
												
												<input id="email" name="email"
													   class="form-control{{ $emailError }}" placeholder="{{ t('Email') }}" type="hidden"
													   value="{{ old('email', ((auth()->check() and isset(auth()->user()->email)) ? auth()->user()->email : '')) }}">
											</div>
										</div>
										
										<?php
											if (auth()->check()) {
												$formPhone = (auth()->user()->country_code == config('country.code')) ? auth()->user()->phone : '';
											} else {
												$formPhone = '';
											}
										?>
										<!-- phone -->
										<?php $phoneError = (isset($errors) and $errors->has('phone')) ? ' is-invalid' : ''; ?>
										<div class="form-group label-font row required" style="display: none">
											<label class="col-md-3 col-form-label" for="phone">{{ t('Phone Number') }}</label>
											<div class="input-group col-md-8">
												{{-- <div class="input-group-prepend">
													<span id="phoneCountry" class="input-group-text">{!! getPhoneIcon(config('country.code')) !!}</span>
												</div> --}}
												
												<input id="phone" name="phone"
													   placeholder="{{ t('Phone Number') }}"
													   class="form-control input-md{{ $phoneError }}" type="hidden"
													   value="{{ phoneFormat(old('phone', $formPhone), old('country', config('country.code'))) }}"
												>
												
												{{-- <div class="input-group-append">
													<span class="input-group-text">
														<input name="phone_hidden" id="phoneHidden" type="checkbox"
															   value="1" {{ (old('phone_hidden')=='1') ? 'checked="checked"' : '' }}>&nbsp;<small>{{ t('Hide') }}</small>
													</span>
												</div> --}}
											</div>
										</div>
										
										@if (!auth()->check())
											@if (in_array(config('settings.single.auto_registration'), [1, 2]))
												<!-- auto_registration -->
												@if (config('settings.single.auto_registration') == 1)
													<?php $autoRegistrationError = (isset($errors) and $errors->has('auto_registration')) ? ' is-invalid' : ''; ?>
													<div class="form-group label-font row required">
														<label class="col-md-3 col-form-label"></label>
														<div class="col-md-8">
															<div class="form-check">
																<input name="auto_registration" id="auto_registration"
																	   class="form-check-input{{ $autoRegistrationError }}"
																	   value="1"
																	   type="checkbox"
																	   checked="checked"
																>
																
																<label class="form-check-label" for="auto_registration">
																	{!! t('I want to register by submitting this ad.') !!}
																</label>
															</div>
															<small id="" class="form-text text-muted">{{ t('You will receive your authentication information by email.') }}</small>
															<div style="clear:both"></div>
														</div>
													</div>
												@else
													<input type="hidden" name="auto_registration" id="auto_registration" value="1">
												@endif
											@endif
										@endif
										
										@include('post.createOrEdit.singleStep.inc.packages')
										
										@include('layouts.inc.tools.recaptcha', ['colLeft' => 'col-md-3', 'colRight' => 'col-md-8'])

										<!-- term -->
										<?php $termError = (isset($errors) and $errors->has('term')) ? ' is-invalid' : ''; ?>
										{{-- <div class="form-group label-font row required">
											<label class="col-md-3 col-form-label{{ $termError }}"></label>
											<div class="col-md-8">
												<label class="checkbox mb-0" for="term-0">
													{!! t('By continuing on this website, you accept our <a :attributes>Terms of Use</a>', ['attributes' => getUrlPageByType('terms')]) !!}
												</label>
											</div>
										</div> --}}

										<!-- Button  -->
										<div class="form-group row pt-3">
											<div class="col-md-12 text-center">
												<button id="submitPostForm" class="btn btn-save-detail"> {{ t('Submit') }} </button>
											</div>
										</div>

									</fieldset>
								</form>
							</div>
						</div>
					</div>
				</div>
				<!-- /.page-content -->
			</div>
		</div>
	</div>
@endsection

@section('after_styles')
	@include('layouts.inc.tools.wysiwyg.css')
	
	<link href="{{ url('assets/plugins/bootstrap-fileinput/css/fileinput.min.css') }}" rel="stylesheet">
	@if (config('lang.direction') == 'rtl')
		<link href="{{ url('assets/plugins/bootstrap-fileinput/css/fileinput-rtl.min.css') }}" rel="stylesheet">
	@endif
	<style>
		.krajee-default.file-preview-frame:hover:not(.file-preview-error) {
			box-shadow: 0 0 5px 0 #666666;
		}
		.file-loading:before {
			content: " {{ t('Loading') }}...";
		}
		/* Preview Frame Size */
		/*
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-caption-info,
		.krajee-default .file-size-info {
			width: 90px;
		}
		*/
		.krajee-default.file-preview-frame .kv-file-content {
			height: auto;
		}
		.krajee-default.file-preview-frame .file-thumbnail-footer {
			height: 30px;
		}
		.subcat {
			display: none !important;
		}
	</style>
@endsection

@section('after_scripts')
    @include('layouts.inc.tools.wysiwyg.js')

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.payment/1.2.3/jquery.payment.min.js"></script>
	@if (file_exists(public_path() . '/assets/plugins/forms/validation/localization/messages_'.config('app.locale').'.min.js'))
		<script src="{{ url('assets/plugins/forms/validation/localization/messages_'.config('app.locale').'.min.js') }}" type="text/javascript"></script>
	@endif

	<script src="{{ url('assets/plugins/bootstrap-fileinput/js/plugins/sortable.min.js') }}" type="text/javascript"></script>
	<script src="{{ url('assets/plugins/bootstrap-fileinput/js/fileinput.min.js') }}" type="text/javascript"></script>
	<script src="{{ url('assets/plugins/bootstrap-fileinput/themes/fa/theme.js') }}" type="text/javascript"></script>
	@if (file_exists(public_path() . '/assets/plugins/bootstrap-fileinput/js/locales/'.ietfLangTag(config('app.locale')).'.js'))
		<script src="{{ url('assets/plugins/bootstrap-fileinput/js/locales/'.ietfLangTag(config('app.locale')).'.js') }}" type="text/javascript"></script>
	@endif
@section'()	
	<script>
	var cat_id = JSON.parse("{{ json_encode($id) }}");
     	//alert(cat_id);

		 var parent_id = "{{ ($parent_id_data) }}";
     	//alert(parent_id);

	 	/* Translation */
		var lang = {
			'select': {
				'category': "{{ t('Select a category') }}",
				'subCategory': "{{ t('Select a sub-category') }}",
				'country': "{{ t('Select a country') }}",
				'admin': "{{ t('Select a location') }}",
				'city': "{{ t('Select a city') }}"
			},
			'price': "{{ t('Price') }}",
			'salary': "{{ t('Salary') }}",
			'nextStepBtnLabel': {
			    'next': "{{ t('Next') }}",
                'submit': "{{ t('Submit') }}"
			}
		};
		
		/* Categories */
		var category = {{ old('parent_id', 'parent_id') }};
		
		var categoryType = '{{ old('parent_type') }}';
		if (categoryType=='') {
			var selectedCat = $('select[name=parent_id]').find('option:selected');
			categoryType = selectedCat.data('type');
		}
		var subCategory = {{ old('category_id', 
		'cat_id') }};

		//alert(subCategory);
		
		/* Custom Fields */
		var errors = '{!! addslashes($errors->toJson()) !!}';
		var oldInput = '{!! addslashes(collect(session()->getOldInput('cf'))->toJson()) !!}';
		var postId = '';
		
		/* Locations */
        var countryCode = '{{ old('country_code', config('country.code', 0)) }}';
        var adminType = '{{ config('country.admin_type', 0) }}';
        var selectedAdminCode = '{{ old('admin_code', (isset($admin) ? $admin->code : 0)) }}';
        var cityId = '{{ old('city_id', (isset($post) ? $post->city_id : 0)) }}';
		
		/* Packages */
		var packageIsEnabled = false;
        @if (isset($packages) and isset($paymentMethods) and $packages->count() > 0 and $paymentMethods->count() > 0)
            packageIsEnabled = true;
        @endif

	</script>
	<script>
		/* Images Upload */
		$('.post-picture').fileinput(
		{
			theme: "fa",
			language: '{{ config('app.locale') }}',
			@if (config('lang.direction') == 'rtl')
				rtl: true,
			@endif
			dropZoneEnabled: false,
			overwriteInitial: true,
			showCaption: true,
			showPreview: true,
			showClose: true,
			showUpload: false,
			showRemove: false,
			previewFileType: 'image',
			allowedFileExtensions: {!! getUploadFileTypes('image', true) !!},
			browseLabel: '{!! t("Browse") !!}',
			minFileSize: {{ (int)config('settings.upload.min_image_size', 0) }}, {{-- in KB --}}
			maxFileSize: {{ (int)config('settings.upload.max_image_size', 20000) }}, {{-- in KB --}}
			/* Remove Drag-Drop Icon (in footer) */
			fileActionSettings: {
				dragIcon: '',
				dragTitle: ''
			},
			layoutTemplates: {
				/* Show Only Actions (in footer) */
				footer: '<div class="file-thumbnail-footer pt-2">{actions}</div>',
				/* Remove Delete Icon (in footer) */
				actionDelete: ''
			}
		});
		
		$(document).ready(function() {
			/* Tags */
			$('#tags').tagit({
				fieldName: 'tags',
				placeholderText: '{{ t('add a tag') }}',
				caseSensitive: false,
				allowDuplicates: false,
				allowSpaces: false,
				tagLimit: {{ (int)config('settings.single.tags_limit', 15) }},
				singleFieldDelimiter: ','
			});
		});
	</script>
	<script>
  function addCommas(nStr)
  {
		var commaRegex = /,/gm;
		nStr += '';
		nStr = nStr.replace(commaRegex, '');
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
			console.log('hey', x1);
		}
		return x1 + x2;
  }
 
</script>
	<script src="{{ url('assets/js/app/d.select.category.js') . vTime() }}"></script>
	<script src="{{ url('assets/js/app/d.select.location.js') . vTime() }}"></script>
	
@endsection
