var mycarousel_itemList = [
    {url: '/images/screenshot-iphone-sm-lalaradio.png', title: 'iPhone - lalaRadio', height:'124', width:'230'},
    {url: '/images/screenshot-android.png', title: 'Android', height:'239', width:'124'},
    {url: '/images/screenshot-iphone.png', title: 'iPhone', height:'239', width:'124'},
    {url: '/images/screenshot-bb-hires1.jpg', title: 'Blackberry', height:'70', width:'124'},
    {url: '/images/screenshot-bb-lores1.jpg', title: 'Blackberry', height:'70', width:'124'},
    {url: '/images/screenshot-bb-touch1.jpg', title: 'Blackberry', height:'217', width:'124'}
];
function mycarousel_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, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<img src="' + item.url + '" alt="' + item.title + '" />';
};

var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
		scroll: 1,
		animation: 'slow',
		auto: '4',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });

	 
	   headline_count = $("div.headline").size();
	   $("div.headline:eq("+current_headline+")").css('top','5px');
	 
	   headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
	   $('#scrollup').hover(function() {
		 clearInterval(headline_interval);
	   }, function() {
		 headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
		 headline_rotate();
	   });
});

 function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 
   $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
	 $(this).css('top','210px');
   });
   $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
   old_headline = current_headline;
 }
 
 function recordOutboundLink(link, category, action) {
  try {
    var pageTracker=_gat._getTracker("UA-15232978-1");
    pageTracker._trackEvent(category, action);
    if(link.href != undefined){
		if(document.location.href.match(link.href)){return false;}
		else{
			setTimeout('', 100);
			return true;
		}
	}
  }catch(err){}
}

