function Onlynumber(inputValue) //只允许输入数字
{
    var str = inputValue.value.replace(/\D/g,"。");
    if(str.indexOf('。') > -1)
	{
	    inputValue.value = str.substr(0,str.indexOf('。'));
	}
}
//控制输入字符串长度
function ValueLength(inputValue,NumberLength)
{
    if(inputValue.value.length > NumberLength)
    {
        inputValue.value = inputValue.value.substr(0,NumberLength);
    }
}
//文本框验证float数据
function onlyNumAndD(strValue)
{
	var str = strValue.value.replace(/[^0-9\.]/,"。");
	if (str.indexOf(".") == 0)
	{
		strValue.value = "";
	}
	if(str.split(".").length > 2)
	{
		strValue.value = str.substring(0,str.indexOf('.'));
	}
	
	if(str.indexOf('。') > -1)
	{
	    strValue.value = str.substr(0,str.indexOf('。'));
	}
}
///小数可以为负数
function onlyNumAndD2(strValue)
{
	var str = strValue.value.replace(/[^0-9\.\-]/,"。");
	if (str.indexOf(".") == 0)
	{
		strValue.value = "";
	}
	if(str.split(".").length > 2)
	{
		strValue.value = str.substring(0,str.indexOf('.'));
	}
	if(str.indexOf("-") > -1)
	{
		if(str.indexOf("-") != 0)
		{
			strValue.value = str.substring(0,str.indexOf('-'));
		}
		if(str.split("-").length > 2)
		{
			strValue.value = str.substring(0,str.split("-")[1].length + 1);
		}
	}
	
	if(str.indexOf('。') > -1)
	{
	    strValue.value = str.substr(0,str.indexOf('。'));
	}
}
//只能输入英文字母和数字,不能输入中文
function onlyNumAndEng(strValue)
{
    var str = strValue.value.replace(/[^\w\.\/\:\@]/ig,"。");
    if(str.indexOf('。') > -1)
	{
	    strValue.value = str.substr(0,str.indexOf('。'));
	}
}
//只能输入汉字
function onlyChina(strValue)
{
    var str = strValue.value.replace(/[^\u4E00-\u9FA5]/g,"。");
    if(str.indexOf('。') > -1)
	{
	    strValue.value = str.substr(0,str.indexOf('。'));
	}
}

//显示灰色JS遮罩层
function showBg(ct){
    var bH=$("body").height()+16;
    var bW=$("body").width()+16;
    var objWH=getObjWh(ct);
    $("#fullbg").css({width:bW,height:bH,display:"block"});
    var tbT=objWH.split("|")[0]+"px";
    var tbL=objWH.split("|")[1]+"px";
    $("#"+ct).css({top:tbT,left:tbL,display:"block"});
    $(window).scroll(function(){resetBg(ct)});
    $(window).resize(function(){resetBg(ct)});
}
function getObjWh(obj){
    var st=document.documentElement.scrollTop;//滚动条距顶部的距离
    var sl=document.documentElement.scrollLeft;//滚动条距左边的距离
    var ch=document.documentElement.clientHeight;//屏幕的高度
    var cw=document.documentElement.clientWidth;//屏幕的宽度
    var objH=$("#"+obj).height();//浮动对象的高度
    var objW=$("#"+obj).width();//浮动对象的宽度
    var objT=Number(st)+(Number(ch)-Number(objH))/2;
    var objL=Number(sl)+(Number(cw)-Number(objW))/2;
    return objT+"|"+objL;
}
function resetBg(divNmae){
    var fullbg=$("#fullbg").css("display");
    if(fullbg=="block"){
    var bH2=$("body").height()+16;
    var bW2=$("body").width()+16;
    $("#fullbg").css({width:bW2,height:bH2});
    var objV=getObjWh(divNmae);
    var tbT=objV.split("|")[0]+"px";
    var tbL=objV.split("|")[1]+"px";
    $("#" + divNmae).css({top:tbT,left:tbL});
    }
}

//关闭灰色JS遮罩层和操作窗口
function closeBg(divNmae){
    $("#fullbg").css("display","none");
    $("#" + divNmae).css("display","none");
}

function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value);
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

function JsServer(Uid)
{
    var strUid = document.getElementById(Uid);
    strUid.click();
}

