//IMAGE RESIZING
confMaxDim = 350; // in pixel

function _resize(obj) {
imgStaticWidth = obj.width;
thisWidth = obj.width;
thisHeight = obj.height;

if(thisWidth > thisHeight) thisMaxDim = thisWidth;
else thisMaxDim = thisHeight;

if(thisMaxDim > confMaxDim) {
thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * confMaxDim) / thisMaxDim);

if(thisWidth > thisHeight) {
thisWidth = confMaxDim;
thisHeight = thisMinDim;
} else {
thisHeight = confMaxDim;
thisWidth = thisMinDim;
}
} // if(thisMaxDim > confMaxDim)

obj.height = thisHeight;
obj.width = thisWidth;

if(imgStaticWidth > confMaxDim){
bottomPara = document.createElement('p');
bottomPara.setAttribute('style', 'text-align: center;width:' + obj.width + 'px;');
bottomPara.setAttribute('class', 'resizedImageLink');
bottomPara.innerHTML = '<a href="'+ obj.src +'" rel="external">Klick here for original size</a>';
obj.parentNode.appendChild(bottomPara);
}
}
