﻿// JavaScript File
function imgutils_resize(aimg,height,width)
{
    if(aimg.nodeName != "IMG") aimg = document.getElementById(aimg)
    if(aimg!=null)
    {
        var h = aimg.height;
        var w = aimg.width;
        if(h<=height && w<=width) return;
        var imgratio = aimg.height/aimg.width;
        var thumbratio = height/width;
        if(imgratio > thumbratio)
		{
			aimg.width = height;
			aimg.heigh = (h/imgratio);
		}
		else 
		{
			aimg.width = width;
			aimg.heigh = (w*imgratio);
		}
    }
}

function imgutils_window(imgurl)
{
    var popupoptions = "'toolbar=no,location=no,directories=no,resizable=yes,width=800,height=600'";
    var newwin = window.open('','imgwindow',popupoptions);
    if(newwin != null)
    {
        newwin.document.write('<HTML><HEAD><SCRIPT type="text/javascript">function resizeWindow(){');
        newwin.document.write('var img=document.getElementById("img"); window.resizeTo(img.width,img.height);}</SCRIPT></HEAD>');
        newwin.document.write('<BODY style="margin:0px;border:0px;" onload="resizeWindow();">');
        newwin.document.write('<img id="img" src="'+imgurl+'" border="0" /></BODY></HTML>');
    }
}


