<script type ="text/javascript">
      $(window).load(function() {
   // alert("jdfgj");exit;
        var groupby = $("#community_category").val();
        var page = 1;  
       	var _throttleTimer = null;
	var _throttleDelay = 100;
            $(window ).scroll(function() {
                //alert(TOTAL_PAG);
	    clearTimeout(_throttleTimer);
	    _throttleTimer = setTimeout(function () {
	    if($(window).scrollTop() + $(window).height() > $(document).height()-100) {
	        if(page < T_PAG){
                //   alert(page);
                    page++;
                    $.blockUI({ message: '' }); 
                  //  var user_id      = $("#user_id").val();
                  //  var business_name    = $("#business_name").val();
                    $.ajax({
                        type    : 'Post',
                        url     : mainUrl+'user/group_listajax/'+page+'/'+groupby,
                       // data    : 'user_id='+user_id,
                        cache   : false,
                        success :function(data){
                            $('.bizcomlisting').append(data);
                            $('.listitem').fadeIn(3000);
                            $('.listitem').hide();
                        }
                    }) 
    	        }
	    }
	    },_throttleDelay);
	    });
    });
    $('#starring .rateit').bind('rated', function (e) {
        var ri = $(this);
        var rateField = $(this).attr("id");
        var status = true;
        var ratetype = ri.rateit('type');
        var ratetypeid = ri.rateit('typeid');     
        var rateflag = ri.rateit('flag');
        //if the use pressed reset, it will get value: 0 (to be compatible with the HTML range control), we could check if e.type == 'reset', and then set the value to  null .
        var ratevalue = ri.rateit('value');
        // alert("hi "+ratevalue);
        var userid = ri.rateit('id'); // if the product id was in some hidden field: ri.closest('li').find('input[name="productid"]').val()
        if(rateflag == 1 && userid <= 0){ //alert("2");
            status = checkLogin2(ratetype,ratetypeid,'rate',rateField);	    	
        }	 
        if(status != false){
            // alert("here");
            checkRated1(rateField);	    
        }
	 
    });

</script>
<div class="container">
    <div class="row"> 
        <div class="col-sm-12 col-md-12 col-lg-12">
<div id="o-wrapper" class="o-wrapper">
<!---Menu Link----------------- -->
{if PageContext::$response->sess_user_id >0}
<div class="main">
<div class="header-main">
     <main class="o-content">
        <div class="o-container">
          
          <div class="c-buttons">
            <button id="c-button--slide-right" class="button-nav-toggle"><span class="icon">&#9776;</span></button>
          </div>
          
          <div id="github-icons"></div>

        </div><!-- /o-container -->
      </main><!-- /o-content -->    
</div>
</div>  
{/if}
</div>
<!---EOF Menu Link----------------- -->
            <h3>Groups <span class="round-search">{PageContext::$response->total_rec}</span> {if PageContext::$response->sess_user_id neq 0 and PageContext::$response->sess_user_status neq 'I'} <span class="addbusiness "><a href="{php} echo PageContext::$response->baseUrl;{/php}add-group">Add Group</a></span> {/if}</h3>
        </div>
        <section class="searchbar">

            <div class="col-sm-12 col-md-12 col-lg-12">

                <div class="businesslist_search_blk">
                    <div class="row"> 
                        <div class="col-sm-6 col-md-4 col-lg-4">
                            <input type="hidden" value="{PageContext::$response->sess_user_id}" class="login_status" name="" id="login_status">
                            Sort by : A-Z <a href="{php} echo PageContext::$response->baseUrl; {/php}groups?sort=community_name&sortby={php} echo PageContext::$response->order; {/php}&searchtext={php} echo PageContext::$response->searchtext; {/php}&searchtype={php} echo PageContext::$response->searchtype; {/php}&page={php} echo PageContext::$response->page; {/php}">{PageContext::$response->community_name_sortorder}</a>
                        </div>

                        <div class="col-sm-6 col-md-4 col-lg-4">
                            {php}PageContext::renderRegisteredPostActions('searchbox');{/php}
                        </div>
<!--                        <div class="col-sm-6 col-md-4 col-lg-4">
                        <select class="form-control" placeholder="Category" name="community_category" id="community_category" value="" >
	                                    {foreach from=PageContext::$response->categories key=category item=id}
	                                        <option value="{$id}" {if PageContext::$response->cat_id eq $id} selected="selected" {/if}>{$category}</option>
	                                    {/foreach}

	                </select>
                        </div>    -->
                    </div>
                </div>
                {php}PageContext::renderRegisteredPostActions('messagebox');{/php}
            </div>
        </section>
        <div class="clearfix"></div>
        <section class="bizcomlisting">
            {if PageContext::$response->totalrecords > 0}
            {assign var="i" value=PageContext::$response->slno}
            {foreach from=PageContext::$response->leads key=id item=lead}
            <div class="col-sm-6 col-md-6 col-lg-6">
                <div class="mediapost">
                    <div class="mediapost_left pull-left">
                        <span class="mediapost_pic">

                            <a href="{php} echo PageContext::$response->baseUrl;{/php}community/{$lead->community_alias}"><img class="business_profile_desc_colside_pic" alt="{$lead->file_orig_name}" src="{php} echo PageContext::$response->userImagePath;{/php}{if $lead->file_path neq ''}{$lead->file_path}{elseif $lead->file_path eq ''}default/no_image_bbf.jpg{/if}"> </a>
                        </span>
                    </div>

                    <div class="media-body">
                        <h4 class="media-heading"><span><a href="{php} echo PageContext::$response->baseUrl;{/php}group/{$lead->community_alias}">{$lead->community_name}</a></span></h4>
                        {if $lead->community_status =='I'}   
                        <span class="status clserror" >Pending Approval</span> 
                        {else}
                        <div class="display_table">
                            <div class="display_table_cell wid60per">
                                <div id="starring">
                                    <div class="rateit" id="rateit_{$lead->ratetype_id}" data-rateit-value="{$lead->ratevalue}" data-rateit-ispreset="true" data-rateit-id="{$lead->rateuser_id}" data-rateit-type="{$lead->ratetype}" data-rateit-typeid="{$lead->ratetype_id}" data-rateit-flag="{$lead->rateflag}" data-rateit-step=1 data-rateit-resetable="false">
                                    </div>
                                    <div class="right">
                                        {if PageContext::$response->sess_user_id eq $lead->community_created_by}
                                        <a href="{php} echo PageContext::$response->baseUrl;{/php}edit-group/{$lead->community_id}" class="edititem left marg5right"><i class="fa fa-pencil"></i></a>
                                        <a href="{php} echo PageContext::$response->baseUrl;{/php}index/delete_community/{$lead->community_id}" class="deleteitem left"><i class="fa fa-trash"></i></a> 
                                        {/if}
                                    </div>
                                </div>
                            </div>

                        </div>
                        {/if}
                        <p>
                             {$lead->community_description|substr:0:200}....
                        </p>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
            {assign var="i" value=$i+1}
            {/foreach} 
            {else}
            <div class="col-sm-12 col-md-12 col-lg-12">{if PageContext::$response->searchtype eq ''}No groups added.{else}No matches found.{/if}
        {if PageContext::$response->sess_user_id neq 0 and PageContext::$response->sess_user_status neq 'I'}Click to <a href="{php} echo PageContext::$response->baseUrl;{/php}add-group">create a group</a>. {/if}
    </div>
    {/if}   
            <div class="clear"></div>
            {if PageContext::$response->totalrecords gt PageContext::$response->itemperpage}
    <!--<div>{PageContext::$response->pagination} </div>-->
    {/if}

        </section>
    </div>
</div>


