<link rel="stylesheet" type="text/css" href="<?=base_url()?>js/shadowbox-3.0.3/shadowbox.css">
<script type="text/javascript" src="<?=base_url()?>js/shadowbox-3.0.3/shadowbox.js"></script>
<script type="text/javascript">
Shadowbox.init();
</script>

<script type="text/javascript" src="<?=base_url()?>js/jquery.form.js"></script>

				<!--<link rel="stylesheet" href="<?php echo base_url() ?>css/jquery.fileupload-ui.css">
				-->
				<script type="text/javascript">
					$(document).ready(function(){
						$('#tabs').tabs();
					});
				</script>
				
				<br/>
                <div class="breadcrumb ui-corner-tl ui-corner-tr" style="">
                <div  class="contenerNodeBreadcrumb"><img class="breadcrumbIcon" align="absmiddle"  src='<?php echo base_url();?>images/homePage.png' /> <a href="<?php echo base_url(); ?>">Administracja</a>
                </div>
                <img src="<?php echo base_url(); ?>images/breadcrumbSeparator.png" align="absmiddle" class="separatorBreadcrumb"  />
                <div class="contenerNodeBreadcrumb"><img class="breadcrumbIcon" align="absmiddle"  src='<?php echo base_url();?>images/asterisk_orange.png' /> <a href="<?php echo base_url(); ?>admin/baner">Baner</a>
                <img class="pointerBreadcrumb" src='<?php echo base_url();?>images/pointer_breadcrumb.png' /> 
                </div>
                
                
     
                </div>
                
				<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs" >
						<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
	
							<li class="ui-state-default ui-corner-top"><a href="#baner">Baner</a></li>
							<li class=" ui-corner-top"><a href="#ustawienia">Ustawienia</a></li>
						</ul>
						
						
						
						<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="baner">
							
							<script type="text/javascript">
							function showCoords(c)
							{
								
								$('#w').text(c.w);
								$('#h').text(c.h);

								$("#wytnijBaner form input[name=x]").attr("value", c.x);
								$("#wytnijBaner form input[name=y]").attr("value", c.y);
								$("#wytnijBaner form input[name=x2]").attr("value", c.x2);
								$("#wytnijBaner form input[name=y2]").attr("value", c.y2);
								$("#wytnijBaner form input[name=w]").attr("value", c.w);
								$("#wytnijBaner form input[name=h]").attr("value", c.h);
							};
							function successFunc(data)  { 
								//alert(data);
								$('#ajax-loader').html("");
								var base_url = "<?php echo base_url(); ?>";
								var i = Math.floor(Math.random()*100000);
					            

					            if(data != ''){
						        	$(".ui-overlay").attr("style", "display:block;");
									$("#wytnijBaner").dialog("open");
									$("#wytnijBaner #miejsceNaZdjecie").html("<img src='"+data+"'/>");
									jQuery("#wytnijBaner #miejsceNaZdjecie img").Jcrop({
										onChange: showCoords,
										onSelect: showCoords
									});
						        }

					            if(!$.browser.msie) $("#sortableBanerGlowny").html('Proszę czekać...').load(base_url+"admin/baner/"+i+" li.banerLi");
							}
							$(document).ready(function(){
								
								$("#baner_form input[name=change_size]").click(function(){
									$("#baner_szerokosc").toggle();
									var change_s;
					            	if ($('#baner_form input[name=change_size]').is(':checked')){
						            	change_s = 1;
					            	} else {
						            	change_s = 0;
					            	}
								});


								$('.plik_button').click(function(){
									$('form.upload input[name=plik]').click();
								});

								$('form.upload input[name=plik]').change(function(){
									
									var change_s;
					            	if ($('#baner_form input[name=change_size]').is(':checked')){
						            	change_s = 1;
					            	} else {
						            	change_s = 0;
					            	}
					            	//alert(change_s);
				                    
				                    $('form.upload input[name=header]').val($("#baner_form input[name=header]").val());
					            	$('form.upload input[name=link]').val($("#baner_form input[name=link]").val());
					            	$('form.upload input[name=foto_x]').val($("#baner_form input[name=foto_x]").val());
					            	$('form.upload input[name=foto_y]').val($("#baner_form input[name=foto_y]").val());
					            	$('form.upload input[name=user_id]').val($("#baner_form input[name=user_id]").val());
					            	$('form.upload input[name=change_size]').val(change_s);

					            	
									var options = { 
									        target:        '',   // target element(s) to be updated with server response 
									        dataType:	'html', 
									        success:	successFunc  // post-submit callback 
									 		//,
									 		//url: '<?=base_url()?>index.php/strona/tmp_logo'
									    }; 
									$("form.upload").ajaxSubmit(options);
				                    					                
									$('#ajax-loader').html("<img src='<?=base_url()?>images/ajax-loader.gif' />");
								});
								
																
							});
							</script>
							
							<form id="baner_form" action="<?php echo base_url(); ?>admin/addbanerglownyphoto" method="post" enctype="multipart/form-data">
							<table border="0" cellpadding="0" cellspacing="0" id="id-form">
								<tr><th>Nowe zdjęcie: </th></tr>
								<tr>
									<th valign="top" style="font-weight:normal;">Nagłówek:</th>
									<td><input type="text" class="inp-form" name="header" /></td>
									<td class="error-td">&nbsp;</td>
								</tr>
								<tr>
									<th valign="top" style="font-weight:normal;">Adres strony internetowej:</th>
									<td><input type="text" class="inp-form" name="link" /></td>
									<td class="error-td">&nbsp;</td>
								</tr>
								
								<tr><th><input type="checkbox" name="change_size"/> Zmień rozmiar zdjęcia:</th></tr>

								<input type="hidden" class="inp-form" name="foto_y" value="600" />
								
								<tr id="baner_szerokosc" style="display: none;">
								<th valign="top" style="font-weight: normal;">Szerokość (px):</th>
									<td><input type="text" class="inp-form" name="foto_x" value="800" /></td>
									<td class="error-td">&nbsp;</td>
								</tr>
								<tr>
								<th>Wybierz zdjęcia:</th>
								</tr>
							
								<tr><td >
								<input type="hidden" name="user_id" value="<?php echo $this->session->userdata('uzytkownik_id'); ?>" />
							
								</td >
			                    <td style="padding-left:0px;"></td>
			                     <td></td>
			                    </tr>
							</table>
							</form>
							
							<form class="upload" action="<?php echo base_url(); ?>admin/addbanerglownyphoto/1" method="POST" enctype="multipart/form-data">
								<input type="file" name="plik">
								
								<input type="hidden" name="description" value=""/>
								<input type="hidden" name="header" value=""/>
								<input type="hidden" name="link" value=""/>
								<input type="hidden" name="foto_x" value=""/>
								<input type="hidden" name="foto_y" value=""/>
								<input type="hidden" name="user_id" value=""/>
								<input type="hidden" name="change_size" value=""/>
								
								<!--<button>Upload</button>
								<div class="plik_button" style="cursor: pointer;"><img src="<?php echo base_url(); ?>images/image_add.png" align="absmiddle" />Dodaj zdjęcia</div>
							-->
							</form>		
							<br/><br/>
							<div id="ajax-loader"></div>
							<table class="upload_files"></table>
							<table class="download_files"></table>
							

							
							<br/><br/>
							
							<script type="text/javascript">
							$(document).ready(function(){
								
								$("form#baner_form").submit(function(){
									return false;
								});
								
			
								
								$("#edytujBanerFoto").dialog({ 
									autoOpen: false,
									//modal: true,
									width: 600,
									//position: [500,100],
									close: function(event, ui) {
										$(".ui-overlay").attr("style", "display:none;");
									},
									buttons:{
										"Anuluj": function(){
											$(this).dialog("close");
											$(".ui-overlay").attr("style","display:none;");
										},
										"Zapisz": function(){
											$(this).find("form input[type=submit]").click();
										}
									}
								});
			
								$("#wytnijBaner").dialog({
									autoOpen: false,
									width: 'auto',
									height: 400,
									close: function(){
										$(".ui-overlay").attr("style", "display:none;");
									},
									buttons:{
										"Anuluj": function(){
											$(this).dialog("close");
											$(".ui-overlay").attr("style","display:none;");
			
											$(this).find("form input[name=foto]").attr("value", "");
											$(this).find("form input[name=x]").attr("value", "");
											$(this).find("form input[name=y]").attr("value", "");
											$(this).find("form input[name=x2]").attr("value", "");
											$(this).find("form input[name=y2]").attr("value", "");
											$(this).find("form input[name=h]").attr("value", "");
											$(this).find("form input[name=w]").attr("value", "");
											$("#miejsceNaZdjecie").html('');
											if($.browser.msie) window.location.href="<?=base_url()?>admin/baner";
										},
										"Zapisz": function(){
											$(this).find("form input[name=foto]").attr("value", $(this).find("#miejsceNaZdjecie img").attr("src"));
											//$(this).find("form input[name=x]")
											
											$.post($(this).find("form").attr("action"), $(this).find("form").serialize(), function(data){
												//alert(data);
												var base_url = "<?php echo base_url(); ?>";
												$("#sortableBanerGlowny").html('Proszę czekać...').load(base_url+"admin/baner li.banerLi");
											});
			
											$(this).dialog("close");
											$(".ui-overlay").attr("style","display:none;");
			
											$(this).find("form input[name=foto]").attr("value", "");
											$(this).find("form input[name=x]").attr("value", "");
											$(this).find("form input[name=y]").attr("value", "");
											$(this).find("form input[name=x2]").attr("value", "");
											$(this).find("form input[name=y2]").attr("value", "");
											$(this).find("form input[name=h]").attr("value", "");
											$(this).find("form input[name=w]").attr("value", "");
											$("#miejsceNaZdjecie").html('');
											
											//$(this).find("form input[type=submit]").click();
											if($.browser.msie) window.location.href="<?=base_url()?>admin/baner";
										}
									}
								});
								
								$("button.edytujbaner").live('click', function(){
									//alert($(this).attr("id"));
									$("div#edytujBanerFoto form input[name=baner_id]").attr("value", $(this).attr("id"));
									//alert($(this).attr("id"));
									$.getJSON("<?php echo base_url(); ?>admin/getbanerglownydata/"
											+$(this).attr('id'),
										function(data){
											$("div#edytujBanerFoto form input[name=header]").attr("value", data.header);
											$("div#edytujBanerFoto form input[name=link]").attr("value", data.link);
			
											$(".ui-overlay").attr("style", "display:block;");
											$("#edytujBanerFoto").dialog("open");
										}
									);
								});
								
								function showCoords2(c)
								{
									/*$('#x').text(c.x);
									$('#y').text(c.y);
									$('#x2').text(c.x2);
									$('#y2').text(c.y2); */
									$('#w').text(c.w);
									$('#h').text(c.h);
			
									$("#wytnijBaner form input[name=x]").attr("value", c.x);
									$("#wytnijBaner form input[name=y]").attr("value", c.y);
									$("#wytnijBaner form input[name=x2]").attr("value", c.x2);
									$("#wytnijBaner form input[name=y2]").attr("value", c.y2);
									$("#wytnijBaner form input[name=w]").attr("value", c.w);
									$("#wytnijBaner form input[name=h]").attr("value", c.h);
								};
								
								$("button.wytnijbaner").live('click', function(){
									$(".ui-overlay").attr("style", "display:block;");
									$("#wytnijBaner").dialog("open");
									var file = $(this).parents(".banerLi").find("a").attr("href");
									$("#wytnijBaner #miejsceNaZdjecie").html("<img src='"+file+"'/>");
									jQuery("#wytnijBaner #miejsceNaZdjecie img").Jcrop({
										onChange: showCoords2,
										onSelect: showCoords2
									});
								});
							});
							</script>
							
							<script type="text/javascript" src="<?php echo base_url(); ?>js/submitDelete.js"></script>
							
							<div id="edytujBanerFoto" title="Edytuj opis zdjęcia" >
								<h2><strong>Edytuj opis zdjęcia</strong></h2>
								<form action="<?php echo base_url(); ?>admin/edytujbanerglowny" method="post">
									<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
									<tr>
										<th valign="top">Nagłówek:</th>
										<td><table><tr id="input-header">
											<td><input type="text" class="inp-form" name="header" /></td>
											<td class="">
											
											</td>
										</tr></table></td>
									</tr>
									<tr>
										<th valign="top">Adres strony internetowej:</th>
										<td><table><tr id="input-link">
											<td><input type="text" class="inp-form" name="link" /></td>
											<td class="">
											
											</td>
										</tr></table></td>
									</tr>
															
									</table>
									<input type="hidden" name="baner_id" value="" />
									<input type="hidden" name="user_id" value="<?= $this->session->userdata('uzytkownik_id') ?>" />
									<input style="display: none;" type="submit" value="Edytuj" />
								</form>
							</div>
							
							<div id="wytnijBaner" title="Wybierz fragment zdjęcia">
								<h2><strong>Wytnij fragment zdjęcia</strong></h2>
								<p>Wysokość: <span id="h"></span><br/>
								Szerokość: <span id="w"></span><p/>
								<p id="miejsceNaZdjecie"></p>
								<form method="post" action="<?=base_url()?>admin/cropbanerglowny">
									<input type="hidden" name="foto" />
									<input type="hidden" name="x" />
									<input type="hidden" name="y" />
									<input type="hidden" name="x2" />
									<input type="hidden" name="y2" />
									<input type="hidden" name="h" />
									<input type="hidden" name="w" />
									<input style="display: none;" type="submit" value="wytnij" />
								</form>
							</div>
							
							<ul id="sortableBanerGlowny">
							<?php if($photos && $photos->num_rows() > 0) { ?>
							
								<?php foreach($photos->result() as $baner) { ?>
									<li class="banerLi ui-state-default" id="baner_<?php echo $baner->ID_baner_glowny; ?>">
										<?php if(file_exists('foto/baner/'.$baner->baner_glowny_name)) { ?>
										<a href="<?php echo base_url().'foto/baner/'.$baner->baner_glowny_name; ?>" rel="shadowbox" >
											<div style="background: url('<?php echo base_url(); ?>foto/baner/<?php echo $baner->baner_glowny_name; ?>') no-repeat scroll 50% 50% transparent;">
											</div>
										</a>
										<?php } else { ?>
										<a href="<?php echo reduce_double_slashes(prep_url($adres).'/foto/baner/'.$baner->baner_glowny_name); ?>" rel="shadowbox" >
											<div style="background: url('<?php echo reduce_double_slashes(prep_url($adres)."/foto/baner/".$baner->baner_glowny_name); ?>') no-repeat scroll 50% 50% transparent;">
											</div>
										</a>
										<?php } ?>
										<p class="photoHeader"><?php echo $baner->baner_glowny_header; ?></p>
										<p class="photoHeader"><?php echo $baner->baner_glowny_link; ?></p>
										<button title="Edytuj zdjęcie"  class="edytujbaner button buttonLightGrey tooltip" id="<?php echo $baner->ID_baner_glowny; ?>"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/pencil.png" /></button>
										<button title="Wytnij fragment zdjęcia"  class="wytnijbaner button buttonLightGrey tooltip" id="<?php echo $baner->ID_baner_glowny; ?>"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/transform_crop.png" /></button>
										<form class="usunbaner" action="<?php echo base_url(); ?>admin/removebanerglownyphoto" method="post">
											<input type="hidden" name="id" value="<?php echo $baner->ID_baner_glowny; ?>" />
											<input type="hidden" name="name" value="<?php echo $baner->baner_glowny_name; ?>" />
											<input type="hidden" name="user_id" value="<?php echo $baner->baner_glowny_user_id; ?>" />
											
											<button title="Usuń zdjęcie" onclick ="this.submit" class="button buttonLightGrey tooltip"  value="" type="submit"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/bin.png" /></button>
										</form>
									</li>
								<?php } ?>
							
							<?php } ?>
							</ul> 
							<div class="clear"></div>
							
							
					</div>
					
					<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="ustawienia">
					<form action="<?=base_url()?>admin/banerglownyustawienia" method="post">
						<table border="0" cellpadding="0" cellspacing="0" id="id-form">
							
							<tr><th>Wyświetlanie baneru:</th></tr>
							<tr><td><label><input type="radio" name="checkbaner" value="1" <?php if($allpages == 1) echo 'checked'; ?>/> Wyświetlaj na każdej podstronie</label></td></tr>
							<tr><td><label><input type="radio" name="checkbaner" value="0" <?php if($allpages == 0) echo 'checked'; ?>/> Wyświetlaj tylko na stronie głównej</label></td></tr>
							<tr><td>&nbsp;</td></tr>
							<tr>
								<td align="left">  <a  style="margin-left:10px;" class=" button buttonBlack submit" ><img src="<?php echo base_url(); ?>images/add.png" />Zapisz</a>
								</td>
							</tr>
						</table>
					</form>
					</div>
					
				</div>
				

				
				
				<?php /* ?>
				<!--<script src="<?php echo base_url()?>js/jquery.fileupload.js"></script>
				<script src="<?php echo base_url()?>js/jquery.fileupload-ui.js"></script>-->
				<script>
				
				$(function () {
					var uploadCounter = 0,
			        onCompleteAll = function () {
						var base_url = "<?php echo base_url(); ?>";

			            $("#sortableBanerGlowny").html('Proszę czekać...').load(base_url+"admin/baner li.banerLi");
			        };
			        var uploadSequence = [];
			        uploadSequence.start = function (index) {
			            var next = this[index];
			            if (next) {
			                next();
			                this[index] = null;
			            }
			        };
			        function showCoords(c)
					{
						/*$('#x').text(c.x);
						$('#y').text(c.y);
						$('#x2').text(c.x2);
						$('#y2').text(c.y2); * /
						$('#w').text(c.w);
						$('#h').text(c.h);

						$("#wytnijBaner form input[name=x]").attr("value", c.x);
						$("#wytnijBaner form input[name=y]").attr("value", c.y);
						$("#wytnijBaner form input[name=x2]").attr("value", c.x2);
						$("#wytnijBaner form input[name=y2]").attr("value", c.y2);
						$("#wytnijBaner form input[name=w]").attr("value", c.w);
						$("#wytnijBaner form input[name=h]").attr("value", c.h);
					};
			        $('.upload').fileUploadUI({
			        	uploadTable: $('.upload_files'),
				        downloadTable: $('.download_files'),
				        buildUploadRow: function (files, index) {
				            var file = files[index];
				            return $(
				                '<tr>' +
				                '<td>' + file.name + '<\/td>' +
				                '<td class="file_upload_progress"><div><\/div><\/td>' +
				                '<td class="file_upload_cancel">' +
				                '<div class="ui-state-default ui-corner-all ui-state-hover" title="Anuluj">' +
				                '<span class="ui-icon ui-icon-cancel">Anuluj<\/span>' +
				                '<\/div>' +
				                '<\/td>' +
				                '<\/tr>'
				            );
				        					    				            
				        },
				        buildDownloadRow: function (file) {

					        if(file.img != ''){
					        	$(".ui-overlay").attr("style", "display:block;");
								$("#wytnijBaner").dialog("open");
								$("#wytnijBaner #miejsceNaZdjecie").html("<img src='"+file.img+"'/>");
								jQuery("#wytnijBaner #miejsceNaZdjecie img").Jcrop({
									onChange: showCoords,
									onSelect: showCoords
								});
					        }
				        	return $(   '<tr><td>' + file.name + '<\/td><td>&nbsp;-&nbsp;</td><td>'+file.message+'</td><\/tr>'   );
				            //<td>'+file.type+'<\/td><td>'+file.size+'<\/td>
				        },
				        onComplete: function (event, files, index, xhr, handler) {
				        	uploadSequence.start(index + 1);

					        uploadCounter = uploadCounter + 1;
				            if (uploadCounter === files.length) {
				                uploadCounter = 0;
				                //$("div#dodane_pliki").html('asd');
				                
				                onCompleteAll();
				            }
				            
				        },
				        onAbort: function (event, files, index, xhr, handler) {
				            handler.removeNode(handler.uploadRow);
				            uploadCounter = uploadCounter + 1;
				            if (uploadCounter === files.length) {
				                uploadCounter = 0;
				                onCompleteAll();
				            }
				            
				            uploadSequence[index] = null;
				            uploadSequence.start(index + 1);
								            
				        },
						beforeSend: function (event, files, index, xhr, handler, callBack) {
				        	
				            //handler.uploadRow.find('.file_upload_start').click(function () {
				            	var change_s;
				            	if ($('#baner_form input[name=change_size]').is(':checked')){
					            	change_s = 1;
				            	} else {
					            	change_s = 0;
				            	}
				            	//alert(change_s);
				                handler.formData = {
				                    description: handler.uploadRow.find('.file_upload_desc input').val(),
				                    header: $("#baner_form input[name=header]").val(),
				                    link: $("#baner_form input[name=link]").val(),
				                    foto_x: $("#baner_form input[name=foto_x]").val(),
				                    foto_y: $("#baner_form input[name=foto_y]").val(),
				                    user_id: $("#baner_form input[name=user_id]").val(),
				                    change_size: change_s
				                };
				                //callBack();
				            //});
			                uploadSequence.push(callBack);
				            if (index === 0) {
				                uploadSequence.splice(0, uploadSequence.length - 1);
				            }
				            if (index + 1 === files.length) {
				                uploadSequence.start(0);
				            }  
				            //callback();  
				        }
				    });
				});
				</script>
			
			<?*/?>
						
