<!--

var ErrorCode = 0; // 1 -  Timeout for consumer to answer a question, 2 - Timeout for data supplier to provide a response
var timer = null;
var min, sec;
var ShowCountdown;
var WaitStatusLine;
var HolidayId;
var HolidayType;
var RespondStatusLine;
var StatusLineCountDown;
var RequiresTermination = true;

function CancelBooking()
{
	location.replace("index.phtml?command=search-process&method=error");
}

/* Not currently Used
function StartWaitCountDown(p_min, p_sec)
{
	min = p_min;
	sec = p_sec;
	ShowCountdown = false;
	StatusLineCountDown = 0;
	ErrorCode = 2;
	WaitStatusLine = "";
	MonitorCountDown('wait');
}
*/

function StartQuestionCountDown(holidayType, holidayId)
{
	min = 3;
	sec = 0;
	HolidayType = holidayType;
	HolidayId = holidayId;
	ShowCountdown = true;
	StatusLineCountDown = 0;
	ErrorCode = 1;
	WaitStatusLine = "";
	MonitorCountDown('question');
}

function MonitorCountDown(type)
{
	if (--sec == -1)
	{
		sec = 59;
		min--;
	}

	if (++StatusLineCountDown == 5)
	{
		StatusLineCountDown = 0;
		WaitStatusLine += ".";
	}
	if (!RequiresTermination && type == 'wait')
	{
		window.status = "";
		return false;
	}

	if (ShowCountdown)
		window.status = "You have " + min.toString() + ":" + sec.toString() + " left to respond";
	else
		window.status = "Communicating with tour operator" + WaitStatusLine;

	if (min == 0 && sec == 0)
	{
		// Timed out
		NotifyError(ErrorCode);
	}
	else
	{
		// Reset the timeout
		if (timer!=null)
			window.clearTimeout(timer);

		timer = setTimeout("MonitorCountDown('"+type+"')", 1000);
	}
}

function NotifyError(p_error_id)
{
	var m_error_type = '';

	switch (p_error_id)
	{
		case 1:
			m_error_type = 'timeout';
		break;
		default:
			m_error_type = 'timeout';
		break;
	}

	RequiresTermination = false;
	// Trap error if at all possible
	//location.replace("index.phtml?command=search-process&method=availability&holiday-type=" + HolidayType + "&searchMode=details&package-id=" + HolidayId + "&error-type=" + m_error_type);
	location.replace("index.phtml?command=search-process&method=error&error-type=timeout");
}

// -->

