$(document).ready(function(){
	// slider1
    $('#slider1').bxSlider();

	// the texting function
	$('#educator').click( function() {
		
		// variable
		var attributeClass = $(this).attr('class');
		// check to see if class is selected or not
		if (attributeClass == 'hello') {
			$(this).removeClass('hello');
			$(this).html('Educator');
		} else {
			$(this).addClass('hello');
			$('#youngPerson').removeClass('hello');
			$('#corporate').removeClass('hello');
		
			$.get('educator.php', function(data) {
				$('.selection:nth-child(2)').html(data);
				
				// this function is triggered after selecting courseType
				$('.courseType > p > label').click( function() {
					
					// grab the value that the "label" ID is "for"
					var value = $(this).attr('for');
					if (value == 'intCourse') {
						// coding goes here
						$.get('signUp.php?courseType=Intensive%20Course', function(data) {
							$('.selection:nth-child(3)').html(data);
						});
						
						var checkedInt = $(this).parent().find('input');
						
						if(!checkedInt.attr('checked')) {
							$(this).html('Selected');
							$('.courseType:nth-child(2) > p > label').html('Select');
						} 
						
					} else {
						if (value == 'extCourse') {
							$.get('signUp.php?courseType=Extensive%20Course', function(data) {
								$('.selection:nth-child(3)').html(data);
								$('.message:nth-child(2)').html('You\'ve selected extensive course, please go to the next stage.');
							});
								
							var checkedExt = $(this).parent().find('input');
												
							if(!checkedExt.attr('checked')) {
								$(this).html('Selected');
								$('.courseType:nth-child(1) > p > label').html('Select');
								$('.courseType:nth-child(1) > p > label').css('borderColor','#ff4000');
							} 
						}
					}
				});
			});
		}
		
	}); // educator button ends here.
	
	// this function is loaded when young person button is clicked
	$('#youngPerson').click( function() {
	  
		// variable
		var attributeClass = $(this).attr('class');
		// check to see if class is selected or not
		if (attributeClass == 'hello') {
			$(this).removeClass('hello');
		} else {
			$(this).addClass('hello');
			$('#educator').removeClass('hello');
			$('#corporate').removeClass('hello');
		
			$.get('youngPerson.php', function(data) {
				$('.selection:nth-child(2)').html(data);
				
				// this function is triggered after selecting courseType
				$('.courseType > p > label').click( function() {
					
					// grab the value that the "label" ID is "for"
					var value = $(this).attr('for');
					if (value == 'intCourse') {
						// coding goes here
						$.get('signUp.php?courseType=Intensive%20Course', function(data) {
							$('.selection:nth-child(3)').html(data);
						});
						
						var checkedInt = $(this).parent().find('input');
						
						if(!checkedInt.attr('checked')) {
							$(this).html('Selected');
							$('.courseType:nth-child(2) > p > label').html('Select');
						} 
						
					} else {
						if (value == 'extCourse') {
							$.get('signUp.php?courseType=Extensive%20Course', function(data) {
								$('.selection:nth-child(3)').html(data);
								$('.message:nth-child(2)').html('You\'ve selected extensive course, please go to the next stage.');
							});
								
							var checkedExt = $(this).parent().find('input');
												
							if(!checkedExt.attr('checked')) {
								$(this).html('Selected');
								$('.courseType:nth-child(1) > p > label').html('Select');
								$('.courseType:nth-child(1) > p > label').css('borderColor','#ff4000');
							} 
						}
					}
				});
			});
		}	  
	  
	});
		
	// this function is loaded when corporate button is clicked
	$('#corporate').click( function() {
	  
	  alert('Coming soon!');
	  
	  	// variable
		var attributeClass = $(this).attr('class');
		// check to see if class is selected or not
		if (attributeClass == 'hello') {
			$(this).removeClass('hello');
		} else {
			$(this).addClass('hello');
			$('#educator').removeClass('hello');
			$('#youngPerson').removeClass('hello');
			
			$.get('signUp.php?courseType=Intensive%20Course', function(data) {
				$('.selection:nth-child(3)').html(data);
			});
		}
	  
	});
		
});
