function KduLoader(elementBase,categoryId,itemId,min,max){
	var loader=this;
	this.idBase="#"+elementBase;
	this.catid=categoryId;
	this.total=max;
	this.begin=min;
	this.itemid=itemId;
	
	$(this.idBase+"ViewAll").bind("click",function(event){	
										
										box=loader.idBase+"Box";
										childDivs=$(box).children();
										offset=loader.total-loader.begin;
										
										if(childDivs.length==0){
											$.ajaxq("ajaxQueue",{url:"index.php?option=com_kdu&view=kdu&Itemid=12&task=ajax&itemid="+loader.itemid+"&catid="+loader.catid+"&st="+loader.begin+"&offset="+offset,beforeSend:function(){$(loader.idBase+"Spinner").show();},success:function(html){	loader.animateBox(childDivs.length+offset,0);$(box).append(html);$(loader.idBase+"Spinner").hide();$('.elementDiv:hidden').fadeIn("slow");}});
											
										}else{
											loader.animateBox(childDivs.length,childDivs.length);
										}
								});
	
	this.animateBox=function(childrenCount,index){
		
					
					if(index!=0){
						$(loader.idBase+"ViewAll").fadeOut('slow',function(){$(loader.idBase+"ViewAll").html("View all");}).fadeIn("slow");

						$(loader.idBase+"Box").animate({"height":"0px"},800,"easeInOutQuad",function(){
						for(i=index;i>=0;i--){
							$(loader.idBase+"Box > div:nth-child("+i+")").fadeOut('normal',function(){$(this).remove()});
						}
																											   });
					}else{
						var rows=Math.floor(childrenCount/4);
						if(childrenCount%4!=0){
							rows++;
						}
						$(loader.idBase+"ViewAll").fadeOut('slow',function(){$(loader.idBase+"ViewAll").html("Collapse");}).fadeIn("slow");
						$(loader.idBase+"Box").animate({"height":(rows*167)+"px"},800,"easeInOutQuad");
					}
	}

}