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() {
	if (typeof setCanvas == 'function') {
		setCanvas();} else { alert ('setCanvas() failed!');} 
	if (typeof setLeftColumn == 'function') {
		setLeftColumn();} else { alert ('setLeftColumn() failed!');} 
	if (typeof setRightColumn == 'function') {
		setRightColumn();} else { alert ('setRightColumn() failed!');} 
	leftHeight = $("div#left").outerHeight();
	rightHeight = $("div#right").outerHeight();
 	if (leftHeight < rightHeight) {
 		$("div#left").css("height",rightHeight);
 	} else {
		$("div#right").css("height",leftHeight);	
 	}
 });

// 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:"15px 35px 15px 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-2011<br />'+
		'University of British Columbia</p></div>';
		$("#left").append($(template));
	template = '<p id="addr" align="center"></p>';
		$("#left").append($(template));
	template = '';
	template += '<br />Association of Professors Emeriti<br />';
	template += 'UBC Alumni Association<br />';
	template += '#4004, Copp Building<br />';
	template += '2146 Health Science Mall<br />';
	template += 'V6T 1Z3<br />';
	template += 'Ph.: 604-822-1752<br />';
	template += 'admin@emeriti.ubc.ca<br />';
		$("#addr").append($(template));		
	template ='<p align="center">This page was last updated '+ 
		document.lastModified+ '</p>';
		$("#left").append($(template));
}

