/********************/
/* Photobar at bottom/
/********************/
SM.PhotoBar.config.position = 'bottom';

/********************/
/* Photobar eliminated/
/********************/
showPhotoBar = false;

/*************/
/* Galleries */
/*************/
function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}


/****************/
/* Footer Stuff */
/****************/
YE.onAvailable("cobrand_footer", function() {this.innerHTML = this.innerHTML.replace(/\||what are feeds\?/gi, '');});



/*************/
/* Slideshow */
/*************/
function createSWF( w, h, params) { 
 var args = ""; 
 for (var i in params) { 
     args += i + "=" + params[i] + "&amp;"; 
 } 
 document.writeln('<object width="100%" height="100%" align="middle">'+ 
'<param name="movie" value="http://www.smugmug.com/ria/ShizamSlides-2007091201.swf?'+args+'"/>'+ 
'<param name="wmode" value="transparent" />'+ 
'<embed src="http://www.smugmug.com/ria/ShizamSlides-2007091201.swf?'+args+'" wmode="transparent" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all"/></object>'); 
return 1; 
} 


/*********************/
/* Gallery filmstrip */
/*********************/
function moveFilmstrip() {
  var parent = this.parentNode;
  var obj = parent.removeChild(this);
  parent.insertBefore(obj, YD.get('sizePicker'));
}
YE.onAvailable('moveWrapper', moveFilmstrip);
rightMoves = -5;
leftMoves = 5;
filmstripMove = 1;


/***************/
/* Vanity URLs */
/***************/

var vanityTable = 
 {
     guestbook : "http://www.rogernordstromphoto.com/gallery/3720670",
     contact : "http://www.rogernordstromphoto.com/gallery/3720528",
     about_me: "http://www.rogernordstromphoto.com/gallery/3720659",
     buying_prints: "http://www.rogernordstromphoto.com/gallery/3751056",
     note_cards: "http://www.rogernordstromphoto.com/gallery/3838878",
     kelley_farm: "http://www.rogernordstromphoto.com/gallery/4180774",
     friends_fans: "http://www.rogernordstromphoto.com/gallery/9258947_WQ8JD#618380676_TsT9s"
 };

function IsHomePage()
 {
    return(YD.hasClass(document.body, 'homepage'));
 }
 
 function CheckRedirects()
 {
     if (IsHomePage())    // only run this code on the home page
     {
         // get the path from the current URL, 
         // convert it to lowercase and remove the leading slash
         var path = window.location.pathname.toLowerCase().substr(1);
         
         var newURL = vanityTable[path];        // look it up in our table
         
         // if we found it in the table && newURL is different than where we are
         if (newURL && (newURL != window.location))
         {
             window.location.replace(newURL);        // go to the new URL
         }
     }
 }


/************************/
/* Encrypt email address*/
/************************/
function writeEMail(pLinkText, pSubject)
{

  var v2="2HKGSPYB6RTCY8JDZQWBVPYMUAUM4";
  var v7=unescape("@%27%2C%22%21%10+-Q7%26-6J.7.%238/%26869%3Ao6%22Y");
  var v5=v2.length;
  var v1="";
  for(var v4=0;v4<v5;v4++)
    {v1+=String.fromCharCode(v2.charCodeAt(v4)^v7.charCodeAt(v4));}
    document.write('<a href="javascript:void(0)" onclick="window.location=\'mail\u0074o\u003a'+v1+'?subject='+escape(pSubject)+'\'">'+pLinkText+'</a>');
}


