/*======================================================*/
/*== Force Non-Customizable Galleries to Smugmug view ==*/
/*======================================================*/

function ForceSmugmugView()
{
    // if we're on a galleryPage, and the view isn't already smugmug
    if (!YD.hasClass(document.body, "smugmug"))
    {
        var url = window.location.toString();
        var re = new RegExp(/forceView=(\d+)/);
        var match = re.exec(url);
        var curTime = new Date();
        if (match && (match.length > 1))
        {
            var prevTime = new Date();
            prevTime.setTime(match[1]);
            // check to see if we've already done this in the last 60 seconds to avoid loops
            if (curTime - prevTime < (60*1000))
            {
                return;
            }
        }
        var postData = 'tool=setCookie&value=3&type=Template';
        var broken = function() {};
        var reloadPage = function() 
        {
            var newUrl;
            if (match)
            {
                newUrl = url.replace(/forceView=\d+/, "forceView=" + curTime.getTime());
            }
            else if (url.indexOf("?") != -1)
            {
                newUrl = url.replace("?", "?forceView=" + curTime.getTime());
            }
            else if (url.indexOf("#") != -1)
            {
                newUrl = url.replace("#", "?forceView=" + curTime.getTime() + "#");
            }
            else
            {
                newUrl = url + "?forceView=" + curTime.getTime();
            }
            window.location.replace(newUrl);
        };
        var callback = {
            success: reloadPage,
            failure: broken,
            scope: this
        };
        YAHOO.util.Connect.asyncRequest('POST','/rpc/settings.mg', callback, postData);
    }
}

// only trigger this function if there is a stylebar because that means the gallery isn't locked into a particular view
YE.onAvailable("stylebar", ForceSmugmugView);


/*====================================*/
/*== GuestBook Comment Title Change ==*/
/*====================================*/

function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_2343970"))
  {
    var objElement = YD.get("comment")
    if (objElement != null)
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'Guestbook');
      objElement.innerHTML = str;
    }
  }
}
 
YE.onAvailable("comment", ModifyText);
/*== End of GuestBook Header Change ==*/


/*=================================*/
/*== Creating passwordPage Class ==*/
/*=================================*/
function checkPasswordPage()
{
   if ( YD.getElementsByClassName('passwordPage', 'div')[0] ) {
      YD.addClass(document.body,"passwordPage"); 
   }
}


/*======================*/
/*== Customized Title ==*/
/*======================*/
// On IE/FF set the title before the Document OnLoad takes place
document.title = "Brandolino Imaging";
addEvent( window, "load", CustomizeTitle );

function CustomizeTitle()
{
	var baseTitle = "Brandolino Imaging";
	var separator = " - ";
	var albumTitle = GetText( document.getElementById("albumTitle") );
	var galleryTitle = GetText( document.getElementById("galleryTitle") );
	var singleImage = document.body.className && document.body.className.indexOf("singleImage") > -1 ? true : false;
	var pageTypeDefined = typeof( pageType ) != "undefined";
	var pageTypeDetailsDefined = typeof( pageTypeDetails ) != "undefined";

	// Don't change the title from the above document.title on the homepage
	if( document.body.className && document.body.className.indexOf("homepage") > -1 )
	{
		document.title = baseTitle + separator + "Anthony Brandolino";
		return;
	}

	// The guestbook album gets a special title
	if( window.AlbumID && window.AlbumID == "1128948" )
	{
		// Guestbook
		document.title = "Brandolino Imaging's Guestbook";
		return;
	}

	// An album page (holds a bunch of photos, could be "zoomed in" on a specific photo)
	if( albumTitle )
	{
		var photoTitle = GetPhotoTitle();
		if( photoTitle )
			document.title = baseTitle + separator + albumTitle + separator + photoTitle;
		else
			document.title = baseTitle + separator + albumTitle;
		return;
	}

	// A gallery page (holds a bunch of albums and/or a bunch of sub categories)
	if( galleryTitle )
	{
		// Strip " sub-categories" off the end of the category text
		var finalPositionCategory = galleryTitle.indexOf(" sub-categories");
		if( finalPositionCategory > -1 )
			galleryTitle = galleryTitle.substr( 0, finalPositionCategory );
		else
		{
			// Strip " galleries" off the end of the category/sub-category text
			var finalPositionSubCategory = galleryTitle.indexOf(" galleries");
			if( finalPositionSubCategory > -1 )
				galleryTitle = galleryTitle.substr( 0, finalPositionSubCategory );
		}
		document.title = baseTitle + separator + galleryTitle;
		return;
	}

	// A single image (like the kind you get when you click an image in a keyword page)
	if( singleImage )
	{
		var photoTitle = GetPhotoTitle();
		if( photoTitle )
			document.title = baseTitle + separator + photoTitle;
		else
			document.title = baseTitle + separator + "untitled photo";
		return;
	}

	// A single keyword page
	if( pageTypeDefined && pageType == 'Keyword' && pageTypeDetailsDefined )
	{
		// Keyword page
		document.title = baseTitle + separator + "Keyword: " + pageTypeDetails;
		return;
	}

	// A multiple keyword page
	if( pageTypeDefined && pageType == 'Keywords' && pageTypeDetailsDefined )
	{
		// Multiple keywords page
		// Put " + " between each keyword instead of -
		var keywordList = pageTypeDetails;
		keywordList = keywordList.replace(/\-/g, " + ");
		document.title = baseTitle + separator + "Keywords: " + keywordList;
		return;
	}

	// The main keywords page. Note: single image takes precedence over this type
	if( document.body.className && document.body.className.indexOf("keywordPage") > -1 )
	{
		// Main Keywords Page
		document.title = baseTitle + separator + "Keywords";
		return;
	}

	// None of the rules above set the title! Oh well, fall back on the base title.
	document.title = baseTitle;
} // CustomizeTitle

