//jQuery's slideDown is always jerky on our site - it seems to calculate future width incorrectly for the element to slide down.
//So here is modified version where we supply correct width (using parent's width)
//add_params is an object containing additional params if any
jQuery.fn.extend({ 
	mySlideDown: function(params){ 
	   	//function code 
		if(params.widthSel){
			if(typeof(params.widthAdj) == "undefined") params.widthAdj = 0;
			var width = $(params.widthSel).width() + params.widthAdj;
//			console.log(width);
			this.css({visibility: 'hidden', position: 'absolute', display: 'block', width: width + 'px'});
			var h = this.height();
			this.css({visibility: 'visible', position: 'relative', display: 'none', height: '0px', width: 'auto'});
			this.animate({height: h + "px"}, params.time);
		}else{
			this.slideDown(params.time);
		}
	},
	shown: function(){
		return !(this.css('display') == "none");
	},
	hideVis: function(){
		this.css('visibility', "hidden");
	},
	showVis: function(){
		this.css('visibility', "visible");
	},
	myHeight: function(){ //mostly useless...
		var display = this.css('display');
		this.css({visibility: 'hidden', position: 'absolute', display: 'block'});
		var h = this.height();
		this.css({visibility: 'visible', position: 'relative', display: display});
		return h;
	},
	equalHeight: function(params){
		// process those only who are in need of adjusting
		var h = 0;
		this.each(function(){ if($(this).height() > h && $(this).attr(params.attr) != params.attrVal) { h = $(this).height() }  });
		this.each(function(){ if($(this).attr(params.attr) != params.attrVal) { $(this).css('height', h + 'px'); /*console.log('setting height', this, h);*/ }  });
		this.each(function(){ if($(this).attr(params.attr) != params.attrVal) { $(this).attr(params.attr, params.attrVal); /*console.log('setting attr',params.attr, 'to', params.attrVal );*/ }});
	}	
});