// ---------------------------------------------
// 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: "false",
		showSpeed: "false",
		showThumbs: "true",
		captions: "false",
              borderThickness: "14",
              borderColor: "FFFFFF",
              crossFadeSpeed: "200",
		transparent: "true"		// no comma after the last entry in this table or IE7 will barf
	};


	var globalFullScreenSlideshowConfigOverride = {
		showButtons: "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
// ---------------------------------------------



//-------------------------------------------------------------------------
// Code to move the slideshow button to the same row 
// as the buy button
//-------------------------------------------------------------------------
function MyNewSlideshowInit(container, id, config)
{
	if (config && config.slideshowDiv && (config.slideshowDiv == "fsssButton"))
	{
		var cartDiv = YD.get("cartButtonsWrapper");
		if (cartDiv)
		{
			var ssDiv = YD.get("fsssButton");
			if (ssDiv)
			{
				ssDiv.parentNode.removeChild(ssDiv);
			}
			var newDiv = document.createElement("div");
			newDiv.id = "fsssButton";
			cartDiv.appendChild(newDiv);
			container = "cartButtonsWrapper";
		}
	}
	return (myOldSlideshowInit.apply(this, arguments));
}

var myOldSlideshowInit;
if (typeof(SM.buttons.slideshow) != "undefined")
{
	// hook the init function on the SM.buttons.slideshow object
	myOldSlideshowInit = SM.buttons.slideshow.prototype.init;
	SM.buttons.slideshow.prototype.init = MyNewSlideshowInit;
}