function sendMsgText(iId)
{
	var oMsgTextForm = document.getElementById("msgtext_"+iId);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
	//	showProgress(true, "potwierdzBillingPostep", "potwierdzBilling");
		xmlHttp.open("POST", "engine/sendMsgTextToGateway.php", true);  
		xmlHttp.onreadystatechange = sendMsgTextResults;
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.send("id=" + encodeURIComponent(iId) + "&text=" + encodeURIComponent(oMsgTextForm.value));
	}
	else
	    setTimeout('sendMsgText()', 1000);
}
function sendMsgTextResults() 
{
	// kontynuuje jedynie jesli transakcja zostala zakonczona
	if (xmlHttp.readyState == 4) 
	{
  		// status 200 oznacza pomyslne ukonczenie transakcji
		if (xmlHttp.status == 200) 
		{	
			// wyodrebnia wiadomosc wyslana z serwera
			sResponse = xmlHttp.responseText;
			if (sResponse == "ERR")
				alert("Aby wysłać tę wiadomość musisz się najpierw zalogować.");
			else
				window.location = "http://bramka.gsmservice.pl/?msgText="+encodeURIComponent(sResponse);
		} 
		// dla statusu protokolu HTTP innego niz 200 zglasza blad
		else 
		{
			alert("Wystapil blad podczas uzyskiwania dostepu do serwera: " + xmlHttp.statusText);
		}
	}
}

