/*-------------------------------------------------------------------- 
 * HAccrodion
--------------------------------------------------------------------*/


jQuery.fn.extend({
	haccordion: function(params){
		var jQ = jQuery;
		var params = jQ.extend({
				speed: 500,
				headerclass: "header",
				contentclass: "content",
				contentwidth: 650
			}, params);
		return this.each(function(){
			this.opened = jQ("."+params.contentclass,this).filter(".visible").next();
			
			jQ("."+params.headerclass,this).click(function(){
				var p = jQ(this).parent()[0];
				if (p.opened != "undefined" && p.opened != this || p.opened == "undefined"){
					if (p.opened != "undefined"){
						jQ(p.opened).prev("div."+params.contentclass).animate({
							width: "0px"
						}, params.speed);
					}
					p.opened = this;
					jQ(this).prev("div."+params.contentclass).animate({
						width: params.contentwidth + "px"
					}, params.speed);
				}
			});
		});
	}
});

