<?php
include("header.php");
//echo'<pre>';print_r($_POST);exit;

$sby="";$mcat="";$cityid="";$city="";
$maincategory=array();$category=array();$subcategory=array();$maxPrice="100000";$minPrice="0";$sortby="";$condition=array();$type=array();$transaction=array();$negotiable=array();$citid="";
$start=0;
$limit=3;
if(isset($_POST['page']) && $_POST['page']!=="")
{
	$page=$_POST['page'];
	$start=($page-1)*$limit;
}
else{
	$page=1;
}



if(isset($_GET['city']))
{
	$city=$_GET['city'];
	
	if(isset($_GET['cityid']))
	{
		$cityid=$_GET['cityid'];
		$cityid=str_replace("-"," ",$cityid);
		
		if(isset($_GET['mcat']))
		{
			$mcat=$_GET['mcat'];
		
			if(isset($_GET['searchby']))
			{
				$searchby=$_GET['searchby'];
				
				$sby=str_replace("-"," ",$searchby);
			
				$sby=str_replace("and","&",$sby);
			}
			
			
			
			$postuserids="posted_userid!=''";
			if($cityid!=="")
			{
			
				$postuser="";
				$sqluser=mysql_query("select * from tbl_users where city='$cityid'");
				if(mysql_num_rows($sqluser)>0)
				{
					while($resuser=mysql_fetch_assoc($sqluser))
					{
						$postuser.="posted_userid=".$resuser['userid']." || ";
					}
					
					$postuserids=rtrim($postuser," ||");
				}
				else
				{
					$postuserids="posted_userid=''";
				}
			}
			//echo'<pre>';print_r($postuserids);
			
			if($mcat=="all")
			{
				$mnct="maincategory!=''";
			}
			else
			{
				$mnct="maincategory='$mcat'";
			}
			
			
			//echo "select * from tbl_ads where $mnct and title='$sby' and ($postuserids)";
			//echo"select * from tbl_ads where $mnct and title='$sby' and ($postuserids) LIMIT $start, $limit";
			
			
			$searchp=mysql_query("select * from tbl_ads where $mnct and title='$sby' and ($postuserids) and admin_status='Approved' LIMIT $start, $limit");
		
		}

	}
	
}
else
{


if(isset($_POST['submits']))
{
	$mcatss="maincategory!=''";$catgss="category!=''";$scatgss="subcategory!=''";$condi="conditions!=''";$order="order by ads_id asc";$typ="type!=''";$nego="negotiable!=''";$trans="exchange_type!=''";$condi="conditions!=''";
	
	if(isset($_POST['maincategory']))
	{
		$maincategory=$_POST['maincategory'];
		$mcats="";
		foreach($maincategory as $mctgory)
		{
			$mcats.="maincategory=".$mctgory." || ";
		}
		
		$mcatss=rtrim($mcats,' ||');
	}
	
	if(isset($_POST['category']))
	{
		$category=$_POST['category'];
		$catgs="";
		foreach($category as $ctgory)
		{
			$catgs.="category=".$ctgory." || ";
		}
		
		$catgss=rtrim($catgs,' ||');
		
	}
	if(isset($_POST['subcategory']))
	{
		$subcategory=$_POST['subcategory'];
		$scatgs="";
		foreach($subcategory as $sctgory)
		{
			$scatgs.="subcategory=".$sctgory." || ";
		}
		
		$scatgss=rtrim($scatgs,' ||');
	}
	
	if(isset($_POST['minPrice']))
	{
		$minPrice=$_POST['minPrice'];
		if($minPrice=="")
		{
			$minPrice="0";
		}
	}
	
	if(isset($_POST['maxPrice']))
	{
		$maxPrice=$_POST['maxPrice'];
		if($maxPrice=="")
		{
			$maxPrice="100000";
		}
		
	}
	
	if(isset($_POST['sortby']))
	{
		$sortby=$_POST['sortby'];
		
		if($sortby=="lowtohigh")
		{
			$order="order by price asc";
		}
		
		if($sortby=="hightolow")
		{
			$order="order by price desc";
		}
	}
	
	if(isset($_POST['condition']))
	{
		$condition=$_POST['condition'];
		
		//$condi="conditions='$condition'";
		
		$conds="";
		foreach($condition as $cnd)
		{
			$conds.="conditions='".$cnd."' || ";
		}
		
		$condi=rtrim($conds,' ||');
		
	}
	
	if(isset($_POST['type']))
	{
		$type=$_POST['type'];
		$tys="";
		foreach($type as $ty)
		{
			$tys.="type='".$ty."' || ";
		}
		$typ=rtrim($tys,' ||');
		
	}
	
	if(isset($_POST['negotiable']))
	{
		$negotiable=$_POST['negotiable'];
		$negos="";
		foreach($negotiable as $negot)
		{
			if($negot=="no")
			{
				$negot="";
			}
			
			$negos.="negotiable='".$negot."' || ";
		}
		
		$nego=rtrim($negos,' ||');
		
		
	}
	
	if(isset($_POST['transaction']))
	{
		$transaction=$_POST['transaction'];
		
		//$trans="exchange_type='$transaction'";
		
		$trand="";
		foreach($transaction as $tran)
		{
			$trand.="exchange_type='".$tran."' || ";
		}
		$trans=rtrim($trand,' ||');
		//echo'<pre>';print_r($transy);exit;
		
	}
	//$ctts="city!=''";
	$postuserids="posted_userid!=''";
	if(isset($_POST['city']) && $_POST['city']!=="")
	{
		$cityid=$_POST['city'];
		
		$sqlcc=mysql_query("select * from tbl_cities where city_id='".$cityid."'");
		$rescc=mysql_fetch_assoc($sqlcc);
		$city=$rescc['cityname'];
		
		$ctts="city='$cityid'";
		
		$sqluser=mysql_query("select * from tbl_users where $ctts");
		if(mysql_num_rows($sqluser)>0)
		{
			$postuser="";
			while($resuser=mysql_fetch_assoc($sqluser))
			{
				$postuser.="posted_userid=".$resuser['userid']." || ";
			}
			
			$postuserids=rtrim($postuser," ||");
		}
		else
		{
			$postuserids="posted_userid=''";
		}
		
		
	}
	/*echo'<pre>';print_r($cityid);
	
	echo'<pre>';print_r($_POST);*/
	
	$searchp=mysql_query("select * from tbl_ads where ($mcatss) and ($catgss) and ($scatgss) and ($postuserids) and ($condi) and ($typ) and ($nego) and ($trans) and admin_status='Approved' and price between $minPrice and $maxPrice $order LIMIT $start, $limit");

	
	
}
else
{
	
	if(isset($_POST['Serach']))
	{
		$sby=$_POST['ads'];
		$mcat=$_POST['maincategory'];
		$citid=$_POST['city'];
		
		$sqlcc=mysql_query("select * from tbl_cities where city_id='".$citid."'");
		$rescc=mysql_fetch_assoc($sqlcc);
		$city=$rescc['cityname'];
		
		
		$postuser="";$postuserids="posted_userid!=''";
		$sqluser=mysql_query("select * from tbl_users where city='$citid'");
		if(mysql_num_rows($sqluser)>0)
		{
			while($resuser=mysql_fetch_assoc($sqluser))
			{
				$postuser.="posted_userid=".$resuser['userid']." || ";
			}
			
			$postuserids=rtrim($postuser," ||");
		}
		
		
		$searchp=mysql_query("select * from tbl_ads where maincategory='$mcat' and title='$sby' and ($postuserids) and admin_status='Approved' LIMIT $start, $limit");
		
		
		
	}
	else
	{
		$searchp=mysql_query("select * from tbl_ads where admin_status='Approved' LIMIT $start, $limit");
	}
}
}






