<?php
$this->load_template('_header.php');
$this->load_template('_top.php');
?>
<script>
var txtloading = '<?php echo $this->lang('global_txtloading'); ?>';
var txtclose = '<?php echo $this->lang('global_txtclose'); ?>';
var txtnext = '<?php echo $this->lang('global_txt_next'); ?>';
var txtprevious = '<?php echo $this->lang('global_txt_prev'); ?>';
var txtof = '<?php echo $this->lang('global_txt_of'); ?>';
var txtloading = '<?php echo $this->lang('global_txtloading'); ?>';
var txt_norequest = '<?php echo $this->lang('global_txt_no_request') ?>';
var txt_msgalertdelete = '<?php echo $this->lang('dashboard_myalbums_txt_msgalertdelete') ?>';
</script>
<script type="text/javascript" src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME ?>/js/js_dashboard.js"></script>
<script type="text/javascript" src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME; ?>/js/jquery.magnific-popup.js"></script>
<div id="generalspace">
        
    <div id="container">
    
    	<div id="column1"><?php $this->load_template('_verticalmenu-dashboard.php'); ?></div>
        
        <div id="column2">
		
            <div id="dashboard2">

				<div class="boxdash">                    
    
                    <div class="title"><?php echo $this->lang('dashboard_myalbums_title'); ?></div>
                    
					<div class="spaceinfo">
                    
						<div><span class="linkblue2">&laquo; <a href="<?php echo $C->SITE_URL?>dashboard/myalbums"><?php echo $this->lang('dashboard_myalbums_txt_lback')?></a></span></div>
                    
                    	<div class="centered txtsize08 bold"><?php echo $D->namealbum?></div>
                        



						<?php if ($D->numphotos == 0) { ?>
                        
                        <div id="spacelink" class="mrg30B centered">
                            <div class="mrg20T txtsize00 mrg20B"><?php echo $this->lang('dashboard_myalbums_txt_albumempty'); ?></div>

							<div class="centered">
                            	<form id="newpost" name="form" action="<?php echo $C->SITE_URL?>addphotostoalbum" method="POST" enctype="multipart/form-data" target="my_iframe">
                            	<span id="bupload" class="bimageupload">
                                
                                	<input name="images_post[]" id="files_post" size="27" type="file" class="buploadimage" title="<?php echo $this->lang('dashboard_myalbums_txt_uploadimages');?>" multiple/>
                                
                                </span>
                                <input name="codea" type="hidden" id="codea" value="<?php echo $D->codalbum?>">
                                <input name="wsee" type="hidden" id="wsee" value="<?php echo $D->whosee?>">
                                </form>
                            </div>
                            <div class="centered mrg10T grey2"><span id="txtnumphotos">0</span> <span><?php echo $this->lang('dashboard_myalbums_msg_numselected');?></span></div>
                            <div id="msgerror" class="redbox2"></div>
                            <div class="centered mrg20T">
                            	<span id="iloader" class="hide"><img src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME; ?>/imgs/preload.gif"></span>
                            	<span id="bpostear" class="bblue hand"><?php echo $this->lang('dashboard_myalbums_txt_badd');?></span>
                            </div>
                            <div id="msgblock" class="centered txtsize00 mrg10T grey1"><span><?php echo $this->lang('dashboard_myalbums_msg_filesattime', array('#NUM#'=>$C->NUM_PHOTOS_BLOCK_UPLOAD));?></span></div>
                            
                        </div>
                        <iframe id="iframe_postear" name="iframe_postear" src="" style="display: none"></iframe>
                        
                        <?php } else { ?>
                        
						<div class="mrg15T">
							<div class="centered">
                            	<form id="newpost" name="form" action="<?php echo $C->SITE_URL?>addphotostoalbum" method="POST" enctype="multipart/form-data" target="my_iframe">
                            	<span id="bupload" class="bimageupload">
                                	<input name="images_post[]" id="files_post" size="27" type="file" class="buploadimage" title="<?php echo $this->lang('dashboard_myalbums_txt_uploadimages');?>" multiple/>
                                </span>
                                <input name="codea" type="hidden" id="codea" value="<?php echo $D->codalbum?>">
                                <input name="wsee" type="hidden" id="wsee" value="<?php echo $D->whosee?>">
                                </form>
                            </div>
							<div class="centered mrg10T grey2"><span id="txtnumphotos">0</span> <span>image(s) selected</span></div>
                            <div id="msgerror" class="redbox2"></div>
                            <div class="centered mrg20T">
                            	<span id="iloader" class="hide"><img src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME; ?>/imgs/preload.gif"></span>
                            	<span id="bpostear" class="bblue hand"><?php echo $this->lang('dashboard_myalbums_txt_badd');?></span>
                            </div>
                            <div id="msgblock" class="centered txtsize00 mrg10T grey1"><span><?php echo $this->lang('dashboard_myalbums_msg_filesattime', array('#NUM#'=>$C->NUM_PHOTOS_BLOCK_UPLOAD));?></span></div>
                        </div>
                        <iframe id="iframe_postear" name="iframe_postear" src="" style="display: none"></iframe>
                        
                        <div class="mrg20T mrg20B">
							<div id="gallery_<?php echo $D->codalbum?>">
								<?php echo $D->htmlPhotosAlbums?>
                            	<div id="moreitems"></div>
                            </div>
                            <div class="sh"></div>
                        </div>
                        
                        <?php } ?>
                        
						<script>
                            $("#gallery_<?php echo $D->codalbum?>").magnificPopup({
                              delegate: "a",
                              type: "image",
                              tLoading: txtloading + " #%curr%...",
                              mainClass: "mfp-img-mobile",
                              gallery: {
                                enabled: true,
                                navigateByImgClick: true,
                                preload: [0,1] // Will preload 0 - before current, and 1 after the current image
                              },
                              image: {
                                tError: "<a href=\"%url%\">The image #%curr%</a> could not be loaded.",
                                verticalFit: true
                              }
                            });
						</script>

						<script>
						$('#bpostear').click(function(){
							numfiles = parseInt($('#txtnumphotos').html());
							if (numfiles != 0) {
								document.getElementById("newpost").target = "iframe_postear";
								document.getElementById("newpost").submit();
								document.getElementById("msgblock").style.display = "none";
								document.getElementById("bpostear").style.display = "none";
								document.getElementById("iloader").style.display = "block";	
							} else {
								openandclose('#msgerror','<?php echo $this->lang('dashboard_myalbums_msg_noselected')?>',1700);
							}
						});
						
						function endPostear(resp){
							switch (resp.charAt(0)) {
								case '0':
									openandclose('#msgerror',resp.substring(3),1700);
									document.getElementById("iloader").style.display = "none";
									document.getElementById("msgblock").style.display = "block";
									$('#bpostear').show();
									break;
								case '1':
									self.location = siteurl + 'dashboard/myalbums/a:' + resp.substring(3);									
									break;
							}	
							return true;   
						}

						
						$(':file').change(function () {
							$('#txtnumphotos').text(this.files.length);
						});
						
                        $('#linkadd').click(function(){
                            $('#spacelink').slideUp('low',function(){
                                $('#formadd').slideDown('low');
                            });
                        })

                        $('#lcancelf').click(function(){
                            $('#formadd').slideUp('low',function(){
                                $('#spacelink').slideDown('low');
                            });
                        })
                        
                        var txt_error_namealbum='<?php echo $this->lang('dashboard_myalbums_error_namealbum')?>';
                        $('#bsave').click(function(){
                            createAlbum('#msgerror', '#msgok', '#formadd', '#bsave');
                            return false;
                        });

                        </script>
                        
                        
                        <?php if ($D->totalphotos>$D->numphotos) { ?>
                        
                        <div><input name="numitems" type="hidden" id="numitems" value="<?php echo $D->numphotos?>" /></div>
                        
                        <div id="moreitemsbar" class="mrg20T mrg30B">
                            <div class="centered">
                                <span id="bmore" class="bgrey2 rounded"><?php echo $this->lang('global_txt_moreitems')?></span>
                                <span id="morepreload" class="hide"><img src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME ?>/imgs/preload.gif" /></span>
                            </div>
                        </div>
                        <script>
                            var idu = <?php echo $this->user->id ?>;
                            var itemperpage = <?php echo $C->NUM_PHOTOS_PAGE ?>;
							var codalbum = '<?php echo $D->codalbum?>';
                            $('#bmore').click(function(){
                                reload_photosalbum_dashboard();
                                return false;
                            });
                        </script>
                
                        <?php } ?>

					</div>

				</div>

            </div>
        
        
        </div>
        
        <div id="divseparator" class="sh"></div>
        
        <div id="column3"><?php $this->load_template('_accessories-dashboard.php'); ?></div>
        
        <div class="sh"></div>
    
    </div>
            
</div>    

<?php
$this->load_template('_foot.php');
$this->load_template('_footer.php');
?>