		// 记录Description光标位置，以便插入
		function storeCaret (textEl){
			if(textEl.createTextRange){
				textEl.caretPos = document.selection.createRange().duplicate();
			}
		}

		//输入值非空检测
		function InputCheck(Element,Message)
		{
		   if (Element.value=="")
			 {
			    alert(Message);
					Element.focus();
					return (false);
			 }
			 return (true);
		}
		//密码检测
		function PwdCheck(Element)
		{
			PwdStr = Element.value;
			var PwdPat=/\S{4,20}/;
			var matchArray=PwdStr.match(PwdPat);
			if (matchArray==null) {
				alert("输入4-20位的密码。");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//用户名检测
		function NameCheck(Element)
		{
			NameStr = Element.value;
			var NamePat=/\w{4,20}/;
			var matchArray=NameStr.match(NamePat);
			if (matchArray==null) {
				alert("输入4-20位，不带特殊符号的用户登陆名。");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//用户名检测
		function UserNameCheck(Element)
		{
			NameStr = Element.value;
			var NamePat=/^[\u4e00-\u9fa5_a-zA-Z0-9]{4,20}$/;
			var matchArray=NameStr.match(NamePat);
			if (matchArray==null) {
				alert("输入4-20位，不带特殊符号的呢称");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//零的检测
		function zeroCheck (Element) {
			numStr = Element.value;
			var numPat=0;
			if (numStr==0) {
				alert("数量应该大于０！");
				Element.focus();
				return (false);
			}
			return (true);
		}
		
		//数字检测
		function numCheck (Element) {
			numStr = Element.value;
			var numPat=/^\d+$/;
			var matchArray=numStr.match(numPat);
			if (matchArray==null) {
				alert("数量应该输入数值类型值");
				Element.focus();
				return (false);
			}
			return (true);
		}
		
		//数字检测2
		function numberCheck (Element,Message) {
			numStr = Element.value;
			var numPat=/^\d+$/;
			var matchArray=numStr.match(numPat);
			if (matchArray==null) {
				alert(Message);
				Element.focus();
				return (false);
			}
			return (true);
		}
		//float类型数字检测
		function validateFloat(Element){
			numStr = Element.value;
			var numPat=/^(-|\+)?\d+(\.\d+)?$/;
			var matchArray=numStr.match(numPat);
			if (matchArray==null) {
				alert("请输入浮点类型的数字");
				Element.focus();
				return (false);
			}
			return (true);		
		}
		//email检测
		function emailCheck (Element) {
			emailStr = Element.value;
			//var emailPat=/^(.+)@(.+)$/;
			//var emailPat=/^\w+@\w+\.\w{2,3}/;
			var emailPat=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
			var matchArray=emailStr.match(emailPat);
			if (matchArray==null) {
				alert("电子邮件地址必须包括 ( @ 和 . )");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//url检测
		function urlCheck (Element) {
			urlStr = Element.value;
			var urlPat=/^http:\/\/(\w+\.)+\w(\/(\w+\/?%&=)*)?/;
			var matchArray=urlStr.match(urlPat);
			if (matchArray==null) {
				alert("输入合格的URL地址。如http://www.sensor.com.cn的形式");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//日期检测
		function dateCheck (Element) {
			dateStr = Element.value;
			var datePat=/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))/;
			var matchArray=dateStr.match(datePat);
			if (matchArray==null) {
				alert("输入合格的日期格式。");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//邮编检测
		function zipCheck (Element) {
			zipStr = Element.value;
			var zipPat=/^\d{6}$/;
			var matchArray=zipStr.match(zipPat);
			if (matchArray==null) {
				alert("邮编应为六位数字格式");
				Element.focus();
				return (false);
			}
			return (true);
		}
		//radio选中状态判断
		function radioCheck(Element) {
			var radioItem = document.getElementsByName(Element);
			for (i=0; i<radioItem.length; i++)
			{
				if (radioItem[i].checked) return (true);
			}
			return (false);
		}
		
		//float类型数字检测
		function scopelimit(Element){
			numStr = Element.value;
			if ((numStr<=0) || (numStr>10)) {
				alert("级别id必须是1-10之间的数字");
				Element.focus();
				return (false);
			}
			return (true)
		}
		
//图片按比例缩放
var flag=false;
function DrawImage(ImgD){
    var image=new Image();
    var iwidth = 140;  //定义允许图片宽度
    var iheight = 120;  //定义允许图片高度
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){  
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){  
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    }
} 

//图片按比例缩放
var flag=false;
function DrawImg(ImgD,iwidth,iheight){
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){  
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){  
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    }
} 
function CheckBrowser(){
		  var app=navigator.appName;
		  var verStr=navigator.appVersion;
		  if (app.indexOf('Netscape') != -1) {
		    return 'firefox';
		  }
		  else if (app.indexOf('Microsoft') != -1) {
		    if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1) {
		      return 'ie';
		
		    } else {return 'ie';}
		  }
		} 

function strlen(str)
{
var len;
var i;
len = 0;
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len;
}
//输入值长度检测
		function lenCheck(Element,max,Message)
		{
		   if (strlen(Element.value)>max)
			 {
			    alert(Message);
					Element.focus();
					return (false);
			 }
			 return (true);
		}
//输入值长度检测(字符)
function getStrBytes(varStr) {
 var count = 0;
 for (var i = 0; i < varStr.length; i++) {
  if (varStr.charCodeAt(i) > 127 || varStr.charCodeAt(i) == 94) {
   count = count + 2;
  } else {
   count = count + 1;
  }
 }
 return count;
}
 //兼容号码段为：13,15和18号码段  
function IsMobile(value)    
     {    
         return (new RegExp(/^((\(\d{2,3}\))|(\d{3}\-))?((13\d{9})|(15\d{9})|(18\d{9}))$/).test(value));    
     }
//验证区号3-5位数字，必须以0开头
function IsTelCode(value)    
     {    
         return (new RegExp(/^((0\d{2,4}))?$/).test(value));    
     }       
//验证电话7-8位数字，第一位数字非0  
 function IsTel(value)    
     {    
         return (new RegExp(/^[1-9]\d{6,7}?$/).test(value));    
     }       
//验证字典名的非法字符 
 function IsDicName(value)    
     {    
         return (new RegExp(/[\\"\\'\\<\\>\\“\\”\\‘\\’\\《\\》]/).test(value));    
     }
 //验证邮箱
  function IsEmail(value)    
     {    
         return (new RegExp(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/).test(value));    
     }          		
		