function AnagraficaElement(ragioneSociale, nome, cognome, label, posizione, obbligatorio) {
	this.RagioneSociale = ragioneSociale;
	this.Nome = nome;
	this.Cognome = cognome;
	
	// Ereditarietà del controllo
	this.base = BaseElement;
	this.base(ragioneSociale, ragioneSociale, label, posizione, obbligatorio, null);
}

function AnagraficaElement_focus() {
 this.RagioneSociale.focus();
}

// Indica se il campo è stato compilato correttamente
function AnagraficaElement_checkElement() {
	return true;
}

// Indica se il campo è stato compilato
function AnagraficaElement_isCompiledElement() {
	return ((this.Nome.value != '' && this.Cognome.value != '') || (this.RagioneSociale.value != ''))
}

function AnagraficaElement_clear() {
	this.RagioneSociale.value = '';
	this.Nome.value = '';
	this.Cognome.value = '';
}

new AnagraficaElement(null, null, null, null, null, null);
AnagraficaElement.prototype = new BaseElement;
AnagraficaElement.prototype.focus = AnagraficaElement_focus;
AnagraficaElement.prototype.isCompiledElement = AnagraficaElement_isCompiledElement;
AnagraficaElement.prototype.checkElement = AnagraficaElement_checkElement;
AnagraficaElement.prototype.clear = AnagraficaElement_clear;

function CaratteristicheElement(caratteristica, tipoSelezione, valori, label, posizione, obbligatorio) {
	this.caratteristica = caratteristica;
	this.tipoSelezione = tipoSelezione;
	this.valori = valori;
	
		// Ereditarietà del controllo
	this.base = BaseElement;
	this.base(caratteristica, caratteristica, label, posizione, obbligatorio, null);
}

function CaratteristicheElement_focus() {
	this.tipoSelezione[0].checked;
}

// Indica se il campo è stato compilato correttamente
function CaratteristicheElement_isCompiledElement() {
	if (this.Obbligatorio) {
		if (this.tipoSelezione[0].checked) {
			// Tutti gli ementi
			return true;
		}
		else
		{
			// Selezione delle singole voci
			return (this.valori.selectedIndex != -1);
		}
		return false;
		//return ! (this.RagioneSociale.value == '' && (this.Nome.value == '' || this.Cognome.value == ''));
	} else {
		return true;
	}
}

new CaratteristicheElement(null, null, null, null, null, null);
CaratteristicheElement.prototype = new BaseElement;
CaratteristicheElement.prototype.focus = CaratteristicheElement_focus;
CaratteristicheElement.prototype.isCompiledElement = CaratteristicheElement_isCompiledElement;

CFPIVAElement = function(codiceFiscale, partitaIva, label, posizione, obbligatorio) {
	this.codiceFiscale = codiceFiscale;
	this.partitaIva = partitaIva;
	
	this.base = BaseElement;
	this.base(codiceFiscale, codiceFiscale, label, posizione, obbligatorio, null);

}

CFPIVAElement.prototype = new BaseElement;

CFPIVAElement.prototype.focus = function() {
	this.codiceFiscale.focus();
}

CFPIVAElement.prototype.isCompiledElement = function() {
	return ((this.codiceFiscale.value != "") || (this.partitaIva.value != ""));
}

CFPIVAElement.prototype.clear = function() {
	this.codiceFiscale.value = "";
	this.partitaIva.value = "";
}

// Controllo compilazione form inserimento dati nel carrello
function ChkFormCarrello(frm)
{
	var regText = /^(\d?)$/;

	if (frm.Codice.value == '')
	{
		alert('Indicare il codice articolo.');
		frm.Codice.focus();
		return false;
	}
						
	if (! IsNumber(frm.Quantita.value))
	{
		frm.Quantita.value = '1';
	}
	
	if (frm.QTAMin.value != '') {
			if (parseInt(frm.Quantita.value) < parseInt(frm.QTAMin.value)) {
				alert('La quantità minima acquistabile è pari a ' + frm.QTAMin.value);
				frm.Quantita.focus();
				return false;
			}				
	}
	
	if (frm.QTAMax.value != '') {
			if (parseInt(frm.Quantita.value) > parseInt(frm.QTAMax.value)) {
				alert('La quantità massima acquistabile è pari a ' + frm.QTAMax.value);
				frm.Quantita.focus();
				return false;
			}						
	}
	
	return true;	
}