$(document).ready(function() {
  function show_or_hide(elem) {
    if ($(elem).attr('state') == 'open') {
      $('div.shadow', elem).slideUp('slow', function() {
 				$('div.title', this).addClass('bl');
 				$('div:eq(0)', this).addClass('br');
 				$('div.title h3', this).removeClass('border-bottom');
 				$(elem).attr('state', 'closed');
 			});
    } else {
     $('div.title', elem).removeClass('bl');
     $('div:eq(0)', elem).removeClass('br');
     $('div.title h3', elem).addClass('border-bottom');
     $('div.shadow', elem).slideDown('slow');
     $(elem).attr('state', 'open');
    }
  }
  
  $('div.manufacturer-popup').click(function(event) {
  		if ($(event.target).is('a')) {
  			window.location = event.target.href;
  		} else {
  			show_or_hide(this);
  		}
  		return false;
  	});

  $('div.manufacturer-popup').each(function() {
    $(this).attr('state', 'closed').animate({opacity: 1.0}, 3000, function() {
      if ($(this).attr('state') == 'closed') {
        $(this).click().animate({opacity: 1.0}, 11000, function() {
          if ($(this).attr('state') == 'open') $(this).click();
         });
       }
    });
  });

});