/****************/
/* Change Title */
/****************/
// On IE/FF set the title before the Document OnLoad takes place
document.title = "Roger Nordstrom Photography";
addEvent( window, "load", CustomizeTitle );
function CustomizeTitle()
{
    var baseTitle = "Roger Nordstrom Photography";
    var separator = " - ";
    var albumTitle = GetText( document.getElementById("albumTitle") );
    var galleryTitle = GetText( document.getElementById("galleryTitle") );
    var subCatTitle = GetText ( document.getElementById("subCatGalleryTitle") );
    var singleImage = document.body.className && document.body.className.indexOf("singleImage") > -1 ? true : false;
    var pageTypeDefined = typeof( pageType ) != "undefined";
    var pageTypeDetailsDefined = typeof( pageTypeDetails ) != "undefined";
// Don't change the title from the above document.title on the homepage
    if( document.body.className && document.body.className.indexOf("homepage") > -1 )
    {
        document.title = baseTitle + separator + "Home";
        return;
    }
 
// An album page (holds a bunch of photos, could be "zoomed in" on a specific photo)
    if( albumTitle )
    {
        var photoTitle = GetPhotoTitle();
        if( photoTitle )
            document.title = baseTitle + separator + albumTitle + separator + photoTitle;
        else
            document.title = baseTitle + separator + albumTitle;
        return;
    }
// A gallery page (holds a bunch of albums and/or a bunch of sub categories)
    if( galleryTitle )
    {
// Strip " sub-categories" off the end of the category text
        var finalPositionCategory = galleryTitle.indexOf(" sub-categories");
        if( finalPositionCategory > -1 )
            galleryTitle = galleryTitle.substr( 0, finalPositionCategory );
        else
            {
// Strip " galleries" off the end of the category/sub-category text
              var finalPositionSubCategory = galleryTitle.indexOf(" galleries");
              if( finalPositionSubCategory > -1 )
          galleryTitle = galleryTitle.substr( 0, finalPositionSubCategory );
             }
 
            document.title = baseTitle + separator + galleryTitle;
    return;
    }
// Pick up sub-category
    if( subCatTitle )
    {
// Strip " sub-categories" off the end of the category text
        var finalPositionCategory = subCatTitle.indexOf(" sub-categories");
        if( finalPositionCategory > -1 )
            galleryTitle = subCatTitle.substr( 0, finalPositionCategory );
        else
            {
// Strip " galleries" off the end of the category/sub-category text
              var finalPositionSubCategory = subCatTitle.indexOf(" galleries");
              if( finalPositionSubCategory > -1 )
          galleryTitle = subCatTitle.substr( 0, finalPositionSubCategory );
             }
 
            document.title = baseTitle + separator + galleryTitle;
    return;
    }
 
// A single image (like the kind you get when you click an image in a keyword page)
    if( singleImage )
        {
 var photoTitle = GetPhotoTitle();
 if( photoTitle )
            document.title = baseTitle + separator + photoTitle;
 else
     document.title = baseTitle + separator + "untitled photo";
 return;
 }
// A single keyword page
    if( pageTypeDefined && pageType == 'Keyword' && pageTypeDetailsDefined )
 {
// Keyword page
             document.title = baseTitle + separator + "Keyword: " + pageTypeDetails;
     return;
 }
// A multiple keyword page
    if( pageTypeDefined && pageType == 'Keywords' && pageTypeDetailsDefined )
 {
// Multiple keywords page
// Put " + " between each keyword instead of -
             var keywordList = pageTypeDetails;
     keywordList = keywordList.replace(/\-/g, " + ");
     document.title = baseTitle + separator + "Keywords: " + keywordList;
     return;
 }
// The main keywords page. Note: single image takes precedence over this type
    if( document.body.className && document.body.className.indexOf("keywordPage") > -1 )
        {
// Main Keywords Page
            document.title = baseTitle + separator + "Keywords";
            return;
 }
// None of the rules above set the title! Oh well, fall back on the base title.
    document.title = baseTitle;
} // CustomizeTitle
function Trim( text )
{
    text = text.replace(/(^\s+)|(\s+$)/g, ""); // trim leading and trailing white space
    return text;
} // Trim
function GetText( node )
{
    if( !node )
        return "";
    if( node.innerText )
        return Trim( node.innerText ); // For IE
    if( node.textContent )
        return Trim( node.textContent ); // For others
    return "";
} // GetText
function GetPhotoTitle()
{
// If the photo title is set, it starts with the breadcrumb.
    var breadCrumbStart = "Roger Nordstrom > ";
    var mainPhoto = document.getElementById("mainPhoto");
    if( !mainPhoto || !mainPhoto.title || mainPhoto.title.indexOf( breadCrumbStart ) != 0 )
 return "";
    return Trim( mainPhoto.title.substr( breadCrumbStart.length ) );
} // GetPhotoTitle