window.addEvent('domready', function() {
   var productboxes=$$('div.prod-show');
   if (productboxes && productboxes.length > 0) {
    productboxes.each(function(row) {
      row.setStyle('cursor','pointer');
      row.slide=new Fx.Slide($(row.get('id')+'-slide'));
      row.addEvent('click',function(e) {
          if (document.productopen && this.slide != document.productopen) {
          document.productopen.slideOut();
          }
          document.productopen=this.slide;
          this.slide.toggle();
      }.bind(row));
      row.slide.hide();
    });
    var openInitially = window.location.href.substr( window.location.href.indexOf( '#' ) + 1 );
      productboxes.each( function( box ) {
        if( box.get( 'id' ) == 'featurebox-' + openInitially ) {
        box.slide.slideIn();
        document.productopen = box.slide;
      }
    });
    if( !document.productopen ) {
      productboxes[0].slide.slideIn();
      document.productopen=productboxes[0].slide;
    }
   }
});
window.addEvent('domready', function() {
  var productboxes=$$('a.q-hide');
  if (productboxes && productboxes.length > 0) {
    productboxes.each(function(row) {
      row.setStyle('cursor','pointer');
      row.slide=new Fx.Slide($(row.get('id')+'-show'));
      row.addEvent('click',function(e) {
        if (document.productopen && this.slide != document.productopen) {
        document.productopen.slideOut();
        }
        document.productopen=this.slide;
        this.slide.toggle();
      }.bind(row));
      row.slide.hide();
    });
    productboxes[0].slide.slideIn();
    document.productopen=productboxes[0].slide;
    }
  });
window.addEvent('domready', function() {
  var productboxes=$$('a.l-hide');
  if (productboxes && productboxes.length > 0) {
    productboxes.each(function(row) {
      row.setStyle('cursor','pointer');
      row.slide=new Fx.Slide($(row.get('id')+'-show'));
      row.addEvent('click',function(e) {
        if (document.productopen && this.slide != document.productopen) {
        document.productopen.slideOut();
        }
        document.productopen=this.slide;
        this.slide.toggle();
      }.bind(row));
      row.slide.hide();
    });
    document.productopen=productboxes[0].slide;
    }
  });
window.addEvent('domready', function() {
  var productboxes=$$('a.wp-hide');
  if (productboxes && productboxes.length > 0) {
    productboxes.each(function(row) {
      row.setStyle('cursor','pointer');
      row.slide=new Fx.Slide($(row.get('id')+'-show'));
      row.addEvent('click',function(e) {
        if (document.productopen && this.slide != document.productopen) {
        document.productopen.slideOut();
        }
        document.productopen=this.slide;
        this.slide.toggle();
      }.bind(row));
      row.slide.hide();
    });
    productboxes[0].slide.slideIn();
    document.productopen=productboxes[0].slide;
    }
  });
window.addEvent('domready', function() {
var pDiv = $$('.productsDiv');
var cDiv = $$('.childproductsDiv').slide('hide');
pDiv.each(function(div){
  var ceImg =  div.getElement('img');
  var aLink = div.getElement('a');
  var myChild = div.getElement('div.childproductsDiv');
  ceImg.set('src', '/pics/expandbtn.gif');
  ceImg.set('alt', 'expand');
  ceImg.setStyle('cursor', 'pointer');
    div.addEvent('click', function(e) {
      var expanded = (ceImg.get('src') == '/pics/collapsebtn.gif');
      if( e.target == aLink )
        e.stop();
      // Collapse ALL
      pDiv.each(function(div){
        var img = div.getElement('img');
        img.set('src', '/pics/expandbtn.gif');
        img.set('alt', 'expand');
      });
      cDiv.slide('out');
      // Expand the clicked one (if not expanded already)
      if (!expanded) {
        ceImg.set('src', '/pics/collapsebtn.gif');
        ceImg.set('alt', 'collapse');
        myChild.slide('in');
      }
    });
  });
  $$(cDiv).set('slide',{'link' : 'cancel'});
});

