rightClickWarning = "All photos are property of EdgeOfSpeed.com Photography. All rights reserved. Unauthorized use is prohibited."; 

function InsertStretchySlideshow(parms)
{
    // copy all attributes from src object to dest object
    function CopyObj(dest, src)
    {
        for (var i in src)
        {
            dest[i] = src[i];
        }
    }
    
    function GetElementWidth(whichElem)
    {
        var elem = YD.get(whichElem);
        if (!elem) return 0;
        if (typeof elem.clip !== "undefined") 
        {
            return elem.clip.width;
        } 
        else 
        {
            if (elem.style.pixelWidth) 
            {
                return elem.style.pixelWidth;
            }
            else 
            {
                return elem.offsetWidth;
            }
        }
    }

    function GetElementHeight(whichElem)
    {
        var elem = YD.get(whichElem);
        if (!elem) return 0;
        if (typeof elem.clip !== "undefined") 
        {
            return elem.clip.height;
        } 
        else 
        {
            if (elem.style.pixelHeight) 
            {
                return elem.style.pixelHeight;
            }
            else 
            {
                return elem.offsetHeight;
            }
        }
    }
        
    function HandleResize()
    {
        try
        {
            var newSize = CalcAndSetSize();
            
            // set the slideshow to the right size and clear the cache here to get it to take the new size
            var ssObj = YD.get("stretchySSID");
            YD.setStyle(ssObj, "height", newSize.height + "px");
            YD.setStyle(ssObj, "width", newSize.width + "px");
            ssObj.extHookHandler({cmd: "clearCache"});
        } catch (e) {}
    }

    function MakeSlideshowHTML(w, h, params)
    {
        params.elementID = "stretchySSID";
        params.name = "stretchySSID";
        params.allowedDomain = document.location.hostname;
        params.type = "gallery";
        params.transparent = "true";
        var args = "";
        for (var i in params) {
            args += i + "=" + params[i] + "&amp;";
        }
        var html = "";
        // because we need a DOM ID on the object, we can't do both object and embed and have it work right (conflicting IDs)
        // if it's navigator compatible, then just do the embed tag
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)
        {
            // just embed tag
            html += '<embed id="stretchySSID" src="/ria/ShizamSlides-' + SM.appVersion['ShizamSlides'] + '.swf"';
            html += ' flashVars="' + args + '" wmode="transparent"';
            html += ' width="' + w + '" height="' + h + '"';
            html += ' type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all"/>';
            return(html);
        }
        else 
        {
            // must be IE, just use the object tag
            html += '<object id="stretchySSID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" align="middle">';
            html += '<param name="movie" value="/ria/ShizamSlides-' + SM.appVersion['ShizamSlides'] + '.swf?' + args + '" />';
            html += '<param name="wmode" value="transparent"/>';
            html += '</object>';
            return(html);
        }
    }
    
    function CalcAndSetSize()
    {
        // use the width of our container as a starting point
        var ssWidth, ssHeight, viewWidth, viewHeight;
        var ssLocalContainer = YD.get("ssLocalContainer");
        
        // calc the desired height
        viewHeight = YD.getViewportHeight();
        var ssYPos = YD.getY(ssLocalContainer);
        
        // figure out if the homePageTools are there yet (probably aren't) and account for their eventual height
        // this is only an approximation and only affects the site when loggedIn
        if (YD.hasClass(document.body, "homepage") && YD.hasClass(document.body, "loggedIn"))
        {
            var homepageToolsHeight = GetElementHeight("homepageTools");
            if (homepageToolsHeight < 20)
            {
                homepageToolsHeight = 49;            // this is the approx height (measured in Firefox)
            }
            viewHeight -= homepageToolsHeight;        // account for the space that the homepage tools will take after they are added
        }
        
        // adjust height based on passed in parameters and our current position
        viewHeight -= localParms.extraH;                        // sutract out any extraH that was specified
        viewHeight -= ssYPos;                                // subtract out our starting y position so we just fill up the rest of the screen
        viewHeight = Math.min(viewHeight, localParms.maxH);    // don't start with more than maxH
        viewHeight = Math.max(viewHeight, localParms.minH);    // don't start with less than minH
        ssHeight = viewHeight;                                // go with this full height for now
        
        YD.setStyle(ssLocalContainer, "height", ssHeight + "px");
        
        // calc the desired width
        viewWidth = GetElementWidth(ssLocalContainer);
        if (viewWidth == 0)
        {
            viewWidth = YD.getViewportWidth() - 50;        // show something if we don't have a valid width
        }
        
        // if extra width padding is specified, take that out of the viewing area width
        viewWidth -= localParms.extraW;
        viewWidth = Math.min(viewWidth, localParms.maxW);    // don't start with more than maxW
        viewWidth = Math.max(viewWidth, localParms.minW);    // don't start with less than minW
        ssWidth = viewWidth;                                    // go with this full width for now

        // if constraining the aspect ratio, then find out what fits
        if (localParms.aspectHeightConstrain == "true")
        {
            // now calc the size if we are constrained by width
            var ssHeightTest = (ssWidth * localParms.aspectHeight) / localParms.aspectWidth;
            
            // if the full height isn't needed, then go with only what is needed
            if (ssHeightTest < viewHeight)
            {
                ssHeight = ssHeightTest;
                YD.setStyle(ssLocalContainer, "height", ssHeight + "px");    // set the new height
                // Note: it is slightly possible that a scrollbar would have disappeared here (when we shortened the page), throwing our width calc off a little bit
                // not sure what we can do about that or that it's really a problem
            }
        }
        // return our results
        var ssSize = new Object;
        ssSize.width = ssWidth;
        ssSize.height = ssHeight;
        return(ssSize);
    }
    
    function AddSlideshowNow()
    {
        var ssSize = CalcAndSetSize();
        
        // now make a clean version of the parms that doesn't have all our extra ones in it
        var cleanParms = new Object;
        for (var i in localParms)
        {
            // only copy over the params that are not our params (the ones not in our defaults table)
            if (typeof(defaultParms[i]) == "undefined")
            {
                cleanParms[i] = localParms[i];
            }
        }
        
        var containerObj = YD.get("ssLocalContainer");
        containerObj.innerHTML = MakeSlideshowHTML(ssSize.width, ssSize.height, cleanParms);
    }
    
    var localParms = new Object;
    var defaultParms =
    {
        minW: 100,
        minH: 100,
        maxW: 5000,
        maxH: 5000,
        extraH: 10,
        extraW: 0,
        aspectWidth: 600,
        aspectHeight: 400,
        aspectHeightConstrain: "false",
        resize: "true"
    };
    
    // make sure that if we are constraining the aspect ratio that they have also passed in the aspect width and height
    if (parms.aspectHeightConstrain && (parms.aspectHeightConstrain == "true"))
    {
        if (!parms.aspectWidth || !parms.aspectHeight)
        {
            parms.aspectHeightConstrain = "false";        // turn constrain off because no height and width
        }
    }
    
    CopyObj(localParms, defaultParms);    // initialize with defaults
    CopyObj(localParms, parms);            // copy over the passed in parms (replacing default ones )
    
    // Now make sure all the numeric parameters that are passed in as strings are converted to numbers
    for (var i in defaultParms)
    {
        if ((typeof(defaultParms[i]) == "number") && (typeof(localParms[i]) == "string"))
        {
            localParms[i] = parseInt(localParms[i]);
        }
    }
    
    // if we are resizing, then set up a resize monitor
    if (localParms.resize != "false")
    {
        YE.on(window, 'resize', HandleResize);
    }

    // put our place holder div into place
    document.write('<div id="ssLocalContainer" style="text-align: center; margin: 0 auto; height: auto; width: auto;"></div>');
    
    // wait until the document is laid out before we can actually measure the space available and insert the slideshow
    YE.onDOMReady(AddSlideshowNow);
}
If you have any problems or issues or questions, post to 