// JavaScript Document

function initUploads()
{
	var html;
	
	$('#multiupload_new').uploadify({
			'uploader'       : 'swf/uploadify.swf',
			'script'         : 'ajax/uploadfiles2.php',
			'cancelImg'      : 'css/img/buttons/onError_grey.png',
			'width'          : '100',
			'fileExt'		 : '*.jpg;*.jpeg;*.gif;*.png',
			'buttonText'	 : 'BROWSE',
			'wmode'			 : 'transparent',
			'fileDataName'	 : 'userfile',
			'scriptData'	 : {'id':$('#multiupload_new').attr('elem_id'),'type':$('#multiupload_new').attr('elem_type'),'class':$('#multiupload_new').attr('elem_class')},
			'auto'			 : true,
			'multi'          : true,
			'onError'	 :
				function(event,queueID,fileObj,response,data) 
				{ 
					alert(response); 
				},
			'onComplete'	 :
				function(event,queueID,fileObj,response,data) 
				{ 
					if (response!='undefined')
					html = response; 
				},
			'onAllComplete'	 : 
				function(event,queueID,fileObj,response,data) 
				{ 
					//window.location.href=window.location.href;
					if (response!='undefined')
					html += response; 
					$('.img_container').html(html);
				}
	});
	
	$('#multiupload').uploadify({
			'uploader'       : 'swf/uploadify.swf',
			'script'         : 'ajax/uploadfiles.php',
			'cancelImg'      : 'css/img/buttons/onError_grey.png',
			'width'          : '122',
			'fileExt'		 : '*.jpg;*.jpeg;*.gif;*.png',
			'fileDesc'    	 : 'Bilder',
			'height'		 : '37',	
			'hideButton'	 : 'true',
			'wmode'			 : 'transparent',
			'fileDataName'	 : 'userfile',
			'scriptData'	 : {'id':$('#multiupload').attr('immo_id'),'type':'images'},
			'auto'			 : true,
			'multi'          : true,
			onComplete	 	 :
				function(event,queueID,fileObj,response,data) { 
					//alert(response);
				},
			onAllComplete	 : 
				function(event,queueID,fileObj,response,data) { 
					window.location.href=window.location.href;
				},
			onError			 : 
				function(event, queueID, fileObj, errorObj) {       
					alert("Fehler");    
				}
	});
	
	$('#multiuploadpdf').uploadify({
			'uploader'       : 'swf/uploadify.swf',
			'script'         : 'ajax/uploadfiles.php',
			'cancelImg'      : 'css/img/buttons/onError_grey.png',
			'width'          : '12',
			'fileExt'		 : '*.pdf',
			'fileDesc'    	 : 'PDF',
			'height'		 : '37',	
			'hideButton'	 : 'true',
			'wmode'			 : 'transparent',
			'fileDataName'	 : 'userfile',
			'scriptData'	 : {'id':$('#multiuploadpdf').attr('immo_id'),'type':'pdf'},
			'auto'			 : true,
			'multi'          : true,
			onComplete	 	 :
				function(event,queueID,fileObj,response,data) { 
					//alert(response);
				},
			onAllComplete	 : 
				function(event,queueID,fileObj,response,data) { 
					window.location.href=window.location.href;
				},
			onError			 : 
				function(event, queueID, fileObj, errorObj) {       
					alert("Fehler");    
				}
	});
	
	$('#multiuploadvideo').uploadify({
			'uploader'       : 'swf/uploadify.swf',
			'script'         : 'ajax/uploadfiles.php',
			'cancelImg'      : 'css/img/buttons/onError_grey.png',
			'width'          : '122',
			'fileExt'		 : '*.mp4',
			'fileDesc'    	 : 'Videos',
			'height'		 : '37',	
			'hideButton'	 : 'true',
			'wmode'			 : 'transparent',
			'fileDataName'	 : 'userfile',
			'scriptData'	 : {'id':$('#multiuploadpdf').attr('immo_id'),'type':'video'},
			'auto'			 : true,
			'multi'          : true,
			onComplete	 	 :
				function(event,queueID,fileObj,response,data) { 
					//alert(response);
				},
			onAllComplete	 : 
				function(event,queueID,fileObj,response,data) { 
					window.location.href=window.location.href;
				},
			onError			 : 
				function(event, queueID, fileObj, errorObj) {       
					alert("Fehler");    
				}
	});
	
	$('.startupload').click(function(){
		$('#multiupload').fileUploadStart();	
	});
	
	$('.clearqueue').click(function(){
		$('#multiupload').fileUploadClearQueue();
	});	
}
