// JavaScript Document
//**********************************************************
// FUNCTION : changeImage
// DESCRIPTION : swaps image source in img tags identified by 
// the name passed in img_field
//**********************************************************
function changeImage(img_field,new_image,new_width,new_height,max_width){
	if (Number(new_width) > Number(max_width)){
		//calculate ratio to reduce width to fit and height to maintain correct scaling
		perc_adjust = (max_width/new_width)*100;
		final_width = Math.round((new_width/100)*perc_adjust);
		final_height = Math.round((new_height/100)*perc_adjust);
	} else {
		final_width = new_width;
		final_height = new_height;
	}
	document[img_field].src = new_image;
	document[img_field].width = final_width;
	document[img_field].height = final_height;
}
