jQuery().ready(function()
{
	var stepSize = 0;
	var height = ($('#foto_list #foto_wrapper ul').height() - $('#foto_list #foto_wrapper').height());
	setInterval(function()
	{
		if(stepSize > 0)
		{
			if(parseFloat($('#foto_list #foto_wrapper ul').css('margin-top')) + stepSize > 0)
			{
				stepSize = parseFloat($('#foto_list #foto_wrapper ul').css('margin-top')) * -1;
			}
		}
		if(stepSize < 0)
		{
			//$('#foto_titel').html((parseFloat($('#foto_list #foto_wrapper ul').css('margin-top')) + stepSize) + ', ' + (-height));
			if(parseFloat($('#foto_list #foto_wrapper ul').css('margin-top')) + stepSize < -height)
			{
				stepSize = -height - parseFloat($('#foto_list #foto_wrapper ul').css('margin-top'));
			}
		}
		$('#foto_list #foto_wrapper ul').css({ 'margin-top': (parseFloat($('#foto_list #foto_wrapper ul').css('margin-top')) + stepSize) + 'px' });
	}, 1000/24);
	$('#foto_list #foto_wrapper').mousemove(function(event)
	{
		if(event.pageY - $(this).offset().top < 100)
		{
			stepSize = ($(this).offset().top - event.pageY) / 10 + 10;
		}
		else if($(this).height() - (event.pageY - $(this).offset().top) < 100)
		{
			stepSize = ($(this).height() - (event.pageY - $(this).offset().top)) / 10 - 10;
		}
		else
		{
			stepSize = 0;	
		}
	}).mouseleave(function()
	{
		stepSize = 0;
	});
	
	var swfId = 'image_uploader';
	
	var date = new Date();
	
	swfobject.embedSWF('/media/fileupload.swf?time=' + date.getTime(), swfId, '19', '19', '10.0.0', '/media/expressInstall.swf', { toFile: '/fileUpload.php', multipleFiles: true, maxFileSize: (1024*1024*10), name: 'foto', fileFilter: '*.jpg;*.gif;*.png', fileFilterName: 'images', saveText: 'opslaan...', callbackFunction: 'pictureUploadCallback', css: 'a { border-color: #218b00 } a:hover { border-color: #218b00 }', cssFile: '/media/fotoalbum_fileupload.css?time=' + date.getTime(), text: '<a hef="#">browse<a/>', fotogroup_name: $('#fotogroup_name').val() }, { allowScriptAccess: 'always' }, { id: swfId, name: swfId });
});

function pictureUploadCallback(value)
{
	if(value == 'allFilesUploaded')
	{
		window.location.reload();
	}
	else if(value == 'fileUploaded')
	{
		$('#image_uploader').css({ width: '19px' });
	}
	else if(value == 'startUpload')
	{
		$('#image_uploader').css({ width: '141px' });
	}
	else
	{
		alert(value);
	}
}