// SeViR Simple Horizontal Accordion @2007

// http://letmehaveblog.blogspot.com

jQuery.fn.extend({

  haccordion: function(params){



    var params = jQuery.extend({

      speed: 500,

      headerclass: "header",

      contentclass: "content",

      event: "click",

      contentwidth: 590

    },params);

    return this.each(function(){

	  this.opened = jQuery("."+params.contentclass,this).filter(".visible").prev();

	  

      jQuery("."+params.headerclass+" a",this).bind(params.event,function(){

        var p = jQuery(this).parent().parent()[0];

        if (p.opened != "undefined"){
          // get max width
          var maxWidth = 0;
          (jQuery('div.content', p)).each( function() { 
              if(jQuery(this).width() > maxWidth) maxWidth = jQuery(this).width(); 
            } );
          params.contentwidth = maxWidth;

          jQuery(p.opened).next("div."+params.contentclass).animate({

            width: "0px"

          },params.speed);

        }

        p.opened = jQuery(this).parent();
        
        pContent = jQuery(p.opened).next("div."+params.contentclass);
         
        pContent.css('width', '0px');
        pContent.animate({
          width: (params.contentwidth) + "px"
        }, params.speed);

	

		return false;

      });

    });

  }

});
