
	
	var pageTracker = new Object();
	
	pageTracker["aboutUs"] = "aboutUs";
	pageTracker["history"] = "bedfordBasin";
	pageTracker["events"] = "events";
	pageTracker["photoGallery"] = "photoGallery";	
	pageTracker["getInvolved"] = "getInvolved";
	pageTracker["links"] = "links";
	pageTracker["bamse"] = "bamse";
	
	function loadLastSubSection(temp)  //retrieve the correct value for the subsection
	{				
		subSection = pageTracker[temp];
		contentDiv.update('file='+subSection+'.lasso');
	}
	
	var btnTracker = new Object();
	btnName = new Array();
	
	btnName[0] = "aboutUs";
	btnName[1] = "history";
	btnName[2] = "events";
	btnName[3] = "photoGallery";
	btnName[4] = "getInvolved";
	btnName[5] = "links";
	btnName[6] = "bamse";

	var activeSection = "aboutUs";
	var activeSubSection = "bedfordBasin";
		

	function updateDisplay(){
		for (var temp in btnTracker){
			if (btnTracker[temp] == "mouseover")
				if (temp != activeSection)
					document.images[temp].src="images/" + temp + "_36px_Hover_2.png";
			if (btnTracker[temp] == "mouseout")
				if (temp != activeSection)
				  document.images[temp].src="images/" + temp + "_36px_2.png";		
			if (btnTracker[temp] == "click"){
				document.images[temp].src="images/" + temp + "_36px_Active_2.png";
				if(temp != activeSection){
					document.images[temp].src="images/" + temp + "_36px_2.png";
					btnTracker[temp] = 'mouseout';
				}
			}
		}
	}
	
	function btnListeners()
	{
		for (i=0; i<btnName.length;i++)
			{
			
				if(btnName[i] != activeSection)
					btnTracker[btnName[i]] = 'normal';
				else
					btnTracker[btnName[i]] = 'click';
				
				$(btnName[i]).observe('mouseover', function(event)
				{				
					btnTracker[this.name] = "mouseover";
					updateDisplay();		
				});
				
				$(btnName[i]).observe('mouseout', function(event)
				{
					btnTracker[this.name] = "mouseout";
					updateDisplay();		
				});
				
				$(btnName[i]).observe('click', function(event)
				{
					btnTracker[this.name] = "click";
					activeSection = this.name;
					activeSubSection = pageTracker[this.name];
					loadLastSubSection(this.name);
					updateDisplay();
					updateDisplaySub();
					showButtonBar(this.name);	
					changeBackground(this.name);						
				});						
			}		
	}
	
	function showButtonBar(name)
	{	
		/*$('aboutUsButtonBar').style.display = "none";	*/
		$('historyButtonBar').style.display = "none";
		/*$('getInvolvedButtonBar').style.display = "none"; */
		$('subNavSection').style.display = "none";
			 
		switch (name)
		{
		/*	case "aboutUs":
			  $('aboutUsButtonBar').style.display = "";
			  $('subNavSection').style.display = "";
			  $('subNavWidth').style.width = "462px";			  		  
			  break; */
			case "history":		 
			  $('historyButtonBar').style.display = "";
			  $('subNavSection').style.display = "";
			  $('subNavWidth').style.width = "172px";
			  break;
			/*case "getInvolved":		 
			  $('getInvolvedButtonBar').style.display = "";	
			  $('subNavSection').style.display = "";
			  $('subNavWidth').style.width = "339px";	  
			  break; */
			default:
			$('subNavSection').style.display = "none";
			$('subNavWidth').style.width = "";
		  
		}
	}
	
		function changeBackground(name)
	{
		switch(name)
		{
			case "bamse":
				document.getElementById('ccf_content').className = "bamse_body"; 
				break;
			default:
				document.getElementById('ccf_content').className = "ccf_content";		
		}
	
	}
		
	var btnTrackerSub = new Object();
	btnNameSub = new Array();
	
	
	

	btnNameSub[0] = "bedfordBasin";
	btnNameSub[1] = "convoys";	
		
	
	/*btnNameSub[0] = "mStatement"; btnNameSub[2] = "cnfoundation"; btnNameSub[1] = "ccfoundation"; btnNameSub[5] = "archives"; btnNameSub[5] = "support"; btnNameSub[7] = "volunteer"; btnNameSub[8] = "contribute"; btnNameSub[9] = "tellAFriend"; btnNameSub[10] = "contactUs"; */

	function updateDisplaySub(){
		for (var temp in btnTrackerSub){
			if (btnTrackerSub[temp] == "mouseover")
				if (temp != pageTracker[activeSection])
					document.images[temp].src="images/ccf_" + temp + "_hover_29px.png";
			if (btnTrackerSub[temp] == "mouseout")
				if (temp != pageTracker[activeSection])
				  document.images[temp].src="images/ccf_" + temp + "_29px.png";
				else
				  document.images[temp].src="images/ccf_" + temp + "_depressed_29px.png";
			if (btnTrackerSub[temp] == "mousedown")
				document.images[temp].src="images/ccf_" + temp + "_mousedown_29px.png";	  			
			if (btnTrackerSub[temp] == "click"){
				document.images[temp].src="images/ccf_" + temp + "_depressed_29px.png";
				if(temp != pageTracker[activeSection]){
					document.images[temp].src="images/ccf_" + temp + "_29px.png";
					btnTrackerSub[temp] = 'mouseout';
				}
			}
		}
	}
	
	function btnListenersSub()
	{
		for (i=0; i<btnNameSub.length;i++)
			{
				if((Object.values(pageTracker)).indexOf(btnNameSub[i]) == -1)
					btnTrackerSub[btnNameSub[i]] = 'normal';
				else
					btnTrackerSub[btnNameSub[i]] = 'click';
				
				$(btnNameSub[i]).observe('mouseover', function(event)
				{
				
					btnTrackerSub[this.name] = "mouseover";
					updateDisplaySub();		
				});
				
				$(btnNameSub[i]).observe('mouseout', function(event)
				{
					btnTrackerSub[this.name] = "mouseout";
					updateDisplaySub();		
				});
				
				$(btnNameSub[i]).observe('mousedown', function(event)
				{
					btnTrackerSub[this.name] = "mousedown";
					updateDisplaySub();		
				});
				
				$(btnNameSub[i]).observe('click', function(event)
				{
					btnTrackerSub[this.name] = "click";
					activeSubSection = this.name;
					pageTracker[activeSection] = this.name;
					updateDisplaySub();	
				/*	updatefilmstrip();	*/					
				});						
			}
	}	
	