?>
<div class="search-row-wrapper">
<div class="container ">
<form action="" method="post">
<div class="col-sm-3">
<input class="form-control keyword" type="text" name="ads" placeholder="Search Ads" required id="search_ads" value="<?php echo $sby;?>">
<input type="hidden" name="mcid" id="Mcid" value="">
</div>
<div style="position: absolute; max-height: 300px; z-index: 9999; top: 172px; left: 192.5px; width: 218px; display:none;" id="productsearch" class="autocomplete-suggestions">
</div>

<div class="col-sm-3">
<select class="form-control selecter" name="maincategory" id="search-category" required>
<option value="">All Main Categories</option>
<?php $sqlmct=mysql_query("select * from tbl_maincategory order by mcid asc");
	  while($resmct=mysql_fetch_assoc($sqlmct))
	  {

	  ?><option <?php if($mcat==$resmct['mcid']) { echo "selected";} ?> value="<?php echo $resmct['mcid'];?>"> <?php echo $resmct['name'];?> </option><?php } ?>

</select>
</div>
<div class="col-sm-3">
<select class="form-control selecter" name="city" id="id-location" required>
<option  value="">All Cities</option>

<?php $sqlct=mysql_query("select * from tbl_cities");
      while($resct=mysql_fetch_assoc($sqlct))
	  {
		  ?>
		  	<option <?php if($resct['city_id']==$cityid) { echo "selected";} elseif($resct['city_id']==$citid){ echo "selected"; } ?> value="<?php echo $resct['city_id']?>"><?php echo $resct['cityname'];?></option>
		  <?php
	  }
