<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_CSS_PATH; ?>bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_CSS_PATH; ?>bootstrap-ie6.min.css" />
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_CSS_PATH; ?>bootstrap-image-gallery.min.css" />
<link rel="stylesheet" type="text/css" href="<?php echo GLOBAL_ADMIN_CSS_PATH; ?>bootstrap-responsive.min.css" />

<link type="text/css" href="<?php echo SITE_PATH; ?>powerpanel/html/css/photogallery.css" rel="stylesheet" />
<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" src="<?php echo SITE_PATH; ?>powerpanel/html/js/jquery.dragsort-0.5.1.min.js"></script>
<script type="text/javascript" language="javascript">

     function share(id,albumid){
      
        $.ajax({
            type: "GET",
            url:"index.php" ,
            data: "module=photogallery&action=sharedata&ajax=Y&eid="+id+"&albumid="+albumid,
            async: false,
            success: function(result){
                //alert(result);
                $( "#modelpopup" ).html(result);
            }
        });
            
        $( "#modelpopup" ).dialog({            
            height:380,
            width:620,
            modal: true,
            buttons:{
                "Cancel": function() {
                    $(this).dialog( "close" );
                },
                "Push": function() {
					
                    var chked = false;
                    $('input:checkbox[name="fb[]"]:checked,input:checkbox[name="tw[]"]: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=photogallery&action=sharedata&ajax=Y&eid="+id+"&albumid="+albumid ,
                            data: postdata,
                            async: false,
                            success: function(result){
                                
                                if(trim(result)==1){
                                    alert("Photo are pushed successfully.");
                                }else{
                                    alert("Error.. Please try again.");
                                }
                                $( "#modelpopup" ).dialog( "close" );
                                window.location.reload();
                            }
                        });
                    }else{
                        alert(" Please select atleast one page.");
                        return false;
                    }
                }
            }
        });
    }

    function uploadphoto()
    {
        if(document.getElementById('varphotoname').value == '')
        {
            alert('Please upload the photo.');
            document.getElementById('varphotoname').focus();
            return false;
        }
        else if(document.getElementById('varphotoname').value != '' && !LimitAttach_Image(document.getElementById('varphotoname').value))
        {
            alert('Please upload only *.jpg, *.jpeg, *.png, *.bmp, *.gif');
            document.getElementById('varphotoname').focus();
            return false;
        }
        else
        {
            document.getElementById('QT').value = 10;
            
          
            document.frmPhoto.submit();
        }
        return true;
    }
    
    function facebookpopup(id){
        window.open("index.php?module=photogallery&action=fbalbum&fk_album="+id+"&ajax=Y",'target=_parent','width=600,height=600,top=175,left=450,right=200');
        window.focus();
    }
  
    function LimitAttach_Image(file)
    {
         var extArray = new Array(".jpg", ".png", ".bmp",".gif");
        allowSubmit = false;
        if (!file) return;
        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 chkvalid()
    {
        if(document.getElementById('varphotoname').value == '' && document.getElementById('hidvarphotoname').value == '' && document.getElementById('oldphotoimage').value== '')
        {
            alert('Please upload the photo.');
            document.getElementById('varphotoname').focus();
            return false;
        }
        if(document.getElementById('hidvarphotoname').value == '' && document.getElementById('oldphotoimage').value== '')
        {
            alert('Please upload the photo.');
            document.getElementById('upload').focus();
            return false;
        }
        else if(document.getElementById('varphotoname').value != '' && !LimitAttach_Image(document.getElementById('varphotoname').value))
        {
            alert('Please upload only *.jpg, *.jpeg, *.png, *.bmp, *.gif');
            document.getElementById('varphotoname').focus();
            return false;
        }
        else if(trim(document.getElementById('intdisplayorder').value) == '')
        {
            alert('Please enter the Display order.');
            document.getElementById('intdisplayorder').focus();
            return false;
        }
        else if(trim(document.getElementById('intdisplayorder').value) == 0)
        {
            alert('Please enter proper display order.');
            document.getElementById('intdisplayorder').value='';
            document.getElementById('intdisplayorder').focus();
            return false;
        }
        else
        {
            return true;
        }
    }
    
</script>

<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">
    $(document).ready(function(){
        var fk_album=document.getElementById('fk_album').value;
        $("#ajaxphotogallery").dragsort({
            dragSelector: "div",
            dragBetween: true,
            dragEnd: saveOrder,
            placeHolderTemplate: "<li class='placeHolder'><div class='backdrag'><table><tr><td align='center' valign='middle' width='241' height='255'>Drag Photo</td></tr></table></div></li>"
        });
        get_rec_photo(fk_album);
    });
    
    function saveOrder() {
        var rec_ID = document.getElementById('photoAlbumID').value;
        var dataid = $("#ajaxphotogallery li").map(function() { return $(this).attr('id'); }).get();
        set_photo_displayorder(rec_ID,dataid);
    }
    
    function set_photo_displayorder(fk_album,photointglcode)
    {
        var url = "index.php?module=photogallery&action=set_photo_displayorder&fk_album="+fk_album+"&photointglcode="+photointglcode;
        $.ajax({
            type: "GET",
            url: encodeURI(url),
            async: true,
            start : ProcessLoader(),
            success: function(data){
                get_rec_photo(fk_album);
                document.getElementById('dvprocessing').style.display = 'none';
            }
        });
    }
    
    function get_rec_photo(fk_album)
    {
       var url = "index.php?module=photogallery&action=photo_grid&fk_album="+fk_album;
        $.ajax({
            type: "GET",
            url: url,
            async: true,
            start : ProcessLoader(),
            success: function(data){
//                alert(data);
                if(trim(data) == 'invalid'){
                    document.getElementById('ajaxphotogallery').innerHTML = '';
                    window.location.href = "index.php?module=photogallery&fk_album="+fk_album;
                }
                else{
                    document.getElementById('ajaxphotogallery').innerHTML = trim(data);
                    document.getElementById('fk_album').value = fk_album;
                }
                document.getElementById('dvprocessing').style.display = 'none';
            }
        });
        if ( history.pushState )
        window.history.pushState( {}, document.title, "index.php?module=photogallery&fk_album="+fk_album);
}

function deletealbumphoto(photoID,fk_album,delete1)
{
    var fk_album=document.getElementById('fk_album').value;
    if(confirm("Are you sure you want to delete this photo?")){
        var url = "index.php?module=photogallery&action=delphoto&photoID="+photoID+"&fk_album="+fk_album+"&delete="+delete1;
        $.ajax({
            type: "GET",
            url: encodeURI(url),
            async: true,
            start : ProcessLoader(),
            success: function(data){
                get_rec_photo(fk_album);
                document.getElementById('dvprocessing').style.display = 'none';
                alert("Photo deleted successfully.");
            }
        });
    } else {
        return true;
    }
    return false;
}

function setpublish_unpublish(photoID,fk_album,publish)
{
    //alert(photoID+"+"+fk_album+"+"+publish);
    var url = "index.php?module=photogallery&action=set_publish&fk_album="+fk_album+"&photoID="+photoID+"&publish="+publish;
    $.ajax({
        type: "GET",
        url: encodeURI(url),
        async: true,
        start : ProcessLoader(),
        success: function(data){
            //                alert(data);
            get_rec_photo(fk_album);
            document.getElementById('dvprocessing').style.display = 'none';
        }
    });
}

function savealbumcaption(photoID,fk_album)
{
    //        alert("in");return false;
    var fk_album=document.getElementById('fk_album').value;
    if(confirm("Are you sure you want to change the photo title?")) {
        var photocaption = trim(document.getElementById('varphotocaption_'+photoID).value);
        var url = "index.php?module=photogallery&action=savealbumcaption&photoID="+photoID+"&fk_album="+fk_album+"&photocaption="+photocaption;
        $.ajax({
            type: "GET",
            url: encodeURI(url),
            async: true,
            start : ProcessLoader(),
            success: function(data){
                get_rec_photo(fk_album);
                document.getElementById('dvprocessing').style.display = 'none';
                if(data){
                    alert("Photo Title save successfully.");
                }
            }
        });
    } else {
        return true;
    }
    return false;
}
/// old code
 //   jQuery('#var_image').live('change', function() {
      
  //     $('#fileupload').submit();
//});
$(document).ready(function() {
    
   $('#var_image').bind('change', function() {
     jQuery('#fileupload').submit();
  });
  
 
  
});

</script>
<div class="breadcrumbs">
    <a href="index.php">Home</a>&nbsp;>&nbsp;
    <?php if ($_REQUEST['fk_album'] != '') { ?>
        <a href="index.php?module=photoalbum"> Manage Photo Albums</a> &nbsp;>&nbsp;&nbsp;
    <?php } ?>
    <span class="current">Add Photos</span>  </div>
<?php if ($_REQUEST['fk_album'] != '') { ?>
    <span style="float:right; margin-right:15px;margin-top:-15px; "><a href="index.php?module=photoalbum"><img src="<?= GLOBAL_ADMIN_IMAGES_PATH ?>back-button-blue.gif"></a></span>
<?php } ?>
<table>
    <tr><td width="25%">Select Album :</td> <td> <?php echo $photogalleryObj->get_albumcmb($_REQUEST['fk_album']); ?></td>
</table>
<h3 class="add_detail">Photos & Details</h3>
<html lang="en">
        <link rel="stylesheet" href="http://blueimp.github.io/cdn/css/bootstrap.min.css">
        <!-- Generic page styles -->
        <!--<link rel="stylesheet" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/css/photostyle.css">-->
        <!-- Bootstrap styles for responsive website layout, supporting different screen sizes -->
        <link rel="stylesheet" href="http://blueimp.github.io/cdn/css/bootstrap-responsive.min.css">
        <!-- Bootstrap CSS fixes for IE6 -->
        <!--[if lt IE 7]><link rel="stylesheet" href="http://blueimp.github.io/cdn/css/bootstrap-ie6.min.css"><![endif]-->
        <!-- Bootstrap Image Gallery styles -->
        <link rel="stylesheet" href="http://blueimp.github.io/Bootstrap-Image-Gallery/css/bootstrap-image-gallery.min.css">
        <!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
        <link rel="stylesheet" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/css/jquery.fileupload-ui.css">
        <!-- CSS adjustments for browsers with JavaScript disabled -->
        <noscript><link rel="stylesheet" href="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/css/jquery.fileupload-ui-noscript.css"></noscript>
            <form id="fileupload" action="<?php echo $frmaction ?>" method="POST" enctype="multipart/form-data">
                <noscript><input type="hidden" name="redirect" value="http://blueimp.github.io/jQuery-File-Upload/"></noscript>
                <input type="hidden" name="fk_album" id="fk_album" value="<?php echo $_REQUEST['fk_album']; ?>" />
                <div class="row fileupload-buttonbar">
                    <div class="span7" style="width:885px;">
                        <!-- The fileinput-button span is used to style the file input field as button -->
                        <span class="btn btn-success fileinput-button">
                            <i class="icon-plus icon-white"></i>
                            <span>Add Images...</span>
                            <input type="file" name="var_image[]" id="var_image" multiple="multiple">
                        </span>
                        <span class="fileupload-loading"></span> <br/>
                        The maximum file size for uploads is 5 MB (Maximum image file resolution is 3900 X 3900). Only image files (JPEG, JPG, GIF, PNG) are allowed.
                    </div>
                    <!-- The global progress information -->
                    <div class="span5 fileupload-progress fade">
                        <!-- The global progress bar -->
                        <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                            <div class="bar" style="width:0%;"></div>
                        </div>
                        <!-- The extended global progress information -->
                        <div class="progress-extended">&nbsp;</div>
                    </div>
                </div>
                <!-- The table listing the files available for upload/download -->
                <table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
            </form>
            <br>
        
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="additional_detail_content" style="padding: 1px;">
    <tr>
        <td width="100%">
            <div>
                <ul id="ajaxphotogallery" class="photo-drag"></ul>
                <input type="hidden" name="photoAlbumID" id="photoAlbumID" value="<?php echo $_REQUEST['fk_album']; ?>" />
            </div>
        </td>
    </tr>
</table>
    <!--<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>-->
    <script src="js/vendor/jquery.ui.widget.js"></script>
    <script src="http://blueimp.github.io/JavaScript-Templates/tmpl.min.js"></script>
    <script src="http://blueimp.github.io/JavaScript-Load-Image/load-image.min.js"></script>
    <script src="http://blueimp.github.io/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"></script>
    <script src="http://blueimp.github.io/cdn/js/bootstrap.min.js"></script>
    <script src="http://blueimp.github.io/Bootstrap-Image-Gallery/js/bootstrap-image-gallery.min.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.iframe-transport.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload-process.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload-image.js"></script>
<!--        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload-audio.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload-video.js"></script>-->
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload-validate.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/jquery.fileupload-ui.js"></script>
        <script src="<?php echo GLOBAL_ADMIN_JS_PATH; ?>upload/js/main.js"></script>
        <!--[if gte IE 8]><script src="js/cors/jquery.xdr-transport.js"></script><![endif]-->

</html>