jQuery.noConflict();	

function setupDCStory()
{
        jQuery('.dc-story').each(function()
          {
              var $story = jQuery(this); 
              var count = $story.find('.slide').length;
              var width = $story.width();
              $story.data('dc_count', count);
              $story.data('dc_active', 0);
              $story.data('dc_block', false);  
              $story.find('.info-bar .active').text(1); 
              $story.find('.info-bar .count').text(count);
              $story.find('.slide:first').css('display', 'block');
              $story.find('.description:first').css('display', 'block'); 
              
              $story.find('.info-bar .next').click(
                function()
                {
                    var is_blocked = $story.data('dc_block');
                    if(!is_blocked)
                    {
                        $story.data('dc_block', true);
                        var active = $story.data('dc_active');                        
                        var count = $story.data('dc_count', count);
                        
                        var next = active + 1;
                        if(next >= count) { next = 0; }    
                        
                        $story.find('.description:eq('+active+')').stop().animate({opacity:0.0}, 200,
                            function()
                            {
                                jQuery(this).css('left', width).css('display', 'none');
                                $story.find('.description:eq('+next+')').stop().css('opacity', 0.0).css('display', 'block').css('left', 0).animate({opacity:0.9}, 500);     
                            });                          
                        
                        $story.find('.slide:eq('+active+')').stop().animate({opacity:0.0}, 200,
                            function()
                            {
                                jQuery(this).css('left', width).css('display', 'none');
                                $story.find('.info-bar .active').text((next+1)); 
                                $story.find('.slide:eq('+next+')').stop().css('opacity', 0.0).css('display', 'block').css('left', 0).animate({opacity:1.0}, 500,
                                function() { 
                                        $story.data('dc_block', false); 
                                        $story.data('dc_active', next);
                                } );     
                            });     
                    }    
                }
              );

              $story.find('.info-bar .prev').click(
                function()
                {
                    var is_blocked = $story.data('dc_block');
                    if(!is_blocked)
                    {
                        $story.data('dc_block', true);
                        var active = $story.data('dc_active');                        
                        var count = $story.data('dc_count', count);
                        
                        var next = active - 1;
                        if(next < 0) { next = count - 1; }    
                        
                        
                        $story.find('.description:eq('+active+')').stop().animate({opacity:0.0}, 200,
                            function()
                            {
                                jQuery(this).css('left', width).css('display', 'none');
                                $story.find('.description:eq('+next+')').stop().css('opacity', 0.0).css('display', 'block').css('left', 0).animate({opacity:0.9}, 500);     
                            });                           
                        
                        $story.find('.slide:eq('+active+')').stop().animate({opacity:0.0}, 200,
                            function()
                            {
                                jQuery(this).css('left', width).css('display', 'none');
                                $story.find('.info-bar .active').text((next+1)); 
                                $story.find('.slide:eq('+next+')').stop().css('opacity', 0.0).css('display', 'block').css('left', 0).animate({opacity:1.0}, 500,
                                function() { 
                                        $story.data('dc_block', false); 
                                        $story.data('dc_active', next);
                                } );     
                            });                           
                    }    
                }
              );
              
              $story.find('.triger').hover(
                function()
                { 
                    jQuery(this).stop().animate({opacity:0.3}, 200); 
                }, 
                function()
                { 
                    jQuery(this).stop().animate({opacity:0.0}, 200); 
                }
              );
          });    
}



	jQuery(document).ready(function(){
	
		setupDCStory();
	        if(jQuery('#slider-a-container').length)
        	{
	            slider_a.setup('#slider-a-container');
        	}    

	
});




