
function removeHTMLTags(inputString) {
    var returnString = "";
    
    if (inputString) {
        returnString = inputString;
        
        // preserve break tags
        returnString = returnString.replace(/<br\/>/g, "xyxyxyxyxyxy");
        
        returnString = returnString.replace(/<\/?[^>]+(>|$)/g, "");
        
        returnString = returnString.replace("xyxyxyxyxyxy", "<br />");
    }
    return returnString;
}


function buildNewsItemDiv(pNewsItem) {
    var html = "<div class='news-item-container'>";
    
    html += "<div class='news-published-date'>" + formatNiceDate(pNewsItem.publishedDate, false) + "</div>";
    html += "<div class='news-headline'>" + pNewsItem.title + "</div>";
    
    html += "<div class='news-more-link'>more&nbsp;&raquo;</div>";
    
    html += "<div class='news-content news-content-full-story' style='display: none;'>" + pNewsItem.content.replace(/<\/?pre>/, "");
    if (pNewsItem.author) { html += "<div class='news-author'>posted by " + pNewsItem.author + "</div>"; }
    html += "<div style='margin: 1em 0; border-bottom: thin solid #444;'></div>";
    html += "</div>";
    
    html += "</div>";
    
    
    return html;
}


function buildContactRow(contact) {
    var contactRow = "<div style='display: table-row;'>";
    
    contactRow += "<span style='display: table-cell;'><strong>" + contact.role + "</strong> ";
    if (contact.subtitle) {
        contactRow += contact.subtitle;
    }
    contactRow += "</span>";
    
    contactRow += "<span style='display: table-cell;'>" + contact.person.getFullName();
    if (contact.person.isBoardMember) {
        contactRow += "&nbsp;<strong>*</strong>";
    }
    contactRow += "</span>";
    
    contactRow += "<span style='display: table-cell;'>";
    if (contact.email) {
        contactRow += "<a href=mailto:" + contact.email + " style='text-decoration: none;'>" + contact.email + "</a>";
        if (contact.phone || contact.notes) {
            contactRow += " &bull; ";
        }
    }
    if (contact.phone) {
        contactRow += contact.phone;
        if (contact.notes) {
            contactRow += " &bull; ";
        }
    }
    if (contact.notes) {
        contactRow += contact.notes;
    }
    contactRow += "</span>";
    
    contactRow += "</div>";
    
    return contactRow;
}


function buildTrackRecordRow(record) {
    var row = "<div style='display: table-row;'>";
    row += "<span style='display: table-cell;'>" + record.classAbbreviation + "</span>";
    row += "<span style='display: table-cell;'>" + record.lapTime + "</span>";
    row += "<span style='display: table-cell;'>" + record.driverName + "</span>";
    row += "<span style='display: table-cell;'>" + record.marque + "</span>";
    row += "<span style='display: table-cell;'>" + record.date.toString("M/d/yyyy") + "</span>";
    row += "</div>";
    return row;
}

