<div id="divComm" style="top: 100px;left: 300px;position: absolute;background-color: gray"></div>
<script type="text/javascript">
    function showComment(e,id)
    {
        var posx =0;var posy=0;
        if (!e){var e = window.event;}
        if (e.pageX || e.pageY){
            posx = e.pageX;
            posy = e.pageY;
        }
        else if (e.clientX || e.clientY){
            posx = e.clientX;
            posy = e.clientY;
        }
        $('#divCommText'+id).css("top",posy+15);
        $('#divCommText'+id).css("left",posx);
        $('#divCommText'+id).fadeIn();
    }
    function hideComment(id)
    {
        $('#divCommText'+id).fadeOut("slow");
    }




    function loadComment(e,id)
    {
        var posx =0;var posy=0;
        if (!e){var e = window.event;}
        if (e.pageX || e.pageY){
            posx = e.pageX;
            posy = e.pageY;
        }
        else if (e.clientX || e.clientY){
            posx = e.clientX;
            posy = e.clientY;
        }
        $('#divComm').fadeIn("slow");
        $('#divComm').css("top",posy+20);
        $('#divComm').css("left",posx-480);
        $('#divComm').load('<?php echo ConfigUrl::base()?>index/loadComments?id='+id, function() {
        });
    }
    function load(){

        var comm      =    $("#txtComment").val();
        var status    =    $("#cmbStatus").val();
        var id        =    $("#id").val();
        if(comm=="" || id=="")
        {
            $("#divCommReq").html("Please Enter Comment");
        }
        else
        {
            var data 	= 'id='  + id+'&comm='+comm+'&status='+status;
            $.ajax({
                url: "<?php echo ConfigUrl::base(); ?>index/updateComments/",
                type: "POST",
                data: data,
                cache: false,
                success: function (html) {
                    if (html==1) {
                        $("#divComm").fadeOut("slow");
                        $("#divCommVal").html(comm);
                        if(status==1)$("#divStatusVal").html("Approved");
                        else $("#divStatusVal").html("Not Approved");

                        /*$("#cat"+id).hide("slow");
                              $("#catVal"+id).html(cat);
                              $("#catVal"+id).show("slow");*/
                        $("#commMsg"+id).html('<font color="green">Comment updated Successfully</font>');
                        $("#commMsg"+id).fadeIn("Slow");
                        setTimeout(function() {$("#commMsg"+id).fadeOut("slow");$("#commMsg"+id).html('')},2000);
                        return false;
                    }
                    if (html==2)
                        $("#divCommReq").html("Please Enter Comment");

                    else alert('Sorry, unexpected error. Please try again later.');
                }
            });
        }

    }


</script>

