// JavaScript Document
function resizeImage(img,nwsize,nhsize)
{
	var nWidth=img.width;
	var	nHeight=img.height;
	nScale = nWidth/nHeight;
    n =  nwsize/nhsize ;
	//Check:
	if (nScale > n ) {
		nWidth = nwsize;
		nHeight = (nWidth*img.height)/img.width;
		//fix vertical-align:
		nMargin = (nhsize - nHeight)/2;
		//Set style to image:
		img.width = nWidth;
		img.height = nHeight;
		img.style.margin = nMargin + 'px 0px';
		}
	else {
		//Return size:
		nHeight = nhsize;
		nWidth = (nHeight*img.width)/img.height;
		//fix align:
		nMargin = (nwsize - nWidth)/2 ;
		//Set style to image:
		img.width = nWidth;
		img.height = nHeight;
		img.style.margin = '0px ' + nMargin + 'px';
	}
}