<!--<?php /*

 //backup, jakby trzeba było jednak wrócić do poprzedniego skryptu
 // admin/addbanerglownyphoto: echo $img.''; -> echo '{"name":"'.$n.'","message":"'.$message.'","img":"'.$img.'"}';
 
//				<link rel="stylesheet" href="<?php echo base_url() ?>css/jquery.fileupload-ui.css">
				<script type="text/javascript">
					$(document).ready(function(){
						$('#tabs').tabs();
					});
				</script>
				
				<br/>
                <div class="breadcrumb ui-corner-tl ui-corner-tr" style="">
                <div  class="contenerNodeBreadcrumb"><img class="breadcrumbIcon" align="absmiddle"  src='<?php echo base_url();?>images/homePage.png' /> <a href="<?php echo base_url(); ?>">Administracja</a>
                </div>
                <img src="<?php echo base_url(); ?>images/breadcrumbSeparator.png" align="absmiddle" class="separatorBreadcrumb"  />
                <div class="contenerNodeBreadcrumb"><img class="breadcrumbIcon" align="absmiddle"  src='<?php echo base_url();?>images/asterisk_orange.png' /> <a href="<?php echo base_url(); ?>admin/baner">Baner</a>
                <img class="pointerBreadcrumb" src='<?php echo base_url();?>images/pointer_breadcrumb.png' /> 
                </div>
                
                
     
                </div>
                
				<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs" >
						<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
	
							<li class="ui-state-default ui-corner-top"><a href="#baner">Baner</a></li>
							<li class=" ui-corner-top"><a href="#ustawienia">Ustawienia</a></li>
						</ul>
						
						
						
						<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="baner">
							
							<script type="text/javascript">
							$(document).ready(function(){
								$("#baner_form input[name=change_size]").click(function(){
									$("#baner_szerokosc").toggle();
									var change_s;
					            	if ($('#baner_form input[name=change_size]').is(':checked')){
						            	change_s = 1;
					            	} else {
						            	change_s = 0;
					            	}
								});
							});
							</script>
							
							<form id="baner_form" action="<?php echo base_url(); ?>admin/addbanerglownyphoto" method="post" enctype="multipart/form-data">
							<table border="0" cellpadding="0" cellspacing="0" id="id-form">
								<tr><th>Nowe zdjęcie: </th></tr>
								<tr>
									<th valign="top" style="font-weight:normal;">Nagłówek:</th>
									<td><input type="text" class="inp-form" name="header" /></td>
									<td class="error-td">&nbsp;</td>
								</tr>
								<tr>
									<th valign="top" style="font-weight:normal;">Adres strony internetowej:</th>
									<td><input type="text" class="inp-form" name="link" /></td>
									<td class="error-td">&nbsp;</td>
								</tr>
								
								<tr><th><input type="checkbox" name="change_size"/> Zmień rozmiar zdjęcia:</th></tr>

								<input type="hidden" class="inp-form" name="foto_y" value="600" />
								
								<tr id="baner_szerokosc" style="display: none;">
								<th valign="top" style="font-weight: normal;">Szerokość (px):</th>
									<td><input type="text" class="inp-form" name="foto_x" value="800" /></td>
									<td class="error-td">&nbsp;</td>
								</tr>
								<tr>
								<th>Wybierz zdjęcia:</th>
								</tr>
							
								<tr><td >
								<input type="hidden" name="user_id" value="<?php echo $this->session->userdata('uzytkownik_id'); ?>" />
							
								</td >
			                    <td style="padding-left:0px;"></td>
			                     <td></td>
			                    </tr>
							</table>
							</form>
							
							<form class="upload" action="<?php echo base_url(); ?>admin/addbanerglownyphoto/1" method="POST" enctype="multipart/form-data">
								<input type="file" name="plik" >
								<button>Upload</button>
								<div class=""><img src="<?php echo base_url(); ?>images/image_add.png" align="absmiddle" />Dodaj zdjęcia</div>
							</form>		
							<br/><br/>
							
							<table class="upload_files"></table>
							<table class="download_files"></table>
							
							<br/><br/>
							
							<script type="text/javascript">
							$(document).ready(function(){
								
								$("form#baner_form").submit(function(){
									return false;
								});
								
			
								
								$("#edytujBanerFoto").dialog({ 
									autoOpen: false,
									//modal: true,
									width: 600,
									//position: [500,100],
									close: function(event, ui) {
										$(".ui-overlay").attr("style", "display:none;");
									},
									buttons:{
										"Anuluj": function(){
											$(this).dialog("close");
											$(".ui-overlay").attr("style","display:none;");
										},
										"Zapisz": function(){
											$(this).find("form input[type=submit]").click();
										}
									}
								});
			
								$("#wytnijBaner").dialog({
									autoOpen: false,
									width: 'auto',
									height: 400,
									close: function(){
										$(".ui-overlay").attr("style", "display:none;");
									},
									buttons:{
										"Anuluj": function(){
											$(this).dialog("close");
											$(".ui-overlay").attr("style","display:none;");
			
											$(this).find("form input[name=foto]").attr("value", "");
											$(this).find("form input[name=x]").attr("value", "");
											$(this).find("form input[name=y]").attr("value", "");
											$(this).find("form input[name=x2]").attr("value", "");
											$(this).find("form input[name=y2]").attr("value", "");
											$(this).find("form input[name=h]").attr("value", "");
											$(this).find("form input[name=w]").attr("value", "");
											$("#miejsceNaZdjecie").html('');
										},
										"Zapisz": function(){
											$(this).find("form input[name=foto]").attr("value", $(this).find("#miejsceNaZdjecie img").attr("src"));
											//$(this).find("form input[name=x]")
											
											$.post($(this).find("form").attr("action"), $(this).find("form").serialize(), function(data){
												//alert(data);
												var base_url = "<?php echo base_url(); ?>";
												$("#sortableBanerGlowny").html('Proszę czekać...').load(base_url+"admin/baner li.banerLi");
											});
			
											$(this).dialog("close");
											$(".ui-overlay").attr("style","display:none;");
			
											$(this).find("form input[name=foto]").attr("value", "");
											$(this).find("form input[name=x]").attr("value", "");
											$(this).find("form input[name=y]").attr("value", "");
											$(this).find("form input[name=x2]").attr("value", "");
											$(this).find("form input[name=y2]").attr("value", "");
											$(this).find("form input[name=h]").attr("value", "");
											$(this).find("form input[name=w]").attr("value", "");
											$("#miejsceNaZdjecie").html('');
											
											//$(this).find("form input[type=submit]").click();
											
										}
									}
								});
								
								$("button.edytujbaner").live('click', function(){
									//alert($(this).attr("id"));
									$("div#edytujBanerFoto form input[name=baner_id]").attr("value", $(this).attr("id"));
									//alert($(this).attr("id"));
									$.getJSON("<?php echo base_url(); ?>admin/getbanerglownydata/"
											+$(this).attr('id'),
										function(data){
											$("div#edytujBanerFoto form input[name=header]").attr("value", data.header);
											$("div#edytujBanerFoto form input[name=link]").attr("value", data.link);
			
											$(".ui-overlay").attr("style", "display:block;");
											$("#edytujBanerFoto").dialog("open");
										}
									);
								});
								
								function showCoords2(c)
								{
									/*$('#x').text(c.x);
									$('#y').text(c.y);
									$('#x2').text(c.x2);
									$('#y2').text(c.y2); */
				
				/*
									$('#w').text(c.w);
									$('#h').text(c.h);
			
									$("#wytnijBaner form input[name=x]").attr("value", c.x);
									$("#wytnijBaner form input[name=y]").attr("value", c.y);
									$("#wytnijBaner form input[name=x2]").attr("value", c.x2);
									$("#wytnijBaner form input[name=y2]").attr("value", c.y2);
									$("#wytnijBaner form input[name=w]").attr("value", c.w);
									$("#wytnijBaner form input[name=h]").attr("value", c.h);
								};
								
								$("button.wytnijbaner").live('click', function(){
									$(".ui-overlay").attr("style", "display:block;");
									$("#wytnijBaner").dialog("open");
									var file = $(this).parents(".banerLi").find("a").attr("href");
									$("#wytnijBaner #miejsceNaZdjecie").html("<img src='"+file+"'/>");
									jQuery("#wytnijBaner #miejsceNaZdjecie img").Jcrop({
										onChange: showCoords2,
										onSelect: showCoords2
									});
								});
							});
							</script>
							
							<script type="text/javascript" src="<?php echo base_url(); ?>js/submitDelete.js"></script>
							
							<div id="edytujBanerFoto" title="Edytuj opis zdjęcia" >
								<h2><strong>Edytuj opis zdjęcia</strong></h2>
								<form action="<?php echo base_url(); ?>admin/edytujbanerglowny" method="post">
									<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
									<tr>
										<th valign="top">Nagłówek:</th>
										<td><table><tr id="input-header">
											<td><input type="text" class="inp-form" name="header" /></td>
											<td class="">
											
											</td>
										</tr></table></td>
									</tr>
									<tr>
										<th valign="top">Adres strony internetowej:</th>
										<td><table><tr id="input-link">
											<td><input type="text" class="inp-form" name="link" /></td>
											<td class="">
											
											</td>
										</tr></table></td>
									</tr>
															
									</table>
									<input type="hidden" name="baner_id" value="" />
									<input type="hidden" name="user_id" value="<?= $this->session->userdata('uzytkownik_id') ?>" />
									<input style="display: none;" type="submit" value="Edytuj" />
								</form>
							</div>
							
							<div id="wytnijBaner" title="Wybierz fragment zdjęcia">
								<h2><strong>Wytnij fragment zdjęcia</strong></h2>
								<p>Wysokość: <span id="h"></span><br/>
								Szerokość: <span id="w"></span><p/>
								<p id="miejsceNaZdjecie"></p>
								<form method="post" action="<?=base_url()?>admin/cropbanerglowny">
									<input type="hidden" name="foto" />
									<input type="hidden" name="x" />
									<input type="hidden" name="y" />
									<input type="hidden" name="x2" />
									<input type="hidden" name="y2" />
									<input type="hidden" name="h" />
									<input type="hidden" name="w" />
									<input style="display: none;" type="submit" value="wytnij" />
								</form>
							</div>
							
							<ul id="sortableBanerGlowny">
							<?php if($photos && $photos->num_rows() > 0) { ?>
							
								<?php foreach($photos->result() as $baner) { ?>
									<li class="banerLi ui-state-default" id="baner_<?php echo $baner->ID_baner_glowny; ?>">
										<?php if(file_exists('foto/baner/'.$baner->baner_glowny_name)) { ?>
										<a href="<?php echo base_url().'foto/baner/'.$baner->baner_glowny_name; ?>" target='blank' >
											<div style="background: url('<?php echo base_url(); ?>foto/baner/<?php echo $baner->baner_glowny_name; ?>') no-repeat scroll 50% 50% transparent;">
											</div>
										</a>
										<?php } else { ?>
										<a href="<?php echo reduce_double_slashes(prep_url($adres).'/foto/baner/'.$baner->baner_glowny_name); ?>" target='blank' >
											<div style="background: url('<?php echo reduce_double_slashes(prep_url($adres)."/foto/baner/".$baner->baner_glowny_name); ?>') no-repeat scroll 50% 50% transparent;">
											</div>
										</a>
										<?php } ?>
										<p class="photoHeader"><?php echo $baner->baner_glowny_header; ?></p>
										<p class="photoHeader"><?php echo $baner->baner_glowny_link; ?></p>
										<button title="Edytuj zdjęcie"  class="edytujbaner button buttonLightGrey tooltip" id="<?php echo $baner->ID_baner_glowny; ?>"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/pencil.png" /></button>
										<button title="Wytnij fragment zdjęcia"  class="wytnijbaner button buttonLightGrey tooltip" id="<?php echo $baner->ID_baner_glowny; ?>"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/transform_crop.png" /></button>
										<form class="usunbaner" action="<?php echo base_url(); ?>admin/removebanerglownyphoto" method="post">
											<input type="hidden" name="id" value="<?php echo $baner->ID_baner_glowny; ?>" />
											<input type="hidden" name="name" value="<?php echo $baner->baner_glowny_name; ?>" />
											<input type="hidden" name="user_id" value="<?php echo $baner->baner_glowny_user_id; ?>" />
											
											<button title="Usuń zdjęcie" onclick ="this.submit" class="button buttonLightGrey tooltip"  value="" type="submit"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/bin.png" /></button>
										</form>
									</li>
								<?php } ?>
							
							<?php } ?>
							</ul> 
							<div class="clear"></div>
							
							
					</div>
					
					<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="ustawienia">
					<form action="<?=base_url()?>admin/banerglownyustawienia" method="post">
						<table border="0" cellpadding="0" cellspacing="0" id="id-form">
							
							<tr><th>Wyświetlanie baneru:</th></tr>
							<tr><td><label><input type="radio" name="checkbaner" value="1" <?php if($allpages == 1) echo 'checked'; ?>/> Wyświetlaj na każdej podstronie</label></td></tr>
							<tr><td><label><input type="radio" name="checkbaner" value="0" <?php if($allpages == 0) echo 'checked'; ?>/> Wyświetlaj tylko na stronie głównej</label></td></tr>
							<tr><td>&nbsp;</td></tr>
							<tr>
								<td align="left">  <a  style="margin-left:10px;" class=" button buttonBlack submit" ><img src="<?php echo base_url(); ?>images/add.png" />Zapisz</a>
								</td>
							</tr>
						</table>
					</form>
					</div>
					
				</div>
				

				
				
				
				<script src="<?php echo base_url()?>js/jquery.fileupload.js"></script>
				<script src="<?php echo base_url()?>js/jquery.fileupload-ui.js"></script>
				<script>
				
				$(function () {
					var uploadCounter = 0,
			        onCompleteAll = function () {
						var base_url = "<?php echo base_url(); ?>";

			            $("#sortableBanerGlowny").html('Proszę czekać...').load(base_url+"admin/baner li.banerLi");
			        };
			        var uploadSequence = [];
			        uploadSequence.start = function (index) {
			            var next = this[index];
			            if (next) {
			                next();
			                this[index] = null;
			            }
			        };
			        function showCoords(c)
					{
						/*$('#x').text(c.x);
						$('#y').text(c.y);
						$('#x2').text(c.x2);
						$('#y2').text(c.y2); */
				
				/*
						$('#w').text(c.w);
						$('#h').text(c.h);

						$("#wytnijBaner form input[name=x]").attr("value", c.x);
						$("#wytnijBaner form input[name=y]").attr("value", c.y);
						$("#wytnijBaner form input[name=x2]").attr("value", c.x2);
						$("#wytnijBaner form input[name=y2]").attr("value", c.y2);
						$("#wytnijBaner form input[name=w]").attr("value", c.w);
						$("#wytnijBaner form input[name=h]").attr("value", c.h);
					};
			        $('.upload').fileUploadUI({
			        	uploadTable: $('.upload_files'),
				        downloadTable: $('.download_files'),
				        buildUploadRow: function (files, index) {
				            var file = files[index];
				            return $(
				                '<tr>' +
				                '<td>' + file.name + '<\/td>' +
				                '<td class="file_upload_progress"><div><\/div><\/td>' +
				                '<td class="file_upload_cancel">' +
				                '<div class="ui-state-default ui-corner-all ui-state-hover" title="Anuluj">' +
				                '<span class="ui-icon ui-icon-cancel">Anuluj<\/span>' +
				                '<\/div>' +
				                '<\/td>' +
				                '<\/tr>'
				            );
				        					    				            
				        },
				        buildDownloadRow: function (file) {

					        if(file.img != ''){
					        	$(".ui-overlay").attr("style", "display:block;");
								$("#wytnijBaner").dialog("open");
								$("#wytnijBaner #miejsceNaZdjecie").html("<img src='"+file.img+"'/>");
								jQuery("#wytnijBaner #miejsceNaZdjecie img").Jcrop({
									onChange: showCoords,
									onSelect: showCoords
								});
					        }
				        	return $(   '<tr><td>' + file.name + '<\/td><td>&nbsp;-&nbsp;</td><td>'+file.message+'</td><\/tr>'   );
				            //<td>'+file.type+'<\/td><td>'+file.size+'<\/td>
				        },
				        onComplete: function (event, files, index, xhr, handler) {
				        	uploadSequence.start(index + 1);

					        uploadCounter = uploadCounter + 1;
				            if (uploadCounter === files.length) {
				                uploadCounter = 0;
				                //$("div#dodane_pliki").html('asd');
				                
				                onCompleteAll();
				            }
				            
				        },
				        onAbort: function (event, files, index, xhr, handler) {
				            handler.removeNode(handler.uploadRow);
				            uploadCounter = uploadCounter + 1;
				            if (uploadCounter === files.length) {
				                uploadCounter = 0;
				                onCompleteAll();
				            }
				            
				            uploadSequence[index] = null;
				            uploadSequence.start(index + 1);
								            
				        },
						beforeSend: function (event, files, index, xhr, handler, callBack) {
				        	
				            //handler.uploadRow.find('.file_upload_start').click(function () {
				            	var change_s;
				            	if ($('#baner_form input[name=change_size]').is(':checked')){
					            	change_s = 1;
				            	} else {
					            	change_s = 0;
				            	}
				            	//alert(change_s);
				                handler.formData = {
				                    description: handler.uploadRow.find('.file_upload_desc input').val(),
				                    header: $("#baner_form input[name=header]").val(),
				                    link: $("#baner_form input[name=link]").val(),
				                    foto_x: $("#baner_form input[name=foto_x]").val(),
				                    foto_y: $("#baner_form input[name=foto_y]").val(),
				                    user_id: $("#baner_form input[name=user_id]").val(),
				                    change_size: change_s
				                };
				                //callBack();
				            //});
			                uploadSequence.push(callBack);
				            if (index === 0) {
				                uploadSequence.splice(0, uploadSequence.length - 1);
				            }
				            if (index + 1 === files.length) {
				                uploadSequence.start(0);
				            }  
				            //callback();  
				        }
				    });
				});
				</script>
			
			
						
						
				
				*/
 
 
 



?>						
				
				-->