// JavaScript Document

function initUploads()
{
	$('#moreImages').click(function(){
		if ($(this).parent().children('div').length <= 10)
			$(this).parent().children('div:first').clone().insertBefore($(this));
		else
			$(this).hide();
	});
	
	$('#multiupload').uploadify({
			'uploader'       : 'swf/uploadify.swf',
			'script'         : 'ajax/uploadify.php',
			'cancelImg'      : 'css/img/buttons/onError_grey.png',
			'width'          : '300',
			'fileExt'		 : '*.jpg;*.jpeg;*.gif;*.png',
			'fileDesc'    	 : 'Bilder',
			'buttonText'	 : 'BROWSE',
			'wmode'			 : 'transparent',
			'fileDataName'	 : 'userfile',
			'scriptData'	 : {'id':$('#multiupload').attr('upload_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");    
				}
	});
	
	$('.startupload').click(function(){
		$('#multiupload').fileUploadStart();	
	});
	
	$('.clearqueue').click(function(){
		$('#multiupload').fileUploadClearQueue();
	});	
}
