function fileQueued(file) {
	
	// set initial parameters for uploading...
	if (this.total_uploads_for_speed == undefined) {
		if ( uploaded_files_count == undefined ) 
			this.total_uploads_for_speed = 0;
		else
			this.total_uploads_for_speed = uploaded_files_count;
	}
	
	// at the start reset total_bytes to 0
	if ( (uploaded_files_count != undefined && this.total_uploads_for_speed == uploaded_files_count ) || this.total_uploads_for_speed == 0 ) {
		this.total_bytes = 0;
		this.bytes_uploaded = 0;
	}

	this.total_bytes = this.total_bytes + file.size
	this.startIndex = this.getStats().successful_uploads; // used to calculate total time

	this.total_uploads_for_speed += 1;
	this.addFileParam(file.id, "photo_number", current_photo_id);
	file_ext = file.name.substring(file.name.lastIndexOf(".")+1).toLowerCase()
  	this.addPostParam("key", batch.substring(0, 4) + '/' + batch.substring(5) + "/orig." + file_ext);
	current_photo_id = current_photo_id + 1;
}

function fileQueueError(file, errorCode, message) {
	if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
		alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
	}

	if (errorCode === SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT) {
		alert("File is too big! (20MB max upload)");
	}

	if (errorCode === SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE) {
		alert("File is empty!");
	}

	if (errorCode === SWFUpload.QUEUE_ERROR.INVALID_FILETYPE) {
		alert("This file type is not allowed!");
	}
	retry_upload();
}

function fileDialogComplete(numFilesSelected, numFilesQueued) {
	if (numFilesSelected > 0) {
		set_status('Please wait, uploading started...');
		openStatusOverlay(true);
		this.upload_meter = new JS_BRAMUS.jsProgressBar($('progress'), 0, {animate: true, barImage : Array('/images/percentImage_back4.png', '/images/percentImage_back3.png', '/images/percentImage_back2.png', '/images/percentImage_back1.png')});
		Element.show('progress');
		Element.show('time');
		
		this.numFilesQueued = numFilesQueued;
		this.startUpload();
		
    refresh_timer = window.setInterval(function () { refresh_upload_stats(); }, 500);
	}
}

function uploadStart(file) {
	set_status("Please wait, uploading started...<br/>Uploading: " + file.name);
	return true;
}

// this function is not called in linux flash implementation.
function uploadProgress(file, bytesLoaded, bytesTotal) {
	this.upload_meter.setPercentage(Math.ceil(((bytesLoaded + this.bytes_uploaded) / this.total_bytes) * 100));
	speed_text = SWFUpload.speed.formatBPS(file.movingAverageSpeed/8);
  	bytes_to_do = this.total_bytes-(bytesLoaded + this.bytes_uploaded);

	// set time + additional time for switching to other file
	if ( file.currentSpeed > 0 ) {
    time_remaining_text = "Time remaining: " + SWFUpload.speed.formatTime((bytes_to_do*8)/file.averageSpeed);
  }
	
	// set bytes transfered
	transfered_text = SWFUpload.speed.formatBytes((bytesLoaded + this.bytes_uploaded));
}

function uploadSuccess(file, serverData) {
}

function uploadError(file, errorCode, message) {
	if (pro) {
		alert('An error occured while uploading your photo. No credits have been charged, please try again.');
	}
	else {
		alert('An error occured while uploading your photo, please try again.');
	}
	retry_upload();
}

function uploadComplete(file) {
	// update uploaded bytes uploaded
	this.bytes_uploaded += file.size;
	
	// extra update for linux progression where uploadProgress is not called
	this.upload_meter.setPercentage(Math.ceil((this.bytes_uploaded / this.total_bytes) * 100));
	if (pro) {
		var text = "Uploading finished, creating image effect preview.<br/>This may take a minute or longer ... <img src='/images/working.gif' border='0'></img><br/><br/><span style='font-weight:normal'>Please don't refresh this page.</span>";
	  	queue_process_image(batch, file_ext, effect, border, decoration, decoration_text, text, true);
	} else {
		var text = 'Uploading finished, processing image.<br/>This may take a minute ... <img src="/images/working.gif" border="0"></img>';
	  	queue_process_image(batch, file_ext, effect, border, decoration, decoration_text, text, false);
	}
	
	total_uploads = total_uploads + 1;
  	this.setPostParams({"success_action_status" : "201", "AWSAccessKeyId" : aws_access_key_id, "key" : batch + "/orig" + (parseInt(file.post.photo_number)+1), "policy" : s3_policy, "signature" : s3_policy_signature, "acl" : "public-read"});
}

function queueComplete(numFilesUploaded) {
	window.clearInterval(refresh_timer);

	Element.hide('progress');
	Element.hide('upload_lightbox_bottom');
	Element.hide('time');
	
	if (pro) {
	} else {
		set_status('Uploading finished, processing image.<br/>This may take a minute ... <img src="/images/working.gif" border="0"></img>');
	}
}