$(document).ready(function(){
	activitySearch();
	autocomplete();
	facilitySearch();
	$("#loading").hide();
	$("#facilityid").change(activitySearch);
	
	/*$("#daysofweek").change(activitySearch);	*/
		
	$("#menudaysofweek ").click(function(){
		$("#name").val("Search by name");
		activitySearch();
	 });
	
	
	$("#searchbyname").click(function() {  
		 activitySearch(); 
   }); 
	
	$("#subsectionid").change(function() {  
		$("#name").val("Search by name");
		activitySearch(); 
   }); 
	

	

   
   $("#submit").click(function() {  
     activitySearch(); 
   });  
   
	$(function(){
		$('input').keydown(function(e){
			if (e.keyCode == 13) {
				activitySearch();
			}
		});
	});
	
	
	$('.courselinevertical').hover(function() {
		$('.courselinevertical').css('cursor','pointer');
	});
   
/*
		$('#yourElement').getUrlParam("param");
	  	alert("There is no userID");
	*/


});



<!--Show and hide DIVs-->
	function opendescription(id){
	 <!--alert("You are going to visit: " + id);-->
	$('#'+id).slideToggle("fast");
	
	}


	function activitySearch(){

		var view = $("input[name='view']:checked").val();
		var daysofweek = $("input[name='daysofweek']:checked").val();	
		var alldaysofweek = $("input[name='alldaysofweek']").val();
		
		/*Here I have to replace the spaces for '+' because ASP doesn't understand spaces when I use request(query string)*/
		var searchname = encodeURI($("#name").val());
		
		/*Here I change the activity dropdown to All Drop-ins in case someone searches for a key word */
		if( searchname !== "Search%20by%20name" ) {
			$("#subsectionid").val("0");
			daysofweek = 0;
			$("#radioalldays").attr("checked", "checked"); 
		}


		
		$.ajax({
			type:"POST",
			url: "activitysearch.asp",
			dataType: "application/x-www-form-urlencoded",
			data: "facilityid=" + $("#facilityid").val() + "&subsectionid=" + $("#subsectionid").val()+  "&searchbyname=" + searchname + "&daysofweek=" + daysofweek + "&view=" + view + "&alldaysofweek="+alldaysofweek,
			async: false,
			success: function(msg){ 
				$("#activity").html(msg);
				}
		
		})
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	function facilitySearch(){

		var daysofweek = $("input[name='daysofweek']:checked").serialize();
		var subsectionid = $("input[name='subsectionid']:checked").serialize(); 
		/*Here I have to replace the spaces for '+' because ASP doesn't understand spaces when I use request(query string)*/
		var searchname = encodeURI($("#name").val());
		




		$.ajax({
			type:"POST",
			url: "book_facility_search.asp",
			dataType: "application/x-www-form-urlencoded",
			data: subsectionid +  "&searchbyname=" + searchname +"&"+ daysofweek,
			async: false,
			success: function(msg){ 
				$("#facilities_list").hide();
				$("#facilities_list").html(msg);
				$("#facilities_list").fadeIn();
				}
		
		})
		
	}
	
	



















	
	function autocomplete(){

		var searchname = encodeURI($("#name").val());
		if(searchname.length == 0) {
    	    // Hide the suggestion box.
	        $("#autocomplete").hide();
		} else {
			$("#autocomplete").show();
				$.ajax({
					type:"POST",
					url: "autocomplete.asp",
					dataType: "application/x-www-form-urlencoded",
					data: "searchbyname=" + searchname,
					async: false,
					success: function(msg){$("#autocomplete").html(msg);}
				
				})
		}
	}
	
	
	
	function fill(thisValue) {
	   $("#name").val(thisValue);
	   $("#autocomplete").hide();
	   activitySearch();
	}	
	




	$(document).ajaxStart(function() {
		$('#loading').show();	
	});
	$(document).ajaxStop(function() {
		$('#loading').hide();	
	});	 
		
		





	
/*function daySelected(day){
	
	 var dayselected = day

	$.ajax({
		type:"POST",
		url: "activitysearch.asp",
		dataType: "application/x-www-form-urlencoded",
		data: "facilityid=" + $("#facilityid").val() + "&daysofweek=" + dayselected + "&subsectionid=" + $("#subsectionid").val(),
		async: false,
		success: function(msg){ 
			$("#activity").html(msg);			
			}
	})

  	
}
*/
//example 1
/*function testlink(){
	var dayofweek = $("#M").attr("id");
	var dayofweek = $("#Tu").attr("id");
	 alert(dayofweek);

		$("#Tu").click(function() {
    	alert("You are going to visit: " + this.id);
	});

}
*/


/*  $("#vertical").click(function() {  
	   $('#morning').toggleClass("morningvertical");
	   $('#afternoon').toggleClass("afternoonvertical");
	   $('#evening').toggleClass("eveningvertical");
	   $('.days').toggleClass("daysvertical");
	   $('.coursetitleline').toggleClass("coursetitlelinevertical");
	   $("#horizontal").css('display','block');
	   $("#vertical").css('display','none');
   }); 
   
 

   $("#horizontal").click(function() {  
		$('#morning').toggleClass("morningvertical");
		$('#afternoon').toggleClass("afternoonvertical");
		$('#evening').toggleClass("eveningvertical");
		$('.days').toggleClass("daysvertical");
		$('.coursetitleline').toggleClass("coursetitlelinevertical");
		$("#horizontal").css('display','none');
		$("#vertical").css('display','block');		   
   }); */
   
