/**
 * Returns true if custom width and height are supported by material definition
 * 
 * @param mdf
 * @param customWidth
 * @param customHeight
 * @return boolean
 */
function mdfSupportsScalableSize(mdf, customWidth, customHeight) {

	if(!Number(customWidth) || !Number(customHeight)) {
		return false;
	}
	
	customWidth = Number(customWidth);
	customHeight = Number(customHeight);
	
	for(i in mdf.sizes) {
		
		var size = mdf.sizes[i];
		
		var newWHRatio = customWidth / customHeight;
		var newHWRatio = customHeight / customWidth;

		if(
			(customWidth / size.msz_width * 100 >= 100 - mdf.min_scale_width)
			&&
			(customWidth / size.msz_width * 100 <= 100 + mdf.max_scale_width)
			&&
			(customHeight / size.msz_height * 100 >= 100 - mdf.min_scale_height)
			&&
			(customHeight / size.msz_height * 100 <= 100 + mdf.max_scale_height)
			&&
			((size.msz_width / size.msz_height) / newWHRatio <= mdf.max_wh_scale_ratio)
			&&
			((size.msz_height / size.msz_width) / newHWRatio <= mdf.max_hw_scale_ratio)
			) {
				return true;
			}
					
	}
}
