galleryPics = new Array(10);
galleryText = new Array(10);

firstPic  = 0;
secondPic = 1;
thirdPic  = 2;
fourthPic = 3;
fifthPic  = 4;
sixthPic  = 5;

galleryRotate = 0;

setSite();

galleryPics[firstPic]   = "gallery1.jpg";
galleryPics[secondPic]  = "gallery2.jpg";
galleryPics[thirdPic]   = "gallery3.jpg";
galleryPics[fourthPic]  = "gallery4.jpg";
galleryPics[fifthPic]   = "gallery5.jpg";
galleryPics[sixthPic]   = "gallery6.jpg";
galleryPics[6]          = "gallery7.jpg";
galleryPics[7]          = "gallery8.jpg";
galleryPics[8]          = "gallery9.jpg";
galleryPics[9]          = "gallery10.jpg";

uk = baseImages + "uk2.gif"
us = baseImages + "usa.gif"

galleryText[firstPic]  = setName("Hugo" , uk ) + "Hugo loves his new home on the coast at<b><i>Clacton-on-Sea</i></b>.</font>";
galleryText[secondPic] = setName("Tiddles" , us ) + "Tiddles has a new home far away in <b><i>Roanoke</i></b> in the United States.</font>";
galleryText[thirdPic]  = setName("Boris" , uk ) + "Boris made someone's mum a lovely Christmas present! He now lives in <b><i>London</i></b>.</font>";
galleryText[fourthPic] = setName("Rosie" , uk ) + "Rosie now lives with a lovely lady in <b><i>London</i></b>.</font>";
galleryText[fifthPic]  = setName("Snowy" , uk ) + "Snowy lives with lots of other beary friends in <b><i>Ipswich</i></b>.</font>";
galleryText[sixthPic]  = setName("Blue" , uk ) + "Blue is loved by a little girl in <b><i>Cambridge</i></b>.</font>";
galleryText[6]         = setName("Saul" , uk ) + "Saul lives with twins in <b><i>Halstead</i></b>.</font>";
galleryText[7]         = setName("Yuri" , uk ) + "Yuri lives with twins in <b><i>Halstead</i></b>.</font>";
galleryText[8]         = setName("Ralph" , uk ) + "Ralph has a fine new home in <b><i>Clacton</i></b>.</font>";
galleryText[9]         = setName("Emily" , uk ) + "Emily lives with loads of friends in <b><i>Ipswich</i></b>.</font>";
						
						
function setName( theName , theFlag )
{
	return "<font face=\"Comic Sans MS\" size=\"5\" color=\"#800080\">" +
			theName.substring(0,1) + "</font><font face=\"Comic Sans MS\" size=\"5\" color=\"#4F5B75\">" +
			theName.substring(1) + "</font>"+setFlag( theFlag)+"<br><br><font face=\"Comic Sans MS\" style=\"font-size: 11pt\" color=\"#4F5B75\">";
}


function setFlag( theFlag )
{
	return "&nbsp;<img src='"+theFlag+"' width=24 height=18 align=top>";
}

function getIndex( picture )
{
	return (picture + galleryRotate) % 10;
}



function changeText( )
{

	for(i = 0 ; i < 3 ; i++)
	{
		switch(i) {
			case 0 :
				odiv = gp0;
				break;
			case 1 :
				odiv = gp1;
				break;
			case 2 :
				odiv = gp2;
				break;
		}

		ochild = odiv.children(0);
		ihtml = ochild.innerHTML;
		onew = document.createElement("P");
		odiv.replaceChild(onew,ochild);
	    onew.innerHTML=galleryText[getIndex( i )];
	 }
}

function rotateGallery()
{

	galleryRotate++;
	if(galleryRotate == 10) galleryRotate = 0;

	document.gl0.src = imageFolder + galleryPics[getIndex(0)];
	document.gl1.src = imageFolder + galleryPics[getIndex(1)];
	document.gl2.src = imageFolder + galleryPics[getIndex(2)];
	
	changeText(  );
	
	
	setTimeout("rotateGallery()",5000);
}

function showText ( theText )
{
	document.write( galleryText[theText] );
}
				

c1  = 0;
cs1 = 1;
d1  = 2;
ds1 = 3;
e1  = 4;
f1  = 5;
fs1 = 6;
g1  = 7;
gs1 = 8;
a1  = 9;
as1 = 10;
b1  = 11;
c2  = 12;
cs2 = 13;
d2  = 14;
ds2 = 15;
e2  = 16;
f2  = 17;
fs2 = 18;
g2  = 19;
gs2 = 20;
a2  = 21;
as2 = 22;
b2  = 23;
c3  = 24;
cs3 = 25;
d3  = 26;
ds3 = 27;
e3  = 28;
f3  = 29;
fs3 = 30;
g3  = 31;
gs3 = 32;
a3  = 33;
as3 = 34;
b3  = 35;
c4  = 36;
sl  = 37;

allNotes = new Array(38);

