	var x=0;
	var columns=3;
	var rows=3;
	var first = 0;
	var last;
	var bigStr;
	var hint="";
	var annotation;
	
	var titleStr;
	
	var album;
	//var inThumbs=true;
	var inThumbs=false;
	var pic=0;
	
	var text = new Array("Main Entrance",
                 "School Office",
                 "Display Near Office",
                 "Reception",
                 "Foyer",
                 "School Hall",
                 "Harvest",
                 "Class Assembly",
                 "Main Corridor",
                 "Main Corridor",
                 "Corridor Display",
                 "Display In Corridor",
                 "ICT Suite",
                 "Library",
                 "Main Playground",
                 "Semi Final Its a Knockout and Shades Day",
                 "Trim Trail",
                 "Summer Fields",
                 "Early Years Unit",
                 "Entrance",
                 "Early Years Entrance",
                 "Early Years Corridor",
                 "Nursery Entrance",
                 "Foyer",
                 "Reception Class",
                 "Nursery",
                 "Reception Display",
                 "Reception",
                 "Chinese New Year",
                 "Nursery Activity",
                 "Outdoor Wall",
                 "Summer In Nursery",
                 "Outdoor",
                 "Class Display",
                 "Green Class",
                 "KS1 Class",
                 "Mrs Dunn",
                 "Orange Class",
                 "Senses Display",
                 "KS2 Stairwell",
                 "Inside Class",
                 "KS2 Class",
                 "Wall Display",
                 "Victorian Display"                
                 );
                 
  
  var areaIndex = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4);
  var area = new Array("Around School",
                  "Playgrounds",
                  "Early Years",
                  "Key Stage One",
                  "Key Stage Two"
                  );
  
  
  var textIndex = new Array(0,0,0,0,0,1,1,1,2,2,2,2,3,4,5,6,7,8,9,9,10,10,10,10,11,11,12,12,12,13,13,13,13,14,14,14,14,14,14,15,16,16,16,16);
  var text1 =new Array ("Near the main entrance you will find our head teachers office the main office and foyer.",
                  "Our hall is multi use and we host assemblies, have lunch and do PE in the hall.",
                  "Our downstairs corridor leads to three key stage one classrooms.",
                  "We have a new, dedicated ICT suite with 30 workstations.",
                  "Our library is on the ground floor along with a cooking room.",
                  "We are very fortunate to have large, safe playgrounds which have been recently marked.",
                  "School has playground friends and trained members of staff on duty.",
                  "We have tremendous open spaces.",
                  "Our field are extensive and are well used over the spring and summer months.",
                  "The early years unit has been recently constructed.",
                  "There is a dedicated entrance for children in the foundation stage.",
                  "We have two reception classes and a separate nursery.",
                  "All of the rooms are bright and airy.",
                  "We have a safe and purposeful outdoor play area for nursery and reception children.",
                  "There are three key stage one classes in our school.<br>Here are some views of the classrooms and displays.",
                  "Our three key stage two classrooms are on the upper floor.<br>There are two stairwells to access the classrooms and they are near to the ICT suite.",
                  "Here are some views form key stage two."                  
                  );
	




	
	
	function selectAlbum(albumStr)
		{
			//extract album name and number of pics
			var k =0;
			var tempStr="";
			while (albumStr.charAt(k)!='#')
				{
					tempStr+=albumStr.charAt(k);
					k++;
				}
			x=albumStr.slice(k+1);
			album=tempStr;
			
				
			if (x != 0)
				{
										
					//show();
					bigPic(1);
		
          document.getElementById("backdiv").innerHTML="<button type =\"button\" onclick = \"dec()\" id =\"back\" >Back</button>";

					document.getElementById("fordiv").innerHTML="<button type =\"button\" onclick = \"inc()\" id =\"forward\" >Forward</button>";
					
					document.getElementById("slidesDiv").innerHTML="<button type =\"button\" onclick = \"startSlides()\" id =\"slides\" >Slide Show</button>";
					
					
					document.getElementById("counter").style.width="130px";
					document.getElementById("hint").style.width="150px";
				
										
				}
		}

	function inc()
		{
      // added to allow circular incrementing on tour
      if (pic>=x)
	    		{
	    			pic=0;
	    			first=0;
      		}
      
			if (inThumbs)
				{
					if (canMove(1))
						{
							first=first+rows*columns;
						}
					show();
				}
			else
				{
					if (pic<x)
						{
							pic++;
							if (pic>first+rows*columns)
								{
									first=first+rows*columns;
								}
							bigPic(pic);
						}
				}
		}

	function dec()
		{
      // added to allow circular incrementing on tour
      if (pic<=1)
	    		{
            pic=parseInt(x)+1;           
	    			
	    			//first=x;   - not important if thumbnails not used.
      		}
      		
      
			if (inThumbs)
				{
					if (canMove(-1))
						{
							first=first-rows*columns;
						}
					show();
				}
			else
				{
					if (pic>1)
						{
							pic--;
							if (pic==first)
								{
									first=first-rows*columns;
								}
							bigPic(pic);
						}
				}
		}

	function canMove(direction)
		{
			if (direction==1)
				{
 					if ((first+rows*columns) < x)
						{
							return true;
						}
					else
						{
							return false;
						}
				}
			else
				{
					if (first>0)
						{
							return true;
						}
					else
						{
							return false;
						}
				}
		}

