/***
功能：清空对应对象的提示信息(Clear all messages/tips behine the object(textbox))
备注：此对象仅限于<tt>...</tt>，用于页面校验后的输入时清空页面上的校验信息(The id is only for html tag:<tt>...</tt>,to clear tips in the page after verification.)
使用示例(e.g.)
HTML:
<tt id="tipStartDate" style="COLOR: red"></tt>

Add the event to button(2)
ASP.NET:
	button.Attributes["onclick"] = "if(event.keyCode==13){return false;}else{Clear_Tip('tipStartDate');}";
HTML:
	<input type="button" onclick="if(event.keyCode==13){return false;}else{Clear_Tip('tipStartDate');}">
浏览器：>=IE5.0,>=FF1.0,Netscape(not test)
作者：Bright Zhang
日期：2006-12-27
修改：
***/
function Clear_Tip(id)
{
	document.getElementById(id).innerHTML = "";
	return true;
}
/***
功能：检查日期是否合法
Verify Date
***/
function Verify_Date(date){
	var reg = /^(\d{4})([\/,-])(\d{1,2})\2(\d{1,2})$/;
	var r = date.match(reg);
	if(r==null) return false;
	var d= new Date(r[1], r[3]-1,r[4]);
	var newStr=d.getFullYear()+r[2]+(d.getMonth()+1)+r[2]+d.getDate();
	date=r[1]+r[2]+((r[3]-1)+1)+r[2]+((r[4]-1)+1);
	return newStr==date;
}
/***
功能：检查日期是否合法
Verify Date
***/
function Verify_EURDate(date) {
    var newReg = /^(\d{1,2})([[\/,-])(\d{1,2})([\/,-])(\d{4})$/;
    var result = date.match(newReg);
    if (result == null) return false;
    var trueDate = new Date(result[5], result[3], result[1]);
    if (trueDate == NaN) return false;
    return true;
}
/***
功能：檢查是否符合Email規則
***/
function IsEmail(strEmail) {
  var objRe = /^[_a-z0-9+\.]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
  if(objRe.test(strEmail)) return true;
  return false;
}
/***
功能：取得字符串的字节长度
***/
function ByteLen(str)
	{
		var i;
        var len;
        len = 0;
        for (i=0;i<str.length;i++)
			{
			if (str.charCodeAt(i)>255) len+=2; else len++;
		}
        return len;
}
/***
功能：获取字符数/长度
***/
function Len(str)
{
	return str.length;
}
/***
功能：判断是否为float型数据
***/
function IsFloat(val_num)
{
  var checkOK = "0123456789.";
  var checkStr = val_num;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  var n=0;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if(ch==checkOK.charAt(10))
    {
       n++;//判断该字符串中有几个点
    }
    for (j = 0;  j < checkOK.length;  j++)
   if (ch == checkOK.charAt(j))
        break;

    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
 if(n>1)//如果字符串中点的个数>1的,错误
 {
  allValid=false;
  break;
 }
  }
  if (!allValid)
  {
    return (false);
  }
  return (true);
}
/***
功能：按照指定的正则表达式，来校验指定的值，如果匹配，则返回true，否则false
regexExpression:指定的正则表达式
matchString:待匹配的值
such as:"^\d+$"
***/
function RegexMatch(regexExpression,matchString)
{
	var matchResult = matchString.match(regexExpression);
	if(matchResult == null)
		return false;
	else
		return true;
}

//Author:Winson
//Date:2009-12-31
function sAlert(str){
    var msgw,msgh,bordercolor;
    msgw=400;//提示窗口的宽度
    msgh=100;//提示窗口的高度
    titleheight=25 //提示窗口标题高度
    bordercolor="#00aeef";//提示窗口的边框颜色
    titlecolor="#00aeef";//提示窗口的标题颜色

    var sWidth,sHeight;
    sWidth=document.body.offsetWidth;
    sHeight=screen.height;
    var bgObj=document.createElement("div");
    bgObj.setAttribute('id','bgDiv');
    bgObj.style.position="absolute";
    bgObj.style.top="0";
    bgObj.style.background="#777";
    bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
    bgObj.style.opacity="0.6";
    bgObj.style.left="0";
    bgObj.style.width=sWidth + "px";
    bgObj.style.height=sHeight + "px";
    bgObj.style.zIndex = "10000";
    document.body.appendChild(bgObj);

    var msgObj=document.createElement("div")
    msgObj.setAttribute("id","msgDiv");
    msgObj.setAttribute("align","center");
    msgObj.style.background="white";
    msgObj.style.border="1px solid " + bordercolor;
    msgObj.style.position = "absolute";
    msgObj.style.left = "50%";
    msgObj.style.top = "50%";
    msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
    msgObj.style.marginLeft = "-225px" ;
    msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
    msgObj.style.width = msgw + "px";
    msgObj.style.height =msgh + "px";
    msgObj.style.textAlign = "center"; 
    msgObj.style.lineHeight ="30px";// (msgh-titleheight) + "px";
    msgObj.style.zIndex = "10001";

    var title=document.createElement("h4");
    title.setAttribute("id","msgTitle");
    title.setAttribute("align","right");
    title.style.margin="0";
    title.style.padding="3px";
    title.style.background=bordercolor;
    title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
    title.style.opacity="0.75";
    title.style.border="1px solid " + bordercolor;
    title.style.height="18px";
    title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
    title.style.color="white";
    title.style.cursor="pointer";
    title.innerHTML="Sluiten";
    title.onclick=function(){
        document.body.removeChild(bgObj);
        document.getElementById("msgDiv").removeChild(title);
        document.body.removeChild(msgObj);
        }
    document.body.appendChild(msgObj);
    document.getElementById("msgDiv").appendChild(title);
    var txt=document.createElement("p");
    txt.style.margin="1em 0"
    txt.setAttribute("id","msgTxt");
    txt.innerHTML=str;
    document.getElementById("msgDiv").appendChild(txt);
}
 
 //Author:Winson
 //同时兼容ie和firefox的写法 取元素 
 function getEvent(){    
         if(document.all)    return window.event;        
         func=getEvent.caller;            
         while(func!=null){    
             var arg0=func.arguments[0];
             if(arg0){
                 if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
                     || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
                     return arg0;
                 }
             }
             func=func.caller;
         }
         return null;
 }



