var total = 0;
var spon = 1;
var spong = 1;
var spons = 1;

  $(function() {
    $('#sponsorcycle').html("");
	$('#sponsorcycle').crossSlide({
      speed: 25,
      fade: 1
    }, [
      { src: '/p/TENA10/resources/spon_right_1.jpg', dir: 'up'   },
      { src: '/p/TENA10/resources/spon_right_2.jpg',   dir: 'down' },
      { src: '/p/TENA10/resources/spon_right_3.jpg',  dir: 'up'   },
      { src: '/p/TENA10/resources/spon_right_4.jpg', dir: 'down' },
      { src: '/p/TENA10/resources/spon_right_5.jpg',  dir: 'up'   }
    ]);
  });

$(document).ready( function() {
		total = $("#platspon a").size();
		function sponsorIn() 
		{
			total = $("#platspon a").size();
			if (total < spon) { spon = 1; }
			$('#platspon a:nth-child('+spon+')').fadeIn(1250, function() {
				$("#platspon").animate({opacity: '+=0'}, 4000, function() { 
					sponsorOut();
				});
			});
			//$('#platspon a:nth-child('+(spon+1)+')').fadeIn(500);
		}
		function sponsorOut() 
		{
			$('#platspon a:nth-child('+spon+')').fadeOut(750, function() {
				spon += 1; sponsorIn();
			});
			//$('#platspon a:nth-child('+(spon+1)+')').fadeOut(250);
		}
		if (total > 1) { $("#platspon a").hide(); sponsorIn(); }
		
		totalg = $("#goldspon a").size();
		function sponsorIng() 
		{
			totalg = $("#goldspon a").size();
			if (totalg < spong) { spong = 1; }
			$('#goldspon a:nth-child('+spong+')').fadeIn(1250, function() {
				$("#goldspon").animate({opacity: '+=0'}, 4000, function() { 
					sponsorOutg();
				});
			});
			//$('#goldspon a:nth-child('+(spong+1)+')').fadeIn(500);
		}
		function sponsorOutg() 
		{
			$('#goldspon a:nth-child('+spong+')').fadeOut(750, function() {
				spong += 1; sponsorIng();
			});
			//$('#goldspon a:nth-child('+(spong+1)+')').fadeOut(250);
		}
		if (totalg > 1) { $("#goldspon a").hide(); sponsorIng(); }
		
		totals = $("#silvspon a").size();
		function sponsorIns() 
		{
			totals = $("#silvspon a").size();
			if (totals < spons) { spons = 1; }
			$('#silvspon a:nth-child('+spons+')').fadeIn(1250, function() {
				$("#silvspon").animate({opacity: '+=0'}, 4000, function() { 
					sponsorOuts();
				});
			});
			//$('#silvspon a:nth-child('+(spons+1)+')').fadeIn(500);
		}
		function sponsorOuts() 
		{
			$('#silvspon a:nth-child('+spons+')').fadeOut(750, function() {
				spons += 1; sponsorIns();
			});
			//$('#silvspon a:nth-child('+(spons+1)+')').fadeOut(250);
		}
		if (totals > 1) { $("#silvspon a").hide(); sponsorIns(); }
});
