﻿// JavaScript Document
// Contains a series of scripts to build elements of 
// of the sites pages
// Copyright Leonard Horthy 2003 - All rights reserved


// Requires page struct to be declared (see site_struct.js)


var pos;
var sectionId;

var docHREF = document.location.href;
var fileName = docHREF.substring(docHREF.lastIndexOf('/') + 1, docHREF.length);

pos = fileName.indexOf('_');

if (pos > 0) sectionId = fileName.substring(0, pos);
else sectionId = fileName.substring(0, fileName.indexOf('.'));

//alert(sectionId);

// find out which section we are in
var curSection = siteSections[0]; //default to home page
for(var i = 0; i < siteSections.length; i++) {
		//alert('i=' + i + ' sec=' + siteSections[i].id);
	if (siteSections[i].id == sectionId) {
		curSection = siteSections[i];
		break;

	}
}

//alert('done ' + curSection.id);

function buildBanner() 
{
	//alert('function buildBanner()');

	var htmlCode = '';
	htmlCode += '<table border="0" cellpadding="0" cellspacing="0">\n';
	htmlCode += '<tr>\n';
	htmlCode += '<td width="640"><img src="';

	htmlCode += curSection.banner;
	htmlCode += '" width="640" height="125"></td>\n';
	htmlCode += '<td width="3" bgcolor="#000000">';
	htmlCode += '<img src="images/spacer.gif" width="3" height="1"></td>\n';
 	htmlCode += '</tr>\n';
	htmlCode += '</table>';
    
    //alert(htmlCode);
    
    document.write(htmlCode);
}

function buildNavBar() 
{
	//alert('function buildNavBar()');

	var htmlCode = '';
	htmlCode += '<tr>\n';
	htmlCode += '<td height="35" bgcolor="' + curSection.color + '">\n';
	htmlCode += '<table width="100%" border="0" cellpadding="2" cellspacing="3">\n';
	htmlCode += '<tr><td>';
	
	// build a link to each section
	for(var i = 0; i < siteSections.length; i++) {
	
		if (siteSections[i].id == sectionId) {
			// special color for news link
			if (sectionId == 'news') htmlCode += '<a class="highlight1a" href="';
			else htmlCode += '<a class="highlight1" href="';
		} else {
			htmlCode += '<a class="link1" href="';
		}
		
		htmlCode += siteSections[i].fileName + '">' + siteSections[i].navLabel + '</a>';
		
		if (i < (siteSections.length - 1))
			htmlCode += ' <span class="divider1">::</span> \n';
	}
	
	htmlCode += '</td>\n';
	htmlCode += '<td align="right" class="pageTitle">';
	htmlCode += curSection.label1;
	htmlCode += '<span class="pageTitleBold">';
	htmlCode += curSection.label2;
	htmlCode += '</span></td>\n';
	htmlCode += '</tr></table></td>\n';
    htmlCode += '</tr>';
    
    //alert(htmlCode);
    
    document.write(htmlCode);
}

function buildSubNavBar() 
{
	var htmlCode = '';
	
	// build a link to each section
	for(var i = 0; i < curSection.subLinks.length; i++) {
	
		if (curSection.subLinks[i] == fileName) htmlCode += '<a class="highlight2" href="';
		else htmlCode += '<a class="link2" href="';
		
		htmlCode += curSection.subLinks[i] + '">' + curSection.subLabels[i] + '</a>';
		
		if (i < (curSection.subLinks.length - 1))
			htmlCode += ' <span class="divider2">::</span> \n';
	}
	
    

    //alert(htmlCode);
    
    document.write(htmlCode);
}


function buildTiles() 
{
	var htmlCode = '';
	htmlCode += '<table border="0" cellspacing="0" cellpadding="0">\n';
	
	// build a cell for each tile
	for(var i = 0; i < curSection.tiles.length; i++) {

	
		htmlCode += '<tr>\n';
		htmlCode += '<td width="63"><img src="';
		htmlCode += curSection.tiles[i];
		htmlCode += '" width="96" height="96"></td>\n';
		htmlCode += '</tr>\n';
		
		// spacer between cells
		if (i < (curSection.tiles.length - 1)) {
			htmlCode += '<tr>\n';
			htmlCode += '<td height="3"><img src="images/spacer.gif" width="1" height="3"></td>\n';
			htmlCode += '</tr>\n';
		}
	}
	
	htmlCode += '</table>\n';
   
    //alert(htmlCode);
    

    document.write(htmlCode);
}

function buildCopyright() 

{
	var htmlCode = '';
	htmlCode += '<tr>\n';

	htmlCode += '<td height="19" align="center" valign="middle" bgcolor="';
	htmlCode +=  curSection.color;
	htmlCode += '" class="copyrightText">Copyright\n';

	htmlCode += '&copy; 2005 Atalanta Association. All rights reserved.</td>\n';
	htmlCode += '</tr>\n';
   
    //alert(htmlCode);
    
    document.write(htmlCode);
}

