// Right height fix
function resetRightHeight(){
	var text_content_height = $("#text-content").height();
	var right_content_height = $("#right-content").height();
	if(text_content_height > right_content_height){
		$("#right-content").css('height', text_content_height+'px');
	}
}

function mycarousel_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();
    });
	resetRightHeight();
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
    jQuery('#mycarousel_small').jcarousel({
        visible: 4,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
    jQuery('#mycarousel_micro').jcarousel({
        visible: 3,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
	resetRightHeight();
});

$(document).ready(function() {
	$("a#mainimagelink").fancybox({
		'overlayShow'	: true,
		'overlayOpacity' : 0.7,
		'overlayColor' : '#000',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
});
function setMainimage(src){
	// Set new source for main image
	$('#mainimage').attr('src', src);
	$('#mainimagelink').attr('href', src);
	
	// Initialize fancybox
	$("a#mainimagelink").fancybox({
		'overlayShow'	: true,
		'overlayOpacity' : 0.7,
		'overlayColor' : '#000',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
}
