jQuery(document).ready(function() {	
	jQuery('#checkAll').click(function(){$(":checkbox").attr("checked", this.checked);});
});

function deleteMarked(url){
	var flag = false;
	$(":checkbox[name='mark[]']").each(function(i, n) {
		if (n.checked) {
			flag = true;
			return;
		}
	});

	if(flag) {
		if (confirm("确定要删除选择的记录吗?")) {
			$.post(url, $(":checkbox[name='mark[]']").serialize(), function(data){
				window.location.reload();
			});
		}
	} else {
		alert("选择一条记录！");
	}
}

function del(url, deleteId) {
	if (confirm("确定要删除当前记录吗?")) {
		$.post(url, {'deleteId':deleteId}, function(){window.location.reload();});
	}
}

function getListActionNameCn(type)
{
	switch(type)
	{
		case 'activating':
			message = '激活';
			break;
		case 'invalid':
			message = '作废';
			break;
		case 'start':
			message = '启用';
			break;
		case 'del':
			message = '删除';
			break;
	}
	
	return message;
}

function memberListAction(id , type)
{
	var message = getListActionNameCn(type);
	
	if(confirm('确定要' + message + '当前记录吗？')) {
		$.post(
			memberListActionUrl,
			{'id':id,'type':type},
			function(){
				window.location.reload();
			}
		);
	}
}

function storeListAction(id , type)
{
	var message = getListActionNameCn(type);
	
	if(confirm('确定要' + message + '当前记录吗？')) {
		$.post(
			storeListActionUrl,
			{'id':id,'type':type},
			function(){
				window.location.reload();
			}
		);
	}
}

function orderStatus(url , id , status)
{
	if(confirm('确定要更新该订单状态吗？')) {
		$.post(url , {'id':id , 'status': status} , function(){window.location.reload();});
	}
}

function ChangeStatus(url , id , status)
{
	if(confirm('确定要更新该记录状态吗？')) {
		$.post(url , {'id':id , 'status': status} , function(){window.location.reload();});
	}
}

function storeMaster(store_id , master_id)
{
	if(confirm('确定要将该用户设为本店的店主吗？')) {
		$.post(storeMasterUrl , {'store_id':store_id , 'master_id': master_id} , function(){window.location.reload();});
	}
}

