
var maxSize = 240;


/** Tried to hide image and show image, but in that case it was impossible
to retrieve image width/height in IE */
function checkImage(currentImage) {
	currentWidth = currentImage.width;
	currentHeight = currentImage.height;
	if (currentWidth > currentHeight) {
		if (currentWidth > maxSize) {
			currentImage.width = maxSize;
			currentImage.height = (maxSize * currentHeight)/currentWidth;
		}
	} else {
		if (currentHeight > maxSize) {
			currentImage.width = (maxSize * currentWidth) / currentHeight;
			currentImage.height = maxSize;
		}
	}
}
function limitSize(imageNumber) {
	document.getElementById('image' + imageNumber + 'Id').onload=function() {
		checkImage(document.getElementById('image' + imageNumber + 'Id'));
	}
}
function textareaMaxSize(field, maxSize) {
	var safetyFactor = 20;
	if (field.value.length >= maxSize - safetyFactor) {
		field.value = field.value.substring(0, maxSize - safetyFactor);
	}
}


