

function showcasecarousel_initCallback(carousel){
// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
	// $('#showcasecarousel').show();
    $('#showcasecarousel').css('visibility', 'visible');
};

function servicecarousel_initCallback(carousel){
// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
	
   // var count = $('#servicecarousel').find('li').length;
//	alert(carousel.first);
};



function changeSCname(carousel){
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
			$('#showcase-desc').html($('#sc'+i).html());
			$('#showcase-desc img').remove();
			$('#showcase-desc object').remove();
        }
    }
}

function countServices(carousel, item, idx, state) {
   // alert( idx +"<i> of </i>"+ carousel.length);
	var visAm = 4;
    var count = $('#servicecarousel').find('li').length;
	var pageAm = Math.ceil(count/visAm);
	
	
	$('.service-middlestrip1').removeClass('active');
	$('.service-middlestrip2').removeClass('active');
	$('.service-middlestrip3').removeClass('active');
	$('.service-middlestrip4').removeClass('active');
	
	$('.service-middlestrip'+(Math.ceil(carousel.last/visAm))).addClass('active');
	


}


	function usClick(){
		$('#uk-office').hide();
		$('#usa-office').fadeIn("slow");
	}
	function ukClick(){
		$('#uk-office').fadeIn("slow");
		$('#usa-office').hide();
	}
	


$(document).ready(function() {
		
	
    $('#showcasecarousel').jcarousel({
        auto: 5,
		scroll:1,
        wrap: 'last',
        initCallback: showcasecarousel_initCallback,
        itemFirstInCallback: changeSCname
    });



    $('#servicecarousel').jcarousel({
        auto: 6,
		scroll:4,
        wrap: 'last',
        initCallback: servicecarousel_initCallback,
        itemLoadCallback: countServices
    });

	$('input[title!=""]').hint();
	
	
	
	$('#usa-office').hide();
	
	$('#uk-click').click(ukClick);
	$('#usa-click').click(usClick);
	$('#form-close').click(function(){
		$('#mce-responses').fadeOut(400);
	});
	
	ukClick();
	
				
				
});
