
  var scrollSpeed='fast';
  var ScrollDelay= 0; //ms
  var current_index = 0;  
  
  function doScrollNext(obj){
  	if (jQuery('.scrollBlock .scrollItem:visible').last().html() != jQuery('.scrollBlock .scrollItem').last().html()) {
    	jQuery('.scrollBlock .scrollItem:visible').first().animate({opacity:"hide"},scrollSpeed);    
		jQuery('.scrollBlock .scrollItem:visible').next('.scrollItem').delay(200).animate({opacity:"show"});
		if (jQuery('.prev_galery').attr('class') == 'prev_galery prev_galery_no_activ') {
			jQuery('.prev_galery').attr('class','prev_galery'); 
		}
  	} else {
  		jQuery('.next_galery').attr('class','next_galery next_galery_no_activ');
  	}
  	if (jQuery('.scrollBlock .scrollItem:visible').length > 3) {
  		for (i = 3; i <= jQuery('.scrollBlock .scrollItem:visible').length; i++)
  			jQuery('.scrollBlock .scrollItem:visible').first().animate({opacity:"hide"},scrollSpeed);
  	}
  }

  function doScrollPrev(obj){
    if (jQuery('.scrollBlock .scrollItem:visible').first().html() != jQuery('.scrollBlock .scrollItem').first().html()) {
    	jQuery('.scrollBlock .scrollItem:visible').last().animate({opacity:"hide"},scrollSpeed);    
		jQuery('.scrollBlock .scrollItem:visible').prev('.scrollItem').delay(200).animate({opacity:"show"}, function() {
			if (jQuery(this).html() == jQuery('.scrollBlock .scrollItem').first().html()) {
				jQuery('.prev_galery').attr('class','prev_galery prev_galery_no_activ');		
			}
		});
		if (jQuery('.next_galery').attr('class') == 'next_galery next_galery_no_activ') {
			jQuery('.next_galery').attr('class','next_galery'); 
		}
  	}
  	if (jQuery('.scrollBlock .scrollItem:visible').length > 3) {
  		for (i = jQuery('.scrollBlock .scrollItem:visible').length; i > 3 ; i--)
  			jQuery('.scrollBlock .scrollItem:visible').last().animate({opacity:"hide"},scrollSpeed);
  	}
  }

  function doScroll(obj){
    doScrollNext(obj);
  }
  
  jQuery(document).ready(function(){
  	
    if(jQuery('.scrollBlock .scrollItem').length>3) {
    	jQuery('#button-prev').click(function(){doScrollNext(this);});
    	jQuery('#button-next').click(function(){doScrollPrev(this);});
    	jQuery('.scrollBlock').attr('class','scrollBlock slide_width');
    	jQuery('.next_galery').attr('class','next_galery');
    }
    
    if (jQuery('.scrollItem').first().innerHeight() > 0) {
    	max_heigth = jQuery('.scrollItem').first().innerHeight();
    } else {
    	max_heigth = jQuery('.scrollItem').first().height();
    }
    
    jQuery('.scrollItem').each(function(){
    	if (jQuery(this).innerHeight() > 0) {
    		current_heigth = jQuery(this).innerHeight();
    	} else {
    		current_heigth = jQuery(this).height();
    	}
    	if (current_heigth > max_heigth) {
    		max_heigth = current_heigth ;		
    	}
    });
    
    max_heigth = max_heigth + 15;
    max_heigth_ie = max_heigth + 25;
    jQuery('.slide_div').attr('style', 'height:'+max_heigth+'px; *height:'+max_heigth_ie+'px');	
    var first_slide_element = jQuery('.scrollItem:first');
    jQuery(first_slide_element).show();
	jQuery(first_slide_element).next('.scrollItem').show();
	jQuery(first_slide_element).next('.scrollItem').next('.scrollItem').show();
    	
  });

