//right click warning change
rightClickWarning = "All photos are property of Imzadi Designs. All rights reserved. Unauthorized use is prohibited. Violators will be prosecuted to the fullest extent of the law. All images on file with copyright office."; 

//filmStrip values you can override:
filmstripMove = 0;
rightMoves = -5;
leftMoves = 5;

/*
--------------------------------------------------
	Titlebar Customizer
--------------------------------------------------
*/
var titleSettings = new Array();
titleSettings.separator    = ": "; // text to insert between parts of title
titleSettings.maxLength    = -1;   // limits length of title (-1 == no limit)
titleSettings.doPhotos     = true; // true == append photo captions
titleSettings.doAlbums     = true; // true == append album names
titleSettings.doGalleries  = true; // true == append gallery names
titleSettings.stripSmugmug = true; // true == remove " - powered by SmugMug" from title bar text

function ContextualizeTitle()
{
	var smugmugSuffix = " - powered by SmugMug";
	var insertAt = document.title.indexOf(smugmugSuffix);
	var newTitle = document.title;
	var newText = null;
	if(IsHomePage() == false)
	{
		// add gallery title
		if(titleSettings.doGalleries)
		{
			var galleryTitle = document.getElementById("galleryTitle");
			if(galleryTitle)
			{
				var galleryTitleText = GetTextContent(galleryTitle);
				if(galleryTitleText.length > 0)
				{
					var index = galleryTitleText.indexOf(" galleries");
					if(index > -1)
					{
						galleryTitleText = galleryTitleText.substr(0, index);
					}
					newText = titleSettings.separator + galleryTitleText;
					newTitle = InsertString(newTitle, newText, insertAt);
				}
			}
		}
		// add album title
		if(titleSettings.doAlbums)
		{
			var albumTitle = document.getElementById("albumTitle");
			if(albumTitle)
			{
				var albumTitleText = GetTextContent(albumTitle);
				if(albumTitleText.length > 0)
				{
					newText = titleSettings.separator + albumTitleText;
					newTitle = InsertString(newTitle, newText, insertAt);
				}
			}
		}
		// add photo title
		if(titleSettings.doPhotos)
		{
			var photoTitleText = GetPhotoCaption();
			if(photoTitleText.length > 0)
			{
				newText = titleSettings.separator + photoTitleText;
				newTitle = InsertString(newTitle, newText, insertAt);
			}
		}
		if(titleSettings.maxLength > -1)
		{
			newTitle = newTitle.substr(0, titleSettings.maxLength);
		}
	}
	if(titleSettings.stripSmugmug)
	{
		var regexp = /- powered by SmugMug/g;
		newTitle = newTitle.replace(regexp, "");
	}
	document.title = newTitle;
}

function GetPhotoCaption()
{
	var caption = "";
	var photoTitle = document.getElementById("caption_bottom");
	if(!photoTitle)
	{
		photoTitle = document.getElementById("caption_top");
	}
	if(photoTitle)
	{
		caption = GetTextContent(photoTitle);
	}
	return caption;
}

function GetTextContent(node)
{
	var text = "";
	if(node)
	{
		if(node.children)
		{
			text = GetTextContent(node.firstChild);
		}
		else
		{
			if(node.nodeValue)
			{
				text = node.nodeValue; // IE
			}
			else
			{
				text = node.textContent; // mozilla
			}
		}
	}
	text = Trim(text);
	return text;
}

function InsertString(text, insertText, index)
{
	var newText = "";
	if(index > -1 && index < text.length)
	{
		newText = text.substring(0, index) + insertText + text.substring(index);
	}
	else
	{
		newText = text + insertText;
	}
	return newText;
}

function Trim(text)
{
	var regexp = /^\s+|\s+$/g;
	text = text.replace(regexp, "");
	return text;
}

function IsHomePage()
{
	var isHomePage = false;
	// test for the "homepage" class name in the <BODY> tag
	var classStr = document.body.className;
	if (classStr && (classStr.indexOf("homepage") != -1))
	{












		isHomePage = true;
	}
	return isHomePage;
}
/*
--------------------------------------------------
	END Titlebar Customizer
--------------------------------------------------
*/

// 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 BreadCrumb changer.



// script to automatically redirect to the iphone interface from any 
// small screen webkit browser (e.g. iPhone, iPod Touch, Palm Pre, Android, etc...)

// Check if we are on a small screen
function CheckForSmallScreen(minWidth, minHeight)
{
    return(window.screen.height < minHeight || window.screen.width < minWidth);
}

// Check if the browser userAgent string is AppleWebKit
function CheckForWebKitUA()
{
    return(navigator.userAgent.search(/AppleWebKit/i) != -1);
}

// Check if the URL already has /iphone in it
function CheckForIPhoneURL()
{
    return(window.location.pathname.toString().search(/^\/iphone/i) != -1);
}

// Switch to the iphone UI if we're a webkit browser, are not already the /iPhone URL and are on a small screen
function RedirectIfSmallWebKitBrowser()
{
    var parms = window.location.search;
    if (parms.search(/autoPhoneRedirect=no|stripiPhoneCookie=yes/i) != -1)
    {
        SM.util.setCookie("autoPhoneRedirect", "no", 1);
    }
    else if (parms.search(/autoPhoneRedirect=yes/i) != -1)
    {
        SM.util.setCookie("autoPhoneRedirect", "yes", 1);
    }
    // check to see if redirection has been turned off via cookie
    var value = "";
    value = SM.util.getCookie("autoPhoneRedirect");
    if (value != "no")
    {
        if (CheckForWebKitUA() && !CheckForIPhoneURL() && CheckForSmallScreen(600,600))
        {
            window.location.replace("/iphone");
        }
    }
}

RedirectIfSmallWebKitBrowser();

//END Mobile redirect