/*
	function show()
  	{
			if (x<=(first+rows*columns))
				{
					last=x;
				}
			else
				{
					last=first+rows*columns;
				}
			str="<table  class=\"thumb\">";
			for (j=0;j<rows;j++)
				{
					str+="<tr align=\"center\">";
					for (i=1;i<=columns;i++)
						{
							var c=first+j*columns+i;
							if (c<=x)
								{
									str+="<td><img src=\"pix/"+album+"/thumbnails/pic"+c+".jpg\" id=\""+c+"\" height = \"108\" border=\"0\" onclick=\"inThumbs=!inThumbs;bigPic("+c+")\" onmouseover=\"on("+c+")\" onmouseout=\"out("+c+")\" alt=\""+text[c-1]+"\" title=\""+text[c-1]+"\" style=\"border: 1px solid #000000\"></td>";
								}
							else
								{
									str+="<td>\&nbsp</td>";
								}
						}
					str+="</tr>";
				}
			str+="</table>";

			document.getElementById("picture").innerHTML=str;

			annotation="Click forward/back button to scroll through the pictures.";
			document.getElementById("annotation").innerHTML=annotation;

			
			hint="<p>Click on thumbnail to<br>view a larger version</p>";
			document.getElementById("hint").innerHTML=hint;
			document.getElementById("counter").innerHTML="Images <span class=\"blue\">"+(first+1)+"</span> to <span class=\"blue\">"+last+"</span> of <span class=\"blue\">"+x;
  	}
*/

	function bigPic(pIn)
		{
			pic=pIn;
			bigStr="<img src=\"pix/"+album+"/pic"+pic+".jpg\" id=\"big\" onclick=\"stopSlides();<!--inThumbs=!inThumbs;show()-->\" onmouseover=\"on('big')\" onmouseout=\"out('big')\" alt=\""+text[pic-1]+"\" title=\""+text[pic-1]+"\" style=\"border: 2px solid #000000\">";	
			document.getElementById("picture").innerHTML=bigStr;
			
			document.getElementById("big").style.cursor="pointer";
			document.getElementById("annotation").innerHTML=text[pic-1];
			document.getElementById("counter").innerHTML="Image <span class=\"blue\">"+pic+"</span> of <span class=\"blue\">"+x;
			var areaStr=area[areaIndex[pic-1]];
			var overallStr=text1[textIndex[pic-1]];
			document.getElementById("area").innerHTML=areaStr;
			document.getElementById("overall").innerHTML=overallStr;
		}

	function on(name)
		{
			document.getElementById(name).style.cursor="pointer";
		}
	function out(name)
		{
			document.getElementById(name).style.cursor="default";
		}

//link button variations
function changeButton(nameIn,state)
  {
	  if (state==0)
	  {
	  	document.getElementById(nameIn).src="pix/openDay/buttons/"+nameIn+"Hover.jpg";
	  }
	  else
	  {
	  	document.getElementById(nameIn).src="pix/openDay/buttons/"+nameIn+"Normal.jpg";
	  }
  }

/////////////////////////////////////////////////////////////////////////////



var s;
var timeoutId;	
var i=1;	
var slideGo=false;
function stopSlides()
	{
		slideGo=false;
		document.getElementById("slidesDiv").innerHTML="<button type =\"button\" onclick = \"startSlides()\" id =\"slides\" >Slide Show</button>";
		document.getElementById("backdiv").innerHTML="<button type =\"button\" onclick = \"dec()\" id =\"back\" >Back</button>";
		document.getElementById("fordiv").innerHTML="<button type =\"button\" onclick = \"inc()\" id =\"forward\" >Forward</button>";
		document.getElementById("hint").innerHTML="";
	}

function startSlides()
	{
		if ((inThumbs)&&((first>pic)||(last<pic)))
			{
				pic=first+1;
				
			}
		inThumbs=false;
		document.getElementById("slidesDiv").innerHTML="<button type =\"button\" onclick = \"stopSlides()\" id =\"slides\" >Stop Show</button>";
		document.getElementById("backdiv").innerHTML="";
		document.getElementById("fordiv").innerHTML="";
		document.getElementById("annotation").innerHTML="";
		hint="<p style=\"text-align:center\">Click on button<br>or picture<br>to stop slide show</p>";
		document.getElementById("hint").innerHTML=hint;
		
		slideGo=true;
		
		if(pic>0){pic--};
		slideshow();
	}


function slideshow()
	{
		if (slideGo)
			{
				if (pic>=x)
	    		{
	    			pic=0;
	    			first=0;
      		}
    		inc();
				s="slideshow()";
    		timeoutId=setTimeout(s,3000);
    	}
			
	}

