var blinds;

function makeBlinds()
{ 
  $('blindbox').down('td.main').insert('<br /><br />Use the <img src="/images/icons/plus.gif" /> and <img src="/images/icons/minus.gif" /> icons to toggle the sections below or simply <a href="javascript:allBlinds(1);">expand</a> / <a href="javascript:allBlinds(0);">contract</a> them all.');
  blinds = $('blindbox').select('td.articlesTitlesLinks'); //get the tds
  blinds.each(
	function(x) { 
	  x.down('p').hide(); //hide content and make show/hide icon button 
	  x.up('tr').previous(1).down('td').insert({  
	    'top': new Element('img', {'src' : '/images/icons/plus.gif', 'border' : 0, 'class' : 'pullcord'}) 
	  }) 
	}
  ); 
  $('blindbox').select('img.pullcord').each(function(i){
    i.observe('click', pullBlind.bindAsEventListener()); //add event listener to show/hide icon
  });
} 
function pullBlind(evt)
{
  var img = evt.element();
  var blind = img.up('tr').next(1).down('p');
  img.src = '/images/icons/' + [ (blind.visible()) ? 'plus' : 'minus' ] + '.gif';
  blind[ (blind.visible()) ? 'hide' : 'show' ]();  
}
function allBlinds(view)
{
  blinds.each(
  	function(b) {
  	  b.down('p')[ (view) ? 'show' : 'hide' ]();	
  	}
  );	
}

Event.observe(window, 'load', makeBlinds.bindAsEventListener()); 