
$(document).ready(function() {
  var IN_SPEED = 10; //speed new image comes in - higher is slowe
  var OUT_SPEED = 10; //speed old image goes out - higher is slower
  var HIDE_PERCENT = 30; //The percentage size the leaving image goes down to
  var START_HEIGHT = 30; //The height the appearing image starts at
  var START_WIDTH = 0; //The width the appearing image starts at

 setTimeout(function() {

		if (!$.browser.msie && !($.browser.version <= 7)) {
			
			$('.content-bottom-inner > *').fadeIn('fast');
		}	
  }, 2000);
  
	var $images = $('.images-box-inner div');
	var $next_link = $('.images-right-link');
	var $prev_link = $('.images-left-link');
  var max = $images.length-1;
  var x=0;
	var current_image = $images[x];
	$images.hide();
	$(current_image).show();
  
  var $links = $('.content-nav > li a');
	var max_links = $links.length;
	var next = 0;
	var prev = 0;

	$.each($links, function(i) {
		if(i+1 >= max_links) { next = 0; } else { next = i+1; }
		if(i-1 < 0) { prev = max_links-1; } else { prev = i-1; }
		if($(this).parent().hasClass('current_page_item')) {
			previous_case = $links[prev];
			next_case = $links[next];
			current_case = this;
		}
	});
	
	  
	$(".images-box-holder").css({'display':'inline'});
  $('.images-box-inner').cycle({
        fx: 'scrollHorz', 
        sync: true,
        timeout:  0, 
        prev: '.images-left-link',
        next: '.images-right-link',
        speed: 120,
        speed: 600,
		randomizeEffects: 0,
		after:   afterCall

    });
  
  	$('.images-box-inner  div :first').addClass("first");
  	
  	$('.images-left-link').css({'z-index': 100, 'width': 18,'height': 28, bottom: 12, left: 0, 'top':''}).hide();

  	if($(".images-box-inner").find('div').length < 2 )
  	{
  		$('.images-right-link').css({'z-index': 100, 'width': 18,'height': 28, bottom: 12, right: 0, 'top':'', 'left':''}).hide();
  	}else{	
  		$('.images-right-link').css({'z-index': 100, 'width': 18,'height': 28, bottom: 12, right: 0, 'top':'', 'left':''}).show();
  	}
	
	
    function afterCall(curr, next, opts, fwd) {
    	if($(next).next().hasClass('images-left-link')  )
    	{
    		  $('.images-right-link').css({'z-index': 100, 'width': 18,'height': 28, bottom: 12, right: 0, 'top':'', 'left':''}).hide(); 
    		return false;
    	}else{

    		if($(next).find('img').hasClass('first')   )
    		{
    		  	$('.images-left-link').css({'z-index': 100, 'width': 18,'height': 28, bottom: 12, left: 0, 'top':''}).hide();
    		    $('.images-right-link').css({'z-index': 100, 'width': 18,'height': 28, bottom: 12, right: 0, 'top':'', 'left':''}).show(); 
    		}
    		
    	}
    	
    	
    }

  $('.content-bottom-inner').css('height',$('.content-bottom-inner').height());
  $('.content-bottom-inner > *').hide();
  $('.content-bottom-inner').show();
	if ($.browser.msie && $.browser.version <= 7) {
  $('.content-bottom-inner > *').fadeIn(350);  
	}
});

