$(document).ready(function(){
   	$("#home").hover(
	 function(){$(this).attr("src", "/images/home_over.jpg");},
	 function(){$(this).attr("src", "/images/home.jpg");}
	 );  
						   
   	$("#about").hover(
	 function(){$(this).attr("src", "/images/about_over.jpg");},
	 function(){$(this).attr("src", "/images/about.jpg");}
	 );  

   	$("#events").hover(
	 function(){$(this).attr("src", "/images/events_over.jpg");},
	 function(){$(this).attr("src", "/images/events.jpg");}
	 );  
	
   	$("#blog").hover(
	 function(){$(this).attr("src", "/images/blog_over.jpg");},
	 function(){$(this).attr("src", "/images/blog.jpg");}
	 );  

   	$("#forum").hover(
	 function(){$(this).attr("src", "/images/forum_over.jpg");},
	 function(){$(this).attr("src", "/images/forum.jpg");}
	 );  
	
   	$("#project").hover(
	 function(){$(this).attr("src", "/images/resources_over.jpg");},
	 function(){$(this).attr("src", "/images/resources.jpg");}
	 );  
	
   	$("#photo").hover(
	 function(){$(this).attr("src", "/images/photo_over.jpg");},
	 function(){$(this).attr("src", "/images/photo.jpg");}
	 );  
	
   	$("#register").hover(
	 function(){$(this).attr("src", "/images/register_over.jpg");},
	 function(){$(this).attr("src", "/images/register.jpg");}
	 );  
	
   	$("#login").hover(
	 function(){$(this).attr("src", "/images/login_over.jpg");},
	 function(){$(this).attr("src", "/images/login.jpg");}
	 );  
	
   	$("#logout").hover(
	 function(){$(this).attr("src", "/images/logout_over.jpg");},
	 function(){$(this).attr("src", "/images/logout.jpg");}
	 );
	
	 $("#profile").hover(
	 function(){$(this).attr("src", "/images/profile_over.jpg");},
	 function(){$(this).attr("src", "/images/profile.jpg");}
	 );  
	
	/**/
	
  //hide the all of the element with class event_details
      $(".event_details").hide();
  //toggle the componenet with class event_details
      $(".more").click(function()
	  {
		  $(this).next('.event_details').slideToggle(600);
	  });
	  
	$(".more").toggle(
		function(){
			$(this).html("<span class='event'>Details:</span> Less [-]");
		},
		
		function(){
			$(this).html("<span class='event'>Details:</span> More [+]");
		}
	  );
	
	
	var currentTab = "el";
	
	$("#google_container").hide();
	
	$(".google").click(function(){
		$("#list_container").hide();
		$("#google_container").show();
		$(this).attr('src', '/images/calendar_tab_over.jpg');
		$(".events").attr('src', '/images/event_tab.jpg');
		currentTab = "gl";
	});
	
	$(".events").click(function(){
		$("#list_container").show();
		$("#google_container").hide();
		$(this).attr('src', '/images/event_tab_over.jpg');
		$(".google").attr('src', '/images/calendar_tab.jpg');
		currentTab = "el";
	});
	
	$(".events").mouseover(function(){
		if(currentTab != "el"){
			$(".events").attr("src", "/images/event_tab_over.jpg");
		}
	});
	
	$(".events").mouseout(function(){
		if(currentTab != "el"){
			$(".events").attr("src", "/images/event_tab.jpg");
		}
	});
	
	$(".google").mouseover(function(){
		if(currentTab != "gl"){
			$(".google").attr("src", "/images/calendar_tab_over.jpg");
		}
	});
	
	$(".google").mouseout(function(){
		if(currentTab != "gl"){
			$(".google").attr("src", "/images/calendar_tab.jpg");
		}
	});
   
var currentTab;
var oldTab;
var greyOk;

function goGrey(){
	 $(oldTab).css("background-color","#dcdcdc");
	 $(oldTab).css("color","#000000");
}

 $(".extend").mouseover(function()
	  {
		  $(this).css("background-color","#b10a12");
		  $(this).css("color", "white");
	  });
 
 $(".extend").mouseout(function(event)
	  {
		  if(currentTab != event.target ||greyOk == true){
			  $(this).css("background-color","#dcdcdc");
			  $(this).css("color", "black");
		  }
	  });
 
 $(".extend").click(function(event)
	  {
		  if(currentTab){
			  if(event.currentTarget == currentTab){
				  greyOk = true;
			  }
			  else{
				  greyOk = false;
			  }
		  }
		  currentTab = event.currentTarget;
		  $(this).css("background-color","#b10a12");
		  $(this).css("color", "white");
		  if(oldTab != null){
			  goGrey();
		  }
		 oldTab = currentTab;
	  });

});



