﻿

//图片按比例缩放 
function DrawImage_zdy(ImgD,iwidth,iheight) //ImgD ID//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;
		   }
	   }
    }
}
//验证手机号码 
function phones(){
	  var frm             = document.forms['phoneform'];
	  var phone           = frm.elements['phone'].value;
	  if(phone == ""){
			alert("请输入手机号码");
			frm.elements['phone'].focus();
			return false;
		}
		if(phone.length != 11){
			alert("请输入正确的手机号码");
			frm.elements['phone'].focus();
			return false;
		}
	 var regNum =/^\d*$/;
        if(!regNum.test(phone)){
			alert("请输入正确的手机号码");
			frm.elements['phone'].focus();
			return false;
		}
		return true; 	 
}