<input type="text" class="form-control" data-toggle="modal" data-target="#myLocation" name="location" id="location" value="<?php 
echo $location;
?>
" placeholder="All Gujarat" />
		</div>
		<?php 
if ($this->router->fetch_class() == 'index' && $this->router->fetch_method() == 'index') {
    $textboxcls = 'col-lg-7 col-md-7';
} else {
    $textboxcls = 'col-lg-4 col-md-4';
    ?>
		<div class="col-lg-3 col-md-3">
			<span class="search-lable">Find your category</span>
			<div class="form-control">
				<?php 
    echo categoryDropdown(array(), true, '', $category, $catename);
    ?>
			</div>
		</div>
		<?php 
}
?>
		<div class="<?php 
echo $textboxcls;
?>
">
			<span class="search-lable">Find your product here</span>
			<input type="text" class="form-control" name="srchtxt" id="srchtxt" value="<?php 
echo $srchtxt;
?>
"  autocomplete="off" Placeholder="<?php 
function categoryDropdown($categories = array(), $first = true, $idprefix = "", $cateId = '', $catename = '')
{
    if ($first) {
        $CI =& get_instance();
        $categories = $CI->common_model->getCategoryOrderedArray(true, false, true);
        $html = '<div class="dropdown" style="position:relative;width:100%;">
			<input type="hidden" name="category" id="sel_cat_id" value="' . $cateId . '">
				<a href="#" class="categoryListA dropdown-toggle " data-toggle="dropdown">';
        if ($catename == '') {
            $html .= '<span id="categorySelName">Select Category</span> <span class="caret"></span>';
        } else {
            $html .= '<span id="categorySelName">' . $catename . '</span> <span class="caret"></span>';
        }
        $html .= '</a>
				<ul class="dropdown-menu srchcatmenu">';
        if ($catename != '') {
            $html .= '<li data-value=""><a class="trigger">Select Category</a>';
        }
    } else {
        $html = "<ul class='dropdown-menu sub-menu'>";
    }
    foreach ($categories as $category) {
        //echo "<pre>"; print_r($category);exit;
        $catid = str_replace("--", "-", $idprefix . $category['category']['cat_id'] . "-");
        if (isset($category['children'])) {
            $html .= '<li data-value="' . $catid . '"><a class="trigger right-caret">' . $category['category']['cat_name'] . '(' . $category['category']['cat_ad_count'] . ')</a>';
            $childern = array_merge(array($catid => array("category" => array("cat_id" => "", "cat_name" => "All " . $category['category']['cat_name'], "cat_ad_count" => $category['category']['cat_ad_count']))), $category['children']);
            $html .= categoryDropdown($childern, false, $catid);
            $html .= "</li>";
        } else {
            $html .= '<li data-value="' . $catid . '"><a href="#">' . $category['category']['cat_name'] . '(' . $category['category']['cat_ad_count'] . ')</a></li>';
        }
    }
    $html .= "</ul>";
    if ($first) {
        $html .= "</div>";
    }
    return $html;
}