function autoResize()
{
	var ht = $('ccf_content').getHeight();
	
	if (ht < 450)
	{
		$('sec_cons').innerHTML = "<img src=images/ccf_section_cons_400px.png />";
	}
	else if((ht >= 450) && (ht < 700))
		{
			$('sec_cons').innerHTML = "<img src=images/ccf_section_cons_600px.png />";
		}
	else
	{
		$('sec_cons').innerHTML = "<img src=images/ccf_section_cons_750px.png />";
	}

}

function resizeComposite()
{
	var compW = $('ccf_content').getWidth();

	if (compW < 600)
	{		
		$('composite').innerHTML = "<img src=images/composite_300px.png />";
	}
	if((compW >= 800) && (compW < 1000))
		{
			
			$('composite').innerHTML = "<img src=images/composite_550px.png />";
		}
	if(compW >= 1000)
	{
		
		$('composite').innerHTML = "<img src=images/composite_750px.png />";
	}

}


function resizeComposite2()
{
	var compW = $('ccf_content').getWidth();

	if (compW < 1000)
	{		
		$('event-image').innerHTML = "<img src=images/event-image-800w.png width=100% />";
	}
	if((compW >= 1000) && (compW < 1200))
		{
			
			$('event-image').innerHTML = "<img src=images/event-image.png width=100% />";
		}
	if(compW >= 1200)
	{
		
		$('event-image').innerHTML = "<img src=images/event-image-1200w.png width=100% />";
	}

}

/*
	var filmstripId = new Object();

	filmstripId[0] = "filmstrip_1";
	filmstripId[1] = "filmstrip_2";
	filmstripId[2] = "filmstrip_3";
	filmstripId[3] = "filmstrip_4";
	
	currentfilmstrip = 0;
	
		
	function updatefilmstrip()
	{
		
		do{
			var r = Math.floor(Math.random()*4);
		}while(r == currentfilmstrip)
		
		new Effect.Parallel([
	 	new Effect.Fade($(filmstripId[currentfilmstrip]), {sync: true}),
	 	new Effect.Appear($(filmstripId[r]), {sync: true})], {duration: 0.8});
		
		currentfilmstrip = r;			
	}
		
*/
	
