function initializeSlimbox()
{
	$(document).ready(function()
	{
		$('a.slimbox').slimbox({counterText: "Afbeelding {x} van {y}"});
	});
}

function initializeAdminGrid()
{
	$(document).ready(function()
	{
		// Bind pagesize onchange handler
		$('.change-pagesize').live('change', function()
		{
			// Update the gridview with the new pageSize value
			$.fn.yiiGridView.update('admin-grid',{ data:{ pageSize: $(this).val() }})
		});

		// Bind delete action
		$('.action-delete').live('click', function()
		{
			// Get all selected rows
			var data = { 'selectedRows[]' : [] };
			$('#admin-grid input[name=\'selectedRows[]\']:checked').each(function() {
				data['selectedRows[]'].push($(this).val());
			});

			// Check if the user has selected rows
			if (data['selectedRows[]'].length == 0)
			{
				alert('U heeft geen items geselecteerd.');
				return false;
			}

			// Ask for delete confirmation
			if ( ! confirm('Weet u zeker dat u deze items wilt verwijderen?'))
				return false;

			// Post the selected rows and update the gridview
			$.fn.yiiGridView.update('admin-grid', {
				type:'POST',
				url:$(this).attr('href'),
				data:data,
				success:function() {
					$.fn.yiiGridView.update('admin-grid');
				}
			});

			return false;
		});
	});
}
