(function($) {//tip message
 $.fn.slideBox=function(params) {
 
    params=$.extend({firstOpen:false,Trigger:"click"},params);
	
	
	
 if(params.firstOpen)	
   var current_slide_on="slide_0";
 else 
   var current_slide_on="";
   
 return  this.each(function(i) {
   
     $t=$(this);
	 
	  
	 $t.find(".slide-button").bind(params.Trigger,function() {
		 
	   var parts=$(this).attr('id').split('_');	 
	   var slideid=parts[1];
		 
	   if(!$(this).parent().hasClass("collapsible-on")) {
		hideAllTabContent();
		
		
		 $(this).parent().addClass("collapsible-on");
		 
	   		
	   if(current_slide_on) $('#'+current_slide_on).slideUp(); 
	   $('#'+slideid).slideDown('slow',function() {
		   if(!$('#'+slideid).hasClass('done')) {
		   
				  $('#'+slideid).find("img").each(function() {
		//if(!$(this).hasClass('built')) {
		
		var title=$(this).attr('title');
		if(title) {
			var wrapper=$("<div class='img'>");
			var iWidth=$(this).width();
			var iHeight=$(this).height();
			
			var capBgTop=iHeight-40;
			var capTop=capBgTop+5;
			
			$(this).wrap(wrapper);			
			$("<div class='caption-bg' style='width:"+iWidth+"px;top:"+capBgTop+"px'></div><div class='caption' style='top:"+capTop+"px;'>"+title+"</div>").insertAfter($(this));			
		}	
		//}
			
	});
	    $('#'+slideid).addClass('done');
		   } //end of if

		   
		   });   
	
	   current_slide_on=slideid;
	  }
	  
	  else {
	     hideAllTabContent();
		 $('#'+slideid).slideUp();   
	  }
	 });	
	 
	      
   });
 /* end of return---*/
 
   
   
    function hideAllTabContent() {		    
		$('.collapsible').removeClass("collapsible-on");
	};
	

   
  
};
})(jQuery)
