var CurrentHour;
var CurrentMinute;
var CurrentSecond;
var StatusType;
var Status;
var BufferTime;
var BufferTimeStart = "";

var SentryTime;

var iMinute;
var iSecond;

var	EndMinute;
var	EndSecond;

var x;

function DoBuffer(e, vCurrentHour, vCurrentMinute, vCurrentSecond, vStatusType, vStatus, vBufferTime)
{
	CurrentHour = vCurrentHour;
	CurrentMinute = vCurrentMinute;
	x = 0;
	CurrentSecond = vCurrentSecond;
	StatusType = vStatusType;
	Status = vStatus;
	BufferTime = vBufferTime;
	DrawCaption(e);
}

function DrawCaption(e)
{
	document.getElementById(e).style.display = '';
	document.getElementById("CustomerStatus").innerHTML = 'you are logged as <b>' + StatusType + '</b>';
	DoTimer();
}

function DoTimer()
{
	EndMinute = x;
	EndSecond = 60;
	//Status = 2;
	if(Status==2)
	{
		CurrentSecond++;
		if (CurrentSecond == 60)
		{
			CurrentMinute++;
			if (CurrentMinute == 30)
			{
				//refresh the page so that the server can check the time and change the status accordingly
				window.location.reload();
			}
			CurrentSecond = 00
		}
		RemainingTime = 30 - CurrentMinute;
		CurrentSecond = CurrentSecond.toString();
		CurrentMinute = CurrentMinute.toString();
		if(CurrentSecond.length==1)
		{
			CurrentSecond = "0" + CurrentSecond;
		}
		if(CurrentMinute.length==1)
		{
			CurrentMinute = "0" + CurrentMinute;
		}
 		if((CurrentMinute=="30" && CurrentSecond==1) || (CurrentMinute=="25" && CurrentSecond==1) || (CurrentMinute=="20" && CurrentSecond==1) || (CurrentMinute=="15" && CurrentSecond==1) || (CurrentMinute=="10" && CurrentSecond==1) || (CurrentMinute=="05" && CurrentSecond==1))
		{
			remaining = 
 			window.alert("You have " + RemainingTime + " minutes remaining to checkout.");
 			window.location.reload();
		}
	}
	else
	{
		CurrentSecond++;
		if (CurrentSecond == 60)
		{
			CurrentMinute++;
			if (CurrentMinute == 60)
			{
				//refresh the page so that the server can check the time and change the status accordingly
				window.location.reload();
			}
			CurrentSecond = 00
		}
		CurrentSecond = CurrentSecond.toString();
		CurrentMinute = CurrentMinute.toString();
		if(CurrentSecond.length==1)
		{
			CurrentSecond = "0" + CurrentSecond;
		}
		if(CurrentMinute.length==1)
		{
			CurrentMinute = "0" + CurrentMinute;
		}
	}
	
	var c = "#000000";
	var intro = "";
	
	switch (Status)
	{
		case 0:
		{
			c = "#000000";
			intro = "the time is ";
			document.getElementById("Timer").innerHTML = intro + CurrentHour + ":" + CurrentMinute + ":" + CurrentSecond + ' &nbsp;'; 
			break;
		}
		case 1:
		{
			c = "#008000";
			intro = "the time is ";
			document.getElementById("Timer").innerHTML = intro + CurrentHour + ":" + CurrentMinute + ":" + CurrentSecond + ' &nbsp;'; 
			break;
		}
		case 2:
		{
			c = "#FF0000";
			intro = "the time remaining ";
			if(BufferTimeStart == "")
			{
				BufferTimeStart = CurrentHour + ":" + CurrentMinute + ":" + CurrentSecond;
			}
			document.getElementById("Timer").innerHTML = intro + CurrentMinute + ":" + CurrentSecond + ' &nbsp;'; 
			break;
		}
	}
	document.getElementById("Timer").style.color = c;
	setTimeout('DoTimer()', 1000);
}

