function carousel(id,section_count,image_width,not_resize) {
	var now_one,now_time,start_time,start = true;
	this.width;
	this.id = id;
    this.section_count = section_count;
	this.images_count = 0;
    this.section_sizes = new Array();
    this.section_paddings = new Array();
    this.section_paddings_top = new Array();
    this.positions = new Array(); 
    this.image_width = image_width;
	this.container_width = parseInt($(this.id).css('width'));
	this.section_width = parseInt(this.container_width/(this.section_count*2-1));
	this.initial = function () {
	   var i,j,k,k1;
       for (i=1;i<=this.section_count;i++) {
         if (not_resize) 
           this.section_sizes[i] = this.image_width;
         else
           this.section_sizes[i] = parseInt((this.image_width/100)*(60+i*(40/this.section_count)));
         
         this.section_paddings[i] = parseInt((this.section_width-this.section_sizes[i])/2);
         
         this.section_paddings_top[i] = parseInt((this.image_width-this.section_sizes[i])/2+10);
       }
       this.positions[1] = this.section_paddings[1];
       for (i=2;i<=parseInt(this.section_count*2-1);i++) {
	    if (i>this.section_count) k = this.section_count*2 - i; else k = i;
	    if ((i-1)>this.section_count) k1 = this.section_count*2 - (i-1); else k1 = i-1;
	    
	    this.positions[i] = this.positions[i-1] + this.section_sizes[k1] + this.section_paddings[k1]+this.section_paddings[k];
	   }
	    var section_count = this.section_count;
	    var section_paddings_top = this.section_paddings_top;
	    var section_sizes = this.section_sizes;
	    var positions = this.positions;
	    var images_count = 0;
	    var id = this.id;
	    $(this.id+' .head').children().each(
         function (i,elem) {
         images_count++;
		if (i+1 <= section_count*2-1) {
		  if (i+1 > section_count) k = section_count*2 - i-1; else k = i+1;
		  $(elem).attr({'section':i+1});
		  $(elem).css({'left':positions[i+1]+'px'});
		  $(elem).css({'top':section_paddings_top[k]+'px'});
		  $(elem).children('a').children().css({'width':section_sizes[k]+'px'});
		 // $(elem).children('a').children().css({'height':section_sizes[k]+'px'});
		}
        else {
			$(elem).attr({'section':'0'}); 
			//$(elem).css({'display':'none'});
			$(elem).css({'left':positions[section_count]+'px'});
			$(elem).css({'top':section_paddings_top[1]+'px'});
	    	$(elem).children('a').children().css({'width':section_sizes[1]+'px'});
   		    $(elem).children('a').children().css({'display':'none'});
		} 
        });
        this.images_count = images_count;
        html = $(this.id+" div[section="+this.section_count+"] div").html();
        $(this.id+" .description").html(html);
	}
	this.rolling_left = function () {
		var name;
	    var now_one = new Date();
		var now_time = now_one.getTime();
		if (now_time - this.start_time < 600) { 
			return false;
			}
	    var now = new Date();
	    this.start_time = now.getTime();
	for (i=1;i<=parseInt(this.section_count*2-1);i++) {
		if (i == 1) {
			name = $(this.id+" div[section="+i+"]").attr("name");
	        $(this.id+" div[section="+i+"] a img").animate({'height':'hide'},600);
        	$(this.id+" div[section=0]").css({'left':this.positions[parseInt(this.section_count*2-1)]+'px'});
	        //$(this.id+" div[section=0] a img").css({'height':'0px'});
           // $("div[section=0]").css({'top':section_paddings_top[section_count]+'px'});
	        $(this.id+" div[name="+name+"]").attr({"section":'0'});
		} else {
		if ((i-1)>this.section_count) k1 = this.section_count*2 - (i-1); else k1 = i-1;
		$(this.id+" div[section="+i+"] a img").animate({/*'height':this.section_sizes[k1]+'px',*/
	                                     'width':this.section_sizes[k1]+'px'},600);	
		$(this.id+" div[section="+i+"]").animate({'left':this.positions[i-1]+'px',
								         'top':this.section_paddings_top[k1]+'px'},600);
   	    name = $(this.id+" div[section="+i+"]").attr("name");
	    $(this.id+" div[name="+name+"]").attr({"section":i-1});
	    }
	}
	newname = parseInt(name)+1;
	if (newname == parseInt(this.images_count + 1)) newname = 1; 
	$(this.id+" div[name="+newname+"]").attr({"section":parseInt(this.section_count*2-1)});
	$("div[name="+newname+"]").animate({'top':this.section_paddings_top[1]+'px',
								        'wisibility':'show'
										},600);
	$(this.id+" div[name="+newname+"] a img").animate({'height':"show",
	                                    'width':this.section_sizes[1]+'px'
										},600);									
								 
    html = $(this.id+" div[section="+this.section_count+"] div").html();
    $(this.id+" .description").html(html);
}
    this.rolling_right = function () {
		var name;
	    var now_one = new Date();
		var now_time = now_one.getTime();
		if (now_time - this.start_time < 600) { 
			return false;
			}
	    var now = new Date();
	    this.start_time = now.getTime();
	i = parseInt(this.section_count*2-1);
	name = $(this.id+" div[section="+i+"]").attr("name");
	$(this.id+" div[section="+i+"] a img").animate({'height':'hide'},600);
	$(this.id+" div[section=0]").css({'left':this.positions[1]+'px'});
	//$(this.id+" div[section=0] a img").animate({'height':'hide'});
    $(this.id+" div[section=0]").css({'top':this.section_paddings_top[1]+'px'});
	$(this.id+" div[name="+name+"]").attr({"section":'0'});
	while (i > 1) {
	 i--;
	 if ((i+1)>this.section_count) k1 = this.section_count*2 - (i+1); else k1 = i+1;
	 $(this.id+" div[section="+i+"] a img").animate({/*'height':this.section_sizes[k1]+'px',*/
	                             'width':this.section_sizes[k1]+'px'},600);
	 $(this.id+" div[section="+i+"]").animate({'left':this.positions[i+1]+'px',
								 'top':this.section_paddings_top[k1]+'px'},600);
	name = $(this.id+" div[section="+i+"]").attr("name");
	$(this.id+" div[name="+name+"]").attr({"section":i+1});	
	}
	newname = parseInt(name)-1;
	if (newname == 0) newname = parseInt(this.images_count); 
	$(this.id+" div[name="+newname+"]").attr({"section":'1'});
	$(this.id+" div[name="+newname+"] a img").animate({'height':'show'},600);
	$(this.id+" div[name="+newname+"]").animate({'top':this.section_paddings_top[1],'wisibility':'show'},600);
    html = $(this.id+" div[section="+this.section_count+"] div").html();
    $(this.id+" .description").html(html);
    }

}