?>

</select>
</div>
<div class="col-sm-3">
<button class="btn btn-block btn-primary" name="Serach"> <i class="fa fa-search"></i> </button>
</div>
</form>
</div>
</div>

<form method="post" action="<?php echo $actual_link;?>products"> 
<div class="main-container">
<div class="container">
<div class="row">
<div class="col-sm-3 page-sidebar">
<aside>
<div class="inner-box">
<div class="categories-list  list-filter">
<h5 class="list-title"><strong><a href="#">All Categories</a></strong></h5>
<ul class="list-unstyled">
<?php $sqlmct=mysql_query("select * from tbl_maincategory");
	  while($resmct=mysql_fetch_assoc($sqlmct))
	  {
		  ?>
		  	<li><input type="checkbox" <?php if($resmct['mcid']==$mcat) { echo "checked='checked'"; }  if(in_array($resmct['mcid'],$maincategory)) {echo "checked='checked'";} ?>  value="<?php echo $resmct['mcid'];?>" name="maincategory[]" class="maincategory filterM"> &nbsp; <span class="title"><strong><?php echo $resmct['name']?></strong></span><span class="count">&nbsp;8626</span> 
            
            <ul class="list-unstyled long-list Categories_<?php echo $resmct['mcid'];?>" <?php if($resmct['mcid']==$mcat || in_array($resmct['mcid'],$maincategory)) { ?>  <?php } else
			{ ?> style="display:none; overflow-y:scroll;" <?php } ?>>
            <?php 
			$sqlc=mysql_query("select * from tbl_category where mcid='".$resmct['mcid']."'");
			while($resc=mysql_fetch_assoc($sqlc))
			{
				?>
					<li><input type="checkbox" <?php if(in_array($resc['cid'],$category)) {echo "checked='checked'";} ?> name="category[]" class="category filterC" value="<?php echo $resc['cid']?>">&nbsp; <b><?php echo $resc['name']?></b>
					
						<ul class="list-unstyled long-list Subcategories_<?php echo $resc['cid'];?>" <?php if(in_array($resc['cid'],$category)) { }else{ ?> style="display:none;" <?php } ?>> 		    
                        <?php 
							$sql=mysql_query("select * from tbl_subcategory where cid='".$resc['cid']."'");
							while($res=mysql_fetch_assoc($sql))
							{
								?>
									<li><input <?php if(in_array($res['sid'],$subcategory)) {echo "checked='checked'";} ?> type="checkbox" name="subcategory[]" class="subcategory filter" value="<?php echo $res['sid']?>">&nbsp; <?php echo $res['name']?></li>
								<?php
							}
						?>
                        
                        </ul>
					</li>
                   
				<?php
			}
			?>
            
            </ul>
            </ul>
            </li>
           
            
            
		  <?php
	  }
	  ?>

</ul>
</div>
 
<!--<div class="locations-list  list-filter">
<h5 class="list-title"><strong>Cities</strong></h5>
<ul class="browse-list list-unstyled long-list" style="height: 200px; overflow-y: scroll;">

