// script to unlink breadcrumbs
YE.onContentReady("breadCrumbTrail", ReplaceTopOfBreadcrumbWithHome);

function ReplaceTopOfBreadcrumbWithHome()
{
    var str = this.innerHTML.replace(/\n/g, " ");
    this.innerHTML = str.replace(/href/g, "");
}

// Facebook button
  var pos = window.document.URL.indexOf("gallery");
     if (SM) {
//        var thisURL = webServer + '/photos/' + ImageID + '_' + ImageKey + '-M.jpg' ;
        var thisURL = webServer + "/gallery/" + AlbumID + "_" + AlbumKey + "/1/" + ImageID + "_" + ImageKey ;
   
	SM.buttons.FacebookButton = new YAHOO.widget.Button({
		id: 'Share on Facebook',
		label: 'Share on Facebook',
		container: 'altViews',
		type: 'link',
		href: 'http://www.facebook.com/share.php?u='+thisURL+'&t=SmugMug+Image',
		target: '_blank',
		className: 'sm-button sm-button-small facebookButton glyphButton menuButton share_button'
	});
     }

// ---------------------------------------------
// Slideshow parameter modification
// ---------------------------------------------
function MyEmbedSWF(swfURL, containerID, swfID, version, backgroundColor, expressInstall)
{
	// catch all exceptions here so, if there's an error, we just continue on as if we weren't here
	try {
		var overrides = null;
		if (this._type == "gallery")
		{
			overrides = this.gallerySlideshowOverrides;
		}
		else if (this._type == "fullScreen")
		{
			overrides = this.fullScreenSlideshowOverrides;
		}
		if (overrides)
		{
			// copy all overrides over into the objects flashVars
			for (var i in overrides)
			{
				this._flashVars[i] = overrides[i];
			}
		}
	} catch (e) {}
	oldEmbedSWF.apply(this, arguments);		// call the regular handler for this method
}


function SetSlideshowOverrides()
{
	var globalGallerySlideshowConfigOverride = {
		showButtons: "true",
		showSpeed: "true",
		showThumbs: "false",
		captions: "false",
		transparent: "true"		// no comma after the last entry in this table or IE7 will barf
	};

	var globalFullScreenSlideshowConfigOverride = {
		showButtons: "true",
		showThumbs: "false",
                showSpeed: "true"		// no comma after the last entry in this table or IE7 will barf
	};
	
	SM.flash.Slideshow.prototype.gallerySlideshowOverrides = globalGallerySlideshowConfigOverride;
	SM.flash.Slideshow.prototype.fullScreenSlideshowOverrides = globalFullScreenSlideshowConfigOverride;
	
	// now check to see if anything was defined just for this gallery and use it instead
	if (typeof(localGallerySlideshowConfigOverride) == "object")
	{
		SM.flash.Slideshow.prototype.gallerySlideshowOverrides = localGallerySlideshowConfigOverride;
	}
	if (typeof(localFullScreenSlideshowConfigOverride) == "object")
	{
		SM.flash.Slideshow.prototype.fullScreenSlideshowOverrides = localFullScreenSlideshowConfigOverride;
	}
}

// SM.flash.Slideshow is only defined in a galleries page
if (typeof(SM.flash.Slideshow) == "function")
{
	var oldEmbedSWF = SM.flash.Slideshow.superclass._embedSWF;
	SM.flash.Slideshow.superclass._embedSWF = MyEmbedSWF;
	SetSlideshowOverrides();
}

// ---------------------------------------------
// end of slideshow customization
// ---------------------------------------------

