window.addEvent('domready', function() {

	/**
	 * Uploader instance
	 */
	
	/**
	 * ZMIENIC TA SCIEZKE 
	 */
	var root_dir = '/'; 
	
	var up = new FancyUpload3.Attach('fileAttachList', '#fileAttachAnchor, #fileAttachAnchor2', {
		path: root_dir+'foto/source/Swiff.Uploader.swf',
		url: root_dir+'foto/addPhoto.php',
		fileSizeMax: 100 * 1024 * 1024,
		fileListMax: 50,
		
		verbose: true,
		
		onSelectFail: function(files) {
		
			files.each(function(file) {
				new Element('li', {
					'class': 'file-invalid',
					events: {
						click: function() {
							this.destroy();
						}
					}
				}).adopt(
					new Element('span', {html: file.validationErrorMessage || file.validationError})
				).inject(this.list, 'bottom');
			}, this);	
		},
		
		onFileSuccess: function(file) {
				
		},
		
		onFileError: function(file) {
			file.ui.cancel.set('html', 'Retry').removeEvents().addEvent('click', function() {
				file.requeue();
				return false;
			});
			
			new Element('span', {
				html: file.errorMessage,
				'class': 'file-error'
			}).inject(file.ui.cancel, 'after');
		},
		
		onFileRequeue: function(file) {
			file.ui.element.getElement('.file-error').destroy();
			
			file.ui.cancel.set('html', 'Cancel').removeEvents().addEvent('click', function() {
				file.remove();
				return false;
			});
			
			this.start();
		}
		
	});
	
});