var changedAgents = new Array();

function updateTimes(num, day) {

	var agent = "one2ones-"+day+"-"+num;
	var agentsId = jQuery("#"+agent+" option:selected").val();

	if(jQuery("#agent-"+agentsId).html()) {
		jQuery("#"+agent+" option:selected").removeAttr("selected");
		jQuery("#121-times-"+day+"-"+num).html("<select name='agent-0'><option value='' selected>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option></select>");
		alert("Sorry, you can not book the same agent twice");
	}
	else
	{
		changedAgents[day] = 1;

		if(agentsId) {
			jQuery("#121-times-"+day+"-"+num).html("Please wait...");
			jQuery("#121-times-"+day+"-"+num).load("/js/agent121Times.ajax.php?agentsId="+agentsId);

		} else {
			jQuery("#121-times-"+day+"-"+num).html("<select name='agent-0'><option value='' selected>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option></select>");

		}
	}
}

function checkTimeSelected() {

	var returns = true;

	for (var i in changedAgents) {
		var agent = "one2ones-"+i+"-1";
		var agentsId = jQuery("#"+agent+" option:selected").val();

		if(agentsId > 0) {
			if(jQuery("#agent-"+agentsId+" option:selected").val() > 0) {
			}
			else
			{
				returns=false;
			}
		}

		var agent = "one2ones-"+i+"-2";
		var agentsId = jQuery("#"+agent+" option:selected").val();

		if(agentsId > 0) {
			if(jQuery("#agent-"+agentsId+" option:selected").val() > 0) {
			}
			else
			{
				returns=false;
			}
		}
	}

	if(returns==false) {
		alert("You must select a time for your one-2-one agent sessions");
	}

	return returns;
}