function no() {
if (document.layers) {
		document.layers.apt.visibility="hidden";
		}
	else if (document.all) {
		document.all.apt.style.visibility="hidden";
		}
	else {
		document.getElementById("apt").style.visibility="hidden";
		}
}
 
function yes() {
if (document.layers) {
		document.layers.apt.visibility="visible";
		}
	else if (document.all) {
		document.all.apt.style.visibility="visible";
		}
	else {
		document.getElementById("apt").style.visibility="visible";
		}
}
 
function isNumb(field) { 
	var valid = "0123456789";
	var temp; 
	for (var i=0; i<field.value.length; i++) { 
		temp = "" + field.value.substring(i, i+1); 
		if (valid.indexOf(temp) == "-1")
			return false; 
	} 
	return true;
} 

function isNumb(field) { 
	var valid = "0123456789";
	var temp; 
	for (var i=0; i<field.value.length; i++) { 
		temp = "" + field.value.substring(i, i+1); 
		if (valid.indexOf(temp) == "-1")
			return false; 
	} 
	return true;
} 
 
function RTrim(str)
      {
       var whitespace = new String(" \t\n\r");
 
       var s = new String(str);
 
       if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
			var i = s.length - 1;
 
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
            i--;
 
            s = s.substring(0, i+1);
            }
 
        return s;
        }
		
function LTrim(str)
       {
        var whitespace = new String(" \t\n\r");
 
        var s = new String(str);
 
        if (whitespace.indexOf(s.charAt(0)) != -1) {
 
             var j=0, i = s.length;
              while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
              j++;
              s = s.substring(j, i);
            }
 
            return s;
        }
 
function Trim(str)
        {
         return RTrim(LTrim(str));
        }
 
function checkEmailAddress(field) {
 
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
 
	if (goodEmail) {
   		return true;
		}
	else {
   		return false;
   		}
	}		


// Funzione di controllo del form
function checkError() {
	var i;
	var tempobj;
	var P;
	
	if (document.images) {
		
		//Cicla per tutti gli elementi del form.
		for (i=0;i<document.frm1.length;i++)
			{
			
			//tempobj contiene l'elemento corrente.
			tempobj=document.frm1.elements[i]
			
			// Controlla il tipo di campo. Se è campo di testo, allora è richiesto.  e se non è riempito, visualizza un errore.
			if (tempobj.name=="txtAccount"){
				 if (Trim(tempobj.value)=="") {
				 	alert('Inserisci il tuo Numero di Account!');
					tempobj.focus();
					return;
				 }
				 if (tempobj.value.length <= 10) { 
				 	alert('Il Numero di Account non è Valido!');
					tempobj.focus();
					return;
				}
					/* corrado modification */
					 
							
							 var done = 0;
							 //tempobj = document.frm1.txtAccount;
							 // var re = new RegExp(/GHR|FGHR|TGHR|/);
							 var re = new RegExp(/VSR|FVSR|TVSR/);
							 tempobj.value = tempobj.value.toUpperCase()
							  var found = tempobj.value.match(re);		  
							  if ((found)&&(found.index==0)) {
								found = String(found);
								if (tempobj.value.length == (8 + found.length)){
									done=1; // we got a match!
								}
							  } 
							  if (done == 0) {
									alert('Il Numero di Account non è Valido!');
									tempobj.focus();
									return;
							  }
							
					
					  /* end of corrado modification */
			}
			if (tempobj.name=="txtEmail"){
				 if (Trim(tempobj.value)=="") {
				 	alert('Inserisci il tuo Indirizzo Email!');
				 	tempobj.focus();
					return;
				 }
				 if (checkEmailAddress(tempobj) == false) {
				 	alert('Indirizzo Email Non Valido!');
				 	tempobj.focus();
				 	return;
				}
			}
					
			if (tempobj.name=="txtName"){
				 if (Trim(tempobj.value)=="") {
				 	alert('Inserisci il Cognome!');
				 	tempobj.focus();
				 	return;
				}
			}
			if (tempobj.name=="cc"){
				if (!(document.frm1.cc[0].checked || document.frm1.cc[1].checked || document.frm1.cc[2].checked)) {
					alert("Seleziona una carta di credito")
					return;
				}
			}
			if (tempobj.name=="txtLast"){
				if ((Trim(tempobj.value)==false  || tempobj.value.length < 4)) {
					alert('Inserisci le ultime 4 cifre della carta di credito!');
					tempobj.focus();
					return;
				}
				if (!isNumb(tempobj)) {
					alert("Sono Accettati solo numeri!"); 
					tempobj.focus();
					return;
				}
			}
			if (tempobj.name=="del"){
				if (!(document.frm1.del[0].checked || document.frm1.del[1].checked)) {
					alert("Seleziona (Cancellare o Non Cancellare)!")
					return;
				}
			}
			if (tempobj.name=="txtReason"){
				 if (Trim(tempobj.value)=="") {
					 alert('Scrivi le tue ragioni!');
				 	tempobj.focus();
				 	return;
				}
			}
		}
			
		document.frm1.submit();
	}
}								

