<?php $sqlct=mysql_query("select * from tbl_cities");
      while($resct=mysql_fetch_assoc($sqlct))
	  {
		  ?>
		  	
<li> <input type="checkbox" value="<?php echo $resct['city_id'];?>" name="city">  &nbsp;  <?php echo $resct['cityname'];?> </li>
		  <?php
	  }
?>


</ul>
</div>-->
 
<div class="locations-list  list-filter">
<h5 class="list-title"><strong><a href="#">Price range</a></strong></h5>

<div class="form-group col-sm-4 no-padding">
<input type="text" name="minPrice" placeholder="0.00" id="minPrice" class="form-control" value="<?php echo $minPrice;?>">
</div>
<div class="form-group col-sm-1 no-padding text-center"> - </div>
<div class="form-group col-sm-4 no-padding">
<input type="text" name="maxPrice" placeholder="1,00000" id="maxPrice" class="form-control" value="<?php echo $maxPrice;?>">
</div>
<div class="form-group col-sm-3 no-padding">
<button class="btn btn-default pull-right filters" type="submit" id="go">GO</button>
</div>

<div style="clear:both"></div>
</div>
 
<!--<div class="locations-list  list-filter">
<h5 class="list-title"><strong><a href="#">Seller</a></strong></h5>
<ul class="browse-list list-unstyled long-list">
<li> <a href="sub-category-sub-location.html"><strong>All Ads</strong> <span class="count">228,705</span></a></li>
<li> <a href="sub-category-sub-location.html">Business <span class="count">28,705</span></a></li>
<li> <a href="sub-category-sub-location.html">Personal <span class="count">18,705</span></a></li>
</ul>
</div>-->
 
<div class="locations-list  list-filter">
<h5 class="list-title"><strong><a href="#">Condition</a></strong></h5>
<ul class="browse-list list-unstyled long-list">
<li> <input <?php if(in_array('Not Working',$condition)) { echo "checked"; } ?> type="checkbox" value="Not Working" name="condition[]" class="filter"> Not Working</li>
<li><input <?php if(in_array('Functional',$condition)) { echo "checked"; } ?> type="checkbox" value="Functional" name="condition[]" class="filter"> Functional</li>
<li><input <?php if(in_array('Good',$condition)) { echo "checked"; } ?> type="checkbox" value="Good" name="condition[]" class="filter"> Good </li>
<li><input <?php if(in_array('Very Good',$condition)) { echo "checked"; } ?> type="checkbox" value="Very Good" name="condition[]" class="filter"> Very Good</li>
<li><input <?php if(in_array('Excellent',$condition)) { echo "checked"; } ?> type="checkbox" value="Excellent" name="condition[]" class="filter"> Excellent</li>
</ul>
</div>


<div class="locations-list  list-filter">
<h5 class="list-title"><strong><a href="#">Type</a></strong></h5>
<ul class="browse-list list-unstyled long-list">
<li> <input type="checkbox" <?php if(in_array('new',$type)) { echo "checked"; } ?> value="new" name="type[]" class="filter"> New <span class="count">228,705</span></li>
<li> <input type="checkbox" <?php if(in_array('used',$type)) { echo "checked"; } ?> value="used" name="type[]" class="filter"> Used <span class="count">28,705</span></li>
<!--<li> <input type="checkbox" <?php if(in_array('none',$type)) { echo "checked"; } ?> value="none" name="type[]" class="filter"> None </li>-->
</ul>
</div>


<div class="locations-list  list-filter">
<h5 class="list-title"><strong><a href="#">Negotiable</a></strong></h5>
<ul class="browse-list list-unstyled long-list">
<li> <input type="checkbox" value="on" <?php if(in_array('on',$negotiable)) { echo "checked"; } ?> name="negotiable[]" class="filter"> Yes </li>
<li> <input type="checkbox" value="no" <?php if(in_array('no',$negotiable)) { echo "checked"; } ?> name="negotiable[]" class="filter"> No </li>
</ul>
</div>


