jQuery(document).ready(function() {
//    jQuery('#carousel').jcarousel({
//        vertical: true,
//		scroll: -1,
//		animation: "slow",
//		start:1,
//		offset:1,
//		size:5,
//		auto: 3,
//		visible: 3,
//        wrap: 'circular',
//        itemVisibleInCallback: {onBeforeAnimation: carousel_itemVisibleInCallback},
//        itemVisibleOutCallback: {onAfterAnimation: carousel_itemVisibleOutCallback}
//    });
	
//	changeInputCss();

});



/**************************

News Feed Functions 

***************************/

//array with the most recent news
var carousel_itemList = getNews();


/* This function changes the CSS? */
/*
function changeInputCss() {
	$("input").focus( function() {
		$(this).css("color", "black");
		$(this).val("");
	}).blur( function () {
		if ($(this).val() == "") {
		$(this).css("color", "#666666");
		$(this).val($(this).attr("title"));
		}
	});
}
*/


/* This function adds each cell from the array to the newsfeed */
function carousel_itemVisibleInCallback(carousel, item, i, state, evt) {

		// The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, carousel_itemList.length);
    carousel.add(i, carousel_itemList[idx - 1]);
};


/* This function removes the last cell of the carousel */
function carousel_itemVisibleOutCallback(carousel, item, i, state, evt) {
    carousel.remove(i);
};


/* This function returns an array of the most recent news activities */
function getNews() {
	var getnews = 1;
	var newsarr = new Array();

	$.post(dev + "index_rolling_news.php", { getnews: getnews }, function(data){
		for(i = 0; i < data.updates.length; i++) {
			if (data.updates[i]) {
				newsarr.push(data.updates[i]);
			}
		}
	}, "json");
	return newsarr;
}

