var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		id : 'paging',
		l_column : [ {
			colkey : "postId",
			width : "50px",
			hide : true
		}, {
			colkey : "name",
			name : "栏目名称"
		}, {
			colkey : "width",
			name : "宽（px）"
		}, {
			colkey : "height",
			name : "高（px）"
		}, {
			colkey : "pay",
			name : "计费金额（元）",
		}, {
			colkey : "demo",
			name : "效果图"
		}],
		jsonUrl : rootPath + '/advertpost/find.shtml',
		checkbox : true,
		serNumber : false,
		checkValue:'postId'
	});

	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		grid.setOptions({
			data : searchParams
		});
	});
	$("#addBtn").click("click", function() {
		addBoard();
	});
	$("#editBtn").click("click", function() {
		editBoard();
	});
	$("#delBtn").click("click", function() {
		delBoard();
	});
});
function editBoard() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "广告位编辑",
		type : 2,
		area : [ "750px", "60%" ],
		content : rootPath + '/advertpost/editUI.shtml?id=' + cbox
	});
}
function addBoard() {
	pageii = layer.open({
		title : "新增广告位",
		type : 2,
		area : [ "750px", "60%" ],
		content : rootPath + '/advertpost/addUI.shtml'
	});
}
