	$('a').click(function () {
		if ($(':animated').length) {
			return false;
		}
	});
	


function startFading(currentnr, maxnr, obj)	{
	b= $('#'+obj+' .blokje').eq(currentnr);		
	$(b).animate({'opacity':1},300, function(){ 
		$(this).css('filter','');  
		i=$('iframe', this).contents().find('body').length; 
			if(i>0)
			{
				$('iframe', this).contents().find('body').fadeTo(300, 1,function(){$(this).css('filter','')});
			} 
	 });	
	 
	if(currentnr<maxnr)
	{
		currentnr++;//iterator
		setTimeout(function(){startFading(currentnr, maxnr, obj)}, 100)//fade next object
	}	
}


		   
function openPage(p, t){
	$('#menu li.active').css("border-color", "#eee");
	$('#menu li').removeClass('active');
		
$('#btn_'+p).addClass('active');
	myid=$('.page').eq(0).attr('id');
	if(p!=myid){// not the same as current page?			
		if($('#'+p).length>0){//element exists elsewhere?
				$('#'+p).slideUp(1200,  function(){													
					obj=$('#'+p);
					$('iframe', obj).contents().find('body').css('opacity', 0);
					$('.blokje', obj).animate({'opacity':0}, 0);
					$('#'+p).prependTo('#content');						
					$('#'+p).slideDown(600, function(){														
					m=$('.blokje', obj).length;//get amount of blocks					
					startFading(0, m, p)//add animation effects	
				});
			});				
		}
		else{//element doesnt exist yet
			$.get('pages/'+p+'.html', function (data){// get the new page											
				$(data).prependTo('#content');//insert above last page				
				$('.page').eq(0).slideDown(600, function(){															 
					 m=$('.blokje', this).length;//get amount of blocks						
					startFading(0, m, p)//add animation effects
				});						
			});					
		}
		 $('title').text('Response Network - '+t);		
	}//end not the same as last page, so do nothing
}



$(document).ready(function(){						 
	$('#menu li').hover(
		function(){if($(this).attr('class')!='active'){$(this).css('border-bottom', '3px solid #f90')}},
		function(){if($(this).attr('class')!='active'){$(this).css('border-bottom', '3px solid #eee')}}
	);
});
