// SeViR Simple Horizontal Accordion @2007
// http://letmehaveblog.blogspot.com
jQuery.fn.extend({
  haccordion: function(params){
	var toopen=0;
	var jQ = jQuery;
    var params = jQ.extend({
      speed: 200,
      headerclass: "header",
      contentclass: "content",
      contentwidth: 200
    },params);
    this.each(function(){
		jQ("."+params.headerclass,this).click(function(){
			var p = jQ(this).parent()[0];
			if (p.opened != "undefined"){
				jQ(p.opened).next("div."+params.contentclass).animate({
					width: "0px"
				},params.speed);
				p.opened = this;
			}
			jQ(this).next("div."+params.contentclass).animate({
				width: params.contentwidth + "px"
			}, params.speed);
		});
		
		// Get the content to open
		toopen = 0;
		var cpt = 1;
		$(this).children(".content").each(function(){
			if(jQuery.trim($(this).html()) != "" && toopen==0){
				toopen = cpt;
			}
			cpt++;
		});
	});
	
	$($(".haccordion .header")[toopen-1]).click();
  }
});


