<script type="text/javascript">
$(document).ready(function() {
	$("#schedule_tabs").tabs({ 
		show: function(event, ui) { 
		switch(ui.panel.id) { 
			case 'schedule_tab_general': 
				update_tab_general(); 
			break; 
			case 'schedule_tab_scienceolympics': 
				update_tab_scienceolympics(); 
			break; 
			} 
		}, 
		selected: 0 
	});
	event_change();
});

function update_tab_general() {
}

function update_tab_scienceolympics() {
}

function event_change() {
	var ea=$("#edit_event").val().split(":");
	//if its not set, we must be on "choose" still, so disable the other tabs until they choose something
	//then get the heck out of here
	if(!ea[1]) {
		$("#schedule_tabs").tabs("option","disabled",[1,2,3]);
		return;
	}
	//ea[1] is the type
	switch(ea[1]) {
		case "":
		case "general":
		$("#schedule_tabs").tabs("option","disabled",[1,2,3]);
		break;
		case "scienceolympic":
		$("#schedule_tabs").tabs("option","disabled",[2,3]);
		break;
		case "sciencefairjudging":
		$("#schedule_tabs").tabs("option","disabled",[1,3]);
		break;
		case "tour":
		$("#schedule_tabs").tabs("option","disabled",[1,2]);
		break;
		default:
		return;
	}

/*
	if($("#edit_title").val().length) {
		//umm if it already exists, dont change it
		//no, screw it, change it anyways
	}
	else
	{
		*/
		if($("#edit_event").val())
			$("#edit_title").val($("#edit_event option:selected").text());
	//}
	var ed=eventdefaults[ea[0]];
	$("#edit_somaxteams").val(ed.default_max_teams);
	$("#edit_somaxteamsize").val(ed.default_max_team_size);
	$("#edit_sominteamsize").val(ed.default_min_team_size);
}

</script>
    <div id="schedule_tabs">
        <ul>
            <li><a href="#schedule_tab_general"><span><?=i18n('General')?></span></a></li>
            <li><a href="#schedule_tab_scienceolympics"><span><?=i18n('Science Olympics')?></span></a></li>
            <li><a href="#schedule_tab_sciencefairjudging"><span><?=i18n('Science Fair Judging')?></span></a></li>
            <li><a href="#schedule_tab_tour"><span><?=i18n('Tour')?></span></a></li>
        </ul>
		<form method="post" id="edit_event_form">
        <div id="schedule_tab_general">

<?



echo "<input type=\"hidden\" name=\"id\" id=\"edit_schedule_id\">";
echo "<table style=\"width: 95%;\">";
echo "<tr><td>";
echo i18n("Event").": ";
echo "</td><td>";
echo "<select name=\"event_id\" id=\"edit_event\" onchange=\"event_change()\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
$q=mysql_query("SELECT * FROM events WHERE conferences_id='{$conference['id']}' ORDER BY name");
while($r=mysql_fetch_object($q)) {
	echo "<option value=\"$r->id:$r->eventtype\">$r->name</option>\n";
}
echo "</select>\n";
echo "</td><td>";
echo i18n("Location").": ";
echo "</td><td>";
echo "<select name=\"location_id\" id=\"edit_location\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
$q=mysql_query("SELECT * FROM locations WHERE conferences_id='{$conference['id']}' ORDER BY name");
while($r=mysql_fetch_object($q)) {
	echo "<option value=\"$r->id\">$r->name</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";


echo "<tr><td>";
echo i18n("Title").": ";
echo "</td><td>";
echo "<input id=\"edit_title\" type=\"text\" name=\"title\" size=\"20\">";

echo "</td><td>";

echo i18n("Date").": ";
echo "</td><td>";
echo "<input id=\"edit_date\" type=\"text\" name=\"date\" class=\"date\" size=\"12\">";
echo "</td><td>";
echo "</td><td>";
echo "</td></tr>\n";

echo "<tr><td>";

echo i18n("Start at").": ";
echo "</td><td>";
emit_hour_selector('hour',"","id=\"edit_hour\"");
echo ":";
emit_minute_selector('minute',"","id=\"edit_minute\"",15);


echo "</td><td>";

echo i18n("Duration").": ";
echo "</td><td>";
echo "<input id=\"edit_duration\" type=\"text\" name=\"duration\" size=\"4\">";
echo "minutes";
echo "</td></tr>\n";
echo "</table>";

?>

        </div>
        <div id="schedule_tab_scienceolympics">
<?
echo "<table>";
echo "<tr><td>";
echo i18n("Maximum Number of Teams").": ";
echo "</td><td>";
echo "<input type=\"text\" name=\"somaxteams\" id=\"edit_somaxteams\" size=\"4\">";
echo "</td></tr>";

echo "<tr><td>";
echo i18n("Minimum Team Size").": ";
echo "</td><td>";
echo "<input type=\"text\" name=\"sominteamsize\" id=\"edit_sominteamsize\" size=\"4\">";
echo "</td></tr>";

echo "<tr><td>";
echo i18n("Maximum Team Size").": ";
echo "</td><td>";
echo "<input type=\"text\" name=\"somaxteamsize\" id=\"edit_somaxteamsize\" size=\"4\">";
echo "</td></tr>";

echo "</table>";

echo "<h4>".i18n("Judges")."</h4>";
echo "<table style=\"width: 95%;\">";
echo "<tr>";
echo "<td>";
echo "</td><td>";
echo "FIXME: show list of registered judges to choose from";
echo "</td></tr>";
echo "</table>";

echo "<h4>".i18n("Registered Teams")."</h4>";
echo "<div id=\"event_editor_tab_scienceolympics_registeredteams\"></div>";
echo "</div>\n";


?>
        </div>
        <div id="schedule_tab_sciencefairjudging">
        </div>
        <div id="schedule_tab_tour">
        </div>
		</form>
    </div>

