//    (c) Sarrų Alessandro - SSI Cagliari
//		  Andrea Mele
//        Ultima revisione 21/06/2000


function ContaRimanenti(form) {
	var strlength=form.message.value.length
	if (strlength > 98 ) {
		form.message.value=form.message.value.substring(0,98)
	}
	form.num.value = 98 - form.message.value.length
}

function ckSms(form) {
	var msg=""
	if (form.prefix.selectedIndex==0) {
		msg+="- prefisso\n"
	}
	if (form.gsm.value.length==0) {
		msg+="- numero di telefono\n"
	}
	if (form.message.value.length==0) {
			msg+="- messaggio\n"
	}
	if (msg.length==0) {
		if (isNaN(form.gsm.value)||form.gsm.value.length>=8||form.gsm.value.length<=2) {
			alert("Numero telefonico errato")
			return false
		} else {			
//		window.open("","SMS",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=480,height=482,marginwidth=0,marginheight=0');						
//		return ConvertChars(form.message)
		return true
		}
	} else {
		alert("Informazioni insufficienti per\nla spedizione del messaggio SMS:\n"+msg)
		return false
	}
}

function ConvertChars(oTextArea)
{
	var sTextIN, lLen, i, lCharCode, sTextOUT;
	sTextIN = oTextArea.value;
	lLen = sTextIN.length;
	sTextOUT = "";
	for (i=0; i<lLen; i++)
	{
		lCharCode = sTextIN.charCodeAt(i);
		var sChar;
		sChar = new String(sTextIN.charCodeAt(i));
		if (lCharCode < 32)
		{
			sTextOUT += " ";
		}
		else
		{
			if (lCharCode < 127)
			{
				sTextOUT += sTextIN.charAt(i);
			}
			else
			{
				if (lCharCode < 221)
				{
					switch(lCharCode)
					{
						case 192||193||194||195:
							sTextOUT += "A'";
							break;
						case 196||197||198:
							sTextOUT += "A";
							break;
						case 199:
							sTextOUT += "C";
							break;
						case 200||201||202:
							sTextOUT += "E'";
							break;
						case 203:
							sTextOUT += "E";
							break;
						case 204||205:
							sTextOUT += "I'";
							break;
						case 206||207:
							sTextOUT += "I";
							break;
						case 210||211:
							sTextOUT += "O'";
							break;
						case 212||213||214:
							sTextOUT += "O";
							break;
						case 217||218:
							sTextOUT += "U'";
							break;
						case 219||220:
							sTextOUT += "U";
							break;
						default:
							sTextOUT += " ";
							break;
					}
				}
				else
				{
					switch(lCharCode)
					{
						case 232 || 233:
							sTextOUT += "e'";
							break;
						case 234||235:
							sTextOUT += "e";
							break;
						case 236||237:
							sTextOUT += "i'";
							break;
						case 238||239:
							sTextOUT += "i";
							break;
						case 242|| 243:
							sTextOUT += "o'";
							break;
						case 240||244||245||246:
							sTextOUT += "o";
							break;
						case 224||225||226||227:
							sTextOUT += "a'";
							break;
						case 228||229||230:
							sTextOUT += "a";
							break;
						case 231:
							sTextOUT += "c";
							break;
						case 249||250:
							sTextOUT += "u'";
							break;
						case 251||252:
							sTextOUT += "u";
							break;
						case 241:
							sTextOUT += "n";
							break;
						default:
							sTextOUT += " ";
							break;
					}
				}
			}
		}
	}
	oTextArea.value = sTextOUT;
	return true;
}
