<script type="text/javascript" src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>highslide/highslide-with-gallery.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() {
        document.getElementById("var_title").focus();
        $('#dt_startdate').datepicker({
            changeMonth: true,
            changeYear: true,
            minDate:0,
            dateFormat:'d/mm/yy'
        });

	
        $('#dt_expiredate').datepicker({
            changeMonth: true,
            changeYear: true,
            minDate:0,
            dateFormat:'d/mm/yy'
        });
    });
</script>
<script type="text/javascript">
    function validate()
    {
        if(document.getElementById('var_title').value=='')
        {
            alert('Please enter image title.');
            document.getElementById('var_title').focus();
            return false;
        }	
        if(document.getElementById('hidvar_photo').value=='')
        {
            if(document.getElementById('var_image').value=='')
            {
                alert('Please select file for upload.');
                document.getElementById('var_image').focus();
                return false;
            }
        }
        if(document.getElementById('var_image').value != "")
        {
            if(!LimitAttach(document.getElementById('var_image').value ))
            {
                alert("Please select proper file for upload.");
                document.getElementById('var_image').focus();
                return false;
            }
        }
             
        else if(chkObject('int_displayorder') && document.getElementById('int_displayorder').value == "")
        {
            alert("Please enter display order.");
            document.getElementById('int_displayorder').focus();
            return false;
        }
        
        else if(document.getElementById('int_displayorder').value == "0")
        {
            alert("Please enter valid display order.");
            document.getElementById('int_displayorder').focus();
            return false;
        }
        //        alert('mjs');
        document.getElementById('h_save').value ='T';
        return true;
    }

    function LimitAttach(file,id)
    {
        //alert(file);
        allowSubmit = false;
        if (!file) return false;

        var extArray = new Array(".jpg",".jpeg",".png",".bmp",".gif");

        while (file.indexOf("\\") != -1)
            file = file.slice(file.indexOf("\\") + 1);
        ext = file.slice(file.indexOf(".")).toLowerCase();
        for (var i = 0; i < extArray.length; i++) {
            if (extArray[i] == ext) { allowSubmit = true; break; }
        }
        if (allowSubmit) return true;
        else
            return false;
    }

    function fun_del_image(id,file)
    {
        document.getElementById('divdelbro').innerHTML='';
        document.getElementById('hidvar_photo').value='';
        alert('Image is deleted successfully');
        $.ajax({
            type: "GET",
            url: "index.php?module=productphotogallery&action=delphoto&ajax=Y&sid="+id+"&file="+file,
            async: true,
            success: function(data){
                // alert(data);
                if(parseInt(data)==1)
                {
                    document.getElementById('divdelbro').innerHTML='';
                    document.getElementById('hidvar_photo').value='';
                    alert('File is deleted successfully');
                }
                else
                {
                }
            }
        });
    }
    
    function chkObject (theVal)
    {
        if (document.getElementById(theVal) != null)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

</script>
<?php
$pageurl = "index.php?module=productphotogallery";
?>

<div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;&nbsp;>&nbsp;  <a href="index.php?module=productphotogallery">Gallery </a>&nbsp;>&nbsp; <a href="index.php?module=productphotogallery">Manage Photo Gallery</a>&nbsp;>&nbsp; <span class="current">Edit Photo</span>  </div>
<div class="add-new-user-title">
    <h2><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/add-new-user-icon.png">Edit Photo</h2>
</div>
<form  name="frmproductphotogallery"  id="frmproductphotogallery" action="<?= $frmaction ?>" method="post" onSubmit="return validate();" enctype="multipart/form-data" >
    <input name="h_save" type="hidden" id="h_save" value="F" />
    <input name="old_displayorder" type="hidden" id="old_displayorder" value="<?= $row['int_displayorder']; ?>" />
    <input name="hidvar_photo" type="hidden" id="hidvar_photo" value="<?= $row['var_image']; ?>" />
    <input name="hidvar_photos" type="hidden" id="hidvar_photos" value="<?= $row['var_image']; ?>" />
    <input name="hidchr_validthumb" type="hidden" id="hidchr_validthumb" value="<?= $row['chr_validthumb']; ?>" />
    <div class="web-booking-main"></div>
    <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer" onClick="javascript:expandcollapsepanel('asignbanner');" >
        <?php
        if ($row['int_displayorder'] != '') {
            $int_disporder = $row['int_displayorder'];
        } else {
            $int_disporder = '1';
        }
        if ($row['chr_publish'] != '') {
            $hidden_chr_publish = $row['chr_publish'];
        } else {
            $hidden_chr_publish = 'Y';
        }


        if ($_REQUEST['action'] == 'edit') {
            $sql = "UPDATE " . DB_PREFIX . "productphotogallery SET chr_read='Y' where int_glcode=" . $_REQUEST['eid'];
            $productphotogalleryObj->configObj->glDbObj->query($sql);
        }
        ?>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td align="left" valign="top" class="grid-td-left">Photo Uploading</td>
            </tr>
        </table>
    </div>
    <div class="clear"></div>
    <div class="grid-list-inner-table-text">
        <table  border="0" cellspacing="3" cellpadding="3">
            <tr>
                <td width="22%" align="left" valign="top" class="add-new-user-text"> Title : <span>(required)</span> </td>
                <td width="100" align="left" valign="top" class="add-new-user-text">
                    <input name="var_title" style="width:360px" type="text" class="add-new-user-textarea" id="var_title" value="<?= $row['var_title']; ?>" maxlength="100" tabindex="1" />
                </td>
            </tr>

            <tr>
                <td>
                    Photo Album
                </td> 
                <td>
                    <select name="album" id="album">
<?php
if (!empty($albumArr)) {
    foreach ($albumArr as $album) {
        ?>
                                <option value="<?php echo $album['int_glcode']; ?>" <?php echo $selected ?> ><?php echo $album['var_title']; ?></option>
                                <?php
                            }
                        }
                        ?>
                    </select>           
                </td>
            </tr>


            <tr>
                <td width="106" align="left" valign="top" class="add-new-user-text">File : <span>(required)</span></td>
                <td  align="left" valign="top" class="add-new-user-text">
                    <input type="file" name="var_image" id="var_image" size="44"></td>
                <td width="50%" align="left" valign="top">
                    <div  id="divdelbro" style="float: left">
                <?php
                $imagename = $row['var_image'];

                $imagepath = $productphotogalleryObj->configObj->currentModulePath . 'html/uploads/images/thumb/';
                $image = $imagepath . "thumb_" . $imagename;
                ?>


                        <a href="javascript:;" onclick="fun_del_image(<?= $row['int_glcode'] ?>,'<?= $row['var_image']; ?>');">Delete</a>
                        <a id="myimga" onClick="return hs.expand(this)" class="highslide" href="../upimages/productphotogallery/images/thumb/thumb_<?= $row['var_image']; ?>" > <img src="../upimages/productphotogallery/images/thumb/thumb_<?= $row['var_image']; ?>" alt="View" width="30" height="30" border="0" align="absmiddle" id="myimage" /> </a><br/>


                    </div>
                </td>
            </tr>

            <tr>
                <td colspan="2"></td>
            </tr>


        </table>
    </div>
    <div class="clear"></div>
    <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer" onClick="javascript:expandcollapsepanel('asignbannerdisplay');" >
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td align="left" valign="top" class="grid-td-left">Display Information</td>
            </tr>
        </table>
    </div>
    <div class="information-white-bg" id="asignicondisplay" >
        <div class="clear"></div>
        <div class="grid-list-inner-table-text">
            <table width="100%" border="0" cellspacing="3" cellpadding="3">
                  
<?php
if ($row['int_displayorder'] != '')
    $int_disporder = $row['int_displayorder'];
else
    $int_disporder = '1';
?>
                <tr>
                    <td width="236" align="left" valign="top" class="add-new-user-text">Display Order :<span>(required)</span></td>
                    <td colspan="2" align="left" valign="top">

                        <input type="hidden" name="old_displayorder" id="old_displayorder" value="<?= $int_disporder; ?>"/>
                        <input name="int_displayorder" type="text" class="date-textarea" id="int_displayorder" value="<?= $int_disporder; ?>" maxlength="50" onkeypress="return KeycheckOnlyNumeric(event);" />
                    </td>
                </tr>



                <tr>
                    <td height="30" align="left" valign="top" class="add-new-user-text">Publish :<span>(required)</span></td>
                    <td width="106" height="30" align="left" valign="middle" class="add-new-user-text2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="47%"><?php if ($row['chr_publish'] == 'Y') { ?>
                                        <input type="radio" name="chr_publish" id="chr_publishY" value="Y" checked="checked" class="form-rediobutton "/>
<?php } else { ?>
                                        <input type="radio" name="chr_publish" id="chr_publishY" value="Y"  checked="checked" class="form-rediobutton "/>
                                    <?php } ?>
                                    <a href="javascript:" onclick="if(document.getElementById('chr_publishY').checked!=true) document.getElementById('chr_publishY').checked=true;" style="text-decoration:none;"> Yes</a></td>
                                <td width="53%"><?php if ($row['chr_publish'] == 'N') { ?>
                                        <input name="chr_publish" type="radio" class="form-rediobutton " checked="checked" id="chr_publishN" value="N"    />
<?php } else { ?>
                                        <input name="chr_publish" type="radio" class="form-rediobutton " id="chr_publishN" value="N"  />
                                    <?php } ?>
                                    <a href="javascript:" onclick="if(document.getElementById('chr_publishN').checked!=true) document.getElementById('chr_publishN').checked=true;" style="text-decoration:none;"> No</a></td>
                            </tr>
                        </table></td>
                    <td width="864" align="left" valign="middle" class="add-new-user-text2"><img width="16" height="16" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>help.png" onmouseover="showDiv(event,'dvhlpvarwebsite')" onmouseout="hidediv('dvhlpvarwebsite');" alt="">
                        <div id="dvhlpvarwebsite" style=" z-index:99999; position: absolute;background-color: #d5ecfa;width: 400px;height:35px;padding: 10px;color:#0b336a;border: #95d0f2 2px solid;display: none;font-family:Tahoma, Arial, Verdana;font-size:13px;font-weight:bold;">Note : Please select 'Yes' if you want to display / activate this record. Otherwise please select 'NO'. </div></td>
                </tr>
            </table>
        </div>
    </div>
    <br/>
    <input border="0" type="image" hspace="5" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btnsaveande','','html/images//submit-button-blue-hover.gif',1)" src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/submit-button-blue.gif" alt="save-exit" id="btnsaveande" name="btnsaveande" value="1">
    <a href="<?= $productphotogalleryObj->urlwithpara ?>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image351','','<?= GLOBAL_ADMIN_IMAGES_PATH ?>/cancel-button-hover.jpg',1)">
        <img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/cancel-button.jpg" alt="Submit" name="Image351" border="0" id="Image351" />
    </a>
</form>
