<script type="text/javascript">
    function sortCategory() {
        //Text Sort value
        var textsort = $('#txtcategory').val();
        if(textsort!=''){
            
             $.ajax({
                        type: "GET",
                        url: "<?php echo ConfigUrl::base();?>postads/sortcategory",
                        data: "tx="+textsort
              }).done(function(msg) {
                  if(msg) {
                      //
                      if(msg!='') {
                        $('#categoryBox').html(msg);
                      }
                      
                  }

            });
        }
        
    } //End Function
</script>
 
<div class="row">
	<div class="col-xs-12 col-sm-2 col-md-2"></div>
	<div class="col-xs-12 col-sm-8 col-md-8">
		<div class="form_main_outer">
			<h1>Post an Ad </h1>
			<?php
				if(!empty($this->error) || !empty($this->message)) {
					$messageClass = (!empty($this->error)) ? 'red' : 'green';
					$flashMessage = (!empty($this->error)) ? $this->error : $this->message;
			?>
			<div class="messageBox"><span class="<?php echo $messageClass ?>"><?php echo $flashMessage; ?></span></div>
			<?php
				} //
			?>
	
		<form method="post" name="frmPostads" id="frmPostads" action="<?php echo ConfigUrl::base(); ?>ads/postads" enctype="multipart/form-data">
			
			<?php
			   if(!isset($_SESSION['user']['userID']) && $_SESSION['user']['userID']=='') {
			   ?>
 			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label>Email<span class="red">*</span></label>
						<input type="text" class="form-control" name="email">
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
		   }
		   ?>
			<?php
			if(!empty($this->activeFields)) {
				//Title Field
				if(strtolower($this->activeFields[0]->vFldname)==strtolower('Title')) {
					?>
			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $this->activeFields[0]->vFlddesc ?><?php if($this->activeFields[0]->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="text" class="form-control" name="<?php echo $this->activeFields[0]->vFldname ?>">
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
			} //Title Field End
			?> 
					
			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label>Select Category</label>
						<!--<select class="select_drpbx" name="select">
							<option>Category</option>
						</select>-->
						<?php
						if(!empty($this->category_title)) { asort($this->category_title); }
						?>                    
						<?php echo $this->select('category', $this->category_title, '', 'form-control','','category',' size="10"'); ?>
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
			foreach($this->activeFields as $activeFld) {
			   
				if(in_array($activeFld->vFldname, $this->staticFieldArr)) {

					switch(strtolower($activeFld->vFldname)) {
				case 'title':
					break;
				case 'description':
			?>
			
			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<textarea class="form-control" name="<?php echo $activeFld->vFldname; ?>"></textarea>
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
				break;
			case 'image':
				?>
			
			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="file" class="form-control" name="<?php echo $activeFld->vFldname; ?>">
						<br><span class="grey">Allowed image type : jpg/jpeg</span>
					</div>
				</div>
			<div class="clear"></div>
			</div>				 
				<?php
				break;
				case 'video':
				?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="file" class="form-control" name="<?php echo $activeFld->vFldname; ?>">
						<br><span class="grey">Supported video formats : mp4,webm,ogv,flv
						<br>Maximum File Upload Size allowed by your server - <?php echo ini_get('upload_max_filesize'); ?>
						</span>
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
				break;
				case 'videourl':
			?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="text" class="form-control" name="<?php echo $activeFld->vFldname; ?>">
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
				break;
				case 'zipcode':
			?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="text" class="form-control" name="<?php echo $activeFld->vFldname; ?>">
					</div>
				</div>
			<div class="clear"></div>
			</div>
				<?php
					break;	
					case 'address':
				?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<textarea class="form-control" name="<?php echo $activeFld->vFldname; ?>"></textarea>
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
					break;
				} //End Switch
				
				} // End If
				
				if(!in_array($activeFld->vFldname, $this->staticFieldArr)) {
				switch(($activeFld->vInType)) {
				case 'text':
			?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="text" class="form-control" name="<?php echo $activeFld->vFldname; ?>">
					</div>
				</div>
			<div class="clear"></div>
			</div>
					<?php
					break;
				
				case 'textarea':
					?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<textarea class="form-control" name="<?php echo $activeFld->vFldname; ?>"></textarea>
					</div>
				</div>
			<div class="clear"></div>
			</div>
			<?php
				break;
				case 'file-doc/txt':
			?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<input type="file" class="form-control" name="<?php echo $activeFld->vFldname; ?>">
						<br><span class="grey">Supported file formats : doc,pdf,xls</span>
					</div>
				</div>
			<div class="clear"></div>
			</div>			 
			<?php
				break;
				case 'checkbox':
			?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label><?php echo $activeFld->vFlddesc ?><?php if($activeFld->nMandatory==1) { ?><span class="red">*</span><?php } ?></label>
						<?php echo $this->checkbox($activeFld->vFldname, '1', '', 'chkbx_manage',$activeFld->vFldname); ?>
					</div>
				</div>
			<div class="clear"></div>
			</div>
				<?php                                
						break;
					
						} // End Switch
					} // End If
				
				} //
				} // End If
				?>

			<div class="form_main_inner">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<label>Security Code</label>
						<?php echo $this->recaptchaHTML; ?>
					</div>
				</div>
			<div class="clear"></div>
			</div>
			
			<div class="form_main_btt_outer">
				<div class="row">
					<div class="col-xs-12 col-sm-12">
						<input name="" class="button" value="POST AD" type="submit">
					</div>
				</div>
			<div class="clear"></div>
			</div>
			 
			</form>
		</div>
	</div>
	<div class="col-xs-12 col-sm-2 col-md-2"></div>
	 

    <div class="clear"></div>
</div>


<div class="clear"></div>
</div>
<!-- Inner Content Wrap End -->
<div class="clear"></div>
</div>
