/**去掉前后空格:包括全角空格*/
function js_trim(str)
{   
    str += "";
    while( (str.charAt(0)==' ')||(str.charAt(0)=='　')||(escape(str.charAt(0))=='%u3000') )     
         str=str.substring(1,str.length);
    while( (str.charAt(str.length-1)==' ')||(str.charAt(str.length-1)=='　')||(escape(str.charAt(str.length-1))=='%u3000') )  
        str=str.substring(0,str.length-1);
    return str;
}

/*
宽大于高的时候，采用固定宽的大小，按比例缩小高
宽小于高的时候，采用固定高的大小，按比例缩小宽
*/

var flag=false;

function resizeImage(ImgD, newWidth, newHeight){
var image=new Image(); 
image.src=ImgD.src;

if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height >= newWidth/newHeight){ 
   if(image.width>newWidth){
    ImgD.width=newWidth; 
	ImgD.height=(image.height*newWidth)/image.width;     
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
   //ImgD.alt="bigpic" 
  } 
  else{ 
   if(image.height>newHeight){
    ImgD.height=newHeight; 
    ImgD.width=(image.width*newHeight)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   }
   //ImgD.alt="smallpic" 
  } 
}

}

function IsExt(url, opt){  //检验字符
	var sTemp;
	var b=false;
	var s=opt.toUpperCase().split("|");
	for (var i=0;i<s.length ;i++ ){
		sTemp=url.substr(url.length-s[i].length-1);
		sTemp=sTemp.toUpperCase();
		s[i]="."+s[i];
		if (s[i]==sTemp){
			b=true;
			break;
		}
	}
	return b;
}
