/* Author: 

*/


$(document).ready(function () {

	$.ajax({
			url: "/gm/xml/ticker_all_games.asp",
			success: function(xml) {
	            count = 0;
				
				currentTourn = "";
				currentTicker = "";
				nextTourn = "";
				
				
				$("game", xml).each(function(index, node) {
					if  (count == 0)
					{
						
						currentTourn = $(node).attr("programName") +" - " + $(node).attr("eventName") + " - " + $(node).attr("division");
						
						$('#tickerHead').append("<li><div class='tickerLocationBoxes'>" + $(node).attr("programName") +" - " + $(node).attr("eventName") + " - " + $(node).attr("division") + "</div></li>");
						
						currentTicker = "<li><div class='tickerScoreBoxes'><div>" + $(node).attr("team1") +"&nbsp; - &nbsp;"+ $(node).attr("score1") +" </div><div>" + $(node).attr("team2") + "&nbsp; - &nbsp;" + $(node).attr("score2") + "</div></div>";
						
						
						count++;
					}
					else if (count >= 5)
					{
						
						$('#tickerScores').append(currentTicker + "</li>");
						
						currentTicker = "";
						
						
						count = 0;
					}
					else
					{
						
						nextTourn = $(node).attr("programName") +" - " + $(node).attr("eventName") + " - " + $(node).attr("division");
						if(currentTourn != nextTourn)
						{
							$('#tickerScores').append(currentTicker + "</li>");
						
							currentTicker = "";
					
							count = 0;	
						}
						else
						{
						
						currentTicker = currentTicker + "<div class='tickerScoreBoxes'><div>" + $(node).attr("team1") +"&nbsp; - &nbsp;"+ $(node).attr("score1") +" </div><div>" + $(node).attr("team2") + "&nbsp; - &nbsp;" + $(node).attr("score2") + "</div></div>";
						
						count++;
						}
					}
					
					
				});
				
				
				$('#tickerHead').cycle({
					fx: 'fade',
					speed: 1000,
					timeout: 9000,
					pause: 0
				   
				});
	
				 $('#tickerScores').cycle({
					fx: 'scrollDown',
					speed: 1000,
					timeout: 9000,
					pause: 0
				   
				});
				
			}
			
			
		});



		$('.level1').hover(function() {
				$(".subLevel",this).stop().show();
				$(this).addClass('highlighted');
		},function () {
				$(".subLevel", this).stop().hide();
				$(this).removeClass('highlighted');
		});


    $('#homepage-slideshow').cycle({
            fx: 'fade',
            speed: 3000,
            timeout: 10000,
            random: 0,
			pause: 1
        });

});














