<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 album title.');
            document.getElementById('var_title').value = '';
            document.getElementById('var_title').focus();
            return false;
        }	
        if(trim(document.getElementById('var_alias').value) != "")
        {
            makeLowercase1('var_alias');
            var str=document.getElementById('var_alias').value;
            var RE=/ /i;
            if (str.match(RE)==' ')
            {
                alert("Alias is not Valid. Please remove space.");
                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;
            }
        }
        if(trim(document.getElementById('var_alias').value) == "")
        {
           makeLowercase1('var_title');

        }
        
        var text1=document.getElementById('var_alias').value;
        var len1=text1.length;
      
        if(len1 == 1)
        {
            alert("Alias should be greater then  one character.");
            document.getElementById('var_alias').focus();
            return false;
        }
        
        if(!checkingAlias('var_alias','<?= base64_encode("photoalbum") ?>','<?= base64_encode($_REQUEST['eid']) ?>','<?= base64_encode('int_glcode') ?>','pages'))
        {
            return false;
        }
        copytext();
        document.getElementById('h_save').value ='T';
        return true;
    }
    
    function auto_alias(){
        if(document.getElementById('var_title').value != '' && document.getElementById('var_alias').value == '')
        {
            makeLowercase1('var_title');
        }
    }

function makeLowercase1(field)
    {
        var str= trim(document.getElementById(field).value).toLowerCase();

        var temp = new String(str);
        temp =  temp.replace(/[^a-z A-Z 0-9 \-]+/g,'');
        var strlength = temp.length;
        for(i=0; i < strlength; i++)
        {
            var alias=temp.split(' ').join('-');
        }
        document.getElementById('var_alias').value = alias;
    }

    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.');
    }
//    function CountLeft2(field, count, max) 
//    {
//       
//        if (field.value.length > max)
//        {
//            field.value = field.value.substring(0, max);
//        }
//        else
//        {
//            count.value=max - field.value.length;
//        }
//    }
    
    function copytext()
    {
//        var maintext=trim(removeHTMLTags(CKEDITOR.instances.var_study.getData()));
        if(trim(document.getElementById('var_metatitle').value)=="")
        {
            document.getElementById('var_metatitle').value=trim(document.getElementById('var_title').value).substr(0, 64);
        }
//        CountLeft2(document.getElementById('var_metatitle'),document.frmcontact.metatitle_left,200);
        if(trim(document.getElementById('var_metakeyword').value)=="")
        {
            document.getElementById('var_metakeyword').value=trim(document.getElementById('var_title').value).substr(0, 64);
        }
//        CountLeft2(document.getElementById('var_metakeyword'),document.frmcontact.metakeyword_left,400);
        if(trim(document.getElementById('var_metadescription').value)=="")
        {
//            document.getElementById('var_metadescription').value=maintext.substr(0, 180);
            document.getElementById('var_metadescription').value=trim(document.getElementById('var_title').value).substr(0, 180);
        }
//        CountLeft2(document.getElementById('var_metadescription'),document.frmcontact.metadescription_left,400);
    }
</script>
<?php
$pageurl = "index.php?module=photoalbum";

    if ($_REQUEST['action'] == 'add') {
        $action = 'Add';
    } else {
         $var_title = '-' . ' ' . $row['var_title'];
        $action = 'Edit';
    }
?>
<div class="breadcrumbs"><a href="index.php">Home </a>&nbsp;>&nbsp; <a href="index.php?module=photoalbum"> Manage Photo Albums </a>&nbsp;>&nbsp; <span class="current"><?php echo $action; ?> Photo Album</span>  </div>
<div class="add-new-user-title">
    <h2><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>/add-new-user-icon.png"><?= ucwords($_REQUEST['action']) ?> Photo Album <?php echo $var_title; ?> </h2>
</div>
<form  name="frmphotoalbum"  id="frmphotoalbum" 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 type="hidden" name="hid_var_alias" id="hid_var_alias" value="<?= $row['var_alias'] ?>">
    <input type="hidden" name="flag_same_alias" id="flag_same_alias" value="">
    <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('asignicondisplay');" >

<?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';
    }