<div  style="color:red;font-size: 15px " ><?php echo  $this->message; ?></div>
<div class="comm_div">
    <div class="comm_content_block">
        <h3>Manage Comments</h3>
        <div class="comm_content_block_items">
            <div id="commMsg<?php echo $row->nId;?>" style="color: red"></div>
            <div class="btm-padding">
                <form name="frmsearch" method="post" action="<?php echo ConfigUrl::base();?>index/comments">
                    <span class="label-stl">Search</span>
                    <input type="text" value="<?php echo ($_POST['txtSearch'])?$_POST['txtSearch']:$this->txtSearch?>" class="txt_area_2 txt_bx" name="txtSearch" >&nbsp;<input class="btn_styles butnstl" type="submit" name="btnSearch" value="Search">
                </form>
                <div class="clear"></div>
            </div>
            <table width="100%" cellspacing="1" cellpadding="0" border="0" class="list_table">

                <tbody>

                    <tr>
                        <th width="5%" valign="top" align="center">#</th>
                        <th width="16%" valign="top" align="left"><a href="<?php echo ConfigUrl::base()?>index/comments/1/vName/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Name</a></th>
                        <th width="20%" valign="top" align="left"><a href="<?php echo ConfigUrl::base()?>index/comments/1/vEmail/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Email</a></th>
                        <th width="15%" valign="top" align="left"><a href="<?php echo ConfigUrl::base()?>index/comments/1/Title/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Ad Title</a></th>
                        <th width="23%" valign="top" align="left"><a href="<?php echo ConfigUrl::base()?>index/comments/1/vComment/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Comment</a></th>
                        <th width="10%" valign="top" align="center"><a href="<?php echo ConfigUrl::base()?>index/comments/1/dDate/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Added Date</a></th>
                        <th width="18%" valign="top" align="center"><a href="<?php echo ConfigUrl::base()?>index/comments/1/nStatus/<?php echo $this->order == 'ASC' ? 'DESC' : 'ASC'?>">Status</a></th>
                        <th width="5%" valign="top" align="center">Action</th>
                    </tr>
                    <?php
                    if(sizeof($this->resComments)>0) {
                        $i=0;
                        foreach($this->resComments as $row) {
                            $i++;
                            ?>
                    <tr class="row_color1">
                        <td valign="top" align="center"><?php echo ($this->page-1)*$this->pageMaxCount +$i//$i; ?></td>
                        <td valign="top" align="left"><?php echo stripslashes($row->vName)?></td>
                        <td valign="top" align="left"><?php echo stripslashes($row->vEmail)?></td>
                        <td valign="top" align="left"><a href="<?php echo ConfigUrl::base().'index/viewlisting/'.$row->nBusId.'/' ?> " target='_blank'><?php echo stripslashes($row->Title)?></a></td>
                        <td valign="top" align="left" id="divCommVal"><div onmouseover="showComment(event,'<?php echo $row->nId?>')" onmouseout="hideComment('<?php echo $row->nId?>')" ><?php echo substr(stripslashes($row->vComment),0,50)."...";?></div><div style="display: none;background-color:#DDE5F0;border: 1px solid black;padding: 10px;position: absolute;width:400px"  id="divCommText<?php echo $row->nId?>"><?php echo stripslashes($row->vComment);?></div></td>
                        <td valign="top" align="center"><?php echo date("m/d/Y",strtotime(stripslashes($row->dDate))); ?><?php //echo stripslashes($row->dDate)?></td>
                        <td valign="top" align="center" id="divStatusVal"><?php echo ($row->nStatus==1)?"Approved":"Not Approved";?></td>
                        <td valign="top" align="center"><a href="javascript:void(0)" onclick="loadComment(event,'<?php echo $row->nId?>')">Edit</a></td>
                    </tr>
                            <?php
                        }
                    }
                    ?>

                </tbody></table>

            <!--  start paging..................................................... -->


            <div class="clear"></div>
        </div>
    </div>
</div>  <?php if($this->pageCount > 1) {  ?>

<div class="pagination">
    <ul>
            <?php
            if($this->page != 1) {?>
        <li><a href="<?php echo ConfigUrl::base()?>index/comments/1/<?php echo $this->sortfield.'/'.$this->order .'/'. $this->txtSearch?>" class="page_first" >First</a></li>
        <li><a class="page_prev" href="<?php echo ConfigUrl::base()?>index/comments/<?php if($this->page != 1) echo $this->page - 1; else echo $this->page; ?>/<?php echo $this->sortfield.'/'.$this->order .'/'. $this->txtSearch?>" >Previous</a></li>
                <?php
            }?>
        <li class="pageinfo"><div id="page-info">Page <strong><?php echo $this->page; ?></strong> / <?php echo $this->pageCount; ?></div></li>
            <?php if($this->pageCount != $this->page) {?>
        <li><a class="page_next" href="<?php echo ConfigUrl::base()?>index/comments/<?php if($this->pageCount != $this->page) echo  $this->page + 1; else echo $this->pageCount; ?>/<?php echo $this->sortfield.'/'.$this->order .'/'. $this->txtSearch?>" >Next</a></li>
        <li><a class="page_last" href="<?php echo ConfigUrl::base()?>index/comments/<?php echo $this->pageCount; ?>/<?php echo $this->sortfield.'/'.$this->order .'/'. $this->txtSearch?>" >Last</a></li>
                <?php
            }?>
    </ul>
    <div class="clear"></div>
</div>
    <?php
}
?>