/****************************
控制图片显示大小不得超过限制范围
*****************************/
var flag=false;
function DrawImage(ImgD,w,h){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
		flag=true;
		if(image.width>image.height){
			 if(image.width>w){  
			 ImgD.width=w;
			 ImgD.height=(image.height*w)/image.width;
			 }else{
			 ImgD.width=image.width;  
			 ImgD.height=image.height;
			 }
		
		 }
		else{
			 if(image.height>h){  
			 ImgD.height=h;
			 ImgD.width=(image.width*h)/image.height;     
			 }else{
			 ImgD.width=image.width;  
			 ImgD.height=image.height;
			 }
		
		 }
    }
} 



/******************************
判断字符串长字是否超出长度限制
*******************************/
function  LengthVolidation(Str,ValidStrLength)
{   
	if (Str.length>ValidStrLength)
		{  
			return false;
		}	
		return true;
}


/******************************
判断上传文件类型是否合法文件
FileTypeStr:.jpg;.gif;.doc;
*******************************/
function FileTypeValidator(FileTypeStr,FileType)
	{   var temp="";
	    var len0=0;
	    var len1=0;	    	
        if (FileType!="")
			{ 
			temp=FileType;
			temp=temp.toLowerCase();              //将扩展名改为小写

			if (FileTypeStr.indexOf(temp)==-1)
				{ 
				   return false;
				}
		    return true;
	       }
        else
		{
	          return false;
	    }
	}
	
/*****************************
获取上传扩展名
******************************/
function GetFileType(FileStr)
{
     var Path;
	 var FileType;
	 Path=FileStr.split(".");
	 FileType=Path[Path.length-1];
	 return FileType;     
}
	

/********************************
判断字符串是否为空或空格
*********************************/
function IsEmpty(Str)
{ 
	if (strTrim(Str)==""){ 
		   return true;
		    }
	else{
		  return false;
	        }

}

/************************
 去除字符串前后空格
**************************/
function strTrim(Str)
{
	Str=Str.replace(/(^\s*)|(\s*$)/g, ""); 
	return Str;
}

