<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">
				-->
				<div class="breadcrumb ui-corner-tl ui-corner-tr">
                <div style="float:left; position:relative;"><img class="breadcrumbIcon" align="absmiddle"  src="<?php echo base_url();?>images/homePage.png" /><a href="<?php echo base_url(); ?>">Strona WWW</a><img src="<?php echo base_url(); ?>images/breadcrumbSeparator.png" align="absmiddle" style="" /></div>
                <?php
				$counter = count($parents);
				$count = 1;
				$lastNode = null;
				 foreach($parents as $node){
					 
					echo '<div class="contenerNodeBreadcrumb"><img src='.base_url().'images/newspaper.png align="absmiddle" class="breadcrumbIcon"><a href="'.base_url().'admin/wyswietl/'.$node->id.'">'.truncate($node->nodeData['name']).'</a>';
				//	if($counter==$count) echo '<img style="position:absolute; left:40%; top:32px;" src='.base_url().'images/pointer_breadcrumb.png /> ';
				
					echo '</div><img src="'.base_url().'images/breadcrumbSeparator.png"  align="absmiddle"  class="separatorBreadcrumb" />'; 
				 $count++;
				 $lastNode = $node;
				 } 
				 echo '<div class="contenerNodeBreadcrumb"><img src="'.base_url().'images/brick_mini.png" align="absmiddle" class="breadcrumbIcon" /><a  href="'.base_url().'admin/module/'.$this->uri->segment(3).'">'.truncate($module->modules_name).'</a> <img class="pointerBreadcrumb" src='.base_url().'images/pointer_breadcrumb.png /></div>';
				?>
                <a href="<?php echo base_url()?>admin/wyswietl/<?php echo $lastNode->id ?>"><img src="<?=base_url(); ?>images/back_cms_main.png" border="0" style="float:right;"></a>
                </div>
                
				<br/>
				<script type="text/javascript">
		        function showCoords(c)
				{
					$('#w').text(c.w);
					$('#h').text(c.h);

					$("#wytnijSlider form input[name=x]").attr("value", c.x);
					$("#wytnijSlider form input[name=y]").attr("value", c.y);
					$("#wytnijSlider form input[name=x2]").attr("value", c.x2);
					$("#wytnijSlider form input[name=y2]").attr("value", c.y2);
					$("#wytnijSlider form input[name=w]").attr("value", c.w);
					$("#wytnijSlider 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);
					var modId = "<?php echo $this->uri->segment(3); ?>";

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

		            if(!$.browser.msie) $("#sortableSlider").html('Proszę czekać...').load(base_url+"admin/module/"+modId+" li.sliderLi");
				}
				$(document).ready(function(){
					$("#slider_form input[name=change_size]").click(function(){
						$("#slider_szerokosc").toggle();
						var change_s;
		            	if ($('#slider_form input[name=change_size]').is(':checked')){
			            	change_s = 1;
		            	} else {
			            	change_s = 0;
		            	}
						//alert(change_s);
					});
					
					$('form.upload input[name=plik]').change(function(){
						var change_s;
		            	if ($('#slider_form input[name=change_size]').is(':checked')){
			            	change_s = 1;
		            	} else {
			            	change_s = 0;
		            	}
	                    
		            	$('form.upload input[name=header]').val($("#slider_form input[name=header]").val());
		            	$('form.upload input[name=foto_x]').val($("#slider_form input[name=foto_x]").val());
		            	$('form.upload input[name=foto_y]').val($("#slider_form input[name=foto_y]").val());
		            	$('form.upload input[name=module_id]').val($("#slider_form input[name=module_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="slider_form" action="<?php echo base_url(); ?>admin/addsliderphoto" 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><input type="checkbox" name="change_size"/> Zmień rozmiar zdjęcia:</th></tr>
					<!--<tr>
					<th valign="top" style="font-weight:normal;">Wysokość (px):</th>
						<td><input type="text" class="inp-form" name="foto_y" value="600" /></td>
						<td class="error-td">&nbsp;</td>
					</tr>-->
					<input type="hidden" class="inp-form" name="foto_y" value="600" />
					
					<tr id="slider_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>
						<!--<td><input type="FILE" class="file_1" name="plik" /></td>
						<td>&nbsp;</td>-->
					</tr>
				
					<tr><td >
					<input type="hidden" name="module_id" value="<?php echo $this->uri->segment(3); ?>" />
				
					</td >
                    <td style="padding-left:0px;">   
                    	<!--<a style="margin-left:10px;" class="submit button buttonBlack "><img src="<?php echo base_url(); ?>images/buttons/disc.png" />Zapisz</a>
                    --></td>
                     <td></td>
                    </tr>
				</table>
				</form>	
				<form class="upload" action="<?php echo base_url(); ?>admin/addsliderphoto/1" method="POST" enctype="multipart/form-data">
					<input type="file" name="plik" >
					<!-- 
                    -->
                    
                    <input type="hidden" name="header" value="" />
                    <input type="hidden" name="foto_x" value="" />
                    <input type="hidden" name="foto_y" value="" />
                    <input type="hidden" name="module_id" value="" />
                    <input type="hidden" name="change_size" value="" />
					
					<!--<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#slider_form").submit(function(){
						return false;
					});
					

					
					$("#edytujSliderFoto").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();
							}
						}
					});

					$("#wytnijSlider").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/module/<?=$this->uri->segment(3)?>";
							},
							"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(); ?>";
							        var modId = "<?php echo $this->uri->segment(3); ?>";
									$("#sortableSlider").html('Proszę czekać...').load(base_url+"admin/module/"+modId+" li.sliderLi");
								});

								$(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/module/<?=$this->uri->segment(3)?>";
							}
						}
					});
					
					$("button.edytujbaner").live('click', function(){
						//alert($(this).attr("id"));
						$("div#edytujSliderFoto form input[name=slider_id]").attr("value", $(this).attr("id"));
						//alert($(this).attr("id"));
						$.getJSON("<?php echo base_url(); ?>admin/getsliderdata/"
								+$(this).attr('id'),
							function(data){
								$("div#edytujSliderFoto form input[name=header]").attr("value", data.header);

								$(".ui-overlay").attr("style", "display:block;");
								$("#edytujSliderFoto").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);

						$("#wytnijSlider form input[name=x]").attr("value", c.x);
						$("#wytnijSlider form input[name=y]").attr("value", c.y);
						$("#wytnijSlider form input[name=x2]").attr("value", c.x2);
						$("#wytnijSlider form input[name=y2]").attr("value", c.y2);
						$("#wytnijSlider form input[name=w]").attr("value", c.w);
						$("#wytnijSlider form input[name=h]").attr("value", c.h);
					};
					
					$("button.wytnijbaner").live('click', function(){
						$(".ui-overlay").attr("style", "display:block;");
						$("#wytnijSlider").dialog("open");
						var file = $(this).parents(".sliderLi").find("a").attr("href");
						$("#wytnijSlider #miejsceNaZdjecie").html("<img src='"+file+"'/>");
						jQuery("#wytnijSlider #miejsceNaZdjecie img").Jcrop({
							onChange: showCoords2,
							onSelect: showCoords2
						});
					});
				});
				</script>
				
				<script type="text/javascript" src="<?php echo base_url(); ?>js/submitDelete.js"></script>
				
				<div id="edytujSliderFoto" title="Edytuj opis zdjęcia" >
					<h2><strong>Edytuj opis zdjęcia</strong></h2>
					<form action="<?php echo base_url(); ?>admin/edytujslider" 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>
												
						</table>
						<input type="hidden" name="slider_id" value="" />
						<input type="hidden" name="module_id" value="<?= $this->uri->segment(3) ?>" />
						<input style="display: none;" type="submit" value="Edytuj" />
					</form>
				</div>
				
				<div id="wytnijSlider" 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/cropslider">
						<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="sortableSlider">
				<?php if($photos && $photos->num_rows() > 0) { ?>
				
					<?php foreach($photos->result() as $slider) { ?>
						<li class="sliderLi ui-state-default" id="slider_<?php echo $slider->ID_slider; ?>">
							<?php if(file_exists('foto/slider/'.$slider->slider_name)) { ?>
							<a href="<?php echo base_url().'foto/slider/'.$slider->slider_name; ?>" rel="shadowbox" >
								<div style="background: url('<?php echo base_url(); ?>foto/slider/<?php echo $slider->slider_name; ?>') no-repeat scroll 50% 50% transparent;">
								</div>
							</a>
							<?php } else { ?>
							<a href="<?php echo reduce_double_slashes(prep_url($adres).'/foto/slider/'.$slider->slider_name); ?>" rel="shadowbox" >
								<div style="background: url('<?php echo reduce_double_slashes(prep_url($adres)."/foto/slider/".$slider->slider_name); ?>') no-repeat scroll 50% 50% transparent;">
								</div>
							</a>
							<?php } ?>
							<p class="photoHeader"><?php echo $slider->slider_header; ?></p>
							<button title="Edytuj zdjęcie"  class="edytujbaner button buttonLightGrey tooltip" id="<?php echo $slider->ID_slider; ?>"><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 $slider->ID_slider; ?>"><img style="margin-right:0px;" src="<?php echo base_url(); ?>images/transform_crop.png" /></button>
							<form class="usunbaner" action="<?php echo base_url(); ?>admin/removesliderphoto" method="post">
								<input type="hidden" name="id" value="<?php echo $slider->ID_slider; ?>" />
								<input type="hidden" name="name" value="<?php echo $slider->slider_name; ?>" />
								<input type="hidden" name="module_id" value="<?php echo $slider->slider_module_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>
				
				
				
				
				
				
				
				
			
			
						
				
				