<div class="locations-list  list-filter">
<h5 class="list-title"><strong><a href="#">Transaction</a></strong></h5>
<ul class="browse-list list-unstyled long-list">
<li> <input type="checkbox" value="exchange"  <?php if(in_array('exchange',$transaction)) { echo "checked"; } ?> name="transaction[]" class="filter"> Exchange Only </li>
<li> <input type="checkbox" value="exchange_cash" <?php if(in_array('exchange_cash',$transaction)) { echo "checked"; } ?> name="transaction[]" class="filter"> Exchange + Cash </li>
<li> <input type="checkbox" value="cash" <?php if(in_array('cash',$transaction)) { echo "checked"; } ?> name="transaction[]" class="filter"> Cash only </li>
</ul>
</div>
 
<div style="clear:both"></div>
</div>
 
</aside>
</div>
 



<div class="col-sm-9 page-content col-thin-left">
<div class="category-list">
<div class="tab-box ">
 
<ul class="nav nav-tabs add-tabs" id="ajaxTabs" role="tablist">
<li class="active"><a role="tab" data-toggle="tab">All Ads <?php /*?><span class="badge">228,705</span><?php */?></a></li>

</ul>

<div class="tab-filter">
<select name="sortby" class="form-control filter" data-style="btn-select" data-width="auto">
<option value="">Short by</option>
<option <?php if($sortby=="lowtohigh") { echo "selected='selected'";} ?> value="lowtohigh">Price: Low to High</option>
<option <?php if($sortby=="hightolow") { echo "selected='selected'";} ?> value="hightolow">Price: High to Low</option>
</select>
</div>
</div>

 
<div class="listing-filter">
<div class="pull-left col-xs-6">
<div class="breadcrumb-list"> <a href="#" class="current"> <span>All ads</span></a> in <?php echo $city;?> <a href="#selectRegion" id="dropdownMenu1" data-toggle="modal"> <span class="caret"></span> </a> </div>
</div>

<div style="clear:both"></div>
</div>
 
