function menuGoTo(menuform) {
    var baseurl = "https://www.lowellfootball.com/" ;
	
    selecteditem = menuform.newurl.selectedIndex ;
    newurl = menuform.newurl.options[ selecteditem ].value ;
    if (newurl.length != 0) {
		location.href = baseurl + newurl ;
    }
}

$(document).ready(function(){
	/*******HEADLINES VIEW MORE/LESS*******/
	$("#view-more").click(function() {
		$("#more-headlines").slideToggle("fast", function(){
			var txt = $("#more-headlines").is(':visible') ? 'View Less...' : 'View More...';
			$("#view-more").text(txt);
		});
	});
 
	/*******ANNOUNCEMENT MESSAGE*******/
	$('a.closeEl').bind('click', toggleContent);

	/*******FOOTER BLOCKS*******/
	$("img.blocks").fadeTo("slow", 0.3);
	$("img.blocks").hover(function(){
		$(this).stop().fadeTo("fast", 1.0);
	},function(){
   		$(this).stop().fadeTo("slow", 0.5);
	});
	
	/*******PAST SEASONS BUTTONS*******/
	$('.ps-button a').click(function(){
		for(i=2010; i >= 1900; i-=10){
			$('.'+i).hide();
		}
		
		var decadeStart = $(this).attr('id');
		var decadeEnd = parseInt($(this).attr('id'))+9;
		
		if($(this).attr('id') == 'full-list'){
			for(i=2010; i >= 1900; i-=10){
				$('.'+i).show();
				$('.table-header').html('All Seasons');
			}
		} else {
			$('.'+($(this).attr('id'))).show();
			$('.table-header').html(decadeStart+'-'+decadeEnd);
		}
	});
	
	/*******MENU FUNCTIONS*******/
	//$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").hover(function(){ //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('slow').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	

				$(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up

		});
 
	//Following events are applied to the trigger (Hover events for the trigger)
	}).hover(function() { 
		$(this).addClass("subhover"); //On hover over, add class "subhover"
	}, function(){	//On Hover Out
		$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	
	/*******MAPS FUNCTIONS*******/
	$('.map').click(function(){
		var teamsString = '';
        var conference_id = $(this).attr('rel'); 
        $.getJSON('get-conference.php', {id: conference_id}, function(data){
			$.each(data, function(i, embed){
				var linkName = embed.fullname;
				linkName = linkName.replace(new RegExp(" ", "g"), "-");
				teamsString += '<tr><td><a href="/maps/'+linkName.toLowerCase()+'">'+embed.fullname+'</a></td><td>'+embed.address+'</td><td>'+embed.phone+'</td></tr>';
				//$('#conference-teams').html(teamsString);
			});
			$('#conference-teams table tr:not(:first-child)').remove();
			$('#conference-teams table tr:first').after(teamsString);
		}); 
		$('.map').removeClass('active');
		$(this).addClass('active');
    }); 
});

var toggleContent = function(e) {
	var targetContent = $('div.groupItem'); //, this.parentNode.parentNode
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		//$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		//$(this).html('[+]');
		var message = "false";
		
		$.post("/2011/sessionUpdate.php", { message: "no" });
	}
	return false;
};

$(function() {
	$('#gallery a').lightBox();
});
