rightClickWarning = "Images copyright Jeremy King Photography"; /*  Begin
Removes the word "Gallery" for galleries and sub-galleries
*/

function RemoveGalleryWord()
{
    this.innerHTML = this.innerHTML.replace(/ Galleries$| Sub-Categories$/, "");
}

YE.onAvailable("subCatGalleryTitle", RemoveGalleryWord);
YE.onAvailable("galleryTitle", RemoveGalleryWord);

/*  End
Removes the word "Gallery" for galleries and sub-galleries
*/


// Script to change the breadcrumb link to your homepage to point to your galleries page instead of your slideshow
// It also changes that link to say "Galleries" instead of your user name

function AdjustBreadcrumb()
{
    // there are something like six different forms of the breadcrumb including search and keyword and date and communities, categories and galleries that we have to make this work for
    var tags = YD.getElementsByClassName("nav", "a", this);        // get all the <a> tags with class "nav"
    var filteredTags = new Array;
    // filter out any that aren't at the top level in the breadCrumbTrail (this gets rid of the relatedDate tags)
    for (var i in tags)
    {
        if (tags[i].parentNode == this)
        {
            filteredTags.push(tags[i]);
        }
    }
    if (filteredTags.length == 0)
    {
        return;
    }
    // default to targeting the first filtered tag
    var targetTag = filteredTags[0];
    
    // see if we have a community here
    if (filteredTags.length > 1)
    {
        // if we have a community here, then the user top level is in the 2nd position
        if (filteredTags[0].href.search(/\/community\//) != -1)
        {
            targetTag = filteredTags[1];
        }
    }
    // make sure URL ends with a slash
    var str = targetTag.href;
    if (str.search(/\/$/) == -1)
    {
        str += "/";
    }
    str +="galleries";
    targetTag.href = str;
    targetTag.innerHTML = "Galleries";
}

YE.onContentReady("breadCrumbTrail", AdjustBreadcrumb);

//End script to customize breadcrumbs

/* Begin
Create a separate galleries/find page
*/

function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

if (hasPath("galleries"))
YD.addClass(document.body, "galleries");

/*
if (hasPath("find"))
YD.addClass(document.body, "find");
*/

/* End
Create a separate galleries/find page
*/




/***** right-click warning **********/
rightClickWarning = "All photos are © Jeremy King Photography. All rights reserved. Unauthorized use is prohibited."



// Because the slideshow button is created itself in onDOMReady, 
// we don't know the timing of it's creation relative to our function getting called
// so we trigger our event this way to make it execution order independent
/*******************************
*
*issues with navigation not showing up, possible cause
*is this hack. trying to remove it 09-07-2009
*
********************************/

/*
YE.onDOMReady(function () {YE.onContentReady("slideshowButton", MoveSlideshowButtonToCartLine);});

function MoveSlideshowButtonToCartLine()
{
    var sourceObj = document.getElementById("slideshowButton");
    var destObj = document.getElementById("buyButton");
    if (sourceObj && destObj)
    {
        var obj = sourceObj.parentNode.removeChild(sourceObj);
        destObj.parentNode.insertBefore(sourceObj, destObj);
    }    
}
*/

//-------------------------------------------------------------------------
// 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;
}
//-------------------------------------
// end code for moving slideshow 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: "false",
		showSpeed: "true",
		showThumbs: "true",
		captions: "false",
		transparent: "true"		// no comma after the last entry in this table or IE7 will barf
	};

	var globalFullScreenSlideshowConfigOverride = {
		showButtons: "false",
		showSpeed: "false"		// 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
// ---------------------------------------------

//----------------------------------------------
// removes pesky hover-over on images
//----------------------------------------------
function delHover() {
  oLst = YD.getElementsBy(function(el) {return (YD.hasClass(el,'imgBorder') || YD.hasClass(el,'imgBorderOn'))},'img');
  for (i=0; i < oLst.length ; i++)  {
    if (oLst[i].title && oLst[i].title != '') oLst[i].title = '';
    if (oLst[i].alt && oLst[i].alt != '') oLst[i].alt = '';
  }
}
YE.onContentReady('bodyWrapper', function() {if (!YD.hasClass(document.body, 'smugmug_ajax')) delHover()});
onPhotoShow.subscribe(function(){YE.onAvailable('mainImage', delHover)});

//----------------------------------------------
// end hover-over script
//----------------------------------------------
