$(document).ready(function() {
  	
  	$('#course_name').keyup(
		function(e) {
			e.preventDefault();
			
			var course_name = $('#course_name').val();
			if (course_name.length > 2) {
					    
			var data = $('#course_name').serialize();
			
			$.post('get-under-courses-do.php',data,
				function(response) {
				var courses_html = "";
				var array = response.split("|");
				for (i=0; i < array.length-1; i++) {
      				var array2 = array[i].split("~");	
      				var course_folder = array2[0];
      				var course_name = array2[1];
      				courses_html = courses_html+"<blockquote><a href='"+course_folder+"/index.php'>"+course_name+"</a></blockquote>";
      			}
      			$('#courses').css('visibility','visible');
      			$('#courses').html(courses_html);
      			}
			);
			} else {
			$('#courses').html("");
			$('#courses').css('visibility','hidden');
			}
			
	});
	
	$('#state').change(
		function(e) {
			e.preventDefault();
			
			var criteria = "state";
			var criteria_value = $('#state').val();
								    
			var data = "criteria="+criteria+"&criteria_value="+criteria_value;
			
			window.location = "under-construction-results.php?"+data;
	});
	
	$('#country').change(
		function(e) {
			e.preventDefault();
			
			var criteria = "country";
			var criteria_value = $('#country').val();
								    
			var data = "criteria="+criteria+"&criteria_value="+criteria_value;
			
			window.location = "under-construction-results.php?"+data;
	});
		
	
	
	
		
});
