function CheckAll(this_id, str, form)
{
	var var_this = document.getElementById(this_id);
	for (i = 0; i < form.elements.length; i++)
	{
		var item=form.elements[i];
		if (item.name.indexOf(str)>=0)
		{
			item.checked = !!var_this.checked;
		}
	}
}

function peopleDelete(event)
{
	event.preventDefault();
	var form = jQuery('#delete_form');
	form.html('');
	var ids = [];
	jQuery("#peopleForm input[name='user_id[]']").each(function()
	{
		if (jQuery(this).prop('checked'))
			form.append('<input name="user_id[]" value="' + jQuery(this).val() + '" />');
	});
	form.submit();
}

function autoAddUpdate(user_name, this_id, form)
{
	var var_this = document.getElementById(this_id);
	if(var_this.checked)
	{
		var str = "use_username[" + user_name + "]";
		for (i = 0; i < form.elements.length; i++)
		{
			var item = form.elements[i];
			if (item.name.indexOf(str) >= 0)
			{
				item.checked = true;
			}
		}
	}
}

function CheckAllUpdate(this_id, update_id, str, form)
{
	var var_this = document.getElementById(this_id);
	if(var_this.checked)
	{
		var var_update = document.getElementById(update_id);
		var_update.checked = true;
		for (i = 0; i < form.elements.length; i++)
		{
			var item=form.elements[i];
			if (item.name.indexOf(str)>=0)
			{
				item.checked = true;
			}
		}
	}
}

jQuery(document).ready(function()
{
	jQuery('body').on('click', '#peopleDelete', peopleDelete);
});