var intVers = parseInt(navigator.appVersion);
var loadingImg = false;
var imgName = ""
var imgPath = ""
var browser = navigator.appName;

// Function to open a link in a new explorer window
function newwindow(content) {
    window.open(content, 'jav', 'width=800,height=600,resizable=yes,scrollbars');
}

// Onload function to load gallery image if on the gallery page only
window.onload = function() {
    if (document.getElementById("tb_0")) {
        imgPath = document.getElementById("tb_0").src;
        imgName = document.getElementById("tb_0").alt;
        var iPath = new String(imgPath);
        imgPath = iPath.substr(0, (iPath.length - 7)) + ".jpg";
        iPath = null;
        imgLoad(imgName, imgPath);
    }
}

//Image Loader for Gallery.  This will pre-load the images while displaying the loading animation
//Once the image is downloaded into memory, it will hide the loading anim and display the picture.
function imgLoad(nm, pth) {
    if (loadingImg) {
        return false;
    } else {
        document.getElementById("loadanimSpan").style.visibility = "visible";
        document.getElementById("loadanimSpan").innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='150' height='150' id='loadanim' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='flash/loadanim.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#ffffff' /><embed src='flash/loadanim.swf' quality='high' wmode='transparent' bgcolor='#ffffff' width='150' height='150' name='loadanim' align='middle' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
        loadingImg = true;
        imgName = nm;
        imgPath = pth;
        setTimeout(startLoad, 300);
    }
}

function startLoad() {
    var gImg = new Image;
    gImg.onload = imgLoaded();
    gImg.src = imgPath;
}

function imgLoaded() {
    document.getElementById("gimgDiv").style.backgroundImage = "url(" + imgPath + ")";
    document.getElementById("gimgDesc").innerHTML = "<strong>" + imgName + "</strong>";
    gImg = null;
    loadingImg = false;
    document.getElementById("loadanimSpan").style.visibility = "hidden";
}

function imgBrandingLoad(pth) {
    if (loadingImg) {
        return false;
    } else {
        loadingImg = true;
        imgPath = pth;
        setTimeout(startBrandingLoad, 300);
    }
}

function startBrandingLoad() {
    var gImg = new Image;
    gImg.onload = imgBrandingLoaded();
    gImg.src = imgPath;
}


function imgBrandingLoaded() {
    document.getElementById("brandingImgDiv").style.backgroundImage = "url(" + imgPath + ")";
    gImg = null;
    loadingImg = false;
}