<div class="adds-wrapper">
<div class="tab-content">
<div class="tab-pane active" id="allAds"> 
	
    <?php 
	if(mysql_num_rows($searchp)>0)
	{
		while($ressearchp=mysql_fetch_assoc($searchp))
		{
			//echo'<pre>';print_r($ressearchp);
			$files="1";
			if($ressearchp['file2']!=="")
			{
				$files=2;
				if($ressearchp['file3']!=="")
				{
					$files=3;
					if($ressearchp['file4']!=="")
					{
						$files=4;
						if($ressearchp['file5']!=="")
						{
							$files=5;
							
						}
					}
				}
			}
			
			?>
			
			
			<div class="item-list make-list" style="">
				<!--<div class="cornerRibbons urgentAds">
					<a href="#"> Urgent</a>
				</div>-->
				<div class="col-md-2 no-padding photobox">
				<div class="add-image"> 
				<span class="photo-count"><i class="fa fa-camera"></i> <?php echo $files;?> </span> 
				<a href="<?php echo $actual_link;?>ads_details/<?php echo $ressearchp['ads_id'];  ?>"><img class="thumbnail no-margin"  src="<?php echo $actual_link;?>postedfile/<?php echo $ressearchp['file1']?>" alt="img"></a>  </div>
				</div>
				 
				<div class="add-desc-box col-md-6">
				<div class="add-details">
				<h5 class="add-title"> <a href="<?php echo $actual_link;?>ads_details/<?php echo $ressearchp['ads_id'];?>"> <?php echo ucwords($ressearchp['title']);?> </a> </h5>
				<h5 class="add-title"> 
				<?php echo ucfirst($ressearchp['description']);?> 
			 </h5>
			 
			 <span class="info-row"> 
				
				Want in return: <?php //echo $ressearchp['desire_products'];?>
				<?php 
					$desirep=explode(",",$ressearchp['desire_products']); 
					
					echo $desirep=implode(", ",$desirep); 
					
				?> 
			  
			   
			 </span>
			 
			 <span class="info-row"> 
				
				<span class="date"><i class=" icon-clock"> </i> <?php echo date('d M Y',strtotime($ressearchp['postdate']));?> </span> 
			   <!-- <span class="category">Electronics </span>- 
				<span class="item-location"><i class="fa fa-map-marker"></i> London </span>-->
			 </span>
				 </div>
				 
				 
				</div>
				 
				<div class="col-sm-4 text-right  price-box">
				<h2 class="item-price"><i class="fa fa-inr">&nbsp; <?php echo $ressearchp['price'];?></i></h2>
				<a href="<?php echo $actual_link;?>prodreq/<?php echo $ressearchp['ads_id'];?>" class="btn btn-danger  btn-sm make-favorite"> <i class="fa fa-certificate"></i> <span>I Want It</span> </a> 
                
                
                <?php 
				if(isset($_SESSION['cid']))
				{
					if($_SESSION['cid']!==$ressearchp['posted_userid'])
					{?>
					<a class="btn btn-default  btn-sm make-favorite Clickchat" id="<?php echo $ressearchp['ads_id'];?>"> <i class="fa fa-comment"></i> <span>Chat</span> </a>
					
					
					<?php  
					}
			   }
			   else
			   {
				   ?>
				   	<a class="btn btn-default  btn-sm make-favorite Clickchat" id="<?php echo $ressearchp['ads_id'];?>"> <i class="fa fa-comment"></i> <span>Chat</span> </a>
				   <?php
			   }
				
				if(isset($_SESSION['cid']))
				{
					$sqlfavo=mysql_query("select * from tbl_favorite where ads_id='".$ressearchp['ads_id']."' and userid='".$_SESSION['cid']."'");
					$resfavo=mysql_num_rows($sqlfavo);
					  
				?>
                <a class="btn btn-success  btn-sm make-favorite Favourite" <?php if($resfavo>0) { echo 'value="unfavourite"'; }else { echo 'value="favourite"'; }?> id="<?php echo $ressearchp['ads_id'];  ?>" > <?php if($resfavo>0) { echo '<i class="fa fa-heart" style="color:black"></i> <span>Unfavourite</span>'; }else { echo '<i class="fa fa-heart"></i> <span>Favourite</span>'; }?>   </a> 
			   
               
               <?php } 
			   else
			   {
				   ?>
				   <a class="btn btn-success  btn-sm make-favorite Favourite" value="favourite" id="<?php echo $ressearchp['ads_id'];  ?>" > <i class="fa fa-heart"></i> <span>Favourite</span>   </a> 
				   <?php
			   }
			   ?>
               </div>
				 <span class="pull-right">
				<?php
				
					 $sqllocality=mysql_query("select * from tbl_users where userid='".$ressearchp['posted_userid']."'");
					 $reslocality=mysql_fetch_assoc($sqllocality);
					 
					 ?><?php echo '<i class="fa fa-marker"></i>'.ucfirst($reslocality['locality']);
											 
				
				?></span>
			   
	 
			</div>
	<?php }
   
	}
	else
	{
		?>
			<div class="item-list make-list" style="">
				<!--<div class="cornerRibbons urgentAds">
					<a href="#"> Urgent</a>
				</div>-->
				<div class="col-md-12 no-padding photobox">
					<?php echo "<h2 align='center'>No record found</h2>"; ?>
				</div>
				 				
				
			   
	 
			</div>
		<?php
	}
    ?>
    
    
    
<div class="tab-pane" id="businessAds"></div>
<div class="tab-pane" id="personalAds"></div>
</div>
</div>
 
<!--<div class="tab-box  save-search-bar text-center"> <a href=""> <i class=" icon-star-empty"></i> Save Search </a> </div>-->
</div>
<div class="pagination-bar text-center">
<!--<ul class="pagination">
<li class="active"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#"> ...</a></li>
<li><a class="pagination-btn" href="#">Next »</a></li>
</ul>-->

<?php
//fetch all the data from database.
$totaladds=mysql_query("select * from tbl_ads");
$rows=mysql_num_rows($totaladds);
//calculate total page number for the given table in the database 
$total=ceil($rows/$limit);?>
<ul class='pagination'>
<?php if($page>1)
{
	//Go to previous page to show previous 10 items. If its in page 1 then it is inactive
	echo "<li><a id='".($page-1)."' class='button pages'>PREVIOUS</a></li>";
	
}
?>

