var itemOver = function (event) {
  if(this.src.include('_on.gif')) return;
  this.src=this.src.sub('.gif', '_bw.gif');
};
var itemOut = function (event) {
  if(this.src.include('_on.gif')) return;
  this.src=this.src.sub('_bw.gif', '.gif');
};
var itemClick = function (event) {
 //check we are not on already
   if(this.src.include('_on.gif')) return;
 // reset all item images
 document.getElementsByClassName('item').each(function(el) { 
 	if(el.src.include('_on.gif')) {
	el.src=el.src.sub('_on.gif', '.gif');
	el.height=40;
	el.width=40;
	el.setStyle({
    margin: '4px'
});
	}
	el
	});
 //select this img
 this.src=this.src.sub('_bw.gif', '_on.gif');
 this.height=48;
 this.width=48;
 this.setStyle({
    margin: '0px'
});
// new Ajax.Updater('content', '/ajax.php?do=getProfile&itemid='+this.id, {asynchronous:true});
// new Ajax.Updater('side-b', '/ajax.php?do=getBody&itemid='+this.id, {asynchronous:true});

new Ajax.Request('/ajax.php?do=getProfile&itemid='+this.id,
{ onSuccess: function (transport) {
 var data = transport.responseText;
 new Effect.Opacity('content', {duration:0.75, from:1.0, to:0.0, afterFinish: function () {
 $('content').update(data);
 new Effect.Opacity('content', {duration:0.75, from:0.0, to:0.99});
 }
 })
 }
 }); 





new Ajax.Request('/ajax.php?do=getBody&itemid='+this.id,
{ onSuccess: function (transport) {
 var data = transport.responseText;
 new Effect.Opacity('side-b', {duration:0.75, from:1.0, to:0.0, afterFinish: function () {
 $('side-b').update(data);
 new Effect.Opacity('side-b', {duration:0.75, from:0.0, to:0.99});
 }
 })
 }
 }); 
 return false;
 }

//
Event.observe(window, 'load', function(){ 
//mouseovers for items
document.getElementsByClassName('item').each(function(el) { 
	el.observe( 'mouseover', itemOver ); 
});
//mouseouts for items
document.getElementsByClassName('item').each(function(el) { 
	el.observe( 'mouseout', itemOut ); 
	});
//mouseouts for items
document.getElementsByClassName('item').each(function(el) { 
	el.observe( 'click', itemClick ); 
	});
});



