rightClickWarning = "All photos are TM and © 2009 juniormonkey.com. All rights reserved. Unauthorized use is prohibited. To find out how to remove right click protection, contact me at junior@juniormonkey.com.";

// -----------------------------------------------------------
// Code to add descriptions to categories and/or sub-categories
// ----------------------------------------------------------- 

function addCategoryTitleToBreadcrumb(description) 
{
	var breadCrumb = YD.get("breadcrumb");
	if (breadCrumb)
	{
		var divTag = document.createElement("div");
		divTag.className = "categoryDescription";
		divTag.innerHTML = description;
		breadCrumb.parentNode.insertBefore(divTag, breadCrumb.nextSibling);
	}
}

function addCategoryTitleToThumbs(descriptionObject, boxObjectName) 
{
	var re = /\>([^\<]+)<\/a>/i;    // pattern to find the category name between the <a> and </a> tags
	var divTag = YD.get(boxObjectName);
	if (divTag) 
	{
		var divTags = YD.getElementsByClassName("albumTitle", "p", divTag);
		for (var i = 0; i < divTags.length; i++) 
		{
			var matches = re.exec(divTags[i].innerHTML);    // get just the category name
			if (matches && (matches.length > 1))
			{
				var nameWithUnderscores = matches[1].replace(/ |&/g, "_");		// replace spaces with underscores
				// if we have this object in our array, then proceed
				if (descriptionObject[nameWithUnderscores] != undefined)
				{
					var pTag = document.createElement("p");
					pTag.className = "categoryDescription";
					pTag.innerHTML = descriptionObject[nameWithUnderscores];
					divTags[i].parentNode.insertBefore(pTag, divTags[i].nextSibling);
				}
			}
		}
	}
}

/* Category descriptions */
function addCategoryDescription(titleOnly) 
{
    var categoryDescription = {
		// list "categoryname" : "category title",
		// or "categoryname.subcategoryname" : "subcategory title",
		// Examples:
		// "Kenya"  : "Our vacation to Kenya",
		// "Kenya.Highlights" : "The highlights galleries from our vacation to Kenya",
		"2Fast"  : "<p class='JMattention'>Welcome to juniormonkey.com's <a href='http://2-fast.org' target='_blank'>2Fast</a> photography!</p><p>Have you attended a <a href='http://2-fast.org' target='_blank'>2Fast</a> event recently? While flying down the asphalt did you find yourself looking at some weird Asian guy at trackside pointing an intimidatingly large camera at you? Chances are, you have a gallery here! See below to find yours, or <a href='mailto:junior@juniormonkey.com'>contact me</a> for more information.</p><p><span class='JMattention'>$35</span> unlocks that single gallery, which allows you to download, link to, and save directly from this site. Don't worry about hosting or resizing another picture again! Just click on the <span class='JMattention'>Buy Now</span> button at the top of the gallery of your choice, <strong>note the <em>date</em> and <em>gallery name</em> in the details section of your purchase</strong> (very important, as i don't know what you're paying for, otherwise), and you're golden!</p><p>Got questions? Have concerns? Just want to shoot the (expletive)? Feel free to <a href='mailto:junior@juniormonkey.com'>contact me</a> or give me a slap on the back (if you make me drop my camera, you owe me a new one) the next time you're tearing it up at <a href='http://2-fast.org' target='_blank'>2Fast</a>.</p><hr /><p><span class='JMattention'><a href='http://2-fast.org' target='_blank'>2010 2Fast Track Day Schedule</a></span> Visit <a href='http://2-fast.org' target='_blank'>2-fast.org</a> for more details about track days...</p><p>Dates in <span style='color: #fff; font-weight: bold;'>bold</span> indicate days juniormonkey.com will be photographing. Remaining dates are tentative (hey, I've gotta get some riding in some time).</p><div class='JMul'><ul><li class='JMattention'>Mar 17 PR</li><li class='JMattention'>Apr 14 PR</li><li>May 5 PIR</li><li class='JMattention'>May 12 PR</li></ul></div><div class='JMul'><ul><li>Jun 7 PIR</li><li class='JMattention'>Jun 16 PR</li><li>Jul 7 PIR</li><li class='JMattention'>Jul 14 PR</li></ul></div><div class='JMul'><ul><li class='JMattention'>Jul 24 PR</li><li>Jul 31 ORP</li><li>Aug 1 ORP</li><li class='JMattention'>Aug 11 PR</li></ul></div><div class='JMul'><ul><li>Aug 25 PIR</li><li class='JMattention'>Sep 6 PR</li><li>Sep 9 PIR</li><li class='JMattention'>Sep 22 PR</li></ul></div><hr />"
    };
	
    var re, matches, i;        // various local variables

	// now fix it so that it works automatically even if the category or sub-category name has spaces in it
	// we replace those spaces with underscores (which is what the classname does) and add those to our object so we can match those too
	for (i in categoryDescription) 
	{
		var newName = i.replace(/ |&/g, "_");
		categoryDescription[newName] = categoryDescription[i];    // add a property to the object that has only underscores in the name
	}
    // on the homepage, we want to check for category names and add a description if a match found
	// on a category page, we want to check to see if the category that the page is needs a description under the breadcrumb
	//      and, we need to see if any of the sub-category items on the page need us to add a description under the name
	// on a sub-category page, we want to check to see if the sub-category that the page is needs a description under the breadcrumb
	if (YD.hasClass(document.body, "category")) 
	{
		// fetch the category name
		re = /category_(\S+)/i;
		matches = re.exec(document.body.className);
		if (matches && (matches.length > 1)) 
		{
			var categoryName = matches[1];
			// now see if we have a subcategory too
			if (YD.hasClass(document.body, "subcategory")) 
			{
				re = /subcategory_(\S+)/i;
				matches = re.exec(document.body.className);
				if (matches && (matches.length > 1)) 
				{
					var subcatName = matches[1];
					// category and subcategory so we are on a subcategory page showing a list of galleries in this subcategory
					// we need to just add a subcategory title to this page if the category-subcategory matches
					var fullName = categoryName + "." + subcatName;
					if (categoryDescription[fullName])
					{
						addCategoryTitleToBreadcrumb(categoryDescription[fullName]);
					}
				}
			}
			// here we're on a category page
			// we need to add a category description for the category page
			// and potentially add subcategory descriptions to the subcategory names displayed on this page
			else 
			{
				if (categoryDescription[categoryName])
				{
					addCategoryTitleToBreadcrumb(categoryDescription[categoryName]);
				}
				if (!titleOnly)
				{
					// now we need to build a temporary subcategoryDescription object that has only the subcategory names in it that are in this category
					var subcatDescriptions = {};
					re = new RegExp("^" + categoryName + "\\.(.+)$", "i");
					for (i in categoryDescription)
					{
						matches = re.exec(i);
						if (matches && (matches.length > 1))
						{
							subcatDescriptions[matches[1]] = categoryDescription[i];
						}
					}
					addCategoryTitleToThumbs(subcatDescriptions, "subcategoriesBox");
				}
			}
		}
	}

    // then see if we're on the homepage
    if (!titleOnly && YD.hasClass(document.body, "homepage")) 
	{
		addCategoryTitleToThumbs(categoryDescription, "categoriesBox");
	}
}

function addCategoryDescriptionBoth()
{
	addCategoryDescription(true);
}

YE.onDOMReady(addCategoryDescriptionBoth); 

// ------------------------------------------------------------------
// End of code to add descriptions to categories and/or sub-categories
// ----------------------------------------------------------------- 