redirectPath();

function redirectPath() {

  re = /(primarycolors.smugmug.com)/;
  tmp = window.location.href;
  if (re.test(tmp)) {
    tmp = tmp.replace(re, 'gallery.primarycolors.com');
    window.location.href = tmp;
  }

  re = /(www.smugmug.com)/;
  tmp = window.location.href;
  if (re.test(tmp)) {
    tmp = tmp.replace(re, 'gallery.primarycolors.com');
    window.location.href = tmp;
  }
}

function redirectCategory() { // called from custom header

  if (YD.hasClass(document.body, 'loggedIn')) // don't run when logged in
    return;

  re = /gallery.primarycolors.com\/Sessions\/?$/i;
  tmp = window.location.href;

  if (re.test(tmp)) {
    window.location.href = "http://www.billgerrard.com/session.php";
  }

} 

var vanityTable = {
     recent        : "http://gallery.primarycolors.com/gallery/2088815",
     woodies       : "http://gallery.primarycolors.com/Cars",
     infrared      : "http://gallery.primarycolors.com/gallery/2074879",
     neon          : "http://gallery.primarycolors.com/gallery/1957040",
     photo2        : "http://gallery.primarycolors.com/gallery/2112659",
     pamweek2      : "http://www.smugmug.com/gallery/2059620/",
     halloween2006 : "http://gallery.primarycolors.com/gallery/2062285",
     legohalloween : "http://gallery.primarycolors.com/gallery/2087008",
     cadreamride   : "http://gallery.primarycolors.com/gallery/2039953",
     missionsjc    : "http://gallery.primarycolors.com/gallery/2023752",
     miramar2006   : "http://gallery.primarycolors.com/gallery/2020077",
     autumn2006    : "http://gallery.primarycolors.com/gallery/1992494",
     wavecrest2006 : "http://gallery.primarycolors.com/gallery/1904550",
     wavecrest2008 : "http://gallery.primarycolors.com/gallery/6037203_jbmNt",
     woodies2007   : "http://gallery.primarycolors.com/gallery/1802033",
     alexander2007 : "http://gallery.primarycolors.com/gallery/2435046",
     alexander2008 : "http://gallery.primarycolors.com/gallery/4296477_YPV7m#252102511",
     alexander2009 : "http://gallery.primarycolors.com/gallery/9353661_nNvan#625931285_rumdq",
     jtnp2007      : "http://gallery.primarycolors.com/gallery/2508522",
     bodie         : "http://gallery.primarycolors.com/gallery/1825206",
     bwbodie       : "http://gallery.primarycolors.com/gallery/1825262",
     rwb2008       : "http://gallery.primarycolors.com/gallery/4158197",
     blossomtrail07  : "http://primarycolors.smugmug.com/gallery/2576620_vJWaa",
     valleywoodies07 : "http://gallery.primarycolors.com/gallery/2576056_EYXMr",
     lasvegas      : "http://gallery.primarycolors.com/Places/432380",
     redrocksnow2008: "http://gallery.primarycolors.com/gallery/6883236_CLaDH/1/439508913_S77Av/Large",
     snowvegas     : "http://primarycolors.smugmug.com/gallery/7714731_Rkaua/1/498511857_6JAhL/Large",
     durango       : "http://gallery.primarycolors.com/Temple%20Vista/776948",
     roadtrip09 : "http://gallery.primarycolors.com/gallery/8659283_mcyZP",
     hikingsticks : "http://gallery.primarycolors.com/Other/HikingSticks/9575465_tdSgM"
};

function checkVanityRedirects() {

     if (YD.hasClass(document.body, 'homepage')) // only run 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);

         // If the last character is '/', strip it
         while (path.charAt(path.length - 1) == '/') {
             path = path.substr(0, path.length - 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
         }
     }
}

var emptyCategories = {
     cars       : "http://gallery.primarycolors.com/Cars/295341"
};

function checkEmptyCategories() { // prevent display of empty categories

  if (YD.hasClass(document.body, 'loggedIn')) // don't run when logged in
    return;

  var path   = window.location.pathname.toLowerCase().substr(1);
  var newURL = emptyCategories[path];

  if (newURL && (newURL != window.location)) {
    window.location.replace(newURL);
  }
}

//checkEmptyCategories();

// Force photo display size
SM.SmugMug.config.alterScreenHeight = -100;
//showImagePreview = false;