<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" />
<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
        }
    });
    
     function share(id){
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=photoalbum&action=sharedata&ajax=Y&eid="+id,
            async: false,
            success: function(result){
                //alert(result);
                $( "#modelpopup" ).html(result);
            }
        });
            
        $( "#modelpopup" ).dialog({            
            height:400,
            width:700,
            modal: true,
            buttons:{
                "Cancel": function() {
                    $(this).dialog( "close" );
                },
                "Push": function() {
					
                    var chked = false;
                    $('input:checkbox[name="fb[]"]:checked,input:checkbox[name="tw[]"]:checked,input:checkbox[name="gl[]"]:checked').each(function(k,v){
                        chked = true;
                    });
                    if ($('#var_title').val()=='')
                        {
                         alert('Please Enter title');
                         return false;
                        }
                    if ($('#var_short_description').val()=='')
                        {
                         alert('Please Enter description');
                         return false;
                        }
					
                    if(chked){
                        var postdata=$("#frmshareoption").serialize();
                        $.ajax({
                            type: "POST",
                            url:"index.php?module=photoalbum&action=sharedata&ajax=Y&eid="+id ,
                            data: postdata,
                            async: false,
                            success: function(result){
//                                alert(result)
                                if(trim(result)==1){
                                    alert("Photoalbum pushed successfully.");
                                }else{
                                    alert("Error.. Please try again.");
                                }
                                $( "#modelpopup" ).dialog( "close" );
                                window.location.reload();
                            }
                        });
                    }else{
                        alert(" Please select atleast one page.");
                        return false;
                    }
                }
            }
        });
    }
    function sharemutiple(){
        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;
            }
        }
        if(countChecked == 0){
            alert(" Please select atleast one record to be push.");
            return false;
        }
        // alert(ids);
        share(ids);
    }
</script>
<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('<?= $photogalleryObj->urlwithpara . '&flag=u' ?>','gridbody','D','chkgrow');
    }
</script>
<div id="modelpopup" title="Share on Facebook & Twitter"></div>
<div class="highslide-html-content" id="person_info">
    <div class="highslide-header">
        <ul>
            <li class="highslide-close">
                <a href="#" onclick="return hs.close(this)"></a>
            </li>
        </ul>
    </div>