<?php
//show all the page link with page number. When click on these numbers go to particular page. 
		for($i=1;$i<=$total;$i++)
		{
			if($i==$page) { echo "<li id='".$i."' class='active pages'><a class='active'>".$i."</a></li>"; }
			
			else { echo "<li><a id='".$i."' class='pages'>".$i."</a></li>"; }
		}
		
		
if($page!=$total)
{
	////Go to previous page to show next 10 items.
	
	//echo "<li><a href='?page=".($page+1)."' class='button pages'>NEXT</a></li>";
	echo "<li><a id='".($page+1)."' class='button pages'>NEXT</a></li>";
}

?>
</ul>


</div>


<input type="hidden" name="page" id="pagess" value="">
 
<div class="post-promo text-center">
<h2> Do you get anything for sell ? </h2>
<h5>Sell your products online FOR FREE. It's easier than you think !</h5>
<a href="<?php echo $actual_link;?>post_ads" class="btn btn-lg btn-border btn-post btn-danger">Post a Free Ad </a></div>
 
</div>
 
</div>
</div>
</div>


<div class="modal fade" id="selectRegion" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel"><i class=" icon-map"></i> Select your region </h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<p>India's <strong>Cities</strong>
</p>
<div style="clear:both"></div>
<div class="col-sm-6 no-padding">

</div>
<div style="clear:both"></div>
<hr class="hr-thin">
</div>

<input type="checkbox" name="city" id="ctyid" value='<?php echo $cityid;?>' checked="checked"  style="display:none;" >


<div class="col-md-12" style="height:200px; overflow-y:scroll;">
<?php $sqlct=mysql_query("select * from tbl_cities order by cityname asc");
      while($resct=mysql_fetch_assoc($sqlct))
	  {
		  ?>
          <div class="col-md-4">
<ul class="list-link list-unstyled">	  	
<li> 

<a <?php if($cityid==$resct['city_id']) { ?> style="color:blue; font-wieght:bold;" <?php } ?> id="<?php echo $resct['city_id'];?>" class="Choosecity filters" title="<?php echo $resct['cityname'];?>"><?php echo $resct['cityname'];?></a> </li> 
</ul>
</div>
		  <?php
	  }
?>
</div>


<!--<div class="col-md-4">
<ul class="list-link list-unstyled">
<li> <a href="#" title="Elmont">Elmont</a> </li>
<li> <a href="#" title="Elmsford">Elmsford</a> </li>
<li> <a href="#" title="Farmingville">Farmingville</a> </li>
<li> <a href="#" title="Floral Park">Floral Park</a> </li>
<li> <a href="#" title="Flushing">Flushing</a> </li>
<li> <a href="#" title="Fonda">Fonda</a> </li>
<li> <a href="#" title="Freeport">Freeport</a> </li>
<li> <a href="#" title="Fresh Meadows">Fresh Meadows</a> </li>
<li> <a href="#" title="Fultonville">Fultonville</a> </li>
<li> <a href="#" title="Gansevoort">Gansevoort</a> </li>
<li> <a href="#" title="Garden City">Garden City</a> </li>
</ul>
</div>
<div class="col-md-4">
<ul class="list-link list-unstyled">
<li> <a href="#" title="Oceanside">Oceanside</a> </li>
<li> <a href="#" title="Orangeburg">Orangeburg</a> </li>
<li> <a href="#" title="Orient">Orient</a> </li>
<li> <a href="#" title="Ozone Park">Ozone Park</a> </li>
<li> <a href="#" title="Palatine Bridge">Palatine Bridge</a> </li>
<li> <a href="#" title="Patterson">Patterson</a> </li>
<li> <a href="#" title="Pearl River">Pearl River</a> </li>
<li> <a href="#" title="Peekskill">Peekskill</a> </li>
<li> <a href="#" title="Pelham">Pelham</a> </li>
<li> <a href="#" title="Penn Yan">Penn Yan</a> </li>
<li> <a href="#" title="Peru">Peru</a> </li>
</ul>
</div>-->
</div>
</div>
</div>
</div>
</div>
<input type="hidden" name="submits"  >
</div>
</form>

<?php 
include("footer.php");
?>

