var centralEmail = 'centralu[code:at]wightman[code:ca]';
var centralPhone = '<nobr>(519) 271-7946</nobr>';
var centralFax = '<nobr>(519) 271-2582</nobr>';

function createHeader(returnURL, returnlink) {
    var html =
    '<div id="page">'+
    '<table width="100%" id="header" border="0" cellspacing="0" cellpadding="0">'+
    '  <tr>'+
    '    <td width="210px" align="left">'+
    '      <img src="church_sketch_transparent_noshadow.gif" alt="Central United Church drawing by Chris Crozier"><br/>'+
    '    </td>'+
    '    <td align="center" valign="middle" nowrap>'+
    '      <H1>Central United Church</H1>'+
    '      Stratford, Ontario, Canada'+
    '';
    if (!returnURL) {
        html +=
        '      <div style="font-size: 90%; padding-top: 10px">'+
        '      Ministers:&nbsp;&nbsp;Rev. Cheryl-Ann Stadelbauer-Sampa<BR/>'+
        '      Rev. Cindy Bourgeois (Pastoral Care and Christian Education)</div>'+
        '';
    }
    html +=
    '    </td>'+
    '';
    if (returnlink && !location.existsParam('launched')) {
        html +=
        '    <td width="210px" align="center" valign="bottom">'+
        '       <a style="font-size: 95%; font-weight: normal;" href="' + returnURL + '" target="_parent">' + returnlink + '</a>';
    } else {
        html +=
        '    <td width="210px" align="right" valign="bottom">'+
        '       &nbsp;';
    }
    html +=
    '    </td>'+
    '  </tr>'+
    '</table>'+
    '<table id="content" width="100%" border="0" cellspacing="0" cellpadding="0">'+
    '  <tr>' +
    '';
    document.writeln(html);

    if (!returnURL) {
        document.write('  <td id="menu" valign="top" width="1%">');
        createMenu();

//        document.write('<br/><a href="http://www.united-church.ca/en/communications/news/moderator/070606" target="_parent">Post-Surgery Message from the Moderator</a>');

        document.write('  </td>');
    }

    document.write('  <td class="details" valign="top">');
}


function createMenu() {
    document.write('  <ul>');
    create_menu_item('index', 'Home');
    create_menu_item('worship', 'Worship');
    create_menu_item('events', 'Events');
//    document.write('<li><a class="menu_link" href="Spring Fling 2010.pdf" target="_blank"><nobr>Spring Fling</nobr></a></li>');
//    create_menu_item('springfling', 'Spring Fling');
    create_menu_item('programs', 'Programs');
    create_menu_item('youth', 'Youth');
    create_menu_item('music', 'Music');
    create_menu_item('outreach', 'Outreach');
    create_menu_item('pastoralcare', 'Pastoral Care');
    create_menu_item('sermons', 'Sermons');
    create_menu_item('about', 'About Us');
    create_menu_item('contacts', 'Contact Us');
    create_menu_item('location', 'Find Us');
    create_menu_item('caringfunds', 'Caring Funds');
    create_menu_item('links', 'Related Links');
//    create_menu_item('JNAC', 'JNAC Survey');
//    document.write('<li><a class="menu_link" href="JNAC Report.pdf" target="_blank"><nobr>JNAC Report</nobr></a></li>');
//    create_menu_item('employment', 'Employment<br/>Opportunities');
    document.write('  </ul>');
}


function create_menu_item(link, text) {
    document.write('    <li class="' + link + '"><a class="menu_link" href="' + link + '.html" target="_parent"><nobr>' + text + '</nobr></a><nobr class="menu_text">' + text + '</nobr></li>');
}


function createFooter() {
    var lastModified = new Date(document.lastModified);
    var displayDate = monthText[lastModified.getMonth()] + " " + lastModified.getDate() + ", " + lastModified.getFullYear();

    var html =
    '</td></tr></table>'+
    '<table id="footer" width="100%" border="0" cellspacing="0" cellpadding="0">'+
    '  <tr valign="bottom">'+
    '    <td width="10%" align="left"><nobr>'+
    '        Site contents copyright &copy;2004-' + new Date().getFullYear() + ' Central United Church, Stratford, Ontario.  All rights reserved.'+
    '    </nobr></td>'+
    '    <td width="10%" align="right"><nobr>'+
    '      This page last updated: ' + displayDate +
    '    </nobr></td>'+
    '  </tr>'+
    '</table>'+
    '</div>'+
    '';
    document.writeln(html);

    var message = document.getElementById('script_message');
    if (message) message.style.display = 'none';

}

function createPopupLink(link, text, winName, winProps) {
    var html = '<a href="' + link + '" onClick="return popupWindow(\'' + link + '\'';
    if (winName) {
        html += ", '" + winName + "'";
    } else {
        html += ", '" + text + "'";
    }
    if (winProps) html += ", '" + winProps + "'";
    html +=  ');" target="_parent">' + text + '</a>';
    return (html);
}

function contentResize(maxWidth) {
    var contentHeight = document.body.clientHeight - document.getElementById('header').offsetHeight - document.getElementById('footer').offsetHeight;
    if (document.getElementById('content').offsetHeight < contentHeight) document.getElementById('content').style.height = contentHeight;
//    if (maxWidth == null) maxWidth = 900;
//    if (document.body.clientWidth < maxWidth) {
//        document.getElementById('container').width = "100%";
//    } else {
//        document.getElementById('container').width = maxWidth + "px";
//    }
}
