<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
        }
    });
</script>
<script type="text/javascript">
    function validate()
    {
        if(trim(document.getElementById('var_title').value)=='')
        {
            alert('Please enter banner image title.');
            document.getElementById('var_title').value = '';
            document.getElementById('var_title').focus();
            return false;
        }	

        if(document.getElementById('hidvar_photo').value=='')
        {
            if(document.getElementById('var_image').value=='')
            {
                alert('Please upload image.');
                document.getElementById('var_image').focus();
                return false;
            }
        }
        if(document.getElementById('var_image').value != "")
        {
            if(!LimitAttach(document.getElementById('var_image').value ))
            {
                alert("Only .bmp, .gif, .jpg, .jpeg, .png Image formats are supported.");
                document.getElementById('var_image').focus();
                return false;
            }
        }
     
        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.lastIndexOf(".")).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_image1()
    {
        document.getElementById('divdelbro').innerHTML='';
        document.getElementById('hidvar_photo').value='';
        alert('Image is deleted successfully.');
    }
</script>
<?php
$pageurl = "index.php?module=photogallery";
?>
<?php
if ($_REQUEST['action'] == 'add') {
    $action = 'Add';
} else {
    $action = 'Edit';
}
?>
<div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp;<a href="index.php?module=pages"> Manage Pages </a>&nbsp;>&nbsp; <a href="index.php?module=pagephoto&fk_recid=<?= $_REQUEST['fk_recid'] ?>&fk_modid=<?= $_REQUEST['fk_modid'] ?>"> Banner Gallery </a>&nbsp;>&nbsp; <span class="current"><?php echo $action; ?> Banner Image</span>  </div>
<div class="add-new-user-title">
    <h2><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/add-new-user-icon.png"><?= ucwords($_REQUEST['action']) ?> Banner Image (<?= $photogalleryObj->getpagename($_REQUEST['fk_recid']) ?>)</h2>
</div>
<form  name="frmphotogallery"  id="frmphotogallery" 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_photo1" type="hidden" id="hidvar_photo1" 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 . "pagephoto SET chr_read='Y' where int_glcode=" . $_REQUEST['eid'];
    $photogalleryObj->configObj->glDbObj->query($sql);
}
?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" valign="top" class="grid-td-left">Banner Information</td>
        </tr>
    </table>
    </div>
    <div class="clear"></div>
    <div class="information-white-bg" id="asignicondisplay" >
        <div class="clear"></div>
        <div class="grid-list-inner-table-text">
            <table  border="0" cellspacing="3" cellpadding="3">
                <tr>
                    <td width="20%" align="left" valign="top" class="add-new-user-text">Banner Image 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 width="12%" align="left" valign="top" class="add-new-user-text">Image : <span>(required)</span></td>
                    <td width="46%" align="left" valign="top">
                        <input type="file" name="var_image" id="var_image" class="mgl15" style="float: left"/>
                        <div  id="divdelbro" style="float: left">&nbsp;
                    <?php
                            $imagename = $row['var_image'];
                            $imagepath = '../upimages/pagephoto/images/';
                            $image = $imagepath . "thumb_" . $imagename;
                            if ($imagename != "") {
                            if (file_exists($image) && $row['chr_validthumb'] == 'Y') {
                    ?>
                    <a onClick="return hs.expand(this);"  style="text-decoration:none;" href="<?php echo "../upimages/pagephoto/images/thumb_" . trim($row['var_image']) ?>"><img  src="../upimages/pagephoto/images/thumb_<?= $row['var_image'] ?>" alt="View" width="30" height="30" border="0" align="absmiddle" id="myimage" />&nbsp;</a>
                            <a href="javascript:;" onclick="return fun_del_image1();">&nbsp;Delete</a>
                        <?php } else { ?> &nbsp;
                <?php } } else { ?>
                                <br/><div ><span class="mgl15">(Only .bmp, .gif, .jpg, .jpeg, .png Image Formats are supported.)</span></div>
                            <?php } ?>
                        </div>
                        <span class="fl mgt5 mgl10"> &nbsp;(Required Size : <?php if ($_REQUEST['fk_recid'] == 1) {
            echo '(' . HOME_BANNER_WIDTH . 'px ' ?>  x  <?php echo HOME_BANNER_HEIGHT . 'px' . ')'; ?> <?php } else {
            echo '(' . INNERBANNER_WIDTH . 'px ' ?>  x  <?php echo '' . INNERBANNER_HEIGHT . 'px' . ')' ?><?php } ?>)</span>
                    </td></tr>
                <tr>
                    <td colspan="2"></td>
                </tr>
            </table>
        </div>
    </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="<?= $photogalleryObj->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>
