jQuery.fn.center = function () {
    this.css("position","absolute");
	if(this.height() < $(window).height() && this.width() < $(window).width()){
		this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
		this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
	}
    return this;
}

dialog = function(id){
	if($('#' + id).hasClass('hide')){
		$('#' + id).removeClass('hide');
	} else {
		$('#' + id).addClass("hide");
	}
	
	$('#' + id).center();
}


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

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });

    jQuery('#next').bind('click', function() {
        carousel.next();
		carousel.startAuto(0);
        return false;
    });

    jQuery('#prev').bind('click', function() {
        carousel.prev();
        return false;
    });
	
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(
		function() {
			carousel.stopAuto();
		},
		function() {
			carousel.startAuto();
		}
	);

};


