function fabrixImageResizer(image,width,height,stretch){
	fabrixImageResizer(image,width,height,stretch,false)
}

function fabrixImageResizer(image,width,height,stretch,pad){
	var resized = false;
	image.style.width="auto";
	var scale = (width>0 && image.width != width)? width/image.width : false;
	if(height>0 && image.height != height)
		scale = (scale==false || height/image.height<scale)? height/image.height : scale;
	if(scale && (stretch || scale<1)){
		resized=true;
		image.style.width=Math.max((scale*image.width),1)+"px";
	}else{
		image.style.width="auto";
	}
	if(pad){
		if(resized){
			if(width>0){
				image.style.marginLeft=((width-parseFloat(image.style.width))/2)+"px";
				image.style.marginRight=((width-parseFloat(image.style.width))/2)+"px";
			}if(height>0){
				image.style.marginTop=((height-image.height)/2)+"px";
				image.style.marginBottom=((height-image.height)/2)+"px";
			}
		}else{
			if(width>0){
				image.style.marginLeft=((width-image.width)/2)+"px";
				image.style.marginRight=((width-image.width)/2)+"px";
			}
			if(height>0){
				image.style.marginTop=((height-image.height)/2)+"px";
				image.style.marginWidth=((height-image.height)/2)+"px";
			}
		}
	}
}
