    function DisplayScaledImage(BrowserName, ImgSrc, origWidth, origHeight, WidthToUse, AltText, ImgID, OnClick){

        if (OnClick != '') document.write('<a href="#' + ImgID + '">');
        
        document.write('<img src="' + ImgSrc + ImageSizeString(BrowserName, origWidth, origHeight, WidthToUse) );
        if (AltText != '') document.write(' alt="' + AltText + '" ');
        if (ImgID != '') document.write(' ID="' + ImgID + '" ');
        if (OnClick != '') document.write(' onclick="' + OnClick + '" ');
        document.write('>');
        if (OnClick != '') document.write('</a>');
    }
    
    
    function addslashes(str) {
        //str=str.replace(/\\/g,'\\\\');
        //str=str.replace(/\'/g,'\\\'');
        str=str.replace(/\"/g,'\'');
        str=str.replace(/\0/g,'\\0');
        return str;
    }
    /*
    function DisplayScaledImage(BrowserName, ImgSrc, origWidth, origHeight, WidthToUse, AltText, ImgID, OnClick){
 
        if (OnClick != '') document.write('<a href="#' + ImgID + '">');
        var writeCommand;
        var writeCommand='<img src="' + ImgSrc + ImageSizeString(BrowserName, origWidth, origHeight, WidthToUse) ;
        if (AltText != '') writeCommand+=' alt="' + addslashes(AltText) + '" ';
        if (ImgID != '') writeCommand+=' ID="' + addslashes(ImgID) + '" ';
        if (OnClick != '') writeCommand+=' onclick="' + addslashes(OnClick) + '" ';
        writeCommand+='/>';
        if (OnClick != '') writeCommand+='</a>';
                alert(writeCommand);
                document.write(writeCommand);
    }*/

    
    function ImageSize(BrowserName, origWidth, origHeight, WidthToUse){
        var pageWidth=800;
       var pageHeight=533;
       
       
       if(BrowserName.toLowerCase() == 'netscape' || BrowserName.toLowerCase() == 'firefox' || BrowserName.toLowerCase() == 'opera' || BrowserName.toLowerCase() == 'safari') {
            pageWidth=innerWidth;
            pageHeight=innerHeight;
        } else if(BrowserName.toUpperCase() == 'MSIE') {
            pageWidth=document.body.clientWidth;
            pageHeight=document.body.clientHeight;
        } 
       
        var WidthRatio = pageWidth / origWidth;
        var HeightRatio = pageHeight / origHeight;
        var Ratio = (WidthRatio < HeightRatio ? WidthRatio : HeightRatio);
        var ImgWidth = origWidth * Ratio *WidthToUse;
        var ImgHeight = origHeight * Ratio*WidthToUse;
        
        var retval = {
            'Width': ImgWidth,
            'Height': ImgHeight
            };
        return retval;
        }
        
    function ImageSizeString(BrowserName, origWidth, origHeight, WidthToUse){
        var ImgSizes = ImageSize(BrowserName, origWidth, origHeight, WidthToUse);
        return '" width="' + ImgSizes['Width']    + '"  height="' + ImgSizes['Height'] + '" ';
    }

    function ChangeImageSize(Element, targetWidth){
        //alert ('Change Size of ' + Element.ID + ' to ' + targetWidth);
        
        var newTargetWidth;
        
        if (targetWidth > 0.5){ //double it
            Element.height *= 2;
            Element.width *= 2;
            newTargetWidth = targetWidth/2;
        }else{ //half it
            Element.height *= .5;
            Element.width *= .5;
            newTargetWidth = targetWidth*2;        
        }
        
        Element.onclick = function(){
          ChangeImageSize(this, newTargetWidth )
        }
        
    }
    
    function wopen(url, name, w, h)
    {
        //http://www.boutell.com/newfaq/creating/windowsize.html
        // Fudge factors for window decoration space.
         // In my tests these work well on all platforms & browsers.
        w += 32;
        h += 96;
         var win = window.open(url,
          name,
          'width=' + w + ', height=' + h + ', ' +
          'location=no, menubar=no, ' +
          'status=no, toolbar=no, scrollbars=no, resizable=no');
         win.resizeTo(w, h);
         win.focus();
    
    }