</div>
<div class="web-booking-main" id="gridbody">
    <div class="breadcrumbs"><a href="index.php">&nbsp;Home</a>&nbsp;&nbsp;>  <span class="current">Manage Photo Albums </span>  </div>
    <div class="clear"></div>
    <?= $messagebox; ?>
    <?php echo $headerpanel; ?>
    <?php echo $pagingTop; ?>
    <?= $notemessagebox ?>
    <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" valign="middle" class="grid-td-left"><input name="chkall" id="chkall" type="checkbox" onclick="checkall('chkgrow')"  /></td>
                <td width="30%" align="left" valign="middle" class="grid-td-top">
                    <a href="javascript:;" onclick="SendGridBindRequest('<?= $photogalleryObj->urlwithoutsort ?>&orderby=var_title&sorting=Y','gridbody','ST')">Album Title<?= $setsortimgvar_title ?></a>
                </td>
                <td width="20%" align="center" valign="middle" class="grid-td-top"style="padding-left:0px;">Album Image</td>
                <td width="10%" align="center" valign="middle" class="grid-td-top"style="padding-left:0px;">View Photos</td>

                <td width="12%" align="center" valign="middle" class="grid-td-top" ><a onclick="SendGridBindRequest('<?= $photogalleryObj->urlwithoutsort ?>&orderby=chr_publish&sorting=Y','gridbody','ST')">Publish<?= $setsortimgchr_publish ?></a></td>
                 <td width="10%" align="center" valign="middle" class="grid-td-top">
                    Share                
                </td>   
            </tr>
        </table>
    </div>

    <div class="information-white-bg" id="dvpersonalinformation" style="margin-right: 2px;">
        <div class="clear"></div>
        <input type="hidden" value="photoalbum" name="hdnmodule" id="hdnmodule">
        <div class="grid-list-inner-table-text">
            <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";
                        $tickimg = ($row['chr_publish'] == 'Y') ? "tick.png" : "tick_cross.png";
                        $checked = ($row['chr_defaultimage'] == 'Y') ? "checked" : "";
                        $shareimg = "1-push.png";
                        ?>
                        <?php $count=$photogalleryObj->countphoto($row['int_glcode']);?>
                        <tr id="gtr-<?= $row['int_glcode'] ?>"  style="background-color: transparent;"  class="<?= $clsname ?>" onmouseover="this.style.backgroundColor='#f6f6f6'" onmouseout="this.style.backgroundColor='transparent'" >
                            <td width="3%" align="left" valign="middle" class="grid-td-left">
                            <?php if($count ==0) { ?>
                                <input name="chkgrow" id="chkgrow" type="checkbox" value="<?php echo $row['int_glcode'] ?>" />
                            <?php } else { ?>
                                 <img border="0" src="<?=GLOBAL_ADMIN_IMAGES_PATH?>/dialog-warning1.png" onmouseout="hidediv('dvhlpvarwebsite<?=$rowcount?>');" onmouseover="showDiv(event,'dvhlpvarwebsite<?=$rowcount?>')" alt="not delete" id="<?php echo $row['int_glcode']?>">
                                    <div style="z-index: 99999; position: absolute; background-color: rgb(213, 236, 250); width: 380px; height: 16px; padding: 10px; color: rgb(11, 51, 106); border: 2px solid rgb(149, 208, 242); font-family: Tahoma,Arial,Verdana; font-size: 13px; font-weight: bold; display: none;" id="dvhlpvarwebsite<?=$rowcount?>">
                                     There are some photo(s) in this album so can't be deleted.
                                    </div>
                            <?php } ?>    
                            </td>
                            <td width="30%" align="left" valign="middle" class="grid-td-top">
                                <a href="index.php?module=photoalbum&action=edit&eid=<?= $row['int_glcode'] ?>" ><?= $row['var_title']; ?></a>
                            </td>
                            <td width="20%" align="center" valign="middle" class="grid-td-top">
                                <?php if (file_exists("../upimages/photoalbum/images/thumb_" . trim($row['var_image']))) { ?>
                                    <a onClick="return hs.expand(this);" href="<?php echo "../upimages/photoalbum/images/thumb_" . trim($row['var_image']) ?>">
                                        <img border="0" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/photo-gallery-icon.png" >
                                    </a>
                                <?php } ?>
                            </td>
                            
                            <td width="10%" align="center" valign="middle" class="grid-td-top"><a href="index.php?module=photogallery&amp;fk_album=<?= $row["int_glcode"] ?>">View & Add (<?php echo $count;?>)</a></td>

                            <td width="12%" align="center" valign="middle" class="grid-td-top">
                                <?php
                                if ($row['chr_publish'] == 'Y') {
                                    $publishtext = "Hide me";
                                } else {
                                    $publishtext = "Publish me";
                                }
                                ?>
                                <a href="javascript:;">
                                    <img id="tick-<?= $row['int_glcode'] ?>" height="16" width="16" alt="publish me" title="" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $tickimg ?>" style="vertical-align:middle;cursor:pointer;" onclick="UpdatePublish_modulewise('<?= DB_PREFIX ?>photoalbum','chr_publish','<?= $row['int_glcode'] ?>','','photoalbum');">
                                </a>
                            </td>
                            
                            <td  id="push_<?=$row['int_glcode']?>" width="10%" align="center" valign="middle" class="grid-td-top" >
                                <?php
                                if ($row['chr_publish'] == 'Y')
                                    { ?>
                                        <img id="shar-<?= $row['int_glcode'] ?>" height="25" width="77" alt="<?= $title . "share" ?>" title="<?= $title . " is share." ?>" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?><?= $shareimg ?>" style="vertical-align:middle;cursor:pointer;<?= $display ?>" onclick="share(<?= $row['int_glcode'] ?>);">
                                  <?php  }
                                    else
                                    {
                                        echo "N/A";
                                    }
                                ?>
                            </td>
                            
                        </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 records are available.</td>
                    </tr>
<?php } ?>
                <input type="hidden" name="ptrecords" id="ptrecords" value="<?= $rowcount ?>">
            </table>
        </div>
    </div>
    <div class="clear"></div>
<?php echo $pagingBottom;

if ($numofrows > 0) {
    ?>
        <div 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> 