// adds onclick event for ga tracking code
function trackThis(title, action, cssClass) {
	var label, title, cssClass;
	
	switch( title ) {
		case 'Evolve your 3G Network':
			label = 'IMMS';
			break;
		case 'RadiSys Military and Aerospace Solutions':
			label = 'MilAero';
			break;
		case 'Integrated 40G ATCA Platform':
			label = 'ATCA 40G';
			break;
		case 'RadiSys ATCA Solutions':
			label = 'ATCA';
			break;
		case 'RadiSys Embedded Solutions':
			label = 'Embedded';
			break;
	}
	
	if( label ) {

    	if( cssClass == 'learn-more' ) { 
    		label += ' link';
    	} else if( action == 'banner' ) {
    		label += ' banner';
    	} else {
    		label += ' nav';
    	}

		pageTracker._trackEvent('spotlight', action, label);
    }
}

// build pager links
function buildPager(idx, slide) {
    return '<li><a href="#"><span>' + (idx+1) + '</span><em>' + $(slide).attr('title') + '</em></a></li>';
}

// execute on DOM ready
$(document).ready(function(){
	
	// insert pager container markup
	$('#spotlight-cycle').append('<div id="spotlight-pager"><span id="spotlight-prev"><a href="#">Previous</a></span><ol></ol><span id="spotlight-next"><a href="#">Next</a></span>');
	
	// configure cycle options
	$('#spotlight-cycle .items').cycle({
	    fx:      'fade',
	    timeout:  4000,
	    prev:    '#spotlight-prev',
	    next:    '#spotlight-next',
	    pager:   '#spotlight-pager ol',
	    activePagerClass: 'on',
	    pagerAnchorBuilder: buildPager,
	    pause: true,
	    pauseOnPagerHover: true
	});
	
	// track clicks
	$('#spotlight-cycle .items a').click(function() {
		trackThis($(this).parent().attr('title'), 'banner', $(this).attr('class'));
	});
	$('#spotlight-pager ol a').click(function() {
		trackThis($(this).children('em').text(), 'nav', '');
	});

});
