<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.mouse.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.draggable.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.resizable.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.dialog.min.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide-with-html.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide.css" />
<link type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/themes/base/jquery.ui.dialog.css" rel="stylesheet" />
<link type="text/css" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/themes/base/jquery.ui.resizable.css" rel="stylesheet" />
<script type="text/javascript">
    hs.graphicsDir = '<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/graphics/';
    hs.outlineType = 'rounded-white';
    hs.showCredits = false;
    hs.wrapperClassName = 'draggable-header';
</script>

<script type="text/javascript">
    function verify()
    {	
        SendGridBindRequest('<?= $commentsObj->urlwithpara ?>','gridbody','D','chkgrow');
    }

    function popreply(id)
    {
        var response;
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=comments&action=email&ajax=Y&id="+id,
            async: false,
            success: function(data){
                //alert(data);
                response=data;
            }
        });

        ////////////ajax end
        $('#dialog-modal').html(response);
        $('#dialog-modal').dialog({
            autoOpen: false,
            height: 295,
            width: 615,
            modal: true
        });
        $('#dialog-modal').dialog('open');
    }

    function excelreport()
    {
        var chkelements = document.getElementsByName('chkgrow');
        var ids = "";
        var countChecked = 0;

        for(var i = 0; i < chkelements.length; i++)
        {
            if(chkelements.item(i).checked == true)
            {
                countChecked++;
                if(ids != "")
                    ids += ",";
                ids += chkelements.item(i).value;
            }
        }
        var totalpagerecords = document.getElementById('ptrecords').value;
        document.getElementById('totalrecords').value = totalpagerecords;
        document.getElementById('chkids').value = ids;

        document.forms["exportform"].submit();
    }
    
     function changestatus(intglcode,value)

    {
//        alert("in");
        globalmakefeatureid = intglcode; 

        var r = confirm('Are you sure you want to change status?');

        if(r==true)

        {

            xmlHttp = GetXmlHttpObject();

            if (xmlHttp == null)

            {

                alert (SUPPORT_BROWSER_XMLHTTP);

                return;

            }

            globalmakefeatureid = intglcode;
           
            var url = "<?= SITE_PATH ?>powerpanel/index.php?module=comments&action=changestatus&id="+intglcode+"&value="+value;
    

            xmlHttp.onreadystatechange = function(){

                if(xmlHttp.readyState==1)

                {

                    ProcessLoader();

                }

                if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))

                {

                    var result = xmlHttp.responseText;            

                    if(result == 1)

                    {

                        alert('Status changed successfully', 'Success');

                    }

                    else

                    {

                        //alert(NOT_UPDATE);

                        alert('Not update successfully', 'Error Message');

                    }

                    document.getElementById('dimmer').style.width=0;

                    document.getElementById('dimmer').style.height=0;

                    document.getElementById('dimmer').style.visibility="";

                    document.getElementById('dvprocessing').style.display = 'none';

                }
                

            };
            //alert(url);
            
            xmlHttp.open("GET",url,true);

            xmlHttp.send(null);

        }

        else

        {

            oldvalue = document.getElementById('hdnvarstatus'+globalmakefeatureid).value;

            document.getElementById('varstatus'+globalmakefeatureid).value = oldvalue;

            return;
        }

    }
    
     function changepriority(intglcode,value)

    {
        globalmakefeatureid = intglcode; 
        var r =  confirm('Are you sure you want to change the priority?'); {
            if(r==true)
            {
                xmlHttp = GetXmlHttpObject();
                if (xmlHttp == null)
                {
                    alert (SUPPORT_BROWSER_XMLHTTP);
                    return;
                }

                globalmakefeatureid = intglcode;

                var url = "<?= SITE_PATH; ?>powerpanel/index.php?module=comments&action=changepriority&id="+intglcode+"&value="+value;
    

                xmlHttp.onreadystatechange = function(){

                    if(xmlHttp.readyState==1)

                    {

                        ProcessLoader();

                    }

                    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))

                    {

                        var result = xmlHttp.responseText;            

                        if(result == 1)

                        {

                            alert('Priority set successfully.', 'Success');

                        }

                        else

                        {
                            alert('Not upadte sucessfully', 'Error Message');
                        }
                        document.getElementById('dimmer').style.width=0;
                        document.getElementById('dimmer').style.height=0;
                        document.getElementById('dimmer').style.visibility="";
                        document.getElementById('dvprocessing').style.display = 'none';
                    }
                };
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
            }
            else
            {

                oldvalue = document.getElementById('hdnvarpriority'+globalmakefeatureid).value;
                document.getElementById('varpriority'+globalmakefeatureid).value = oldvalue;
                return;
            }
        }
    }
    
    function saveadmincomment(txaid, hid)

    {
//    alert("in");
        xmlHttp=GetXmlHttpObject();

        if (xmlHttp==null)

        {

            alert (SUPPORT_BROWSER_HTTP);

            return;

        }

        var postdata = $("#frmadmincomment").serialize();

    

        var url = '<?= SITE_PATH ?>powerpanel/index.php?module=comments&action=addcomment&';

        var params =postdata+"&id="+hid;
//        alert(params);

        xmlHttp.open("POST",url+params ,true)

        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

        xmlHttp.setRequestHeader("Content-length", params.length);

        xmlHttp.setRequestHeader("Connection", "close");

	

        xmlHttp.onreadystatechange = function(txaid) {

            if (xmlHttp.readyState == 1)

            {

                ProcessLoader();

            }

            if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

            {

                var str = xmlHttp.responseText;

                //alert(str);

                if(str == 1)

                {

                    alert(' Your comment has been successfully placed.');                

                      document.getElementById("dvregisterfrm").style.innerHTML = "";

        document.getElementById("dvregisterfrm").style.display = "none";

        document.getElementById('dimmer').style.visibility = 'hidden';

//        hideIframe();

                    document.getElementById('dvprocessing').style.display = 'none';

                }

            }

        }

	

        xmlHttp.send(null)

    }
    function stateChangeloginpopup()

    {
//        alert('fdsfs');
        

        SetBackground();

    

        if(xmlHttp.readyState==1)

        {

            ProcessLoader();

        }

    

        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))

        {
            
         

            var popuph = 316;

            var popupw = 500;

            var popuph2 = popuph/2;

            var popupw2 = popupw/2;

            var winW = screen.width;

            var winH = screen.height;



            //alert(xmlHttp.responseText);



            if (parseInt(navigator.appVersion)>3) {
                
                  



                if (navigator.appName=="Netscape") {
                    
//                     alert('fdffsdf');

                    winW = document.body.offsetWidth;

                    winH = document.body.offsetHeight;

                }



                if (navigator.appName.indexOf("Microsoft")!=-1) {

                    winW = document.body.clientWidth;

                    winH = document.body.offsetHeight;

                }

            }

        

            var sh = winH;

            var sw = winW;

            var sh2 = sh/2;

            var sw2 = sw/2;

            var topf1 = sh2 - popuph;

            var leftf1 = sw2 - popupw2;



            document.getElementById('dvprocessing').style.display='none';

            document.getElementById('dvregisterfrm').style.display='';

            document.getElementById('dvregisterfrm').style.top=CalculateTop('211')+ "px";

            document.getElementById('dvregisterfrm').style.left=leftf1 + "px";

            document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;

		

            //unhideIframe();

        }

    }
    
 function editcomment(id) // for photo view/edit
    {

        xmlHttp=GetXmlHttpObject()
        if(xmlHttp==null)
        {
            alert(SUPPORT_BROWSER_HTTP)
            return;

        }
 
        var url= "<?php echo SITE_PATH ; ?>powerpanel/index.php?module=comments&action=viewPopup&id="+id;
        xmlHttp.onreadystatechange= stateChangeloginpopup

        xmlHttp.open("GET",url,true)

        xmlHttp.send(null)



    }
    function styledPopupClose(event)

    {
        if (event.which==27)
            {
       
//        alert('dfgdfgdfg');

//        document.getElementById("fadeboxiframe").value = "";

        document.getElementById("dvregisterfrm").style.innerHTML = "";

        document.getElementById("dvregisterfrm").style.display = "none";

        document.getElementById('dimmer').style.visibility = 'hidden';

        hideIframe();
            }
  

    }
    
    function styledPopupClose_CM(event)

    {
        

//        document.getElementById("fadeboxiframe").value = "";

        document.getElementById("dvregisterfrm").style.innerHTML = "";

        document.getElementById("dvregisterfrm").style.display = "none";

        document.getElementById('dimmer').style.visibility = 'hidden';

        hideIframe();
          
  

    }

    
     function updateread(id)
    {
        var p='';
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=comments&action=updatereaddata&ajax=Y&id="+id,
            async: false,
            success: function(data){
                p=data;
                document.getElementById('gtr-'+id).className = 'grid-list-inner-table-text';
                document.getElementById('star1-'+id).style.display='none';
               
            }
        });
    }
