function populateDateAJAX(type) {
	var game_type = type;
	var position = document.form.season.selectedIndex;
	var season = parseInt(document.form.season.options[position].value);

	$('#date').html('<option>Loading .. </option>');
	var loadDatesURL = "/admin/functions/filters/matchDates.php?season=thisisnotaseasonid&type="+ game_type+"";
	var loadDatesURL = loadDatesURL.replace("thisisnotaseasonid", season);
	
	$.get("/admin/functions/filters/matchDates.php", { season: season, type: game_type },
  		function(data){
			//alert(data);
			data =  '<option value="">ALL</option>' + data ;
			$('#date').html(data);
  		}
	);
}

function populateTeamAJAX() {
	
	var position = document.form.season.selectedIndex;
	var season = parseInt(document.form.season.options[position].value);
	
	var position2 = document.form.div.selectedIndex;
	var div = parseInt(document.form.div.options[position2].value);

	$('#team').html('<option>Loading .. </option>');	
	var loadDatesURL = "/admin/functions/filters/teamDivs.php?div="+ div+"";
	var loadDatesURL = loadDatesURL.replace("thisisnotaseasonid", season);
	
	$.get("/admin/functions/filters/teamDivs.php", { div: div },
  		function(data){
			//alert(data);
			data =  '<option value="" SELECTED >ALL</option>' + data ;
			$('#team').html(data);
  		}
	);
}

function hideSelects() {
	$('select').css({ 'visibility' : 'hidden' });
}

function showSelects() {
	$('select').css({ 'visibility' : 'visible' });
}

rotateTopStory = function(){
	clearInterval(window.golfinterval)

			var p=1;													   
			var pos = $('#story-container .story-nav li').index($('#story-container .story-nav li.story-on')[0]);
			
			
			if(pos==4){pos=-1;}
			
			$('#story-container .story-nav li').eq(pos+1).trigger('click','x');
			
			window.golfinterval = setInterval("rotateTopStory()",7000);
	}

topStory = function(){
	//$('.count').html("1 of 5");
	
	var first = $('#story-container li.story-content:eq(4)').clone();

	$('#story-container .story-scroll').prepend(first).css({marginLeft:-480});

	rotateTopStory();
	
	$('#story-container .story-nav li').click(function(click,p){
	

		var pos = $('#story-container .story-nav li').index($(this));
		
		pos = pos;
		
		if(pos==4 && p=='x'){
			$('#story-container .story-scroll').animate({marginLeft:((480*pos)*-1)-480},800,function(){
				
				$('#story-container .story-scroll').css({'marginLeft':0})
			});
		} else{
			$('#story-container .story-scroll').animate({marginLeft:((480*pos)*-1)-480},{duration:800,queue:false});
		}

		$('#story-container .story-nav li').removeClass('story-on');
		$(this).addClass('story-on');
		if(p!='x'){
			clearInterval(window.golfinterval)
			//$('.TStimer').css('width',1);
		}
		return false;
													   
})

}



$(document).ready(function(){
	topStory();
	$('a[@rel*=lightbox]').lightBox();			
});






