<?php
	include('includes/db.php'); 
   	$id = trim($_GET['id']);
   
   	switch ($_GET[mode]): 	
															
		case 'category':
			$sql="SELECT * FROM `$_GET[mode]` WHERE `id`='$id'";						
			$rrow = mysql_fetch_array(mysql_query($sql));
			$header="
			<a href='#'>Kategorie</a> 						
			<a href='$basehttp/admin/modules/files/files.list.php?mode={$_GET[mode]}&id={$_REQUEST[id]}'>{$rrow[title]}</a>
			<span><a href='#'>Dodaj plik</a></span> ";								 
			$link="$basehttp/admin/modules/files/files.list.php?typ={$_GET[mode]}&id={$_REQUEST[id]}";
			$handlers="<script type='text/javascript' src='$basehttp/admin/js/swfupload/handlers_poto.js'></script>";							
		break;		
			
		case 'news':
			$sql="SELECT * FROM `$_GET[mode]` WHERE `id`='$id'";						
			$rrow = mysql_fetch_array(mysql_query($sql));
			$header="
			<a href='#'>Pliki</a> 						
			<a href='$basehttp/admin/modules/files/files.list.php?mode={$_GET[mode]}&id={$_REQUEST[id]}'>{$rrow[title]}</a>
			<span><a href='#'>Dodaj plik</a></span> ";								 
			$link="$basehttp/admin/modules/files/files.list.php?mode={$_GET[mode]}&id={$_REQUEST[id]}";
			$handlers="<script type='text/javascript' src='$basehttp/admin/js/swfupload/handlers_poto.js'></script>";							
		break;	
		
		case 'szkolenia':
			$sql="SELECT * FROM `$_GET[mode]` WHERE `id`='$id'";						
			$rrow = mysql_fetch_array(mysql_query($sql));
			$header="
			<a href='#'>Pliki</a> 						
			<a href='$basehttp/admin/modules/files/files.list.php?mode={$_GET[mode]}&id={$_REQUEST[id]}'>{$rrow[title]}</a>
			<span><a href='#'>Dodaj plik</a></span> ";								 
			$link="$basehttp/admin/modules/files/files.list.php?mode={$_GET[mode]}&id={$_REQUEST[id]}";
			$handlers="<script type='text/javascript' src='$basehttp/admin/js/swfupload/handlers.js'></script>";							
		break;	
		
				
		
		
				
		default:
		$header="<a href=''>error</a> ";

	endswitch;

?>


 <div id="right_column">
        <!-- RIGHT -->
        <div id="right_top">
        	<div id="right_home"></div>
            <div id="right_right">            
			<? echo $header; ?>                     
            </div>
        </div>
        
        
        
        <div id="right_bg">        
      	  <h3>Dodaj plik</h3>
          
          
<div id="table">


<? if($_GET[id]) { ?>
<link href="<? echo $basehttp; ?>/admin/js/swfupload/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<? echo $basehttp; ?>/admin/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<? echo $basehttp; ?>/admin/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="<? echo $basehttp; ?>/admin/js/swfupload/fileprogress.js"></script>
<? echo $handlers; ?>

<script type="text/javascript">
		var swfu;

		window.onload = function() {
			var settings = {
				flash_url : "<? echo $basehttp; ?>/admin/js/swfupload/swfupload.swf",
				upload_url: "<? echo $basehttp; ?>/admin/upload.php",
				post_params: {"<?php echo $_REQUEST[mode]; ?>_file" : "<?php echo $_REQUEST[id]; ?>"},
				file_size_limit : "100 MB",
				file_types : "*",	
				file_types_description : "wszystkie",
				file_upload_limit : 0,
				file_queue_limit : 0,
				custom_settings : {
					progressTarget : "fsUploadProgress",
					cancelButtonId : "btnCancel"
				},
				debug: false,
				upload_successful : true,

				// Button settings
				button_image_url: "<? echo $basehttp; ?>/admin/gfx/upload.png",
				button_width: "120",
				button_height: "29",
				button_placeholder_id: "spanButtonPlaceHolder",
	
				
				// The event handler functions are defined in handlers.js
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete	// Queue plugin event
			};

			swfu = new SWFUpload(settings);
	     };
	</script>
  

<form id="form1" action="<? echo $link; ?>" name="formupload" method="post" enctype="multipart/form-data">
<div id="divStatus"></div>
<table width="100%" border="0">
  <tr>
    <td>    
    <div class="fieldset flash" id="fsUploadProgress">
	<span class="legend">Proces</span>    </div>      </td>
    </tr>
  <tr>
    <td style="padding-top:20px;">
    
    <span id="spanButtonPlaceHolder"></span>
    <input name="" id="btnCancel" type="image" onclick="swfu.cancelQueue();" disabled="disabled"  style="margin-left: 2px; font-size: 8pt; border:none;" src="/admin/gfx/buttons/button_cancel.gif" />
     </td>
    </tr>
</table>
</form>	

    
<? } else { echo "błąd"; } ?>
          </div>
          <!-- table-->
        
        </div>
        
        <div id="right_bottom"></div>
       
        <!-- RIGHT -->
     


    </div>
  



</div>
</div>





<? include($basepath.'/admin/templates/footer.php'); ?>