function butMessage()
{
    var username = document.getElementById("MessUserName");
    var Tel = document.getElementById("MessTex");
    var Mobile = document.getElementById("MessMob");
    var MessText = document.getElementById("MessText");
    var MessContent = document.getElementById("MessContent");
    if(username.value == '')
    {
        alert("请输入您的姓名");
    }
    else
    {
        if (Tel.value == '' && Mobile.value == '')
        {
            alert("电话号码和手机必须输入一项");
        }
        else
        {
			if(MessText.value == '')
			{
				alert("请输入留言主题");
			}
			else
			{
				if (MessContent.value.length < 5)
				{
					alert("留言内容必须大于五个字符");
				}
			}
        }
    }
}

function En_butMessage()
{
    var username = document.getElementById("username");
    var Tel = document.getElementById("Tel");
    var Mobile = document.getElementById("Mobile");
    var msg = document.getElementById("msg");
    if(username.value == '')
    {
        alert("Please enter your name !");
    }
    else
    {
        if (Tel.value == '' && Mobile.value == '')
        {
            alert("Phone or mobile phones must be input a item!");
        }
        else
        {
            if (msg.value.length < 6)
            {
                alert("Message content must be more than five characters!");
            }
        }
    }
}

///Js 获取FileUpload 是绝对路径，参数，file 控件ID，赋值的hidden控件ID
function jsFileImg(fileName,hidName)
{
    if ((window.navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)) {
        var isIE = (document.all) ? true: false;
        var isIE6 = isIE && (navigator.userAgent.indexOf('MSIE 6.0') != -1);
        var isIE7 = isIE && (navigator.userAgent.indexOf('MSIE 7.0') != -1);
        var isIE8 = isIE && (navigator.userAgent.indexOf('MSIE 8.0') != -1);

        var file = document.getElementById(fileName);
        if (isIE7 || isIE8) {
            file.select();
            var fullpath = document.selection.createRange().text;
            document.getElementById(hidName).value = fullpath; //隐藏域
            document.selection.empty();
        } else { //机器上没安装ie6，还未测试ie6能直接获得完整路径不? GAGAHJT 2010
            document.getElementById(hidName).value = file.value; //隐藏域
        }
    } else if (navigator.userAgent.indexOf('Firefox') >= 0) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch(e) {
            document.getElementByIdx_x(fileName).value = "";
            var tip = "如果您用的是火狐浏览器请设置如下：\n\n在地址栏输入： about:config \n然后找到" + "signed.applets.codebase_principal_support" + "双击进行修他后面的键值，将值修改为true关闭即可，否则您不能上传店面招牌！";
            alert(tip);
            return;
        }
        var fname = document.getElementById(fileName).value;
        var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
        try {
            file.initWithPath(fname.replace(/\//g, "\\\\"));
        } catch(e) {
            if (e.result != Components.results.NS_ERROR_FILE_UNRECOGNIZED_PATH) throw e;
            alert(' 无法加载文件 ');
            return;
        }
        document.getElementById(hidName).value = fname; //隐藏域
    } else if (navigator.userAgent.indexOf('Opera') >= 0) {
        //未测试。。。。。。。。
    }
 }
 
 

///Grid Out事件
function GridOut(strId)
{
	var trId = document.getElementById(strId);
	var strClsName = trId.className;
	if (strClsName.indexOf("linkDown") < 0)
	{
		trId.className = "";
	}
}

///Grid Over事件
function GridOver(strId)
{
	//alert(strId);
	var trId = document.getElementById(strId);
	//trId.style.height = "100";
	var strClsName = trId.className;
	if (strClsName.indexOf("linkDown") < 0)
	{
		trId.className = "BotDas";
	}
}

///Grid单击事件
function GridDown(intNow,intCount)
{
	var ForIndex;
	var GridItems = document.getElementById("PageUrlDataGrid1_GridItems");
	var GridCount = document.getElementById("PageUrlDataGrid1_GridCount");
	
	if(parseInt(intNow) >= parseInt(intCount))
	{
		intNow = intCount - 1;
	}
	
	for(ForIndex=0;ForIndex<intCount;ForIndex++)
	{	
		var trId = document.getElementById("tr" + ForIndex.toString());
		var strClsName = trId.className;
		
		if(intNow == ForIndex)
		{
			if (strClsName.indexOf("linkDown") < 0)
			{
				trId.className += " linkDown";
				GridItems.value = intNow.toString();
				
				var GridBut = document.getElementById("GridBut");
				GridBut.click();
			}
		}
		else
		{
			if (strClsName.indexOf("linkDown") > -1)
			{
				trId.className -= " linkDown";
			}
		}
	}
}

///根据QueryString参数名称获取值
function getQueryStringByName(name){
	var result = location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i"));
	if(result == null || result.length < 1){
		return "";
	}
		return result[1];
}

