﻿//Copyright 2010 Yontoo technology, Inc.

function msgBox(msg) { alert(msg); }

function PreloadImage(imgSrc)
{
    var img = new Image();
    img.src = imgSrc;
}
function PreloadImage(imgSrc) {
    var img = new Image();
    img.src = imgSrc;
}
function PreloadImages() {
    PreloadImage("http://images.buzzdock.com/site/buzzdock10/downloadbuttonro.jpg");
    PreloadImage("http://images.buzzdock.com/site/homepage/downloadbuttonro.jpg");
    PreloadImage("http://images.buzzdock.com/site/homepage/installlinkro.jpg");
}
PreloadImages();

function getInstallId()
{
    try
    {
        if (typeof(yontooAPI) == "undefined")
        {
            try
            {
                if (window.ActiveXObject)
                {
                    yontooAPI=new ActiveXObject("YontooIEClient.Api");
                }
            }
            catch(ex)
            {
            }
        }

        if (typeof(yontooAPI) != "undefined")
        {
            var id = yontooAPI.getInstallId();
            return id;
        }
        else
        {
            var idElement = document.getElementById("YontooInstallID");
            return idElement.textContent;
        }
    }
    catch(ex)
    {
    }
    return "";
}



function isIE() {
    try {
        if (window.ActiveXObject)
            return true;
        else
            return false;
    }
    catch (ex) {
    }
    return false;
};

function isFF() {
    try {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.indexOf("firefox") != -1)
            return true;
        else
            return false;
    }
    catch (ex) {
    }
    return false;
};

function isGC() {
    try {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.indexOf("chrome") != -1)
            return true;
        else
            return false;
    }
    catch (ex) {
    }
    return false;
};

function isWin() {
    try {
        if (navigator.appVersion.toLowerCase().indexOf("windows") >= 0) {
            return true;
        }
    }
    catch (ex) {
    }
    return false;
};

function startInstall(installUrl,instructionsFFUrl,instructionsIEUrl){
    if (isFF() || isIE() || isGC()) 
    {
        if (isWin()) {
            document.location.href = installUrl, "InstallYontooLayers";
            if (isFF()) {
                setTimeout("document.location.href = '" + instructionsFFUrl + "', 'InstallYontooLayers';", 500);
            }
            else {
                if (isGC()) {
                    setTimeout("document.location.href = '" + instructionsFFUrl + "', 'InstallYontooLayers';", 500);
                } else {
                    setTimeout("document.location.href = '" + instructionsIEUrl + "', 'InstallYontooLayers';", 500);

                }
            }
        }
        else {
            document.location.href = "http://www.buzzdock.com/download/YontooFFClient.xpi", "InstallYontooLayers";
        }
    }
    else {
        msgBox("Sorry - Yontoo Layers only works with Internet Explorer, Firefox, or Google Chrome.");
    }
};

