// JavaScript Document
$(document).ready(function(){
 	$("input[name^='outsideUK']").click(function() {
		if (this.name == "outsideUKYes") {
			$("input[name^='outsideUKNo']").attr('checked', false);
			$("#hideCountry").css("display","");
		} else {
			$("input[name^='outsideUKYes']").attr('checked', false);
			$("#hideCountry").css("display","none");
		}
	});
	 $("input[name^='duration']").change(function() {
		temp=jQuery.trim($(this).val());									  
		if (temp !== "") {
			$("input[name^='sinceBirth']").attr('checked', false);
		}
	});
	 $("input[name^='sinceBirth']").click(function() {
		if ($(this).attr('checked')) {
			$("input[name^='duration']").val("");
		}
	});


 	$("input[name^='disabled']").click(function() {
		if (this.name == "disabledYes") {
			$("input[name^='disabledNo']").attr('checked', false);
		} else {
			$("input[name^='disabledYes']").attr('checked', false);
		}
	});
 	$("input[name^='learning']").click(function() {
		if (this.name == "learningYes") {
			$("input[name^='learningNo']").attr('checked', false);
		} else {
			$("input[name^='learningYes']").attr('checked', false);
		}
	});
/* new code 16/04/10 to select either expected or achieved */
	$("input[name^='qual_row\[']").change(function() {
		/* trim whitespace from all input to tidy verification process */	
		$(this).val(function(index, value) {
			return jQuery.trim(value);
		});
		/* Trap achieved or predicted entries */
		if ((this.name).substr(12,1) == 2 || (this.name).substr(12,1) == 3) {
			/* Set position to retrieve partner value */
			if ((this.name).substr(12,1) == 2) {
				relPos=3;
			} else {
				relPos=2;
			}
			/* Build sting for comarison input field */
			prevName="input[name^='qual_row\[";
			prevName+=(this.name).substr(9,1);
			prevName+="\]\[";
			prevName+=relPos;
			prevName+="\]']";
			testAlert=$(prevName).val();
			/* If partner input has a value, then reject this update */
			if (testAlert) {
				$(this).val(function(index, value) {
				  return "";
				});
				alert("Enter 'Expected' or 'Achieved' \n but not both !");
			}
		}
	});
	
 	$("input[name^='liscence_']").click(function() {
		if (this.name == "liscence_yes") {
			$("input[name^='liscence_no']").attr('checked', false);
		} else {
			$("input[name^='liscence_yes']").attr('checked', false);
			$("input[name^='vehicle_yes']").attr('checked', false);
		}
	});
 	$("input[name^='vehicle_']").click(function() {
		if (this.name == "vehicle_yes") {
			if ($("input[name^='liscence_yes']").attr('checked') == true) {
				$("input[name^='vehicle_no']").attr('checked', false);
			} else {
				$("input[name^='vehicle_yes']").attr('checked', false);
				alert ("please ensure you check drivers liscence \n before selecting this option");
			}
		} else {
			$("input[name^='vehicle_yes']").attr('checked', false);
		}
	});
 	$("input[name^='dependant_']").click(function() {
		if (this.name == "dependant_yes") {
			$("input[name^='dependant_no']").attr('checked', false);
		} else {
			$("input[name^='dependant_yes']").attr('checked', false);
		}
	});
 	$("input[name^='convictions_']").click(function() {
		if (this.name == "convictions_yes") {
			$("input[name^='convictions_no']").attr('checked', false);
		} else {
			$("input[name^='convictions_yes']").attr('checked', false);
		}
	});
	$("input[name^='eq_']").click(function() {
	tempObject=this;
		$("input[name^='eq_']").each(function() {
			$(this).attr('checked', false);
		});
	$(tempObject).attr('checked', true);
	});
	
	$("input[name^='employ_']").click(function() {
	tempObject=this;
		$("input[name^='employ_']").each(function() {
			$(this).attr('checked', false);
		});
	$(tempObject).attr('checked', true);
	});


 });

