// SeViR Simple Horizontal Accordion @2007
// http://letmehaveblog.blogspot.com

jQuery.fn.extend({
	haccordion: function(params){
    params = jQuery.extend({
      contentwidth: 250,
      speed: 500,
      headerclass: "header",
      contentclass: "content",
      event: "click"
    }, params);
		
    return this.each(function(){
	  	this.opened = jQuery("."+params.contentclass,this).filter(".visible").prev();
			
      jQuery("."+params.headerclass, this).bind(params.event, function(){
        var p = jQuery(this).parent()[0];
				if (!p.opened.isSameElement(jQuery(this))){
       	 if (p.opened != "undefined"){
						jQuery(p.opened).next("div."+params.contentclass).animate({ width: "0px" }, params.speed, "swing", function(){
							jQuery(this).css("display", "none");
						});
					}
					p.opened = jQuery(this);
					jQuery(p.opened).next("div."+params.contentclass)
						.css("display", "block")
						.animate({ width: params.contentwidth + "px" }, params.speed);
				}
				return false;
      }); 
    });	
  }
});