function SelectAll()
{    
	var length=document.forms[0].chkNum.value;

	if(length==0)
	{	    
		return;
	}
	
	if(length==1)
	{
		document.forms[0].ckb_dataItem.checked=document.forms[0].ckb_selectAll.checked;
	}
	if(length>1)
	{
		for(var i=0;i<length;i++)
		{
			document.forms[0].ckb_dataItem[i].checked=document.forms[0].ckb_selectAll.checked;
		}
	}
}
function UnSelectAll(itemIndex)
{	
	if(document.forms[0].ckb_selectAll.checked)
	{
		document.forms[0].ckb_selectAll.checked = document.forms[0].ckb_dataItem.checked;
	}
}

function checkSelect() {
    var result = false;    
    var length = document.forms[0].chkNum.value;

    if (length == 0) {
        return true;
    }

    if (length == 1) {
        document.forms[0].ckb_dataItem.checked = document.forms[0].ckb_selectAll.checked;
    }
    else if (length > 1) {
        for (var i = 0; i < length; i++) {
            if (document.forms[0].ckb_dataItem[i].checked) {
                result = true;
                break;
            }
        }
    }

    if (!result) {
        alert("请选择要操作的项！");
    }
    return result;
}

function checkSelectForDelete() {
    var result = false;

    var length = document.forms[0].chkNum.value;

    if (length == 0) {
        return true;
    }

    if (length == 1) {
        document.forms[0].ckb_dataItem.checked = document.forms[0].ckb_selectAll.checked;
    }
    else if (length > 1) {
        for (var i = 0; i < length; i++) {
            if (document.forms[0].ckb_dataItem[i].checked) {
                result = true;
                break;
            }
        }
    }

    if (!result) {
        alert("请选择要操作的项！");
    }

    if (result) {
        return confirm('确定要删除选定项吗？（注：删除后不可恢复）');
    }

    return result;
}