function ResizeImage(id,dimmax,maxwidth,maxheight)
{
	var imgWidth = document.getElementById(id).width;
	var imgHeight = document.getElementById(id).height;
	var newWidth = 100;
	var newHeight = 100;
	
	trace(imgWidth);
	trace(imgHeight);
		
	if (imgWidth>0 && imgHeight>0)
	{
		if (imgHeight>=imgWidth)
		{
			newWidth = Math.round(imgWidth*dimmax/imgHeight);
			newHeight = dimmax;
		}
		else
		{
			newWidth = dimmax;
			newHeight = Math.round(imgHeight*dimmax/imgWidth);
		}
		
		if (newWidth>maxwidth)
		{
			newWidth = maxwidth;
			newHeight = Math.round(imgHeight*maxwidth/imgWidth);
		}
		
		if (newHeight>maxheight)
		{
			newHeight = maxheight;
			newWidth = Math.round(imgWidth*maxheight/imgHeight);
		}
		
		
		//document.getElementById(id).width = newWidth;
		//document.getElementById(id).height = newHeight;
	}
}


function ResizeImageToElemWidth(id,elemid,maxwidth,maxheight)
{	
	var imgWidth = document.getElementById(id).width;
	var imgHeight = document.getElementById(id).height;
	
	var newWidth = imgWidth;
	var newHeight = imgHeight;
	
	dimmax = document.getElementById(elemid).offsetWidth;
	
	if (imgWidth>0 && imgHeight>0)
	{
		newWidth = dimmax;
		newHeight = Math.round(imgHeight*dimmax/imgWidth);
		
		if (newWidth>maxwidth || newHeight>maxheight)
		{
			if (newWidth>maxwidth)
			{
				newWidth = maxwidth;
				newHeight = Math.round(imgHeight*maxwidth/imgWidth);
			}
			
			if (newHeight>maxheight)
			{
				newHeight = maxheight;
				newWidth = Math.round(imgWidth*maxheight/imgHeight);
			}
			
			document.getElementById(id).width = newWidth;
			document.getElementById(id).height = newHeight;	
		}
	}
}

function ResizeHomeImage()
{	
	ResizeImageToElemWidth('homeImg','photoBig',600,500)
}
//onresize = ResizeHomeImage;


function ImageMaxSize(id,maxwidth,maxheight)
{
	var imgWidth = document.getElementById(id).width;
	var imgHeight = document.getElementById(id).height;
	var newWidth = 100;
	var newHeight = 100;
	
	if (imgWidth>0 && imgHeight>0)
	{
		if (imgWidth>maxwidth || imgHeight>maxheight)
		{
			if (imgHeight>=imgWidth)
			{
				newHeight = maxheight;
				newWidth = Math.round(imgWidth*maxheight/imgHeight);
			}
			else
			{
				newWidth = maxwidth;
				newHeight = Math.round(imgHeight*maxwidth/imgWidth);
			}
			
			document.getElementById(id).width = newWidth;
			document.getElementById(id).height = newHeight;
		}
	}
}


function ImageMaxWidth(id,maxwidth)
{
	var imgWidth = document.getElementById(id).width;
	var imgHeight = document.getElementById(id).height;
	
	if (imgWidth>maxwidth)
	{
		newWidth = maxwidth;
		newHeight = Math.round(imgHeight*newWidth/imgWidth);
			
		document.getElementById(id).width = newWidth;
		document.getElementById(id).height = newHeight;
	}
}





