﻿/*
说明：刷新验证码用

修改记录：

调用：
reloadcode(this)
*/

function reloadcode(o) {
    o.src = o.src + '?' + Math.random();
}



/*
说明：表格背景变换
用法：TrBgColor(对象,Css1，Css2，Css3);
修改记录：
tr.t1 td {background-color:#EFFEDD;}
tr.t2 td {background-color:#ffffff;}
tr.t3 td {background-color:#D2FCA0;}
调用：
    <script type="text/javascript">
        var Ptr = document.getElementById("tab").getElementsByTagName("tr");
        window.onload = function() { TrBgColor(Ptr, "t1", "t2", "t3"); }
    </script>
*/
function TrBgColor(o, cls1, cls2, clsOn) {
    for (i = 1; i < o.length + 1; i++) {
        o[i - 1].className = (i % 2 > 0) ? cls1 : cls2;
    }
    for (var i = 0; i < o.length; i++) {
        o[i].onmouseover = function() {
            this.tmpClass = this.className;
            this.className = clsOn;
        };
        o[i].onmouseout = function() {
            this.className = this.tmpClass;
        };
    }
}

/*
说明：语言转换
用法：Lang("en");
修改记录：
统一转换为小写
*/
function Lang(NewStr) {
    var url = document.location.href.toLowerCase();
    var newUrl;
    if (url.indexOf("/" + NewStr + "/") > 0) {
    } else {
        if (NewStr == "en") {
            newUrl = url.replace("\/cn\/", "\/" + NewStr + "\/");
            window.location = newUrl;
        }
        if (NewStr == "cn") {
            newUrl = url.replace("\/en\/", "\/" + NewStr + "\/");
            window.location = newUrl;
        }
    }
}

/*
说明：设置表格样式===调用TrBgColor函数
*/
function SetBgColor(TbId) {
	if (null != document.getElementById(TbId)) {
		var Ptr = document.getElementById(TbId).getElementsByTagName("tr");
		window.onload = function() { TrBgColor(Ptr, "t1", "t2", "t3"); }
	}
}

/*
* 2010-2-3
* 说明：修改排序编号
*/
/*
$(document).ready(function() {
	$(".BY").dblclick(function() {
		var old = $(this).text();
		var o = $(this);
		o.html("<input class=\"OnBY\" type=\"text\" onMouseOver=\"this.select();\" value=\"" + old + "\"/>");
		$(".OnBY").blur(function() {
			//设置鼠标样式为繁忙就好了
			$.ajax({
				type: "GET",
				url: "../EditOrderBY.aspx",
				data: "AC=" + o.attr("table") + "&ID=" + o.attr("BYID") + "&BY=" + $(".OnBY").val(),
				success: function(msg) {
					//解决系统安全问题
					if (msg.indexOf("[UPDATEOK]") >= 0) {
						o.html($(".OnBY").val());
					} else {
						alert("发生错误： " + msg);
						o.html(old);
					}
				}
			});
		});
	});
});
*/

/**
*页面复选框 全选 或是 反选
*通过传来控件ID，如果此控件选中，刚全选中，否则相反
*/
function checkAll(ck){
    var check=document.getElementsByTagName("input");
    for(var i=0;i<check.length;i++){
        if(check[i].type=="checkbox")
            check[i].checked=ck.checked;
    }
}
