function messcontacar()  {
	conta=160-document.smsArubaForm.smstesto.value.length ;
	document.smsArubaForm.smscar.value=conta;
	if (conta < 0)  {
	    	smsArubaForm.smstesto.value = smsArubaForm.smstesto.value.substr(0, 160);
	    	document.smsArubaForm.smscar.value=0;
      }
  }

function sms_Valid(TheForm,StrVar1,StrVar2,StrVar3,StrVar4,StrVar6,StrVar7)
{
	theForm=document.smsArubaForm;
	bono=true;

	prefiss=theForm.smsprefcell.selectedIndex;
	if ( prefiss==0 | prefiss==1 | prefiss==14 | prefiss==21 | prefiss==26 | prefiss==31 ) {
	        alert("Seleziona prefisso cellulare.");
		theForm.smsprefcell.focus();
		bono=false;
	      }
	if (bono==true & theForm.smsdestinatario.value.length < 1) {
		     alert("Attenzione: inserire numero cellulare Destinatario!");
			 theForm.smsdestinatario.focus();
	         bono=false;
	      }
	if (bono==true & theForm.smsdestinatario.value.length < 6) {
		     alert("Attenzione: lunghezza numero cellulare Destinatario non valida!");
			 theForm.smsdestinatario.focus();
	         bono=false;
	      }
	if (bono==true & theForm.smsdestinatario.value.length > 7) {
		     alert("Attenzione: numero cellulare Destinatario troppo lungo!");
			 theForm.smsdestinatario.focus();
	         bono=false;
	      }
	if (bono==true) {
	  var checkOK = "0123456789";
	  var checkStr = theForm.smsdestinatario.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	  }
	  if (!allValid) {
	    alert("Inserire solo numeri nel campo Numero Cellulare.");
	    theForm.smsdestinatario.focus();
	    bono=false;
	  }
	}
	if (bono==true && theForm.smsmittente.value.length < 1) {
		alert("Attenzione: inserisci il tuo nome!");
		theForm.smsmittente.focus();
		bono=false;
	}
	if (bono==true & theForm.smstesto.value.length < 1) {
		     alert("Attenzione: inserire testo messaggio!");
			 theForm.smstesto.focus();
	         bono=false;
	      }
	/*if (theForm.smstesto.value.indexOf('"') != -1) {
			alert('Il carattere  "  non � ammesso.')
			return false
			}*/
	if (bono==false)
	{
		return false
	}
	else
	{
		GeneraCookie(StrVar1,StrVar2,StrVar3,StrVar4,StrVar6,StrVar7)
		Redirect()
	}
}

/////////////////////////////////
function Redirect()
{
	window.open("/sms/ProxyPage.php?TipoOperazione=UNO","finestra","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=300,top=200,left=450")
}

function GeneraCookie(StrVar1,StrVar2,StrVar3,StrVar4,StrVar6,StrVar7)
{
	var UrlCliente = ""
	setCookie("TestoMessaggio",StrVar1, false, "/sms/")
	setCookie("NumeroMessaggio",StrVar2, false, "/sms/")
	setCookie("PrefissoMessaggio",StrVar3, false, "/sms/")
	setCookie("MittenteMessaggio",StrVar4, false, "/sms/")
	setCookie("smstipodest",StrVar6, false, "/sms/")
	setCookie("tptarget",StrVar7, false, "/sms/")
	setCookie("smsflash", "no", false, "/sms/")
	UrlCliente = document.location.host + document.location.pathname
	setCookie("UrlCliente",UrlCliente, false, "/sms/")
}

