<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide-with-gallery.js"></script>
<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>jquery/ui/minified/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="html/js/jquery/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" type="text/css" href="html/js/jquery/themes/base/jquery.ui.dialog.css" />
<script type="text/javascript">
    hs.graphicsDir = '<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/graphics/';
    hs.align = 'center';
    hs.transitions = ['expand', 'crossfade'];
    hs.wrapperClassName = 'dark borderless floating-caption';
    hs.fadeInOut = true;
    hs.dimmingOpacity = .75;

    // Add the controlbar   
    if (hs.addSlideshow)
        hs.addSlideshow({
            slideshowGroup: 'group1',
            interval: 5000,
            repeat: false,
            useControls: true,
            fixedControls: 'fit',
            overlayOptions: {
                opacity: .6,
                position: 'bottom center',
                hideOnMouseOut: true
            }
        });

</script>
<script type="text/javascript">
    function verify()
    {
        //////////////alert('Only unused pages will be deleted');
        SendGridBindRequest('<?= $pagesObj->urlwithpara ?>', 'gridbody', 'D', 'chkgrow');
    }

    function GetXmlHttpObject()
    {
        var xmlHttp = null;
        try
        {
            xmlHttp = new XMLHttpRequest();
        }
        catch (e)
        {
            try
            {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        return xmlHttp;
    }

    function updatedisplayorder(url, id, action, targetdiv)
    {


        xmlHttp = GetXmlHttpObject();
        if (id == "")
        {
            document.getElementById(targetdiv).innerHTML = "";
            return;
        }
        if (window.XMLHttpRequest)
        {
            xmlhttp = new XMLHttpRequest();
        }
        else
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                document.getElementById(targetdiv).innerHTML = xmlhttp.responseText;
            }
        }
        var appendurl = '';
        switch (action)
        {
            case 'moveup':
                appendurl = '&action=moveup';
                break;

            case 'movedown':
                appendurl = '&action=movedown';
                break;
        }
        xmlhttp.open("GET", url + appendurl + '&mid=' + id + '&ajax=Y', true);
        xmlhttp.send();
    }
</script>

