jQuery(document).ready(function() {
				
	function timeCheck() {
		
		flag1_2 = false;
		flag1_3 = false;
		flag2_3 = false;
		
		// get the first date
		if(jQuery("select[name='date-1'] :selected").length > 0) {
			date_1_chosen = jQuery("select[name='date-1'] :selected").text();
		}
		else {
			date_1_chosen = '';
		}
		
		
		// get the second date
		if(jQuery("select[name='date-2'] :selected").length > 0) {
			date_2_chosen = jQuery("select[name='date-2'] :selected").text();
		}
		else {
			date_2_chosen = '';
		}
		
		
		// get the third date
		if(jQuery("select[name='date-3'] :selected").length > 0) {
			date_3_chosen = jQuery("select[name='date-3'] :selected").text();
		}
		else {
			date_3_chosen = '';
		}
			
		
		// compare ( date 1 & date 2 ) - if there is a match, get time 1 and time 2 and compare
		// if there is a match highlight row 1 and row 2
			
		if ( ( date_1_chosen == date_2_chosen ) & ( date_1_chosen != '' ) & ( date_2_chosen != '' ) ) {
		
			time_1_chosen = jQuery("select[name='time-1'] :selected").text();
			time_2_chosen = jQuery("select[name='time-2'] :selected").text();
			
			if ( time_1_chosen == time_2_chosen ) {
				flag1_2 = true;
			}
		}
			
			
		// compare ( date 1 & date 3 ) - if there is a match, get time 1 and time 3 and compare
		// if there is a match highlight row 1 and row 3
			
		if ( ( date_1_chosen == date_3_chosen ) & ( date_1_chosen != '' ) & ( date_3_chosen != '' ) ) {
		
			time_1_chosen = jQuery("select[name='time-1'] :selected").text();
			time_3_chosen = jQuery("select[name='time-3'] :selected").text();
			
			if ( time_1_chosen == time_3_chosen ) {
				flag1_3 = true;
			}
		}
			
			
		// compare ( date 3 & date 2 ) - if there is a match, get time 3 and time 2 and compare
		// if there is a match highlight row 2 and row 3
	
		if ( ( date_2_chosen == date_3_chosen ) & ( date_2_chosen != '' ) & ( date_3_chosen != '' ) ) {
		
			time_2_chosen = jQuery("select[name='time-2'] :selected").text();
			time_3_chosen = jQuery("select[name='time-3'] :selected").text();
			
			if ( time_2_chosen == time_3_chosen ) {
				flag2_3 = true;
			}
		}
			
		if ( flag1_2 == true ) {
			jQuery("p.row_one").css({ background: "url(/images/exclamation.png) no-repeat 96% 50% #FDBAA6", padding: "5px"});
			jQuery("p.row_two").css({ background: "url(/images/exclamation.png) no-repeat 96% 50% #FDBAA6", padding: "5px"});
		}
		
		if ( flag1_3 == true ) {
			jQuery("p.row_one").css({ background: "url(/images/exclamation.png) no-repeat 96% 50% #FDBAA6", padding: "5px"});
			jQuery("p.row_three").css({ background: "url(/images/exclamation.png) no-repeat 96% 50% #FDBAA6", padding: "5px"});
		}
		
		if ( flag2_3 == true ) {
			jQuery("p.row_three").css({ background: "url(/images/exclamation.png) no-repeat 96% 50% #FDBAA6", padding: "5px"});
			jQuery("p.row_two").css({ background: "url(/images/exclamation.png) no-repeat 96% 50% #FDBAA6", padding: "5px"});
		}
		
		if ( ( flag1_2 == false ) & ( flag1_3 == false ) ) {
			jQuery("p.row_one").css({ background: "#fff", padding: "0px"});
		}
		
		if ( ( flag1_2 == false ) & ( flag2_3 == false ) ) {
			jQuery("p.row_two").css({ background: "#fff", padding: "0px"});
		}
		
		if ( ( flag1_3 == false ) & ( flag2_3 == false ) ) {
			jQuery("p.row_three").css({ background: "#fff", padding: "0px"});
		}
			
	} // end timeCheck
	
	
	jQuery("select[name='date-1']").change(function () {

		timeCheck();
		
	});
	
	jQuery("select[name='date-2']").change(function () {
	
		timeCheck();
	
	});
	
	jQuery("select[name='date-3']").change(function () {
		
		timeCheck();
		
	});
	
	jQuery("select[name='time-1']").change(function () {
		
		timeCheck();
		
	});
	
	jQuery("select[name='time-2']").change(function () {
		
		timeCheck();
		
	});
	
	jQuery("select[name='time-3']").change(function () {
		
		timeCheck();
		
	});	
	
});