function Trim( text )
{
	text = text.replace(/(^\s+)|(\s+$)/g, ""); // trim leading and trailing white space
	return text;
} // Trim

function GetText( node )
{
	if( !node )
		return "";
	if( node.innerText )
		return Trim( node.innerText ); // For IE
	if( node.textContent )
		return Trim( node.textContent ); // For others
	return "";
} // GetText

function GetPhotoTitle()
{
	// If the photo title is set, it starts with the breadcrumb.
	var breadCrumbStart = "Brandolino Imaging > ";
	var mainPhoto = document.getElementById("mainPhoto");
	if( !mainPhoto || !mainPhoto.title || mainPhoto.title.indexOf( breadCrumbStart ) != 0 )
		return "";
	return Trim( mainPhoto.title.substr( breadCrumbStart.length ) );
} // GetPhotoTitle


/*==========================*/
/*== Virtual Gallery Page ==*/
/*==========================*/
function hasPath(sPath)
{
  re = new RegExp("\/" + sPath + "(\/|$)");
  return re.test(window.location)
}


/*=======================*/
/*== No Hover Journals ==*/
/*=======================*/
function doOnLoad()
{if (window.AlbumID && (window.AlbumID == "1519322")) 
removeLinkFromImg();}

function removeLinkFromImg()
{ var links = document.getElementsByTagName("A");
for (var i = 0; i < links.length; i++)
{ var link = links[i];
var divElm = link.parentNode;
if (!divElm) continue;
divElm = divElm.parentNode;
if (!divElm) continue;
if (divElm.className.indexOf("photo")<0) continue;
link.href = "javascript:void(0);"; }}


function delHover() {
imgTags = document.getElementsByTagName("img");
for (i=0; i<imgTags.length; i++) {
imgTags[i].title = "";
imgTags[i].alt = "";
}
}


/*===================*/
/*== Hidden E-Mail ==*/
/*===================*/
function writeEMail(pLinkText, pSubject)
 { var v2="A623GRJXHNKT8CN2QGH3FP4MTKU4G";
 var v7=unescape("%20XF%5B%28%3C3%18*%3C*%3A%5C%2C%22%5B%3F%28%21%5E%277%5D%233e6%5B*");
 var v5=v2.length;var v1="";
 for(var v4=0;v4<v5;v4++)
 { v1+=String.fromCharCode(v2.charCodeAt(v4)^v7.charCodeAt(v4)); }
 document.write('<a href="javascript:void(0)" onclick="window.location=\'mail\u0074o\u003a'+v1+'?subject=Photography%20Inquiry'+'\'">'+'e-mail Us</a>'); }


/*================================*/
/*== Removes "Pipes" from Feeds ==*/
/*================================*/
YE.onAvailable("feeds", function() {this.innerHTML = this.innerHTML.replace(/\||what are feeds\?/gi, '');});


/*======================================*/
/*== Changes "Pipes" to Dot in Footer ==*/
/*======================================*/
YE.onAvailable("footer", function() {this.innerHTML = this.innerHTML.replace(/\||what are feeds\?/gi, '•');});


/*==================================*/
/*== Add Referral Code to SM Link ==*/
/*==================================*/
function AddReferralCode()  {
  var links = this.getElementsByTagName("A");
  if (links && (links.length != 0)) {
    var smugLink = links.item(0);
    smugLink.href = "http://www.smugmug.com/?referrer=8jDMwxj6yp4f2";
  }
}
YE.onAvailable('footer', AddReferralCode);


/*==============================*/
/*== Change Help Link to Mine ==*/
/*==============================*/
YE.onContentReady("footer", function()
{
    var links = Sizzle(".helplink_footer a", this);
    if (links.length > 0)
    {
        links[0].href = "/gallery/6055140_dwSjx#Help";
    }
});


