function trim(str)//去除首尾空格函数
{
	return str.replace(/(^\s*)|(\s*$)/g, ""); 
}
function Trim(str)
{
	return str.replace(/(^\s*)|(\s*$)/g, ""); 
}

function LockRightMouse()
{
	if (event.button==2 || event.button==3 || event.button==6 || event.button==7)
	{
		alert("禁止使用右键！");
		// oncopy="document.selection.empty()"  onselectstart="event.returnValue=false"
	}
}
function IsNumber(n)
{
	return (/^\d+$/g).test(n)
}
function IsValidDate(d)
{
	return (/^\d{4}-\d{2}-\d{2}$/).test(d);
}
function IsAge(v)
{
	var a = (/^\d{1,3}$/).test(v);
	return a;
}
function IsEmail(str)
{
	var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/;
	return reg.test(str);
}
function IsTel(str)
{
	return (/^[\d-_]+$/).test(str);
}
function DrawImage(ImgD,iwidth,iheight)
{
     //参数(图片,允许的宽度,允许的高度)
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0)
	 {
		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;
			 }
		 }
		 else
		 {
			 if(image.height>iheight)
			 {  
				 ImgD.height=iheight;
				 ImgD.width=(image.width*iheight)/image.height;        
			 }
			 else
			 {
				 ImgD.width=image.width;  
				 ImgD.height=image.height;
			 }
         }
     }
} 


