rightClickWarning = "Property of Salty Grapes. All rights reserved. Unauthorized use is prohibited.";

SM.PhotoBar.config.position = 'bottom';

showPhotoBar = false;

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)});



function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}



function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_2833430"))
  {
    var objElement = YD.get("comment")
    if (objElement != null)
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'Guestbook');
      objElement.innerHTML = str;
    }
  }
}

YE.onAvailable("comment", ModifyText);




function AddReferralCode()  {
  var links = this.getElementsByTagName("A");
  if (links && (links.length != 0)) {
    var smugLink = links.item(0);
    smugLink.href = "http://www.smugmug.com/?referrer=fMDHhpWnn6Ilo";
  }
}
YE.onAvailable('footer', AddReferralCode);






function doOnLoad()
{
if (window.AlbumID && (window.AlbumID == "4025777" || window.AlbumID == "3788393")) //
{
removeLinkFromImg();
}
}

function removeLinkFromImg()
{
var links = document.getElementsByTagName("A");
for (var i = 0; i < links.length; i++)
{
var link = links[i];
var divElm = link.parentNode;
if (!divElm) continue;
if (divElm.className.indexOf("photo")<0) continue;
link.href = "javascript:void(0);";
}
}












// hide the word "sub-categories" from title of category pages
YE.onAvailable('subCatGalleryTitle', function() {this.innerHTML = this.innerHTML.replace(/(sub\-)?categories/, '')});

// hide the word "galleries" from title of category pages
YE.onAvailable('galleryTitle', function() {this.innerHTML = this.innerHTML.replace(/galleries/, '')});

// hide the word "galleries" from title of sub-category pages
YE.onAvailable('subCatGalleryTitle', function() {this.innerHTML = this.innerHTML.replace(/galleries/, '')});





//Goto Recent Gallery 
 function showRecent(days)
{
   endDate = new Date();
   oneDay = 1000*60*60*24;
   startDate = new Date(endDate.getTime() - (parseInt(days) * oneDay));
   sUrl = "/date/";
   sUrl += startDate.getFullYear() + "-" + padDate(startDate.getMonth() + 1) + "-" + padDate(startDate.getDate());
   sUrl += "/";
   sUrl += endDate.getFullYear() + "-" + padDate(endDate.getMonth() + 1) + "-" + padDate(endDate.getDate());
    window.location = sUrl;
}

function padDate(datePart)
{
   if (datePart.toString().length != 1)
     return datePart
   return "0" + datePart;
}
//Goto Recent Gallery




displaySmugPopular = false;





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;
}








// On IE/FF set the title before the Document OnLoad takes place
document.title = "Salty Grapes Photography & Design";
addEvent( window, "load", CustomizeTitle );
function CustomizeTitle()
{
    var baseTitle = "Salty Grapes Photography & Design";
    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 = "Salty Grapes > ";
    var mainPhoto = document.getElementById("mainPhoto");
    if( !mainPhoto || !mainPhoto.title || mainPhoto.title.indexOf( breadCrumbStart ) != 0 )
 return "";
    return Trim( mainPhoto.title.substr( breadCrumbStart.length ) );
} // GetPhotoTitle






var vanityTable = 
 {
     sessioninfo: "http://www.saltygrapes.com/gallery/3797225",
     about: "http://www.saltygrapes.com/gallery/2830462",
     orderingprints: "http://www.saltygrapes.com/gallery/2893344",
     orderingcards: "http://www.saltygrapes.com/gallery/3788393",
     guestbook: "http://www.saltygrapes.com/gallery/2833430",
     favorites: "http://www.saltygrapes.com/gallery/2833430",
     365: "http://www.saltygrapes.com/gallery/2832655",
     grover: "http://www.saltygrapes.com/gallery/2832657",
     enhancement: "http://www.saltygrapes.com/gallery/3934319",
     cards: "http://www.saltygrapes.com/gallery/3840059",
     blog: "http://www.saltygrapes.com/gallery/4132224",
     contact: "http://www.saltygrapes.com/gallery/3719267"
 };



 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
         }
     }
 }







function norobotmail(aUser, aDomain) {
document.location = "mailto:" + aUser + "@" + aDomain;
}





// fix the pesky pipes

YE.onAvailable("cobrand_footer", function() {this.innerHTML = this.innerHTML.replace(/\||what are feeds\?/gi, '');});





//Goto Recent Gallery 
 function showRecent(days)
{
   endDate = new Date();
   oneDay = 1000*60*60*24;
   startDate = new Date(endDate.getTime() - (parseInt(days) * oneDay));
   sUrl = "/date/";
   sUrl += startDate.getFullYear() + "-" + padDate(startDate.getMonth() + 1) + "-" + padDate(startDate.getDate());
   sUrl += "/";
   sUrl += endDate.getFullYear() + "-" + padDate(endDate.getMonth() + 1) + "-" + padDate(endDate.getDate());
    window.location = sUrl;
}

function padDate(datePart)
{
   if (datePart.toString().length != 1)
     return datePart
   return "0" + datePart;
}
//Goto Recent Gallery
