function editContent(){
         if ( $(".editable-content").is(":hidden") ){	
                  $("#page-content").hide();
                  $(".editable-content").show();
                  $(".edit").html("View");
         }
         else {
                  $("#page-content").show();
                  $(".editable-content").hide();
                  $(".edit").html("Edit");
         }
}

function toggleNews(){
	if ( $(".archive-1").is(":hidden") ){
		$(".archive-1").show();
        $(".show-news").html("Hide archived news");
	} 
	else {
		$(".archive-1").hide();
        $(".show-news").html("Show archived news?");
	}
}

function SubmitFormRemove(f,id,type) {
		input_box = confirm("Are you sure you want to delete this "+ type +"?");
		if (input_box == true) {			
		$("#remove-" + id).val('true');
		$("#" + f).submit();	
		}		
}
	
function deleteResult() {
		input_box = confirm("Are you sure you want to delete this result?");
		if (input_box == true) {			
		$("#remove").val('true');
		$("#edit-result").submit();	
		}		
}
	
var formArray = []; 
function addFormToArray(id){
var idx = formArray.indexOf(id);

	if(idx == -1){
	formArray.push(id);
	//alert(formArray);
		if ($(".spinner").not(":hidden")){
			$(".spinner").hide();
		}
	}
}

//javascript to show or hide table rows depending on selection
    function toggle(sectorName) {
         if (sectorName == 'All'){
  			 $("table").find("tr").css('display','');
    		}
		else {
			$('.Saturday').hide();
			$('.Sunday').hide();
			$('.Midweek').hide();
			$('.Friendly').hide();
			$('.All').hide();
			$('.Combined').css("display","none");
			if($('.' + sectorName).is(':hidden')){
				$('.' + sectorName).show();
			}
		}
	$("table.generic tr").removeClass("on");
  	$("table.generic tr:visible:even").addClass("on");
	       
   }
   
   function showTable(id) {      
			if($('#' + id).is(':hidden')){
				$('#' + id).show();
				$('#show-details-table').html("Hide secondary details <<");			
			}  else {
				$('#' + id).hide();
				$('#show-details-table').html("Show secondary details >>");	
			}					
   }
   
   $(document).ready(function(){
   if ($('.scrollTop').length) { 
		$(".scrollTop").css({"cursor": "pointer","font-weight": "bold"});
		$(".scrollTop").click(function(){
			$('html, body').animate({ 
				scrollTop: $('#main-content').offset().top 
			}, 3000);
		});
	}
   });
   
   	$(document).ready(function(){
		$("#select-season").click(function(){
			var season = $("select#season option:selected").val();
			var url = window.location.href;
			var seasonParam = "?season="+season;
			if(url.indexOf("?") > 0){
				seasonParam = "&season="+season;
			}
			window.location = url + seasonParam;
			//window.location = "?season="+season;            
		});
	});

//Player hover function
 $(document).ready(function(){
	$("#main-content a").hover(
		function() {
			var thisClass = $(this).attr("class");
			var imageName = "";
			if (thisClass.indexOf("hover-") >= 0){
				imageName = thisClass.substr(6);
				if(imageName != ""){
					$(this).append("<div class='player-hover'><img src='/images/players/" + imageName + "' /></div>");
				}
			}
		},
		function() {
			 $("div.player-hover").fadeOut(500, function() { $("div.player-hover").remove(); });
		}
	 ); 
  });