
var i=0;
var c=0;
var t;
var g=1;
var s=0;
var p=0;
var quote= new Array(5)
quote[0]="<h3>Sweetheart, I love you, I really do!</h3>";
quote[1]="<h3>Boss, traffic is very bad, and I got a flat tyre in the middle of all of that. Just finished changing tyres, I'll reach in 10 minutes</h3>";
quote[2]="<h3>We are at Barista, why dont you come over and meet her</h3>";
quote[3]="<h3>Where the hell are you man, how long will we wait? If you don't reach in 10 mins flat we are going in and leaving your tickets with the watchman.</h3>";
quote[4]="<h3>Dude, you must hear this, she said yes!</h3>";  

function timedCount()
{

if(g<=1)
{
	c=c+1;
	if(c<60)
	{
	var t=setTimeout("timedCount()",1000);
	}
	else
	{
	endcall();
	}

}
else
{
stopCount();
	return false;

}
}

function startcall()
{
if(i>=4)
{
i=0;
}
c=0;
g=1;
timedCount();
document.getElementById("btnend").disabled = false;
document.getElementById("btnstart").disabled = true;
document.getElementById("divres").innerHTML=quote[i];
i++;
}
function endcall()
{
if(c<60)
{
	if(c<1)
	{
	document.getElementById("divres").innerHTML="<h3>Really? You need to press call first! Come on dude lets not cheat</h3>";
	}
	else
	{
	
	s=60-c;
	p=Math.round((s/60)*100);
	document.getElementById("divres").innerHTML="<h3>You just spoke for "+c+" seconds and saved paying for "+s+" seconds ... that's a saving of "+p+"%!!</h3>";
	}
}
else
{
document.getElementById("divres").innerHTML="<h3>Sorry! You really need to learn to speak English first!</h3>";

}
document.getElementById("btnstart").disabled = false;
document.getElementById("btnend").disabled = true;
g=2;
stopCount();

}
function stopCount()
{
clearTimeout(t);
}
function disEnd()
{
document.getElementById("btnend").disabled = true;
}

