﻿//----------------------------
// File      : manage.js
// Version   : V1.0
// Encoding  : UTF-8
// Author    : Randoer
// Copyright : Tryfly Corp.
// Date      : 08/30/2007
//-----------------------------

//全选
function CheckAll() {
	var checks = checked.checked;
	if (id.length == undefined) {
		id.checked = checks;
	} else {
		for (var i=0;i<id.length;i++) {
			id[i].checked = checks;
		}
	}
}

//action
function toView(module) {
	location.href="?module="+module;
}

function toAdd(module) {
	location.href="?module="+module+"&action=detail&id=0";
}

function toEdit(module) {
	var value = 0;
	if (id.length == undefined) {
		if (id.checked) value = id.value;
	} else {
		for (var i=0;i<id.length;i++) {
			if (id[i].checked){
				value = id[i].value;
			}
		}
	}
	if (value==0) {
		alert("请选定需要编辑的记录！");
	} else {
		location.href="?module="+module+"&action=detail&id="+value;
	}
}

function toDelete(module) {
	var value = 0;
	if (id.length == undefined) {
		if (id.checked || id.type == "hidden") value = id.value;
	} else {
		for (var i=0;i<id.length;i++) {
			if (id[i].checked){
				if (value == 0){
					value = id[i].value;
				} else {
					value += ", " + id[i].value;
				}
			}
		}
	}
	if (value==0) {
		alert("请选定需要删除的记录！");
	} else {
		if (confirm('您是否确认删除选定的记录？')) location.href="?module="+module+"&action=delete&id="+value;
	}
}

function toAction(module, action) {
	location.href="?module="+module+"&action="+action;
}

document.getElementById("body").style.height = '100%';