/*按比例生成缩略图*/
function DrawImage(MyPic,W,H){
  var flag=false;
  var image=new Image();
  image.src=MyPic.src;
  if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= W/H){
      if(image.width>W){  
        MyPic.width=W;
        MyPic.height=(image.height*W)/image.width;
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
    else{
      if(image.height>H){  
        MyPic.height=H;
        MyPic.width=(image.width*H)/image.height;     
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
  }
} 

// 是否是email
function isEmail( str ) {
	var pattern = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;

	return pattern.test( str );
}

/**
 * 校验电话号码,传真号码
 *
 * @param str - 被校验的字符串
 * @return boolean 
 */
function isTel( str ) {
	if ( str.indexOf( ',' ) > 0 ) {
		var begin = str.substring( 0, str.indexOf( ',' ) );
		var end = str.substring( str.indexOf( ',' ) + 1 );
		if ( !isTel( end ) ) {
			return false;
		}

		str = begin;
	}

	var pattern = /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/; 
	return pattern.test( str );
}