﻿//常用JS函数

//文章图片自动大小 
function resizepic(thispic) 
{	
	sWidth = 600;
	var image = new Image();
	image.src = thispic.src;
	if(image.width>sWidth){
		thispic.width=sWidth;
		thispic.height= (image.height/image.width) * sWidth ;
	}
}

//设置图片等比例自动缩放
function setPicSize(pic,imgw,imgh)
{
	//xiaomo 修改版
	var image = new Image();
	image.src = pic.src;
	if(image.width/image.height>=imgw/imgh&&image.width>imgw)
	{
		pic.width=imgw;
		pic.height= (image.height/image.width) * imgw ;
	}
	else if(image.width/image.height<imgw/imgh&&image.height>imgh)
	{
		pic.height=imgh;
		pic.width= (image.width/image.height) * imgh ;
	}
	/*　原版
	if(pic.width/pic.height>=imgw/imgh&&pic.width>imgw)
	{
		 pic.height*=imgw/pic.width;
		 pic.width=imgw;
	}
	else if(pic.width/pic.height<imgw/imgh&&pic.height>imgh)
	{
		 pic.width*=imgh/pic.height;
		 pic.height=imgh;
	}
	*/
}


