$(function() {
	if($("#header .subheader .emptylegs-ticker ul li").length > 4)
		$("#header .subheader .emptylegs-ticker").jCarouselLite({
				vertical: false,
				visible: 5,
				auto:1000,
				speed:1000,
				hoverPause: true
		});

	$("#header .subheader .emptylegs-ticker .flight").click(function() {
		var id = $("input[name=flight_id]", $(this)).val();
		Util.go("empty_legs/index/" + id);
	});

	Util.setLinkSubmit();
});


var Util = {

	redirect: function(link) {
		document.location.href = link;
	},

    go: function(link, confirm_text) {
		link = Util.url(link);
        if (confirm_text != null) {
            if (confirm(confirm_text))
                document.location.href = link;
        } else {
            document.location.href = link;
        }
    },

	url: function(link) {
		return Registry.baseUrl + link;
	},

	corners: function(elements, size) {
		var settings = {
			  tl: { radius: size },
			  tr: { radius: size },
			  bl: { radius: size },
			  br: { radius: size },
			  antiAlias: true
			};
		elements.each(function() {
			curvyCorners(settings, this);
		});
	},

	setLinkSubmit: function() {
		$("a.submit").click(function(e) {
			$(this).parents("form").submit();
			e.preventDefault();
		});
	}
}