﻿// JScript 文件

//格式化输入框只能输入数字（包括小数与整数）
function FormatFloat(v)
{
    if(!/^\d*(\.\d*)?$/.test(v.value))v.value=v.value.substr(0,v.value.length-1);
}

//格式化输入框只能输入整数
function FormatInt(v)
{
    v.value= v.value.replace(/[^\d]/g,'');
}

function display(v,cc)
{
	var top = v.offsetTop;
	var height = v.clientHeight;
	var left = v.offsetLeft;
	while(v = v.offsetParent)
	{
		top += v.offsetTop;
		left += v.offsetLeft;
	}

	cc.style.top = top+ 20;
	//cc.style.height = height;
	cc.style.left = left;
	cc.style.display = "";
}


document.onclick = function()
{
    try
    {
        $("cc").style.display = "none";
    }
    catch(e)
    {}
}


function ForDight(Dight,How)  
{  
    Dight = Math.round   (Dight*Math.pow(10,How))/Math.pow(10,How);
    return Dight;  
}  


function DX(n) {
    var strOutput = "";
    var strUnit = '千百拾亿千百拾万千百拾元角分';
    n += "00";
    var intPos = n.indexOf('.');
    if (intPos >= 0)
        n = n.substring(0, intPos) + n.substr(intPos + 1, 2);
    strUnit = strUnit.substr(strUnit.length - n.length);
    for (var i=0; i < n.length; i++)
        strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(n.substr(i,1),1) + strUnit.substr(i,1);
    return strOutput;
}


function ValidEmail(v)
{
    if(v == null || v == "" || v.length == 0)
    {
        return false;
    }
    
    var   pattern =/^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[_.0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+(.+)$/;
    flag = pattern.test(v); 
    return flag;
}



//js写cookie
function SetCookie(cookieName,cookieValue,expiredTime) 
{ 
    var exp = new Date();
    exp.setTime (exp.getTime() + expiredTime); 
    document.cookie = cookieName + "=" + cookieValue + "; expires="+ 

    exp.toGMTString();
}

//js读cookie
function GetCookie(name) 
{ 
        m=document.cookie; 
        re1=new   RegExp("(?!w)"+name+"=[^;]+",""); 
        re2=new   RegExp("^"+name+"=",""); 
        try 
        { 
            
                var a=m.match(re1)[0]; 
        }
        catch(e) 
        { 
                return null 
        } 
        eval("var   o="+a.replace(re2,"{").replace(/&/g,"',").replace

        (/=/g,":'")+"'}"); 
        return   o; 
}