<!--


function sync_day_buttons() {

	imgf = "../images/btns/bg/ice/";

	str = "";
	if (at_beginning_of_time()) { str = "_off"; }
	document.images["prev"].src = imgf + "prev" + str + ".gif";

	str = ""; if (at_end_of_time()) { str = "_off"; }
	document.images["next"].src = imgf + "next" + str + ".gif";
}


function at_beginning_of_time() {
	if (year > yearStart) return 0;

	if (month < monthStart) return 1;
	if (month == monthStart) {
		if (day < dayStart) return 1;
		if (day == dayStart) {
			if (pass == 0) return 1;
		}
	}

	return 0;
}


function at_end_of_time() {
	if (year < yearEnd) return 0;

	if (month > monthEnd) return 1;
	if (month == monthEnd) {
		if (day > dayEnd) return 1;
		if (day == dayEnd) {
			if (pass == 1) return 1;
		}
	}

	return 0;
}


function sync_buttons() {
	sync_day_buttons();
}


function next() {
	if (at_end_of_time()) return;

	otherDisplay = true;

	if (pass == 0) {
		pass = 1; sync_pass();
	}
	else {
		pass = 0; sync_pass();
		day++;
	}
	if ( !valid_day(day)) {
		day = 1;
		pass = 0; sync_pass();
		month = (month + 1) % 13;
		if (month == 0) {
			year++; sync_year();
			month = 1;
		}
		sync_month();
	}
	sync_day();
	
	if (!exist_data(sat_num) || is_gap(sat_num) ) {
		next_satellite();
		if (!satellite_found) {
			no_satellite_message("next"); message_given = 1;
			next(); return;
		}
	}

	update_display();
	message_given = 0;

}


function previous() {
	if (at_beginning_of_time()) return;

	otherDisplay = true;

	if (pass == 1) {
		pass = 0; sync_pass();
	}
	else {
		pass = 1; sync_pass();
		day--;
		if (day == 0) {
			month--;
			if (month == 0) {
				year--; sync_year();
				month = 12;
			}
			if (month == 2) day = get_Feb_length();
			else day = month_lengths[month];
			sync_month();
		}
		sync_day();
	}
	if ( !valid_day(day)) {
		day--; sync_day();
		pass = 1; sync_pass();
		previous(); return;
	}

	if (!exist_data(sat_num) || is_gap(sat_num) ) {
		next_satellite();
		if (!satellite_found) {
			no_satellite_message("prev"); message_given = 1;
			previous(); return;
		}
	}

	update_display();
	message_given = 0;
	
}


function set_day_within_range() {

	if (year == yearStart) {
		if ( (month < monthStart) || (month == monthStart && day < dayStart) ) {
			out_of_range_msg(-1, "nearest");
			month = monthStart; sync_month();
			day = dayStart; sync_day();
		}
	}

	if (year == yearEnd) {
		if ( (month > monthEnd) || (month == monthEnd && day > dayEnd) ) {
			out_of_range_msg(1, "nearest");
			month = monthEnd; sync_month();
			day = dayEnd; sync_day();
		}
	}

}



// -->
