$(function() {
	$('#slideshow').cycle({
		fx: 'scrollHorz',
		next: '#pager .rightArrow',
		prev: '#pager .leftArrow',
		speed: '700',
		timeout: 5000
	});
	$('#slideshow').css('overflow','visible');
	
	$.ajaxSetup({
		type: "POST",
		contentType: "application/json; charset=utf-8",
		dataType: "json"
	});
	//$('#divDebug').html('working');
	
	$.ajax({
		url:  '/services/Services.asmx/GetFrontPageApplications',
		data: "{}",
		success: function(result) {
			var apps = eval(result.d);
			var i=0;
			var s = '<tbody>';
			for(i=0;i<apps.length;i++) {
				if(s%3 == 0)
					s += '<tr>';
				s += '<td>' +
						'<a href="applications#searchterm=' + apps[i].Name + '">' +
						'<div class="icon-container aps-' + apps[i].Level.toUpperCase() + '-' + apps[i].APSVersion.replace('.', '-') + '">' +
							'<img src="' + apps[i].Image + '" class="app-icon" width="39" height="39" />' +
						'</div>' +
						'' + apps[i].Name + '</a>' +
					'</td>';
				if((i + 1)%3==0)
					s += '</tr>';
						
			}
			s += '</tbody>';
			
			$('.appCatalog').html(s);
			$('.promo').css('background-image', 'none');
		}
	});

});