</script>
<div id="dialog-modal" title="Reply Form"></div>
<div class="web-booking-main" id="gridbody" style="padding-right:2px;">
    <div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp; <span class="current"> Website Comments</span></div>
    <div class="clear"></div>
    <input type="hidden" value='comments' name="hdnmodule" id="hdnmodule" />
    <?php echo $messagebox; ?><?php echo $sendmailstatus; ?>
    <?php echo $headerpanel; ?>  
    <div class="add-new-user-title fr fs16 mgt10 mgr10 fwb" style="width:180px;" >
            <h2>Total Comments: 
                <span style="color: #21759B;font-size: 20px;"><?= $numofrows ?> </span>
            </h2>
        </div>
        <div class="clear"></div> 
    <?php // echo $pagingTop; ?>
    <div class="grid-list-subtitle-bg" style="margin-top:10px;margin-right: 2px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="3%" align="left"  class="grid-td-left1">
                        <input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')" />
                    </td>
                    <td width="4%" align="left" valign="middle class="grid-td-left1>
                        <a href="javascript:;" onclick="SendGridBindRequest('<?= $commentsObj->urlwithoutsort ?>&orderby=int_glcode&sorting=Y','gridbody','ST')">
                            ID#
<?= $setsortimgint_glcode ?>
                        </a>



                    </td>



                    <td width="8%" align="left" >
                         <a href="javascript:;" onclick="SendGridBindRequest('<?= $commentsObj->urlwithoutsort ?>&orderby=fk_userglcode&sorting=Y','gridbody','ST')">
                            User Name<?= $setsortimgfk_userglcode ?></a>
                        </td>
                    <td width="9%" align="center" >
                        <a href="javascript:;" onclick="SendGridBindRequest('<?= $commentsObj->urlwithoutsort ?>&orderby=varpageurl&sorting=Y','gridbody','ST')">
                            Page Url<?= $setsortimgvarpageurl ?></a>
                    </td>
                    <td width="13%" align="left" >Comments</td>
                    <!--<td width="1%" align="left" >&nbsp;</td>-->
                    <td width="9%" align="center" >
                        <a href="javascript:;" onclick="SendGridBindRequest('<?= $commentsObj->urlwithoutsort ?>&orderby=dtcreatedate&sorting=Y','gridbody','ST')">Date<?= $setsortimgdtcreatedate ?></a>
                    </td>    
                     <td width="2%" align="left" >&nbsp;</td>
                    <td width="22%" align="center" >Netclues Comment</td>
                   
                    <td width="10%" align="center" >
                        <a href="javascript:;" onclick="SendGridBindRequest('<?= $commentsObj->urlwithoutsort ?>&orderby=varstatus&sorting=Y','gridbody','ST')">Status<?= $setsortimgvarstatus ?></a>
                    </td>
 <?php
                                    if ($configObj->glSessionObj->value('admin_id') == '1') {
                                        ?>
                    <td width="10%" align="center" >
                        <a href="javascript:;" onclick="SendGridBindRequest('<?= $commentsObj->urlwithoutsort ?>&orderby=varpriority&sorting=Y','gridbody','ST')">Priority<?= $setsortimgvarpriority ?></a>
                    </td>
<?php }  ?>
                </tr>
            </table>
    </div>
    <div class="information-white-bg" id="dvpersonalinformation" style="margin-right: 2px;">
        <div class="clear"></div>
        <div class="grid-list-inner-table-text">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
            </table> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <?php
                if ($numofrows > 0) {
                    $rowcount = 0;
                    while ($row = $configObj->glDbObj->fetch_array($result)) {
                        $clsname = ($row['chr_read'] == 'N') ? "grid-list-inner-table-text-active" : "grid-list-inner-table-text"; // For read unread class
                        $starimg = ($row['chr_star'] == 'Y') ? "gstar.png" : "gstar-disable.png"; // Displaying the stat and unstart image
                        $tool = ($row['chr_star'] == 'Y') ? "Starred" : "Not starred";
                        $tickimg = ($row['chr_publish'] == 'Y') ? "tick.png" : "tick_cross.png"; // Displaying the stat and unstart image
//                        $sql_con_rep = "SELECT fk_contactdetail,GROUP_CONCAT(var_adminreply,'<br/>$$$$$') as add_rep,GROUP_CONCAT(DATE_FORMAT(dtcreateddate, '" . DEFAULT_DATEFORMAT . "'),'$$$$$') as add_rep_date,GROUP_CONCAT(time(dtcreateddate),'<br/>$$$$$') as add_rep_time FROM " . DB_PREFIX . "comments_reply where fk_contactdetail='" . $row['int_glcode'] . "' group by fk_contactdetail order by dtcreateddate desc";
//                        $row_add_rep = $configObj->glDbObj->get_sql_row($sql_con_rep);
                        $arr_admin = explode('<br/>$$$$$,', $row_add_rep['add_rep']);
                        $arr_admin_date = explode('$$$$$,', $row_add_rep['add_rep_date']);
                        $arr_admin_time = explode('<br/>$$$$$,', $row_add_rep['add_rep_time']);

                        if ($row['chr_read'] == 'N') {
                            $style = 'display:inline;';
                        } else {
                            $style = 'display:none;';
                        }

                        $starClass = "<span id='star1-" . $row['int_glcode'] . "' style='" . $style . "'><img width='10px' id='imgStar-" . $row['int_glcode'] . "' style='padding-bottom:5px;' height='10px' title='New Inquiry Added'  src='html/images/star_red.png'></span>";
                        ?>
                        <tr id="gtr-<?= $row->intglcode ?>" onmouseout="this.style.backgroundColor='transparent'" onmouseover="this.style.backgroundColor='#f6f6f6'" class="<?= $clsname ?>">
                                <td width="3%" align="left" valign="top"  class="grid-td-left">
                                    <input name="chkgrow" id="chkgrow" type="checkbox" value="<?= $row['int_glcode']; ?>"/>
                                </td>
                                <td width="4%" align="left" valign="top"  class="grid-td-top"><?= $row['int_glcode']; ?></td>
                                <?php
                                    $sql1="select var_fname from ".DB_PREFIX."users where int_glcode=".$row['fk_userglcode'];
                                    $res1= mysql_query($sql1);
                                    $row1= mysql_fetch_array($res1);
                                ?>
                                <td width="8%" align="left" valign="top"  class="grid-td-top"><?= $row1['var_fname']; ?></td>
                                <td width="9%" align="center" valign="top"  class="grid-td-top">   
                                    <?php // echo GLOBAL_ADMIN_IMAGES_PATH; ?>
                                    <a href="<?= $row['varpageurl']; ?>" style="color:#21759B;font-size:12px;" target="_blank" >
                                        <img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>url-icon.png" alt="Page Url" title="Page Url" />
                                    </a>                                
                                </td>
                                <td width="13%" align="left" valign="top"  class="grid-td-top" style="line-height: 25px;">
        <?php
        $viewmore = '';
        $admincomment = substr($row['varcomment'], '0', '85');
        if (strlen($row['varcomment']) > 85) {
            $admincomment .='...';
            $viewmore = "<a href=\"javascript:;\" onclick=\"viewcomment_new('" . $row['int_glcode']. "');\" style=\"color:#21759B;font-size: 12px;\" >View More</a>";
        }

        echo $admincomment . $viewmore;
        ?>

                                </td>
                                <!--<td width="1%" align="left" valign="top" >&nbsp;</td>-->
                                <td width="9%" align="center" valign="top" class="grid-td-top">
        <?= $row['dtcreatedate'] ?>
                                </td>    
                                  <td width="2%" align="left" >&nbsp</td>

                                <td width="22%" align="center" valign="top"  class="grid-td-top">
        <?php
        if ($configObj->glSessionObj->value('admin_id') == '1') {
            $viewedit = '';
            $netcluescomment = substr($row['varadmincomment'], '0', '85');
            if (strlen($row['varadmincomment']) > 85) {
                $netcluescomment .='...';
            }
            $viewedit = "<a href=\"javascript:;\" onclick=\"editcomment('" . $row['int_glcode'] . "');\" style=\"color:#21759B;font-size: 12px;\" >View / Edit</a>";
            echo $viewedit;
        } else {
            if ($row['varadmincomment'] != '') {
                $viewmoreadmin = '';
                $netcluescomment = substr($row['varadmincomment'], '0', '85');
                if (strlen($row['varadmincomment']) > 85) {
                    $netcluescomment .='...';
                    $viewmoreadmin = "<a href=\"javascript:;\" onclick=\"viewadmincomment_new('" . $row['int_glcode'] . "');\" style=\"color:#21759B;font-size: 12px;\" >View More</a>";
                }
                echo $netcluescomment. $viewmoreadmin;
            } else {
                echo '---';
            }
        }
        ?>
                                </td>
                                <!--<td width="1%" align="left" >&nbsp;</td>-->
                                <td width="10%" align="center" valign="top"  class="grid-td-top">
                                    <?php
                                    if ($configObj->glSessionObj->value('admin_id') == '1') {
                                        ?>
                                        <input type="hidden" id="hdnvarstatus<?= $row['int_glcode'] ?>" name="hdnvarstatus<?= $row['int_glcode'] ?>" value="<?= $row['varstatus'] ?>">
                                        <select name="varstatus<?= $row['int_glcode'] ?>" id="varstatus<?= $row['int_glcode'] ?>" style="width:auto;" class="search-textarea"  onchange="changestatus(<?= $row['int_glcode'] ?>,this.value)">
                                            <option value="Completed" <? echo(($row['varstatus'] == 'Completed') ? 'selected' : '') ?> >Completed</option>
                                            <option value="Work in Progress" <? echo(($row['varstatus'] == 'Work in Progress') ? 'selected' : '') ?> >Work in Progress</option>
                                            <option value="Query" <? echo(($row['varstatus'] == 'Query') ? 'selected' : '') ?> >Query</option>
                                        </select>
                                        <?php
                                    } else {
                                      if ($row['varstatus'] == 'Completed') {
                                            $status_icon ='<img src="'. GLOBAL_ADMIN_IMAGES_PATH .'complete.png" class="mgt5 mgr5" alt="Completed" title="Completed">';
                                            $tooltip = 'Completed';
                                        } else if ($row['varstatus'] == 'Query') {
                                                $status_icon = '<img src="'.GLOBAL_ADMIN_IMAGES_PATH .'query.png" class="mgt5 mgr5" alt="Query" title="Query">';
                                            $tooltip = 'Query';
                                        } else {
                                            $status_icon = '<img src="'.GLOBAL_ADMIN_IMAGES_PATH .'progress.gif" class="mgt5 mgr5" alt="Work in Progress" title="Work in Progress">';
                                            $tooltip = 'Work in Progress';
                                        }
                                         echo $status_icon;
//                                        echo $status_icon . ' ' . $row['varstatus'];
                                    }
                                    ?>
                                </td>
                                    <?php
                                    if ($configObj->glSessionObj->value('admin_id') == '1') {
                                        ?>
                                    <td width="10%" align="center" valign="top"  class="grid-td-top">                                
                                        <input type="hidden" id="hdnvarpriority<?= $row['int_glcode'] ?>" name="hdnvarpriority<?= $row['int_glcode'] ?>" value="<?= $row['varpriority'] ?>">
                                        <select name="varpriority<?= $row['int_glcode'] ?>" id="varpriority<?= $row['int_glcode'] ?>" style="width:auto;" class="search-textarea"    onchange="changepriority(<?= $row['int_glcode'] ?>,this.value)">
                                            <option value="">Please Select</option>
                                            <option value="low" <? echo(($row['varpriority'] == 'low') ? 'selected' : '') ?> >Low</option>
                                            <option value="medium" <? echo(($row['varpriority'] == 'medium') ? 'selected' : '') ?> >Medium</option>
                                            <option value="high" <? echo(($row['varpriority'] == 'high') ? 'selected' : '') ?> >High</option>
                                        </select>                                                                                              
                                    </td>
                                    <?php } ?>
                            </tr>
                        <?php
                        $rowcount++;
                    }
                } else {
                    ?>

                    <tr style="background-color: transparent;"  class="<?= $clsname ?>" onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'">
                        <td height="25" align="center" valign="middle" colspan="6" class="form_titles">

                            No new leads, Please <a href="http://www.netclues.ky/seo-search-engine-optimization-cayman-islands.php" target="_blank"> <strong>Click Here</strong> </a> to find out how to get more leads.

                        </td>
                    </tr>
                    <?php
                }
                ?>
                <input type="hidden" name="ptrecords" id="ptrecords" value="<?= $rowcount ?>">             
            </table>
        </div>
    </div>            
    <div class="clear"></div>

    <?php // echo $pagingBottom; ?>
    <?php if ($paramMain['Delete'] == 'Y' && $numofrows > 0) { ?>

        <div style="width:90px; float: left;" class="add-new-user-button"><a href="javascript:" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image47','','<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete-button-hover.jpg',0)"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete-button.jpg" alt="Delete" name="Image47" width="80" height="25" border="0" id="Image47" onclick="return verify();" /></a>
        </div>
    <?php } ?>

</div>