
	if(!document.getElementById){ //If getElementById is not present create it, for compatibility
  		if(document.all)
  			document.getElementById=function(){
    			if(typeof document.all[arguments[0]]!='undefined')
    				return document.all[arguments[0]];
    			else
    				return null;
  			}
  		else if(document.layers)
  			document.getElementById=function(){
    			if(typeof document[arguments[0]]!='undefined')
    				return document[arguments[0]];
   			 	else
    				return null;
  			}
	}
	var maxp = 35;  //Number of Pictures
	
	var time;
	var curp;
	var moto;
	var month=new Array();
	function writetop(ID){
		var shrefs=new Array();
	  	var stexts=new Array();
	  	var stitle=new Array();
	  	var i;

			shrefs[0]='index.html';   stexts[0]='home';    stitle[0]='The house\'s ethos';
			shrefs[1]='news.html';    stexts[1]='news';    stitle[1]='Recent house events';
			shrefs[2]='history.html'; stexts[2]='history'; stitle[2]='The past of Carrington';
			shrefs[3]='staff.html';   stexts[3]='staff';   stitle[3]='The adults in Carrington';
			shrefs[4]='gallery.html'; stexts[4]='gallery'; stitle[4]='The photos of Carrington';
			shrefs[5]='chapel.html';  stexts[5]='chapel';  stitle[5]='Carrington\' week in chapel';

		document.writeln('<a name=\"top\"><table class=\"bg\" cellspacing=0><tr><td class=\"head\" colspan=2>Carrington House - '+stexts[ID]+'</td></tr>');
		document.writeln('<tr><td class=\"foot\" colspan=2><div align="position: absolute" id=\"mottos\" onmouseover=\"motto('+moto+');\"></div></td>')	;
	  	document.writeln('<tr><td class=\"lbar\">');
		
	  	for(i=0; i < 6; i++)
			if(ID!=i)
				document.writeln('<a class=\"lbar\" href=\"'+shrefs[i]+'\" title=\"'+stitle[i]+'\">'+stexts[i]+' &nbsp;</a><br>');
			else
				document.writeln('<a class=\"lbar\" href=\"'+shrefs[i]+'\" title=\"You are here\"><font color=\"#6677CC\">'+stexts[i]+' &nbsp;</font></a><br>');
	  	
	  	document.writeln('<img id=\"slides\" width=200 align="center" alt="Slideshow" title="Click for next image" onclick=\"nextslide()\"></td>');
		document.writeln('<td class=\"main\"><br>');
		motto(1);
		curp = Math.round(Math.random()*(maxp+1)-1);
	nextslide();
    }
   	function nextslide(){
   		var photo = 0
   			if(curp>maxp)curp=0;
   		document.images.slides.src='images/pics/pic ('+curp+++').JPG';
   		clearTimeout(time)
   		time=setTimeout('nextslide()',5000);
   	}	
   	function motto(EL){
   		if (moto++==0)
   			document.getElementById('mottos').innerHTML='with knowledge, believe in respect and rectitude';
   		else {moto = 0;
   			document.getElementById('mottos').innerHTML='scientia crede reverentiae probati';}
	}
   	function writebot(ID){
   		var count = 0;
   		document.writeln('<br></td></tr>');
   		document.writeln('<tr><td class = \"foot\"><a class=\"foot\" href=\"#top\"> return to top &nbsp;</a></td>');
   		document.writeln('<td class=\"foot\"><a class=\"foot\" href=\"mailto:da.goodenough@fettes.com\">email the housemaster</a><br></td></tr></table>');
   	}
   	function setmonths(){
   		month[1] = "January";
   		month[2] = "February";
   		month[3] = "March";
   		month[4] = "April";
   		month[5] = "May";
   		month[6] = "June";
   		month[7] = "July";
   		month[8] = "August";
   		month[9] = "September";
   		month[10] = "October";
   		month[11] = "November";
   		month[12] = "December";
   	}
   	function date(day,of_month) {
		var th;
		var dy = day % 10;
		     if (dy > 3) th = "th";
		else if (dy == 1) th = "st";
		else if (dy == 2) th = "nd";
		else if (dy == 3) th = "rd";
		return day+'<sup>'+th+'</sup> '+month[of_month];
	}