function phresize(img,maxwidth,maxheight){
	if (img.width > img.height){
		if (img.width > maxwidth){
			img.width = maxwidth;
		}
	}else{
		if (maxheight>0 && img.height > maxheight){
			img.height = maxheight;
		}
	}
	if (maxheight > 0 ){
		if (img.height>maxheight){
			
		}else{
			img.style.marginTop = Math.round((maxheight - img.height) / 2 )+"px";
		}
	}
}


function setWidth(img,maxWidth){
	return img.style.width > maxWidth ? maxWidth+"px" : "auto";
}

function setHeight(img,maxHeight){
	return img.style.height > maxHeight ? maxHeight+"px" : "auto";
}