//auto-select form field contents on click-tab

function highlight(field) {
       field.focus();
       field.select();
};



//jCarousel settings

function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
	
	// Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    },
	
	function() {
        carousel.startAuto()
    });

	// Go to next image when clip is clicked
    carousel.clip.click(function() {
        carousel.next()
    });

};

function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
	$('.jcarousel-control a.current').removeClass('current');
	$('.jcarousel-control a').eq(idx-1).addClass('current');
}

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
		auto: 4,
		wrap: 'both',
		animation: 900,
        initCallback: mycarousel_initCallback,
		itemVisibleInCallback: {
            onAfterAnimation:  mycarousel_itemVisibleInCallbackAfterAnimation
        }
    });
	
	$('textarea').autoResize({
		// On resize:
		onResize : function() {
			$(this).css({opacity:0.8});
		},
		// After resize:
		animateCallback : function() {
			$(this).css({opacity:1});
		},
		// Quite slow animation:
		animateDuration : 200,
		// More extra space:
		extraSpace : 40
	});

});



//make entire div on Our Work page clickable
$(document).ready(function(){

	$(".hubBox").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});

});

