var OBJECT = "object", STRING = "string", NUMBER = "number", BOOLEAN = "boolean", FUNCTION = "function", NULL = "undefined";
var BODY = "BODY", DIV = "DIV", TABLE = "TABLE", TR = "TR", TD = "TD", INPUT = "INPUT", SELECT = "SELECT", TEXTAREA = "TEXTAREA";
var ENTER = 13;
var UNKNOWN = 0, NEW = 5, EDIT = 6, DELETE = 8;

function isObj(o) { return typeof o == OBJECT; }
function isString(v) { return typeof v == STRING; }
function isNumber(v) { return typeof v == NUMBER; }
function isBoolean(v) { return typeof v == BOOLEAN; }
function isFunction(v) { return typeof v == FUNCTION; }
function isNull(v) { return v == null || typeof v == NULL }
function isEmpty(v) { return isNull(v) || String(v) == ""; }

function val(v, d) { return v == null ? d : v; }
function str(v, d) { return v == null ? (d == null ? "" : d) : String(v); }

function obj(o) { return isObj(o) ? o : document.getElementById(o); }
function objs(o) { return isObj(o) ? o : document.getElementsByName(o); }

function parentObj(o) { return obj(o).parentNode; }
function nextObj(o) { return obj(o).nextSibling; }
function previousObj(o) { return obj(o).previousSibling; }
function childObj(o) { return obj(o).firstChild; }

function click(o) { try { obj(o).click(); } catch (e) { pe(e); } }
function focus(o) { try { obj(o).focus(); } catch (e) { pe(e); } }
function select(o) { try { obj(o).select(); } catch (e) { pe(e); } focus(o); }

function show(o) { try { obj(o).style.display = ""; obj(o).style.visibility = "visible"; } catch (e) { pe(e); } }
function hide(o) { try { obj(o).style.display = "none"; obj(o).style.visibility = "hidden"; } catch (e) { pe(e); } }
function enable(o) { try { obj(o).disabled = false; } catch (e) { pe(e); } }
function disable(o) { try { obj(o).disabled = true; } catch (e) { pe(e); } }
function check(o) { try { obj(o).checked = true; } catch (e) { pe(e); } }
function uncheck(o) { try { obj(o).checked = false; } catch (e) { pe(e); } }

function showAll(o) { try { var oa = objs(o); for (var i = 0; i < oa.length; i++) { oa[i].style.display = ""; oa[i].style.visibility = "visible"; } } catch (e) { pe(e); } }
function hideAll(o) { try { var oa = objs(o); for (var i = 0; i < oa.length; i++) { oa[i].style.display = "none"; oa[i].style.visibility = "hidden"; } } catch (e) { pe(e); } }
function enableAll(o) { try { var oa = objs(o); for (var i = 0; i < oa.length; i++) oa[i].disabled = false; } catch (e) { pe(e); } }
function disableAll(o) { try { var oa = objs(o); for (var i = 0; i < oa.length; i++) oa[i].disabled = true; } catch (e) { pe(e); } }
function checkAll(o) { try { var oa = objs(o); for (var i = 0; i < oa.length; i++) if (!oa[i].disabled) oa[i].checked = true; } catch (e) { pe(e); } }
function uncheckAll(o) { try { var oa = objs(o); for (var i = 0; i < oa.length; i++) if (!oa[i].disabled) oa[i].checked = false; } catch (e) { pe(e); } }

function style(o, n) { try { var o = obj(o); if (n != null) o.className = n; return o.style; } catch (e) { pe(e); return null; } }
function html(o, s) { try { var o = obj(o); if (s != null) { o.innerHTML = isObj(s) ? s.innerHTML : s; } return o.innerHTML; } catch (e) { pe(e); return null; } }
function src(o, n) { try { var o = obj(o); if (n != null) o.src = n; return o.src; } catch (e) { pe(e); return null; } }

function value(o, v) { try { var o = obj(o); if (v != null) o.value = v; return o.value; } catch (e) { return null; } }
function values(o, std) { var a = new Array(); if (isSelect(obj(o))) { var o = obj(o); for (var i = 0; i < o.options.length; i++) if (std == null || (std && o.options[i].selected)) a.push(o.options[i].value); } else { var os = objs(o); for (var i = 0; i < os.length; i++) { try { if (std == null || (std && isChecked(os[i]))) a.push(os[i].value); } catch (e) { pe(e); } } } return a; }

