var bgColor = "#636563"; var dkBlue = "#000080";
var topText = 'The University of British Columbia';
var Resources = "./Resources/";
var links = new Array ("index.php","members.html","links.html",
	"exec.php","news.php","announce.html")
var labels = new Array ("Home","Members","Links",
	"Meetings","Newsletters","Announcements");

$(document).ready(function() {
	setCanvas();
	setLeftColumn();
	setRightColumn();
});

// Utility functions
Array.prototype.find = function(searchStr) {
        var returnArray = false;
        for (i=0; i<this.length; i++) {
                if (typeof(searchStr) == 'function') {
                        if (searchStr.test(this[i])) {
                                if (!returnArray) { returnArray = [] }
                                returnArray.push(i);
                        }
                } else {
                        if (this[i]===searchStr) {
                                if (!returnArray) { returnArray = [] }
                                returnArray.push(i);
                        }
                }
        }
        return returnArray;
}

function setCanvas () {
	var topPath = Resources+ "topubc.gif"; var topAlt = "UBC top image";
	var imgPath = Resources+ "title1.gif"; var imgAlt = "UBC Logo";
	$("body").css("backgrounColor",bgColor);
	$("div#outer").css("border","solid black 2px").css("width","800px").
		css("backgroundColor",bgColor);
	$("#toptrim").append("<img></img>");
	$("#toptrim > img").attr({ src: topPath, alt: topAlt, border: 0});
	$("#toptrim > img").css({ position: "relative", left: "558px"});
	$("#topbanner").append('<img></img>');
	$("#topbanner > img").attr({ src: imgPath, alt: imgAlt});
    var template = $("<table align='center'><tr></tr></table>");
    $('#buttons').append(template); // put it into the DOM     
	for (var i=0; i<links.length; i++) {
		var temp = '<th class="button"><a href="'+ links[i]+ '">'; // alert(temp);
		template = $(temp+ labels[i]+ "</a></th>");
		$("tr").append(template);
	}
	$("a.link").css({color: "white",textDecoration: "none"});
	$("th").css({width:133,height:"25px", backgroundColor:"#663"});
 	$("th").hover (
		function () {$(this).css("borderStyle","inset");},
		function () {$(this).css("borderStyle","outset");}
	)
 	$("th:eq("+ iPage+ ")").css("borderStyle","inset");	
 	$("th:eq("+ iPage+ ")").hover (
		function () {$(this).css("borderStyle","inset");},
		function () {$(this).css("borderStyle","inset");}
	)
 	$("th:eq("+ iPage+ ")").css("borderStyle","inset");	
}

function setLeftColumn() {
	var myFigs = ["ubc.gif","ubcalumni.jpg","ubcuniv.jpg"];
	var myLinks = ["", "http://www.alumni.ubc.ca", "http://www.ubc.ca"];
	var myWrap = ['<a href="'+ myLinks[1]+ '"></a>','<a href="'+ myLinks[2]+ '"></a>'];
	for (var i=0; i<3; i++) {
		var leftImg = Resources+ myFigs[i];
	    var template = $("<img align='center' src='"+ leftImg+ "'></img>");
	    $("#left").append(template); // put it into the DOM 
	}
    $("#left").css({border:"solid black 2px"});
	$("#left > img").css({padding:"25px 35px 25px 15px"});
	$("#left > img:eq(2)").wrap(myWrap[1]).css("border","none");
	$("#left > img:eq(1)").wrap(myWrap[0]).css("border","none");
	template = $('<div><p align="center">Copyright 2003-2010<br />The<br />University of British Columbia</p></div>');
	$("#left").append(template);
	template = $('<div><p align="center">This page was last updated '+ document.lastModified+ '</p></div>');
	$("#left").append(template);
}
