﻿// JScript File

function showSlideshow(title, location, description, owner, contractor, ownerLink, contractorLink) {
    var eTitle = document.getElementById("galleryTitle");
    var eLocation = document.getElementById("galleryLocation");
    var eDescription = document.getElementById("galleryDescription");
    var eOwner = document.getElementById('galleryOwner');
    var eContractor = document.getElementById('galleryContractor');
    
    if (title != null && title != 'null') {
        eTitle.innerHTML = title + '<br />';
    } else {
        eTitle.innerHTML = '';
    }
    if (location != null && location != 'null') {
        eLocation.innerHTML = location + '<br />';
    } else {
        eLocation.innerHTML = '';
    }
    if (description != null && description != 'null') {
        eDescription.innerHTML = description;
    } else {
        eDescription.innerHTML = '';
    }
    if (owner != null && owner != 'null') {
        if (ownerLink != null && ownerLink != 'null') {
            owner = buildLink(ownerLink, owner);
        }
        eOwner.innerHTML = '<h2>Owner:</h2>' + owner;
    } else {
        eOwner.innerHTML = '';
    }
    if (contractor != null && contractor != 'null') {
        if (contractorLink != null && contractorLink != 'null') {
            contractor = buildLink(contractorLink, contractor);
        }
        eContractor.innerHTML = '<h2>Contractor:</h2>' + contractor;
    } else {
        eContractor.innerHTML = '';
    }
}

function showAwardSlideshow(title, location, description, owner, award, ownerLink, awardLink) {
    var eTitle = document.getElementById("galleryTitle");
    var eLocation = document.getElementById("galleryLocation");
    var eDescription = document.getElementById("galleryDescription");
    var eOwner = document.getElementById('galleryOwner');
    var eAward = document.getElementById('galleryAward');
    
    if (title != null && title != 'null') {
        eTitle.innerHTML = title + '<br />';
    } else {
        eTitle.innerHTML = '';
    }
    if (location != null && location != 'null') {
        eLocation.innerHTML = location + '<br />';
    } else {
        eLocation.innerHTML = '';
    }
    if (description != null && description != 'null') {
        eDescription.innerHTML = description;
    } else {
        eDescription.innerHTML = '';
    }
    if (owner != null && owner != 'null') {
        if (ownerLink != null && ownerLink != 'null') {
            owner = buildLink(ownerLink, owner);
        }
        eOwner.innerHTML = '<h2>Owner:</h2>' + owner;
    } else {
        eOwner.innerHTML = '';
    }
    if (award != null && award != 'null') {
        if (awardLink != null && awardLink != 'null') {
            award = buildLink(awardLink, award);
        }
        eAward.innerHTML = '<h2>Award:</h2>' + award;
    } else {
        eAward.innerHTML = '';
    }
}

function buildLink(link, text) {
    var result;
    if(link.substring(0,3) == 'www') {
        link = 'http://' + link;
    }
    result = '<a href="' + link + '" target="_blank">' + text + '</a>';
    return result;
}