																																																																																																																																																																																								
$(document).ready(function()
{
	$('.h_gal').cycle({ 
		fx:   'zoom', 
		speed:   100,
		timeout: 8000		
	});
	
	$('h3').each(function(index) {
		if(index>0){
			$(this).prepend('</span>');
		}
		$(this).append('<span class="idea_month" id="content_'+index+'">');
		$(this).attr('id',index);
		$(this).addClass('idea');
	});
	
	$('h3.idea').click(function(){
		var id = $(this).attr('id');
		$('#content_'+id).toggle();
	});
	
});			

function lb()
{
	$('.lightbulb').fadeOut(3000,function(){
		$('.lightbulb').fadeIn(3000,function(){
			lb();
		})
	});
}

function StartGame()
{
	sticks = 0;
	sticktype = 1;
	milisec = 0; 
	seconds = 20; 
	over = 0;
	$('.stick_1').remove();
	$('.stick_2').remove();
	$('.stick_3').remove();
	$('.gameover').hide();
	$('.fire1').remove();
	$('#start').fadeOut(200);
	var left = Math.ceil(400*Math.random())
	var top = Math.ceil(40*Math.random())
	$(".stick-zone").append("<div class='stick_1' id='s_"+sticks+"' style='position:absolute;left:"+left+"px;top:"+top+"px;'></div>");
	$("#s_"+sticks).draggable();
			
	$("#fire").droppable({
		drop: function( event, ui ) {
			if(over !== 1)
			{
				$( "#s_"+sticks).draggable( "disable" );
				sticks++;
				$("#collected").html(sticks);
				var left = Math.ceil(400*Math.random())
				var top = Math.ceil(40*Math.random())
				$( ".stick-zone").append("<div class='stick_"+sticktype+"' id='s_"+sticks+"' style='position:absolute;left:"+left+"px;top:"+top+"px;'></div>");
				$( "#s_"+sticks ).draggable();
				if(sticktype==1){sticktype++;}
				else if(sticktype==2){sticktype++;}
				else if(sticktype==3){sticktype--;sticktype--;}
			}
		}
	});
	
	$('#Time').html('20'); 
	var sec = 19;
	var timer = setInterval(function() { 
	   $('#Time').text(sec--);
	   if (sec == -1) {
	      clearInterval(timer);
		resetGame(sticks);
		$( "#fire").append("<img class='fire1' src='http://www.onomy.org.uk/assets/css/fire1.png' />");
		   flicker();
		   over = 1;
	   } 
	}, 1000);

}

function resetGame(sticks)
{
	$("#s_"+sticks).draggable( "disable" );
	$('.gameover').show();
	$('#Time').text('20'); 
	$('#result').text(sticks);
	sticks = 0;
	milisec = 0; 
	seconds = 20; 
	$('#collected').text(sticks);
	flicker();
	$('#start').fadeIn(1000);
}

function flicker()
{
	$('.fire1').fadeIn(1000);
	$('.fire1').animate({left: '+=2px'}, 500, function() {
	    $('.fire1').animate({
	    left: '-=2px'});
	    flicker();
	  });

}	
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
function showBlogs(pID)
{
	$('#'+pID).toggle();
}

function AccommodationYear(pYear,pRoomID)
{
	$('#Accommodation').load('http://www.onomy.org.uk/accommodation.php?Year='+pYear+'&RoomID='+pRoomID);
}
