function ShowStatus(StatusCode) {
	switch (StatusCode) {
		case 1:
			hello.txtStatus.value =  "Connecting....";
			break;
		case 4:
			hello.txtStatus.value =  "Ringing...";
			break;
		case 6:
			hello.txtStatus.value =  "Connected.";
			break;
		case 2:
			hello.txtStatus.value =  "Disconnected.";
			setTimeout('hello.txtStatus.value = "Ready...."',4000);
			bCallInitialized = false;
			break;
		case 3:
			break;
		case 11:
			hello.txtStatus.value =  "Call Rejected.";
			setTimeout('hello.txtStatus.value = "Ready...."',4000);
			bCallInitialized = false;
			break;
		case 13:
			hello.txtStatus.value =  "Destination Busy.";
			setTimeout('hello.txtStatus.value = "Ready...."',4000);
			bCallInitialized = false;
			break;
		case 14:
			hello.txtStatus.value =  "Destination Not Online.";
			setTimeout('hello.txtStatus.value = "Ready...."',4000);
			bCallInitialized = false;
			break;
		case 15: // Display the RTC error text
			calltable.style.visibility = "hidden";
			fwtable.style.visibility = "hidden";
			rtctable.style.visibility = "visible";
			break;
		case 16: // Display the firewall/port error text
			calltable.style.visibility = "hidden";
			rtctable.style.visibility = "hidden";
			fwtable.style.visibility = "visible";
			break;
	}
}

var bCallInitialized = false;
var bClicked=false;
var bWinClosed=false;
	 	
function StartCall() {
		CCallerCtrl1.Call(hello.Target.value);
		bCallInitialized = true;
}

function EndCall() {
	CCallerCtrl1.EndCall(0);
	bCallInitialized = false;	
}

function Configure() {
	CCallerCtrl1.InvokeTuningWizard();
}

function ConfirmClose() {  //called for OnbeforeUnload()
	//Browser is closed using the 'X' button
	if (window.screenTop&&(window.screenTop>screen.height)) bWinClosed=true;
		
	//While on call, page is refreshed or close IE
	if ((!bClicked) && (!bWinClosed) && bCallInitialized == true) {
		var message = 'You are currently on a call...'; 
		if (typeof evt == 'undefined') {
			evt = window.event; 
		} 
		if (evt) { 
			evt.returnValue = message; 
		} 
		return message;					
	}
}

function userClick() {
	bClicked = true;
	setTimeout("bClicked=false;", 100);
}

function HandleOnClose() {//Called for onUnload
	CCallerCtrl1.EndCall(1);
}

function PageLoaded() {
	CCallerCtrl1.Initialize();
	hello.txtStatus.value =  "Ready....";
	Call.onclick = StartCall;
	End.onclick = EndCall;
	rtctable.style.visibility = "hidden";
	fwtable.style.visibility = "hidden";
	calltable.style.visibility = "visible";
}

window.onload = PageLoaded;
window.onbeforeunload = ConfirmClose;
window.onunload = HandleOnClose;