function clear(o) { try { obj(o).value = ""; } catch (e) { pe(e); } }
function length(o) { try { return obj(o).value.length; } catch (e) { pe(e); } }

function encode(s) { return encodeURIComponent(s); }
function qs(s) { return "?" + (s == null ? "" : s); }
function nv(n, v, e) { return e && v == null ? "" : "&" + n + "=" + (v == null ? "" : encode(v)); }
function param(n, o, e) { var v = o == null ? value(n) : value(o); try { return e && isEmpty(v) ? "" : nv(n, v); } catch (e) { pe(e); return ""; } }
function params(n, o, e) { var s = ""; var  os = o == null ? objs(n) : objs(o); for (var i = 0; i < os.length; i++) { if ((isRadio(os[i]) || isCheckbox(os[i])) && !isChecked(os[i])) continue; try { var v = os[i].value; s += e && isEmpty(v) ? "" : "&" + (n == null ? o : n) + "=" + encode(v); } catch (e) {} } return s; }

function locate(u, t) { (t == null ? window : t).location.href = str(u); }
function submit(u, f, t) { var f = obj(f) || document.forms[0]; f.action = str(u); f.target = str(t); f.method = "post"; f.submit(); }
function reset(f) { f = obj(f) || document.forms[0]; f.reset(); }
function openWin(u, t, p) { return window.open(str(u), str(t, "_blank"), str(p)); }
function closeWin() { window.close(); }
function focusWin() { document.focus(); }

function tag(o) { try { return obj(o).tagName; } catch (e) { return null; } }
function isBody(o) { return tag(o) == BODY; }
function isDiv(o) { return tag(o) == DIV; }
function isTable(o) { return tag(o) == TABLE; }
function isTr(o) { return tag(o) == TR; }
function isTd(o) { return tag(o) == TD; }
function isInput(o) { return tag(o) == INPUT; }
function isSelect(o) { return tag(o) == SELECT; }
function isTextArea(o) { return tag(o) == TEXTAREA; }
function isFormObj(o) { return (isInput(o) || isSelect(o) || isTextArea(o)) && !isEmpty(o.name); }

function type(o) { try { return obj(o).type; } catch (e) { return null; } }
function isHidden(o) { return type(o) == "hidden";}
function isText(o) { return type(o) == "text"; }
function isRadio(o) { return type(o) == "radio"; }
function isCheckbox(o) { return type(o) == "checkbox"; }
function isCheckObj(o) { return isRadio(o) || isCheckbox(o); }
function isChecked(o) { try { return obj(o).checked; } catch (e) { return false; } }
function isDisabled(o) { try { return obj(o).disabled; } catch (e) { return false; } }
function isReadonly(o) { try { return obj(o).readonly; } catch (e) { return false; } }

function parentDiv(o) { while (!isDiv(o) && !isBody(o)) o = parentObj(o); return o; }
function parentTable(o) { while (!isTable(o) && !isBody(o)) o = parentObj(o); return o; }
function parentTr(o) { while (!isTr(o) && !isBody(o)) o = parentObj(o); return o; }
function parentTd(o) { while (!isTd(o) && !isBody(o)) o = parentObj(o); return o; }
function enableTr(o) { try { var os = parentTr(o).all; for (var i = 0; i < os.length; i++) { if (isFormObj(os[i])) enable(os[i]) } } catch (e) { pe(e) } }
function disableTr(o) { try { var os = parentTr(o).all; for (var i = 0; i < os.length; i++) { if (parentObj(os[i]) == parentObj(o)) continue; if (isFormObj(os[i])) disable(os[i]) } } catch (e) { pe(e) } }
function checkTr(o) { try { o.checked ? enableTr(o) : disableTr(o); } catch (e) { pe(e) } }
function checkHidden(o) { try { o.nextSibling.value = o.checked ? 1 : 0 } catch (e) { pe(e) } }

