<script type="text/javascript" src="http://yandex.st/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$("div[id^='div']:not(.selected)").live('click',function() {
$("div[id^='div']").toggleClass('selected');
});
</script>
<style type="text/css">
#div1,#div2{
cursor:pointer;
margin-top:20px;
width:200px;
height:60px;
border:solid 2px;
}
#div1{
border-color:red;
}
#div2{
border-color:blue;
}
#div1.selected{
background-color:blue;
}
#div2.selected{
background-color:red;
}
</style>
<div id=div1 class="selected"></div>
<div id=div2></div>