allNotes[0] = "fs1.wav";
allNotes[1] = "g1.wav";
allNotes[2] = "gs1.wav";
allNotes[3] = "a1.wav";
allNotes[4] = "as1.wav";
allNotes[5] = "b1.wav";
allNotes[6] = "c2.wav";
allNotes[7] = "cs2.wav";
allNotes[8] = "d2.wav";
allNotes[9] = "ds2.wav";
allNotes[10] = "e2.wav";
allNotes[11] = "f2.wav";
allNotes[12] = "fs2.wav";
allNotes[13] = "g2.wav";
allNotes[14] = "gs2.wav";
allNotes[15] = "a2.wav";
allNotes[16] = "as2.wav";
allNotes[17] = "b2.wav";
allNotes[18] = "c3.wav";
allNotes[19] = "cs3.wav";
allNotes[20] = "d3.wav";
allNotes[21] = "ds3.wav";
allNotes[22] = "e3.wav";
allNotes[23] = "f3.wav";
allNotes[24] = "fs3.wav";
allNotes[25] = "g3.wav";
allNotes[26] = "gs3.wav";
allNotes[27] = "a3.wav";
allNotes[28] = "as3.wav";
allNotes[29] = "b3.wav";
allNotes[30] = "c4.wav";
allNotes[31] = "cs4.wav";
allNotes[32] = "d4.wav";
allNotes[33] = "ds4.wav";
allNotes[34] = "e4.wav";
allNotes[35] = "f4.wav";
allNotes[36] = "fs4.wav";
allNotes[37] = "sl.wav";

song_1 = new Note(63);

song_1[0]  = new Note(g1,200);
song_1[1]  = new Note(c2,300);
song_1[2]  = new Note(ds2,200);
song_1[3]  = new Note(d2,200);
song_1[4]  = new Note(ds2,200);
song_1[5]  = new Note(d2,200);
song_1[6]  = new Note(c2,300);
song_1[7]  = new Note(ds2,200);
song_1[8]  = new Note(d2,300);
song_1[9]  = new Note(g1,200);
song_1[10] = new Note(c2,200);
song_1[11] = new Note(d2,200);
song_1[12] = new Note(ds2,200);
song_1[13] = new Note(d2,300);
song_1[14] = new Note(ds2,200);
song_1[15] = new Note(c2,750);
song_1[16]  = new Note(g1+3,200);
song_1[17]  = new Note(c2+3,300);
song_1[18]  = new Note(ds2+3,200);
song_1[19]  = new Note(d2+3,200);
song_1[20]  = new Note(ds2+3,200);
song_1[21]  = new Note(d2+3,200);
song_1[22]  = new Note(c2+3,300);
song_1[23]  = new Note(ds2+3,200);
song_1[24]  = new Note(d2+3,300);
song_1[25]  = new Note(g1+3,200);
song_1[26] = new Note(c2+3,200);
song_1[27] = new Note(d2+3,200);
song_1[28] = new Note(ds2+3,200);
song_1[29] = new Note(d2+3,300);
song_1[30] = new Note(ds2+3,200);
song_1[31] = new Note(c2+3,750);

song_1[32] = new Note(b2,200);
song_1[33] = new Note(c3,300);
song_1[34] = new Note(b2,200);
song_1[35] = new Note(c3,300);
song_1[36] = new Note(b2,200);
song_1[37] = new Note(gs2,200);
song_1[38] = new Note(a2,200);
song_1[39] = new Note(as2,200);
song_1[40] = new Note(gs2,400);

song_1[41] = new Note(fs2,200);
song_1[42] = new Note(sl,200);
song_1[43] = new Note(fs2,300);

song_1[44] = new Note(e2,200);
song_1[45] = new Note(fs2,300);
song_1[46] = new Note(e2,400);
song_1[47] = new Note(c2,200);
song_1[48] = new Note(d2,200);
song_1[49] = new Note(ds2,200);
song_1[50] = new Note(b1,300);

song_1[51] = new Note(sl,200);
song_1[52] = new Note(b1,200);
song_1[53] = new Note(c2,300);
song_1[54] = new Note(ds2,200);
song_1[55] = new Note(b1,200);
song_1[56] = new Note(sl,200);
song_1[57] = new Note(b1,200);
song_1[58] = new Note(c2,200);
song_1[59] = new Note(ds2,200);
song_1[60] = new Note(e2,200);
song_1[61] = new Note(b1,300);
song_1[62] = new Note(g2,500);
song_1[63] = new Note(f2,750);
song_1[64] = new Note(e2,500);

onNote = 0;
activeSong = song_1;
activeSongLength = 65;

function doSong( theSong )
{
	switch (theSong ) {
		case 0:
			activeSong = song_1;
			activeSongLength = 65;
			break;
	}
	
	playSong();
}

function Note(note,duration)
{
	this.note = note;
	this.duration = duration ;
}


function playSong()
{
	if(onNote == activeSongLength) 
	{
		onNote = 0;
		return;
	}
	else
	{
		playSound(activeSong[onNote].note);
		setTimeout("playSong()",activeSong[onNote++].duration);
	}

}


function playSound( snd ) { document.embeds[snd].play(); }

function addNotes()
{
	if(onNote == 38) 
	{
		onNote = 0;
		document.all["gr1"].style.display = "none";
		document.all["gr0"].style.display = "";
		document.all["gr2"].style.display = "";
		document.all["gr3"].style.display = "";
		return;
	}
	
	onew = document.createElement("embed");
	onew.autostart=false;
	onew.hidden=true;
	onew.width=1;
	onew.height=1;
	onew.src = site + "sounds/" + allNotes[onNote++];
	document.body.appendChild(onew);
	
	setTimeout("addNotes()",200);
}	
	