function length(o) { try { return obj(o).length; } catch (e) {} }
function text(o, s) { try { var o = obj(o); var t = o.options[o.selectedIndex]; if (s != null) t.text = s; return t.text; } catch (e) { return ""; } }
function texts(o, std) { var o = obj(o); try { var a = new Array(); for (var i = 0; i < o.options.length; i++) if (std == null || (std && o.options[i].selected)) a.push(o.options[i].text); return a; } catch (e) { return null; } }
function enselect(o) { try { var o = obj(o); for (var i = 0; i < o.options.length; i++) o.options[i].selected = true; } catch (e) { pe(e); } }
function deselect(o) { try { var o = obj(o); for (var i = 0; i < o.options.length; i++) o.options[i].selected = false; o.selectedIndex = -1; } catch (e) { pe(e); } }
function add(o, n, v, ix) { if ((o = obj(o)) == null) return; for (var i = 0; i < o.options.length; i++) if (o.options[i].value == v) return; if (ix != null) o.options.add(new Option(n, v), ix); else o.options.add(new Option(n, v)); }
function copy(c, o, al) { if ((c = obj(c)) == null || (o = obj(o)) == null) return; for (var i = 0; i < c.options.length; i++) { if (al || c.options[i].selected) { var b = false; for (var j = 0; j < o.options.length; j++) { if (o.options[j].value == c.options[i].value) { b = true; break; } } if (!b) o.options.add(new Option(c.options[i].text, c.options[i].value)); } } }
function remove(o, al) { if ((o = obj(o)) == null) return; for (var i = o.options.length - 1; i >= 0; i--) if (al || o.options[i].selected) o.options.remove(i); }
function move(o, p) { try { var o = obj(o); var c = o.options[o.selectedIndex]; var t = o.options[o.selectedIndex + p]; var v = c.value; var s = c.text; c.value = t.value; c.text = t.text; t.value = v; t.text = s; o.selectedIndex += p; } catch (e) { pe(e); } }
function up(o) { move(o, -1); }
function down(o) { move(o, 1); }

function dw(s) { document.write(s); }

function num(o) { return Number(String(o).replace(/[^0-9\.-]/g, "")); }
function round(o, i) { return Math.round(num(o) / Math.pow(10, -i)) / (Math.pow(10, i)); }
function split(s, sp) { return str(s).split(sp == null ? "," : sp); }

function enter() { if (event.keyCode == ENTER && !event.shiftKey) { event.returnValue = false; return true; } return false; }

function preload() { var d = document; if (d.images) { if(!d.p) d.p = new Array(); var i, j = d.p.length, a = preload.arguments; for (i = 0; i > a.length; i++) if (a[i].indexOf("#") != 0) { d.p[j] = new Image; d.p[j++].src = a[i]; } } }

var _timer;
function wait(code, time, timer) { timer = timer || _timer; try { clearTimeout(timer); return timer = setTimeout(code, (time || 1) * 1000); } catch (e) { pe(e); } }
function start(code, time, timer) { timer = timer || _timer; try { return timer = setInterval(code, (time || 1) * 1000); } catch (e) { pe(e); } }
function stop(timer) { try { clearInterval(timer == null ? _timer : timer); } catch (e) { pe(e); } }
function repeat(code, time) { try { return setInterval(code, (time || 1) * 1000); } catch (e) { pe(e); } }

Function.prototype.bind = function(o) { var m = this; return function() { m.apply(o, arguments); } }
function AJAX(u, f, v) {
var c = u.indexOf("&"); this.u = c < 0 ? u : u.substring(0, c); this.q = c < 0 ? null : u.substring(c); this.f = f; this.v = v; this.req; this.res;
this.send = function() { if (window.XMLHttpRequest) this.req = new XMLHttpRequest(); else if (window.ActiveXObject) this.req = new ActiveXObject("Microsoft.XMLHTTP"); if (this.req) { this.req.onreadystatechange = this.process.bind(this); this.req.open(this.q == null ? "get" : "post", this.u, true); if (this.q != null) this.req.setRequestHeader("content-type", "application/x-www-form-urlencoded"); this.req.send(this.q); } }
this.process = function() { if (this.f == null) return; var ready = this.req.readyState; if (ready == 4) { this.res = this.req.responseText; this.f(this.res, this.v); } }
}
function send(u, f, v) { var a = new AJAX(u, f, v); a.send(); return a; }
function ajax(u, o) { send(u, function(r) { html(o, r); }) }

function pe(e) { /*alert(e.description);*/ }

var globalObjStyle;
//鼠标移上改变样式
function mouseOver(obj, className) {
	if (obj == null) obj = event.srcElement;
	globalObjStyle = obj.className;
	if (className == null) className = "over";
	obj.className = className;
}

//鼠标移出改变颜色
function mouseOut(obj, className) {
	if (obj == null) obj = event.srcElement;
	if (className == null) className = globalObjStyle;
	obj.className = className;
}
