﻿
// JScript for Image and Quote

function OutputImageRotatorContent(mainDivName, quoteDivName, ImageRotatorObj)
{
    var divToAddTo = document.getElementById(mainDivName);
    var divToAddQuote = document.getElementById(quoteDivName);
    
    var div = document.createElement("div");
    var image = document.createElement("img");
    
    if(ImageRotatorObj!=null && ImageRotatorObj!=undefined)
    {
        image.setAttribute("src", ImageRotatorObj.ImageUrl);
        image.setAttribute("alt", ImageRotatorObj.Label);
        image.setAttribute("border", "0");
        
        if (ImageRotatorObj.Quote != null && ImageRotatorObj.Quote != undefined)
        {
            var pag = document.createElement("p");
            pag.innerHTML = ImageRotatorObj.Quote;
            divToAddQuote.appendChild(pag);
        }
        
        if(ImageRotatorObj.WebsiteUrl!=null && ImageRotatorObj.WebsiteUrl!=undefined)
        {
            var link = document.createElement("a");
            link.setAttribute("href", ImageRotatorObj.WebsiteUrl);
            link.setAttribute("target", ImageRotatorObj.Target);
            link.appendChild(image);
            div.appendChild(link);
        }
        else
        {
            div.appendChild(image);
        }
        divToAddTo.appendChild(div);
    }
}