?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" valign="top" class="grid-td-left">Photo Album 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">Album Title: <span>(required)</span> </td>
                    <td width="724" 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>
                    <?php
                        if ($configObj->glSessionObj->value('admin_id') == '1' || DISPLAY_ALIAS == 'Y') {
                            $aliasarray = explode('$$', $row['var_alias']);
                            $alias = $aliasarray[0];
                        ?>
                        <tr>
                            <td width="20%" align="left" valign="top" class="add-new-user-text">Alias: <span>(auto)</span> </td>
                            <td width="724" align="left" colspan="2" class="add-new-user-text" valign="top"><input style="float:left; width:356px;" name="var_alias" type="text"  onblur="auto_alias();"  class="add-new-user-textarea" id="var_alias"   value="<?= $row['var_alias']; ?>" maxlength="250"  onkeypress="return KeycheckOnlyalias(event)"    />
                                <div class="fl contact-comment-new position-relative mgl5 mgt5">
                                    <span class="help-icon1"></span>
                                    <div class="contact-hint fl" style="width: 450px; height: 83px;"><?php echo GLOBAL_ALIAS_NOTE; ?></div>
                                </div>  
                                <a herf="javascript:;" style="float: left; margin: 10px 0px 0px 12px;cursor: pointer;"  onclick="checkingAlias('var_alias','<?= base64_encode("photoalbum") ?>','<?= base64_encode($row['int_glcode']) ?>','<?= base64_encode('int_glcode') ?>','pages');">Check Alias</a>
                                <br>
                                <div align="center" style="margin-top:-5px; margin-bottom:5px;"  id="aliasmsg" class=""></div>
                            </td>
                        </tr>
                    <?php } else { ?>
                        <input name="var_alias" type="hidden" class="add-new-user-textarea" id="var_alias" value="<?= $row['var_alias']; ?>" maxlength="255"  />
                    <?php } ?>
                <tr>
                    <td width="20%" align="left" valign="top" class="add-new-user-text">Image: <span>(required)</span></td>
                    <td width="724" align="left" valign="top" class="add-new-user-text">
                        <input type="file" name="var_image" id="var_image"  style="float: left"/>
                        <div  id="divdelbro" style="float: left">&nbsp;
                    <?php
                            $imagename = $row['var_image'];
                            $imagepath = '../upimages/photoalbum/images/';
                            $image = $imagepath . "thumb_" . $imagename;
                            if ($imagename != "") {
                            if (file_exists($image)) {
                    ?>
                    <a onClick="return hs.expand(this);"  style="text-decoration:none;" href="<?php echo "../upimages/photoalbum/images/thumb_" . trim($row['var_image']) ?>"><img  src="../upimages/photoalbum/images/thumb_<?= $row['var_image'] ?>" alt="View" width="30" height="30" border="0" align="absmiddle" id="myimage" />&nbsp;</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  echo '(' . PHOTO_ALBUM_WIDTH . 'px ' ?>  x  <?php echo '' . PHOTO_ALBUM_HEIGHT . 'px' . ')' ?>)</span>
                    </td></tr>
                <tr>
                    <td colspan="2"></td>
                </tr>
            </table>
        </div>
        
    </div>
     <div class="clear"></div>
        <?php if ($configObj->glSessionObj->value('admin_id') == '1' || (DISPLAY_SEO == 'Y')) { ?>
            <div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer" onClick="javascript:expandcollapsepanel('asignbannerseo');" >
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td align="left" valign="top" class="grid-td-left">SEO Information</td>
                    </tr>
                </table>
            </div>
            <div class="information-white-bg" id="asignbannerseo" style="display:none;">
                <div class="clear"></div>
                <div class="grid-list-inner-table-text">
                    <?php echo $configObj->glLibraryObj->seo_textdetails($row['var_metatitle'], $row['var_metakeyword'], $row['var_metadescription']); ?>
                </div>
            </div>
            <div class="clear"></div>
        <?php } else { ?>
            <input name="var_metatitle" type="hidden" id="var_metatitle" value="<?= $row['var_metatitle']; ?>" />
            <input name="var_metakeyword" type="hidden" id="var_metakeyword" value="<?= $row['var_metakeyword']; ?>" />
            <input type="hidden" id="var_metadescription" name="var_metadescription" value="<?= $row['var_metadescription']; ?>" />
        <?php } ?>
</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>
