// Change Home Link (from Devbobo)
YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.com\/([?\w&;=]+)?"/, 'href="' + webServer + '"')});
// 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();

//------------------------------------------------------------------------------------------
// Stretchy Slideshow code
//
// See http://www.dgrin.com/showthread.php?t=141047 for documentation on parameters.

//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
// Flash detection code
//
// We've change the name of the base object to avoid conflicting with anyone
// else.
//------------------------------------------------------------------------------------------

if (typeof deconceptTemp == "undefined") var deconceptTemp = new Object();
if (typeof deconceptTemp.util == "undefined") deconceptTemp.util = new Object();
if (typeof deconceptTemp.SWFObjectUtil == "undefined") deconceptTemp.SWFObjectUtil = new Object();
deconceptTemp.SWFObjectUtil.getPlayerVersion = function () {
    var PlayerVersion = new deconceptTemp.PlayerVersion([0, 0, 0]);
    if (navigator.plugins && navigator.mimeTypes.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if (x && x.description) {
            PlayerVersion = new deconceptTemp.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    } else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
        var axo = 1;
        var counter = 3;
        while (axo) {
            try {
                counter++;
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + counter);
                PlayerVersion = new deconceptTemp.PlayerVersion([counter, 0, 0]);
            } catch(e) {
                axo = null;
            }
        }
    } else {
        try {
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        } catch(e) {
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new deconceptTemp.PlayerVersion([6, 0, 21]);
                axo.AllowScriptAccess = "always";
            } catch(e) {
                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch(e) {}
        }
        if (axo != null) {
            PlayerVersion = new deconceptTemp.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
deconceptTemp.PlayerVersion = function (arrVersion) {
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconceptTemp.PlayerVersion.prototype.versionIsValid = function (fv) {
    if (this.major < fv.major) return false;
    if (this.major > fv.major) return true;
    if (this.minor < fv.minor) return false;
    if (this.minor > fv.minor) return true;
    if (this.rev < fv.rev) return false;
    return true;
}
