var current_anim; 
var current_fade;
var shown="";
var showBox;
var bgimage;
var bgcolour;

	var infoBoxes=[];
	infoBoxes["bedlamtheatre"]="The Bedlam Theatre is a unique, entirely student run theatre in the heart of Edinburgh. The Theatre and café are open for performances at least two nights a week and all day every day during Freshers' Week and Student Festival. <a href='/about'>Find out more.</a>";
	infoBoxes["eutc"]="The Edinburgh University Theatre Company stages shows every week of the academic year. Anyone can join, no experience is necessary and we frequently hold open auditions. Actor? Director? Producer? Techie? <a href='/about/gettinginvolved'>Get involved.</a>";
	infoBoxes["bedlamfringe"]="Every Fringe the Bedlam Theatre hosts companies from across the world. A plethora of diverse performances showcase the full variety of theatre that the Fringe provides. <a href='http://www.bedlamfringe.co.uk'>Visit the Bedlam Fringe website.</a>";
	infoBoxes["improverts"]="The Improverts' legendary show has played to packed houses on Friday nights for the past eighteen years. Various improvisation games based on audience suggestions give rise to a hilarious and unique show every time. <a href='http://www.improverts.co.uk/'>Visit their website.</a>";
	var bgimages=[];
	bgimages["bedlamtheatre"]="/img/box-office-gradient-crop";
	bgimages["eutc"]="/img/cafe-splash";
	bgimages["bedlamfringe"]="/img/bedlam-front-doors-fade-2";
	bgimages["improverts"]="/images/project/1/background";
	bgimages["default"]="/img/box-office-gradient-crop";
	var bgcolours=[];
	bgcolours["bedlamtheatre"]="#210A10";
	bgcolours["eutc"]="#FFFFEB";
	bgcolours["bedlamfringe"]="#ffffff";
	bgcolours["improverts"]="#000000";
	bgcolours["default"]="#210A10";
	var boxcolours=[];
	boxcolours["bedlamtheatre"]="000000";
	boxcolours["eutc"]="36699C";
	boxcolours["bedlamfringe"]="932727";
	boxcolours["improverts"]="E98601";   
		function hideMoreInfo (show) {
			if(current_anim)current_anim.destroy();
			if(shown != ""){
				
if(showBox)current_anim=glow.anim.slideUp(showBox, 1, {
					"onComplete": function(){showMoreInfo (show);}
				});
			}
			else showMoreInfo (show);
			
		}
		function showMoreInfo (show) {
			if(infoBoxes[show]==null)return;
	    		   if(current_anim)current_anim.destroy();
	    		   if(current_fade)current_fade.destroy();
			if (show != shown) {
	    		   var infoBox=glow.dom.get("#infoboxes");
	    		   infoBox.children().destroy();
	    		   showBox=glow.dom.create("<div style='background:#"+boxcolours[show]+";height:0;' class='moreinfo'></div>");
	    		   infoBox.append(showBox);
	    		   glow.dom.create("<p>"+infoBoxes[show]+"</p>").appendTo(showBox);

			current_anim=glow.anim.css(showBox, 1.5,{
					"height": glow.dom.get("#logo").height()-glow.dom.get("#thumbnails").height()

				},
				{
					tween: glow.tweens.overshootOut()
				}).start();
				bgfade(bgimages[show],bgcolours[show]);
				shown=show;
			}
			else{
				bgfade(initbgimage,initbgcolour);
				shown="";
			}

		}
function bgfade(newbgimage,newbgcolour){
	if(bgimage!=newbgimage){
		document.body.style.backgroundImage="none";
		current_fade=glow.anim.highlight("#body", bgcolour, 1.5,{
			completeColour: newbgcolour,
			onComplete: function(){
				document.body.style.backgroundImage="url('"+newbgimage+"')";
				bgcolour=newbgcolour;
				bgimage=newbgimage;
			}
		});
	}

}


glow.ready(
function(){
	bgimage=initbgimage;
	bgcolour=initbgcolour;
	//hideMoreInfo(initTab);
	showBox=glow.dom.get("#infoboxes div");
	showBox.height(0);
	glow.events.addListener(glow.dom.get("#thumbnails img"), "load",function(){ 
		current_anim=glow.anim.css(showBox, 1.5,{
			"height": glow.dom.get("#logo").height()-glow.dom.get("#thumbnails").height()

		},
		{
			tween: glow.tweens.overshootOut()
		}).start();
		shown=initTab;
	});
	glow.events.addListener("#thumbnails a", "click", function(event) {
		hideMoreInfo(glow.dom.get(this).attr("data-infoname"));
		this.blur();
		return false;
	});

}
);

