Toggle 2 divs with 2 links
===

I'm pretty new to jquery and here's what I'm trying to do:

I have two links: link1 - link2
And 2 divs: div1, div2

What I would like to do:

If you click on link1 it slideDown the div1, if you click on link1 again, it slideUp div1
BUT
If you click on link1 and then on link2 I want the div1 to slideUp and then slideDown the div2

Here's the code that I was playing with:


$(document).ready(function(){
 
    $("#div1").hide();
    $("#div2").hide();
    $('.link1').click(function(){
		$("#div2").slideUp();
		$("#div1").slideToggle();
    });
    $('.link2').click(function(){
	$("#div1").slideUp();
	$("#div2").slideToggle();
    });
 
});
