var vanityTable = 
 {
     newestwork : "http://www.vangeestphotography.com/gallery/7435120_STcMj",
     waterscapes : "http://www.vangeestphotography.com/gallery/6517965_pP9ZD",
     nature : "http://www.vangeestphotography.com/gallery/6509437_dY5f2",
     laketahoe : "http://www.vangeestphotography.com/gallery/6549758_2vNms",
     weddings : "http://www.vangeestphotography.com/gallery/11182120_XzKu3",
     landscapes : "http://www.vangeestphotography.com/gallery/6518571_Gv8jj",
     people : "http://www.vangeestphotography.com/gallery/6528064_auZTm",
     restorations: "http://www.vangeestphotography.com/gallery/6982557_hHAmM",
     guestbook : "http://www.vangeestphotography.com/gallery/6544596_RMJau",
     about : "http://www.vangeestphotography.com/gallery/6544507_EgDxX",
     slideshow : "http://www.vangeestphotography.com/gallery/7047072_NUHwB",
     myportfolio : "http://www.vangeestphotography.com/gallery/8813219_ZDYro"
 };

function CheckRedirects()
 {
     if (YD.hasClass(document.body, 'homepage'))    // 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 AddReferralCode() {
var links = this.getElementsByTagName("A");
if (links && (links.length != 0)) {
var smugLink = links.item(0);
smugLink.href = "http://www.smugmug.com/?referrer=SrVy1N0om161o";
}
}
YE.onAvailable('footer', AddReferralCode);


// 

YE.onAvailable('homelink', function(e) {

this.href = "http://SLVanGeest.smugmug.com/";

this.firstChild.alt = "SL Van Geest Photography";

this.firstChild.title = "SL Van Geest Photography";

});

// 

YE.onAvailable('toolbar', function(e) {

this.innerHTML = this.innerHTML.replace(new RegExp(/\|/g),"");

});


// Change Home Link (from Devbobo)
YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.com\/([?\w&;=]+)?"/, 'href="' + webServer + '"')});


slideDuration = 20;

function norobotmail(aUser, aDomain) { document.location = "mailto:" + aUser + "@" + aDomain; }



function updateSS() {
     // look at the body tags classes, if it is the homepage then swap
     bodyClass = document.getElementsByTagName("body")[0].className;
     if (bodyClass.indexOf("slideshow") != -1) {
          slideDuration = 5;
          document.getElementById("duration").value = "5";
     }
}


// 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();
