function PAF_MultiUploader(aIdentifier, aFormName, aPHPSessionId){
	this._identifier = aIdentifier;
	this._selectFileButtonDiv = this._identifier + "__uploaderUI";
	this._uploadButtonA = this._identifier + "__uploadButton";
	this._clearButtonA = this._identifier + "__clearButton";
	this._selectFileButtonImg = "/PAF/design/global/img/selectFileButton.png";
	this._fileHolderDiv = this._identifier + "__FileHolder";
	this._uploadURL = new PAF_AjaxUrl();
	this._uploadMethod = "POST";
	this._uploadParameterName = 'uploaded_file';
	this._formName = aFormName;
	this._phpSessionId = aPHPSessionId;
	this._selectFileButtonDiv = null;
	this._settings = {};

	this.createHTMLLayout = function(){
		var vUploaderWrapperDiv = document.createElement("div");
		var vFileListDiv = document.createElement("div");
		this._selectFileButtonDiv = document.createElement("div");
		var vUploadButtonDiv = document.createElement("div");
		var vClearButtonDiv = document.createElement("div");
		var vClearDiv = document.createElement("div");
		var vFileFieldSet = document.createElement("fieldset");
		var vFileFieldSetLegend = document.createElement("legend");
		var vFilesWrapper = document.createElement("div");
		var vDummy = document.createElement("div");
		var vUploadButtonA = document.createElement("a");
		var vClearButtonA = document.createElement("a");

		vFileListDiv.className="PAF_MultiUploader_FileList";
		vFileListDiv.id=this._identifier + "__FileList";
		this._selectFileButtonDiv.className="PAF_MultiUploader_FileSelectButton";
		this._selectFileButtonDiv.id=this._identifier + "__uploaderUI";
		vUploadButtonDiv.className="PAF_MultiUploader_UploadButton";
		vClearButtonDiv.className="PAF_MultiUploader_ClearButton";
		vClearDiv.style.clear="both";
		vFileFieldSet.className="PAF_MultiUploader_FileFieldSet";
		vFileFieldSetLegend.className="PAF_MultiUploader_FileFieldSetLegend";
		vFilesWrapper.className="PAF_MultiUploader_FilesWrapper";
		vFilesWrapper.id=this._identifier + "__FileHolder";
		vDummy.className="PAF_MultiUploader_Wrapper";
		vUploadButtonA.href="JavaScript:void(0);";
		vClearButtonA.href="JavaScript:void(0);";
		vUploadButtonA.id=this._identifier + "__uploadButton";
		vClearButtonA.id=this._identifier + "__clearButton";

		vDummy.appendChild(document.createTextNode("No Files selected"))
		vFilesWrapper.appendChild(vDummy);
		vFileFieldSetLegend.appendChild(document.createTextNode("Files"));
		vFileFieldSet.appendChild(vFileFieldSetLegend);
		vFileFieldSet.appendChild(vFilesWrapper);
		vFileListDiv.appendChild(vFileFieldSet);
		vUploadButtonDiv.appendChild(vUploadButtonA);
		vClearButtonDiv.appendChild(vClearButtonA);

		vUploaderWrapperDiv.appendChild(vFileListDiv);
		vUploaderWrapperDiv.appendChild(this._selectFileButtonDiv);
		vUploaderWrapperDiv.appendChild(vUploadButtonDiv);
		vUploaderWrapperDiv.appendChild(vClearButtonDiv);
		vUploaderWrapperDiv.appendChild(vClearDiv);

		document.getElementById(this._identifier).appendChild(vUploaderWrapperDiv);
	}

	this.createHTMLLayout();

	this.SWFUploader = null;

	this.destroy = function(){
	     this.SWFUploader.destroy();
	}

	this.clearUploadList = function(){

	    if(this.SWFUploader != null){
	    	//this.SWFUploader.clearUploadList();
	    }
	}

	this.install = function(){
		/*var vUploader = this.SWFUploader;*/

		/*
		if (this._YUI_MultiUploader._fileHolderDiv == null || this._YUI_MultiUploader._selectFileButtonDiv == null
				|| this._YUI_MultiUploader._uploadButtonA == null || this._YUI_MultiUploader._clearButtonA == null){
			alert('Missing DIVs: ' + this._fileHolderDiv + ' or ' + this._selectFileButtonDiv);
			return false;
		}


		$(this._YUI_MultiUploader._uploadButtonA).click(function(){ vUploader.uploadAllFiles(); });
		$(this._YUI_MultiUploader._clearButtonA).click(function(){ vUploader.clearUploadList(); });

		this._YUI_MultiUploader.addListener('contentReady', this._YUI_MultiUploader.handleContentReady);
		this._YUI_MultiUploader.addListener('fileSelect', this._YUI_MultiUploader.handleAddedToUploadList);
		this._YUI_MultiUploader.addListener('uploadProgress', this._YUI_MultiUploader.handleUploadProgress);
		this._YUI_MultiUploader.addListener('uploadComplete', this._YUI_MultiUploader.handleUploadComplete);
		this._YUI_MultiUploader.addListener('uploadError', this._YUI_MultiUploader.handleUploadError);
		this._YUI_MultiUploader.addListener('uploadCompleteData', this._YUI_MultiUploader.handleUploadCompleteData);*/

		this._settings = {
				flash_url : SWF_URL,
				upload_url: this._uploadURL.getUrl(),
				post_params: {
				    kernel__MultiUploader: this._formName,
				    kernel__formElementName: this._identifier,
				    kernel__PHPSESSID: this._phpSessionId
				},
				file_size_limit : "12 MB",
				file_types : "*.*",
				file_types_description : "All Files",
				file_upload_limit : 100,
				file_queue_limit : 0,
				file_post_name: 'kernel__uploaded_file',
				custom_settings : {
					progressTarget : "fsUploadProgress",
					cancelButtonId : "btnCancel"
				},
				debug: false,
				prevent_swf_caching : true,

				// Button settings
				button_image_url: "/PAF/design/global/img/selectFileButton.png",
				button_width: "100",
				button_height: "28",
				button_placeholder_id: $(this._selectFileButtonDiv).attr('id'),
				button_disabled: false,
				file_queued_handler: this.fileQueuedHandler,
				upload_complete_handler: this.handleUploadComplete,
				upload_progress_handler: this.UploadProgressHandler,
				swfupload_loaded_handler: this.installFunctionality,
				file_queue_error_handler: this.QueueErrorHandler
				// 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
			};

		this.SWFUploader = new SWFUpload(this._settings);


		this.SWFUploader._fileArray = new Array();
		this.SWFUploader._identifier = this._identifier;
		this.SWFUploader._uploadURL = this._uploadURL;
		this.SWFUploader._uploadMethod = this._uploadMethod;
		this.SWFUploader._uploadParameterName = this._uploadParameterName;
		this.SWFUploader._formName = this._formName;
		this.SWFUploader._phpSessionId = this._phpSessionId;

		this.SWFUploader._fileHolderDiv = document.getElementById(this._fileHolderDiv);
		this.SWFUploader._selectFileButtonDiv = document.getElementById(this._selectFileButtonDiv);
		this.SWFUploader._selectFileButtonImg = document.getElementById(this._selectFileButtonImg);
		this.SWFUploader._uploadButtonA = document.getElementById(this._uploadButtonA);
		this.SWFUploader._clearButtonA = document.getElementById(this._clearButtonA);

		var vUploader = this.SWFUploader;

		$(this.SWFUploader._uploadButtonA).click(function(){ vUploader.uploadAllFiles(); });
		$(this.SWFUploader._clearButtonA).click(function(){ vUploader.clearUploadList(); });

		return true;
	}

	this.QueueErrorHandler = function(file_object, error_code, message){
	    if(error_code == -110){
		alert('Die Datei ' + file_object.name + ' ist zu groß');
	    }
	}

	this.handleUploadComplete = function(aFile, serverData){
		this.refreshProgressBar(aFile.id, 100);
		if ($('#' + this._identifier + '__' + aFile.id).length > 0){
		    document.getElementById(this._identifier + '__' + aFile.id).className="PAF_MultiUploader_Wrapper_Success";
		    var vDeleteIcon = document.getElementById(this._identifier + '__' + aFile.id + "__deleteIcon");
		    vDeleteIcon.src="/PAF/design/global/img/icons/16/save.gif";
		    
		    //Content2502__obj_280upload_files_container
		    vPrefix=this._identifier.substr(0, this._identifier.length - "upload_files_container".length)
		    $("#" + vPrefix + "save_button").click();
		}
		if (this._fileArray.length > 0){
			this.uploadFile(this._fileArray.shift());
		}
	}

	this.fileQueuedHandler = function(aFile){

	    if (this._fileArray.length == 0){
		this._fileHolderDiv.innerHTML="";
	    }


	    this._fileHolderDiv.appendChild(this.createListItem(aFile.id, aFile.name));
	    this._fileArray.push(aFile.id);

	}

	this.UploadProgressHandler = function(aFile, aBytesLoaded, aTotalBytes){
		var vProgress = Math.round(100*(aBytesLoaded/aTotalBytes));

		this.refreshProgressBar(aFile.id, vProgress);
	}

	this.installFunctionality = function(){


	this.createListItem = function(aFileId, aFileName){
		var vIdentifier = this;

		var vWrapper = document.createElement('div');
		vWrapper.id = this._identifier + "__" + aFileId;
		vWrapper.className="PAF_MultiUploader_Wrapper";

		var vFileNameDiv = document.createElement('div');
		vFileNameDiv.className="PAF_MultiUploader_FileName";

		var vFileDeleteDiv = document.createElement('div');
		vFileDeleteDiv.className="PAF_MultiUploader_FileDelete";

		var vDeleteIcon = document.createElement('img');
		vDeleteIcon.id=this._identifier + "__" + aFileId + '__deleteIcon';
		vDeleteIcon.src="/PAF/design/global/img/icons/16/delete.gif";

		if (!$(vDeleteIcon).click(function(){ vIdentifier.removeFileFromList(vIdentifier._identifier + "__" + aFileId); })){
			alert('Attach Listener failed...')
		}

		var vClearDiv = document.createElement('div');
		vClearDiv.style.clear="both";

		var vProgressBarDiv = document.createElement('div');
		vProgressBarDiv.className="PAF_MultiUploader_ProgressBar";
		vProgressBarDiv.id=this._identifier + "__" + aFileId + '__progressbar';

		vFileDeleteDiv.appendChild(vDeleteIcon);
		vFileNameDiv.appendChild(document.createTextNode(aFileName));

		vWrapper.appendChild(vFileNameDiv);
		vWrapper.appendChild(vFileDeleteDiv);
		vWrapper.appendChild(vClearDiv);
		vWrapper.appendChild(vProgressBarDiv);

		return vWrapper;
	}

	this.clearUploadList = function(){
		var vFile = null;

		while(vFile = this.getFile()){
			this.cancelUpload(vFile.id);
		}
		this._fileArray.splice(0,this._fileArray.length);
		this.addNoFilesSelectedNotification();
	}

	this.addNoFilesSelectedNotification = function(){
		var vNoFilesSelectedNotification = document.createElement('div');
		vNoFilesSelectedNotification.className="PAF_MultiUploader_Wrapper";

		vNoFilesSelectedNotification.appendChild(document.createTextNode("No Files selected"));
		this._fileHolderDiv.innerHTML="";
		this._fileHolderDiv.appendChild(vNoFilesSelectedNotification);
	}

	this.removeFileFromList = function(aFileId){
		var vElements = aFileId.split('__');
		
		if (vElements.length != 3){
			alert('Wrong count of id-splitting: ' + vElements.length);
			return false;
		}

		this.cancelUpload(vElements[2]);

		for(var vFileIndex in this._fileArray){
			if (this._fileArray[vFileIndex] == vElements[2]){
				this._fileArray.splice(vFileIndex,1);
			}
		}

		this._fileHolderDiv.removeChild(document.getElementById(aFileId));

		if (this._fileArray.length == 0){
			this.addNoFilesSelectedNotification();
		}

		return true;
	}

	this.uploadAllFiles = function(){
		//this.setSimUploadLimit(this._fileArray.length);
		//console.log(this._fileArray);
		if (this._fileArray.length > 0){
			this.uploadFile(this._fileArray.shift());
		}
	}

	this.uploadFile = function(aFileId){
		document.getElementById(this._identifier + '__' + aFileId).className="PAF_MultiUploader_Wrapper_In_Progress";

		this.startUpload(aFileId);
	}

	this.refreshProgressBar = function(aFileId, aProgress){

		var vProgressBarElement = document.getElementById(this._identifier + "__" + aFileId + '__progressbar');
		var vProgressElement = document.createElement("div");

		vProgressElement.className='PAF_MultiUploader_Progress';
		vProgressElement.style.width=aProgress+"%";

		vProgressBarElement.innerHTML="";

		vProgressBarElement.appendChild(vProgressElement);
	}

}

	/*this._YUI_MultiUploader.checkForUploads = function(){
		this.uploadAllFiles();
		return false;
	}

	this._YUI_MultiUploader.submitFormIfUploadsDone = function(){
		if (this._fileArray.length == 0){
			return false;
		} else {
			return this.submitFormIfUploadsDone();
		}
	}

	this._YUI_MultiUploader.handleContentReady = function(aEvent){
		this.setAllowMultipleFiles(true);
	}

	this._YUI_MultiUploader.handleAddedToUploadList = function(aEvent){
		this._fileHolderDiv.innerHTML="";

		for (var vItem in aEvent.fileList) {
			this._fileHolderDiv.appendChild(this.createListItem(aEvent.fileList[vItem].id, aEvent.fileList[vItem].name));
			this._fileArray.push(aEvent.fileList[vItem].id);
		}
	}

	this._YUI_MultiUploader.handleUploadComplete = function(aEvent){
		this.refreshProgressBar(aEvent.id, 100);
		document.getElementById(this._identifier + '__' + aEvent.id).className="PAF_MultiUploader_Wrapper_Success";
		var vDeleteIcon = document.getElementById(this._identifier + '__' + aEvent.id + "__deleteIcon");
		vDeleteIcon.parentNode.removeChild(vDeleteIcon);
		if (this._fileArray.length > 0){
			this.uploadFile(this._fileArray.shift());
		}
	}

	this._YUI_MultiUploader.handleUploadProgress = function(aEvent){
		var vProgress = Math.round(100*(aEvent["bytesLoaded"]/aEvent["bytesTotal"]));

		this.refreshProgressBar(aEvent.id, vProgress);
	}

	this._YUI_MultiUploader.handleUploadError = function(aEvent){
		//alert(aEvent.status);
	}

	this._YUI_MultiUploader.handleUploadCompleteData = function(aEvent){
		//alert(aEvent.data);
	}

	this._YUI_MultiUploader.uploadAllFiles = function(){
		this.setSimUploadLimit(this._fileArray.length);

		if (this._fileArray.length > 0){
			this.uploadFile(this._fileArray.shift());
		}
	}

	this._YUI_MultiUploader.uploadFile = function(aFileId){
		document.getElementById(this._identifier + '__' + aFileId).className="PAF_MultiUploader_Wrapper_In_Progress";

		this.upload(aFileId,this._uploadURL.getUrl(),this._uploadMethod,
			{
				kernel__MultiUploader: this._formName,
				kernel__formElementName: this._identifier,
				kernel__PHPSESSID: this._phpSessionId
			}, 'kernel__uploaded_file');
	}

	this._YUI_MultiUploader.clearUploadList = function(){
		this.clearFileList();
		this._fileArray.splice(0,this._fileArray.length);
		this.addNoFilesSelectedNotification();
	}

	this._YUI_MultiUploader.refreshProgressBar = function(aFileId, aProgress){

		var vProgressBarElement = document.getElementById(this._identifier + "__" + aFileId + '__progressbar');
		var vProgressElement = document.createElement("div");

		vProgressElement.className='PAF_MultiUploader_Progress';
		vProgressElement.style.width=aProgress+"%";

		vProgressBarElement.innerHTML="";

		vProgressBarElement.appendChild(vProgressElement);
	}*/

	this.install();


}