﻿/*
author: cray
purpose: a very simple, small script using mootools to resize all images on a page, except ones styled with noresize class;
moooooooooooooooooo!
*/

var ImageResizer = Class.create();
ImageResizer.prototype = {
	initialize: function(width) {
		this.maxWidth = width;
		images = document.images;
		for(i=0;i< images.length;i++){
			el = images[i];
			if (el.width > this.maxWidth){
				if(el.className != "noresize"){
				//if image is wider/taller then max values
				var n = this.calcDim(el);
				images[i].width = n[0];
				images[i].height = n[1];
				}					
			}
		}
	},
	calcDim: function (el){
		nw = this.maxWidth;
		nh = parseInt(((this.maxWidth/el.width)*el.height));
		dims = [nw,nh];
		return dims;
	}
}