YAHOO.util.Event.onContentReady("carousel", function (ev) {
	/* Read the "link" element that tells us how to contact the server. See markup above. */
	var get_init_data = YAHOO.util.Dom.get('get_init_data').href;

	/* Build the AJAX callback object consisting of three parts.  */
	var callback =
	{

		/* Part I: Function called in the event of a successful call. */
		success: function(o) {

                	/* Convert the JSON response into a javascript object.  */
                	var data = YAHOO.lang.JSON.parse(o.responseText); 

			var opts = {numVisible: 1, isCircular: true, autoPlayInterval: 5000};
			opts.numItems = data.length+1;

			var carousel = new YAHOO.widget.Carousel("carousel", opts);

			var i = 0;
			for(i = 0; i < data.length; i++) {
				var item = data[i];
				var text = '<img src="';
				text += item.img;
				text += '" alt="';
				text += item.alt;
				text += '" width="300" height="200" title="';
				text += item.alt;
				text += '"/>';
/*				alert(text); */
				carousel.addItem(text);
			}
			carousel.render(); 
			carousel.startAutoPlay(); 

		},
		failure: function(o) {alert(o.statusText);}

	};

	var transaction = YAHOO.util.Connect.asyncRequest('GET', get_init_data, callback, null);


});
                

