function link_init(domChunk){ 
	
	$(domChunk).mouseover(function(){
		
		$('#icons > a').each(function(){ $(this).removeClass('selected'); } );   
		if($(this).attr('id')=='bgraph1') $("#graph1 > a").attr('class','selected');   
		if($(this).attr('id')=='bgraph2') $("#graph2 > a").attr('class','selected'); 
		if($(this).attr('id')=='bgraph3') $("#graph3 > a").attr('class','selected');    
	});	
   
	$(domChunk).mouseout(function(){ 
		$('#icons > a').each(function(){ $('#workgraph > li > a').removeClass('selected'); } ); 
	});
 
	$(domChunk).click(function(){ 
   			$(this).attr('class','selected');
			$("#subcontainer").empty().prepend("<img src='"+imgLoader.src+"' alt='loading..' />");     
		    $("#subcontainer").load($(this).attr('href')); 
		
			if($(this).attr('id')=='bgraph1') $("#graph1 > a").attr('class','selected');   
			if($(this).attr('id')=='bgraph2') $("#graph2 > a").attr('class','selected'); 
			if($(this).attr('id')=='bgraph3') $("#graph3 > a").attr('class','selected');
		
	    	return false;
	});
}

$(document).ready(function(){
	
		loader_pathToImage = '/img/ajax-loader-bar.gif';
	
		imgLoader = new Image();// preload image
		imgLoader.src = loader_pathToImage; 

	
	$('#calendar > li > a').each(function(){ 
		$(this).click(function(){ 
			$('#calendar > li > a').each(function(){ 
				$(this).removeClass('selected'); } );
	   			$('#calendar > li').each(function(){ 
					$(this).removeClass('selected'); } ); 		                                       

			$("#container").empty().prepend("<img class='imageLoader' src='"+imgLoader.src+"' alt='loading..' />");   
			$(this).addClass('selected');  
  
			$("#container").load($(this).attr('href'),function(){ 
		     link_init('#icons > a'); 
		 	 tb_init('#imageBlock > a'); 
	    	$("a.outlink").attr({target: "_blank"});  
		  	 
			 })
		    	return false;   
			});
	  	});
	
	
	
	$('#workgraph li a').mouseover(function(){
		
		$('#workgraph li a').removeClass('selected');
		
		$(this).addClass('selected');
		$('#key').html($(this).html()); 
		if($(this).attr('id')=='tgraph1') $("a#bgraph1").attr('class','selected');   
		if($(this).attr('id')=='tgraph2') $("a#bgraph2").attr('class','selected'); 
		if($(this).attr('id')=='tgraph3') $("a#bgraph3").attr('class','selected'); 
	})
	
	
   	$('#tabs > li > a').each(function(){ 
		
		$(this).click(function(){
				  $('#tabs > li > a').each(function(){ $(this).removeClass('selected'); } ); 
				  $("#container").empty().prepend("<img  class='imageLoader' src='"+imgLoader.src+"' alt='loading' />");  
				$(this).addClass('selected'); 
				$("#container").load($(this).attr('href'));
			 //   	return false;   
				});
		  	});	
	
	
	
});