<div class="web-booking-main" id="gridbody">
    <div class="breadcrumbs"><a href="index.php">&nbsp;Home</a>&nbsp;>&nbsp;<span class="current">Manage Pages </span>  </div>
    <div class="clear"></div>
    <?php echo $messagebox; ?>
    <?php echo $headerpanel; ?>
    <?php echo $pagingTop; ?>
    <? echo $notemessagebox; ?>
    <input type="hidden" name="hdnmodule" id="hdnmodule" value="pages" />
    <div class="grid-list-subtitle-bg" style="margin-top:10px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="5%" align="left" valign="middle" class="grid-td-left">
                    <?php if ($paramMain['Delete'] == 'Y') { ?>
                        <input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')"  />
                    <?php } else { ?>
                        &nbsp;
                    <?php } ?>
                </td>
                <?php if ($configObj->glSessionObj->value('admin_id') == '1') { ?>
                    <td width="2%" align="center" valign="top" class="grid-td-left">&nbsp;</td>
                <?php } ?>
                <td width="20%" align="left" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $pagesObj->urlwithoutsort ?>&orderby=var_pagename&sorting=Y', 'gridbody', 'ST')">&nbsp;&nbsp;&nbsp;Page Name
                        <?= $setsortimgvar_pagename ?>
                    </a></td>

                <td width="10%" align="left" valign="middle" class="grid-td-top">Banner
                </td>


                <td width="10%" align="center" valign="top" class="grid-td-top"> <table><tr><td width="95%" align="right"><a href="javascript:;" onclick="SendGridBindRequest('<?= $pagesObj->urlwithoutsort ?>&orderby=int_displayorder&sorting=Y', 'gridbody', 'ST')"> Display Order
                                    <?= $setsortimgint_displayorder ?>
                                </a></td>

                            <td width="8%" align="left" valign="top">
                                <?php if ($paramMain['Edit'] == 'Y') { ?>
                                    <a href="javascript:;"  onclick="javascript:SendGridBindRequest('<?= $pagesObj->urlwithoutsort ?>', 'gridbody', 'DO', '', 'parent');">
                                        <?php if ($paramMain['Edit'] == 'Y') { ?> <img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>save.png" width="16" height="16" alt="save" title="save" border="0" /></a><?php } ?>
                                <?php } ?>
                            </td>
                        </tr></table></td>


                <td width="10%" align="center" valign="middle" class="grid-td-top">
                    <a href="javascript:;" onclick="SendGridBindRequest('<?= $pagesObj->urlwithoutsort ?>&orderby=int_pagehits&sorting=Y', 'gridbody', 'ST')"> Hits
                        <?= $setsortimgint_pagehits ?></a></td>



                <td width="10%" align="center" valign="middle" class="grid-td-top"><a href="javascript:;" onclick="SendGridBindRequest('<?= $pagesObj->urlwithoutsort ?>&orderby=chr_publish&sorting=Y', 'gridbody', 'ST')">Publish<?= $setsortimgchr_publish ?></a></td>

            </tr>
        </table>
    </div>
    <div class="information-white-bg" id="dvpersonalinformation" >
        <div class="clear"></div>
        <div class="grid-list-inner-table-text">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" id="test">
                <?php
                if ($numofrows > 0) {
                    $rowcount = 0;
                    $i = 0;
                    $j = 1;

                    foreach ($records as $row) {
                        //$clsname = ($row['chr_read'] == 'N') ? "grid-list-inner-table-text-active" : "grid-list-inner-table-text";
                        if ($configObj->glSessionObj->value('admin_id') == '1') {
//                            $clsname = ($row['chr_read'] == 'N') ? "grid-list-inner-table-text-active" : "grid-list-inner-table-text"; // For read unread class
                        } else {
//                            $clsname = "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
                        $title = ($row['chr_publish'] == 'Y') ? "Hide me" : "Display me"; // The title of Display image

                        if ($row['chr_history_read'] == 'Y') {
                            $trackimage = "histry-icon.png";
                            $title1 = "Read History";
                        } else {
                            $trackimage = "histry-unread-icon.png";
                            $title1 = "Unread History";
                        }
                        if ($row["fk_pages"] != '') {
                            $fk_total = $pagesObj->count_fk_pages($row["int_glcode"]);
                        }
                        ?>
                        <tr id="gtr-<?= $row['int_glcode'] ?>"  style="background-color: transparent;"   onmouseover="this.style.backgroundColor = '#f6f6f6'" onmouseout="this.style.backgroundColor = 'transparent'" >
                            <?php if ($paramMain['Delete'] == 'Y') { ?>
                                <td width="5%" align="center" valign="middle" class="grid-td-left">


                                    <?php if ($row['int_glcode'] != '1') { ?>
                                        <?php
                                        $pagecount = $pagesObj->getpagenameexist($row['int_glcode']);
                                        $pagecount1 = $pagesObj->getpagenameexist1($row['int_glcode']);
                                        if ($pagecount1 > 0) {
                                            ?>
                                            <img border="0" style="margin-left:-55px;" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete_warning.png" title="This page has child pages so cannot be deleted." alt="delete_warning" id="<?php echo $row['int_glcode'] ?>">
                                            <?php
                                        } else if ($pagecount > 1) {
                                            ?>
                                            <img border="0"  style="margin-left:-55px;" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>delete_warning.png" title="This is the Main Module so can't be deleted." alt="delete_warning" id="<?php echo $row['int_glcode'] ?>">
                                        <?php } else { ?>
                                            <input name="chkgrow"  style="margin-left:-55px;" id="chkgrow" type="checkbox" value="<?php echo $row['int_glcode'] ?>" />
                                        <?php } ?>
                                    <?php } ?>

                                </td>
                            <?php } else { ?>
                                <td width="4%" align="center" valign="middle" class="grid-td-left">&nbsp;</td>
                            <?php } ?>
                            <?php if ($configObj->glSessionObj->value('admin_id') == '1') {
                                ?>
                                <!--<td width="2%" align="center" valign="middle" class="grid-td-left"><img id="star-<?= $row['int_glcode'] ?>" height="16" width="16" alt="remember me" title="<? echo $tool; ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $starimg ?>" style="vertical-align:middle;cursor:pointer;"onclick="UpdateStar('<?= DB_PREFIX ?>pages','chr_star','<?= $row['int_glcode'] ?>');"></td>-->
                            <?php } ?>
                            <?php
                            $createdate = strtotime($row['dt_createdate']);
                            $modifydate = strtotime($row['dt_modifydate']);
                            $days = $configObj->glLibraryObj->count_days($row['dt_createdate']);
                            $days_modified = $configObj->glLibraryObj->count_days($row['dt_modifydate']);
                            ?>
                            <td width="20%" align="left" valign="middle" class="grid-td-top">
                                <?php if ($paramMain['Edit'] == 'Y') { ?>
                                    <a href="<?= $pagesObj->urlwithpara; ?>&amp;action=edit&amp;eid=<?php echo $row['int_glcode']; ?>"><span><?= $row['treename'] ?></span></a>
                                    <?php
                                } else {
                                    echo $row['treename'];
                                }
                                ?>

                            </td>
                            <?php // if ($row['int_glcode'] == 1) { ?>
                            <td width="10%" align="left" valign="middle" class="grid-td-top">&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="index.php?module=banner"><image src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/photo-icon.gif"</a>
                            </td> 
                            <?php
//                            }
                            if ($row['int_glcode'] != 1) {
                                ?>
                                <td width="10%" align="left" valign="middle" class="grid-td-top">&nbsp;&nbsp;&nbsp;&nbsp;

            <!--<a href="index.php?module=pagephoto&tname=pages&fk_recid=<?= $row['int_glcode'] ?>&fk_modid=<?= $fk_modules ?>"><image src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/photo-icon.gif"</a>-->
                                </td> 
                            <?php }
                            ?>


                            <td width="10%" align="center" valign="middle" class="grid-td-top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <?php if ($row['int_glcode'] > 1) {
                                    ?>
                                    <input type="text" class="order" name="displayorder<?= $rowcount ?>" id="displayorder<?= $rowcount ?>"  onkeypress="return KeycheckOnlyNumeric(event);" value="<?= $row['int_displayorder'] ?>" maxlength="3" /><?php
                                } else {
                                    ?>
                                    <input type="hidden" name="displayorder<?= $rowcount ?>" id="displayorder<?= $rowcount ?>" value="<?= $row['int_displayorder'] ?>" />
                                <?php } ?>
                                <input type="hidden" name="hdndisplayorder<?= $rowcount ?>" id="hdndisplayorder<?= $rowcount ?>" value="<?= $row['int_displayorder'] ?>" />
                                <input type="hidden" name="hdnintglcode<?= $rowcount ?>" id="hdnintglcode<?= $rowcount ?>"  value="<?= $row['int_glcode'] ?>" />
                                <input type="hidden" name="hdncommonglcode<?= $rowcount ?>" id="hdncommonglcode<?= $rowcount ?>"  value="<?= $row['fk_pages'] ?>" />
                            </td>



                            <td width="10%" align="center" valign="middle" class="grid-td-top"><?php echo $row['int_pagehits']; ?></td>
                            <td width="10%" align="center" valign="middle" class="grid-td-top">&nbsp;
                                <?php if ($pagecount1 > 0) { ?>
                                    <img border="0" height="14" width="14" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>apply.png" title="This page has child pages so cannot be unpblish." alt="pulish_warning" id="<?php echo $row['int_glcode'] ?>">
                                <?php } else if ($pagecount > 1) { ?>
                                    <img border="0" height="14" width="14" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>apply.png" title="This is the Main Module so can't be deleted." alt="pulish_warning" id="<?php echo $row['int_glcode'] ?>">
                                <?php } else { ?>
                                    <a href="#"> <img id="tick-<?= $row['int_glcode'] ?>" height="16" width="16" alt="<?= $title ?>" title="<?= $title ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $tickimg ?>" style="vertical-align:middle;cursor:pointer;" onclick="UpdatePublish('<?= DB_PREFIX ?>pages', 'chr_publish', '<?= $row['int_glcode'] ?>', '');"> </a>
                                <?php } ?>
                            </td>




                        </tr>
                        <?php
                        $rowcount++;
                        $j++;
                    }
                } else {
                    ?>
                    <tr style="background-color: transparent;"   onmouseover="this.style.backgroundColor = '#f6f6f6'" onmouseout="this.style.backgroundColor = 'transparent'">
                        <td height="25" align="center" valign="middle" colspan="6" class="form_titles">No records are available.</td>
                    </tr>
                    <?
                }
                ?>
                <input type="hidden" name="ptrecords" id="ptrecords" value="<?= $rowcount ?>">
            </table>
        </div>
    </div>
    <div class="clear"></div>
    <?php echo $pagingBottom; ?>
    <?php
    if ($numofrows > 0) {
        if ($paramMain['Delete'] == 'Y') {
            ?>
            <div class="add-new-user-button" <?= $paramMain['Delete'] ?>><a href="#" 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>
