﻿/*****************************************************************************
 *
 * photoKandy Studios Smugmug Javascript Library
 * ---------------------------------------------
 *
 * Collection of javascript gleaned from various dgrin posts, and tuned to
 * work with the photoKandy smugmug site.
 *
 * Attributions where appropriate.
 *
 *****************************************************************************/

//
// HACK #1: Remove "Galleries" and "Sub-Categories" text from headers by jfriend
//          http://www.dgrin.com/showthread.php?t=135053
////////////////////////////////////////////////////////////////////////////////

function RemoveGalleryWord()
{
    this.innerHTML = this.innerHTML.replace(/ Galleries$| Sub-Categories$/, "");
    this.innerHTML = this.innerHTML.replace(/Album$/, "photoKandy Albums");
}

YE.onAvailable("subCatGalleryTitle", RemoveGalleryWord);
YE.onAvailable("galleryTitle", RemoveGalleryWord);

//
// HACK #2: If "Album" is in the breadcrumb, replace it...
function HandleBreadcrumb()
{
	this.innerHTML = this.innerHTML.replace(/Album\<\/span\>/, "Albums</span>");
	this.innerHTML = this.innerHTML.replace(/Album\<\/a\>/, "Albums</a>");
	
	// also, handle the home part
	this.innerHTML = this.innerHTML.replace(/href=\"\/\" class=\"nav\"\>photokandy\<\/a\>/, 'href="http://www.photokandy.com/" class="nav">photokandy</a>');
}

YE.onContentReady("breadCrumbTrail", HandleBreadcrumb );

//
// HACK #3: If we're at our homepage, forward us to the real homepage
function forwardHome()
{
	if ( window.location.href == "http://sm.photokandy.com/" || 
	     window.location.href == "http://photokandy.smugmug.com/"
	   )
	{
		window.location = "http://www.photokandy.com";
	}
}

forwardHome();