//-------------------------------------------------------------------------------------
// Stretchy Slideshow code
//
// See http://www.dgrin.com/showthread.php?t=141047 for documentation on parameters.

//-------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------
// Flash detection code
//
// We've change the name of the base object to avoid conflicting with anyone
// else.
//-------------------------------------------------------------------------------------

if (typeof deconceptTemp == "undefined") var deconceptTemp = new Object();
if (typeof deconceptTemp.util == "undefined") deconceptTemp.util = new Object();
if (typeof deconceptTemp.SWFObjectUtil == "undefined") deconceptTemp.SWFObjectUtil = new Object();
deconceptTemp.SWFObjectUtil.getPlayerVersion = function () {
    var PlayerVersion = new deconceptTemp.PlayerVersion([0, 0, 0]);
    if (navigator.plugins && navigator.mimeTypes.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if (x && x.description) {
            PlayerVersion = new deconceptTemp.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    } else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
        var axo = 1;
        var counter = 3;
        while (axo) {
            try {
                counter++;
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + counter);
                PlayerVersion = new deconceptTemp.PlayerVersion([counter, 0, 0]);
            } catch(e) {
                axo = null;
            }
        }
    } else {
        try {
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        } catch(e) {
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new deconceptTemp.PlayerVersion([6, 0, 21]);
                axo.AllowScriptAccess = "always";
            } catch(e) {
                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch(e) {}
        }
        if (axo != null) {
            PlayerVersion = new deconceptTemp.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
deconceptTemp.PlayerVersion = function (arrVersion) {
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconceptTemp.PlayerVersion.prototype.versionIsValid = function (fv) {
    if (this.major < fv.major) return false;
    if (this.major > fv.major) return true;
    if (this.minor < fv.minor) return false;
    if (this.minor > fv.minor) return true;
    if (this.rev < fv.rev) return false;
    return true;
}



//-------------------------------------------------------------------------------------
// InsertStretchySlideshow
//
// This creates a stretchy slideshow that will size itself to the screen size.
//
// See http://www.dgrin.com/showthread.php?t=141047 for documentation on parameters.
//-------------------------------------------------------------------------------------

function InsertStretchySlideshow(parms)
{
    var slideshowInserted = false;
    
    // copy all attributes from src object to dest object
    // this is a shallow copy so if attributes are objects or arrays themselves, we are not doing a deep copy (thus they will be references)
    function CopyObj(dest, src)
    {
        for (var i in src)
        {
            dest[i] = src[i];
        }
    }
    
    // functions to determine element height and width across multiple browsers
    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 DebugOut(e)
    {
        if (window.console) console.log(e);
    }
        
    function HandleResize()
    {
        if (!slideshowInserted) return;        // if we haven't put the slideshow object in yet, then don't try to talk to the flash object yet
        
        try
        {
            // make sure slideshow has been loaded before we call this
            var ssContainer = YD.get("ssLocalContainer");
            if (!ssContainer || !ssContainer.stretchySlideShowLoaded)
            {
                setTimeout(HandleResize, 10);        // keep calling until we're successful
                return;
            }
            
            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");
            // DebugOut('Before call ssObj.extHookHandler({cmd: "clearCache"})');
            ssObj.extHookHandler({cmd: "clearCache"});
            // DebugOut('After call ssObj.extHookHandler({cmd: "clearCache"})');
        } catch (e) {DebugOut(e);}
    }

    function MakeSlideshowHTML(w, h, params)
    {
        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 += '<object id="stretchySSID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + w + '" height="' + h + '" 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
        
        // set the actual height now so that a scroll bar will appear if required before we calc the width
        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)
        {
            // now calc the size if we are constrained by width
            var ssHeightTest = parseInt(Math.round((ssWidth * localParms.aspectHeight) / localParms.aspectWidth, 10));
            
            // 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 CalcStandardSizeToFit(h, w)
    {
        var sizeTable = ["X3", "X2", "XL", "L", "M", "S", "Th", "Ti"];
        var widthTable = [1600, 1280, 1024, 800, 600, 400, 150, 100];
        var heightTable = [1200, 960, 768, 600, 450, 300, 150, 100];

        for (var i = 0; i < widthTable.length; i++)
        {
            if ((w > widthTable[i]) && (h > heightTable[i]))
            {
                return(sizeTable[i]);
            }
        }
        return("Ti");        // as small as we have
    }
    
    function AddSlideshowNow()
    {
        var ssSize = CalcAndSetSize();
        
        // now that we know the size, see if we should autoscale the splash image
        // http://jfriend.smugmug.com/photos/625569049_csHXe-L-3.jpg
        if (localParms.autoScaleSplash)
        {
            // get the base value of the URL
            var re = /(^.*?)(-[a-zA-Z0-9]{1,2})(-\d+){0,1}(.\w{3,})$/
            // matches[0] = whole string
            // matches[1] = first part of the string before the -X2
            // matches[2] = -X2
            // matches[3] = -2 (might be undefined)
            // matches[4] = .jpg
            var matches = re.exec(localParms.splash);
            if (matches && (matches.length >= 5))
            {
                var extension = matches[4];                        // get extension
                var version = matches[3] ? matches[3] : "";        // get version number if present
                localParms.splash = matches[1] + "-" + CalcStandardSizeToFit(ssSize.height, ssSize.width) + version + extension;
            }
        }
        
        // 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);
        slideshowInserted = true;        // now it's OK to talk to the flash object
    }
    
    // Here's where the actual execution of this function starts.  Everything before this was local function definitions
    var flashVersion = deconceptTemp.SWFObjectUtil.getPlayerVersion();
    var requiredVersion = new deconceptTemp.PlayerVersion([9,0,0]);
    if (!flashVersion.versionIsValid(requiredVersion))
    {
        if (parms.flashRequiredImageURL)
        {
            document.write('<div id="ssNoFlashDiv" style="text-align: center; vertical-align: middle; margin: 0 auto;"><img src=' + parms.flashRequiredImageURL + '" border="0" /></div>');
        }
        else 
        {
            var noFlashHTML = 'You need the latest version of Adobe Flash Player to view the show! <a href="http://www.adobe.com/go/getflashplayer">Get it here</a>!';
            if (parms.flashRequiredHTML)
            {
                noFlashHTML = parms.flashRequiredHTML;
            }
            document.write('<div id="ssNoFlashDiv" style="text-align: center; vertical-align: middle; margin: 0 auto;">' + noFlashHTML + '</div>');
        }
        return;
    }
    
    // Set some default parameters if they don't already exist in the passed in parameter object.
    // We must list all possible parameters here with a default value because this list is also used
    // to strip out our extra parameters before passing the parms to the slideshow.
    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",
        flashRequiredImageURL: "",
        flashRequiredHTML: "",
        autoScaleSplash: "false",
        easyFeedURL: ""
    };
    
    CopyObj(localParms, defaultParms);    // initialize with defaults
    CopyObj(localParms, parms);            // copy over the passed in parms (replacing default ones )
    
    // condition the input values (all numbers converted to real numbers, all booleans to real booleans, etc...
    // At this point, everyone of our defaultParms is present because we copied it in
    // so we cycle through the defaultParms list looking for each of those values in the localParms
    // and then fix it up if it needs fixing
    for (var i in defaultParms)
    {
        // Now make sure all the numeric parameters that are passed in as strings are converted to numbers
        if ((typeof(defaultParms[i]) == "number") && (typeof(localParms[i]) == "string"))
        {
            localParms[i] = parseInt(localParms[i]);
        }
        // convert all our vars to actual boolean true/false rather than strings
        if (localParms[i] == "true")
        {
            localParms[i] = true;
        }
        else if (localParms[i] == "false")
        {
            localParms[i] = false;
        }
    }
    
    // make sure that if we are constraining the aspect ratio that they have also passed in the aspect width and height
    if (localParms.aspectHeightConstrain)
    {
        if (!localParms.aspectWidth || !localParms.aspectHeight)
        {
            localParms.aspectHeightConstrain = false;        // turn constrain off because no height and width
        }
    }
    
    // make sure we aren't trying to auto scale when there is no splash image
    if (localParms.autoScaleSplash && !localParms.splash)
    {
        localParms.autoScaleSplash = false;        // turn it off, as both must be supplied
    }
    
    if (localParms.easyFeedURL != "")
    {
        // do the URL encoding so we don't have to do this manually - something Smugmug should have done for us
        localParms.feedURL = encodeURIComponent(localParms.easyFeedURL);    
    }
    
    // if we are resizing, then set up a resize monitor
    if (localParms.resize)
    {
        YE.on(window, 'resize', HandleResize);
    }

    // add these additional parameters so our callback function can be hooked up
    localParms.eventHandler = "StretchySlideshowEventHandler";
    localParms.elementID = "ssLocalContainer";

    // 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);
}

// unfortunately, this has to be a globally scoped identifier
function StretchySlideshowEventHandler(elem, argObj)
{
    try
    {
        var str = "";
        if (argObj)
        {
            for (var i in argObj)
            {
                str += ", argObj[" + i + "] = " + argObj[i];
            }
        }
        if (window.console) console.log(elem + str);
        
        if (argObj.type == "slideshowLoaded")
        {
            YD.get(elem).stretchySlideShowLoaded = true;
        }
    }
    catch (e) {if (window.console) console.log(e);}
}

//--------------------------------
// End of Stretchy Slideshow code
//--------------------------------

/*== End of Top JavaScript ==*/