<script>
/*$(".maincategory").change(function(){

var mcatid=$(this).val();
$.post("<?php echo  $actual_link;?>ajax/prodcategory.php",{mcatid:$(this).val()},function(data){
	$(".Categories_"+mcatid).show();
$(".Categories_"+mcatid).html(data);

});
});

$(".list-unstyled").on('change','.category',function(){

var catid=$(this).val();
$.post("<?php echo  $actual_link;?>ajax/prodcategory.php",{catid:catid},function(data){
	$(".Subcategories_"+catid).show();
$(".Subcategories_"+catid).html(data);

});
});*/





$(".Choosecity").click(function(){
	
	$("#ctyid").val($(this).attr('id'));
	$(".close").click();
});

$(".filter").change(function(){
 $("form").submit();
});

$(".filters").click(function(){
 $("form").submit();
});



$("#maxPrice").keyup(function(){

if($("#minPrice").val()=="")
{
	$("#go").attr('disabled',true);
	return false();
	
}

if(parseInt($("#minPrice").val())>parseInt($(this).val()))
{
	$("#go").attr('disabled',true);
}
else
{
	$("#go").attr('disabled',false);
}


});

$("#minPrice").keyup(function(){
	//$("#maxPrice").val();
	if($("#maxPrice").val()!=="" && parseInt($("#maxPrice").val())>parseInt($(this).val()))
	{
		$("#go").attr('disabled',false);
	}
	else
	{
		$("#go").attr('disabled',true);
	}
	
});

$(".pages").click(function(){

$("#pagess").val($(this).attr('id'));
	$('form').submit();
});


$(".Favourite").click(function(){
	
<?php if(!isset($_SESSION['cid']))
{
	?>
		alert("Please login first");
		return false();
	<?php
}
?>	

var vals=$(this).attr('value');

var ids=$(this).attr('id');

if(vals=="favourite")
{
	$(this).html('<i class="fa fa-heart" style="color:black"></i> <span>Unfavourite</span>');
	$(this).attr('value','unfavourite');
}
else
{
	$(this).html('<i class="fa fa-heart"></i> <span>Favourite</span>');
	$(this).attr('value','favourite');
}


$.post("<?php echo $actual_link;?>ajax/ajax_favorite.php",{vals:vals,ids:ids},function(data){
//alert(data);
//alert(vals);

});


});

$(".filterM").change(function(){
	
	 if(! $(this).is(':checked'))
	 {
		$(this).closest('ul').find('[type=checkbox]').prop('checked', false);
	 }
	
    

$(".Categories_"+$(this).val()).show();

 $("form").submit();
});

$(".filterC").change(function(){

 if(! $(this).is(':checked'))
	 {
		$(this).closest('ul').find('[type=checkbox]').prop('checked', false);
	 }


$(".Subcategories_"+$(this).val()).show();

 $("form").submit();
});




/*$(".Clickchat").click(function(){


<?php if(!isset($_SESSION['cid']))
{
	?>
		alert("Please login first");
		return false();
	<?php
}
?>	

$(".chatBox").show();

$(".chatBox").attr('id',$(this).attr('id'));

var ads=$(this).attr('id');


$.post("<?php echo $actual_link?>ajax/ajax_chat.php",{adid:ads},function(data){
	$(".msg_container_base").html(data);

});
});*/

/*
$(".chat_input").keypress(function(e) {
    if(e.which == 13) 
	{
       $.post("<?php echo $actual_link?>ajax/ajax_chat_msg.php",{msg:$(".chat_input").val(),adid:$(".chatBox").attr('id')},function(data){
			var datdiv=$(".msg_container_base").html();
			$(".chat_input").val("");
			if(datdiv=="")
			{
				$(".msg_container_base").html(data);
			}
			else
			{
				$(".msg_container_base").append(data);
			}
		
		});
    }
});

$("#btn-chat").click(function(){

	$.post("<?php echo $actual_link?>ajax/ajax_chat_msg.php",{msg:$(".chat_input").val(),adid:$(".chatBox").attr('id')},function(data){
	var datdiv=$(".msg_container_base").html();
	$(".chat_input").val("");
	if(datdiv=="")
	{
		$(".msg_container_base").html(data);
	}
	else
	{
		$(".msg_container_base").append(data);
	}

});

});*/



</script>